Jump to content

Home

SC's misc questions thread xD


SecretChord

Recommended Posts

Posted

Just thought I'd have a thread without any real topic where I can ask any questions that would be relatively simple for most people to answer.

 

If I want to change the vector position of any entity, what should I use? I'd use ent->client->ps.origin but that's for players isn't it.. r.currentOrigin didn't seem to work, and there's two s.origin related data bits. They didn't seem to work, but if you know it's one of them or something else it would be a great help to me.

Posted

Doesn't seem to work, say I'm trying to move ent up 50 units, shouldn't this work:

ent->s.origin[2] += 50;

 

I made it print ent->s.origin[2] to the console and it does appear to be altering the value, but chewie doesn't seem to move up at all..

Posted

Still havn't got the above working, but I've got a new question.

 

I'm trying to scale an int variable using a bit of vector calculation and such.

 

someintvar *= 1/(2^(50/someveclength));

 

someveclength is a variable set using VectorLenght. I'm having some real problems with this, 50/someveclength gives me an error saying right operand has type 'float'.

 

someintlength = (int)someveclength;

someintvar *= 1/(2^(50/someintlength));

 

The above doesn't work either, and is behaving really oddly when I print out seperate bits to the console. 50/someintlength seems to be 0, and it's trying to tell me that 2^0 (because of the first bit being 0) is 2, when it would obviously have to be 1. Even with that 1/2 should be 0.5 not 0 as it seems to be doing. I'm sure I'm just getting screwed up by the different variable types, but I'm not too good with that as I'm fairly new to C programming.

Posted

I'm not trying to scale vectors, I was able to do that fine in a previous function. I'm trying to scale an int variable after doing some (relatively simple) calculations on a vector length that I've transformed to int because it was giving me errors when I tried them on the float variable.

Posted

Oh yeah, ent->client->ps.origin is not just for players. It also includes npcs so try using that. And variables with type integer cannot contain a floating decimal. They have to be integers, so when you try to store .5 into an int or 2.5 it would be stored as 0 or 2 respectively.

Posted

'^' is a bit operation in C. You want pow().

 

Also, I think there's a function, something like SetOrigin(), which properly sets origins for most kinds of entities.

Posted
50/someintlength seems to be 0, and it's trying to tell me that 2^0 (because of the first bit being 0) is 2, when it would obviously have to be 1. Even with that 1/2 should be 0.5 not 0 as it seems to be doing. I'm sure I'm just getting screwed up by the different variable types, but I'm not too good with that as I'm fairly new to C programming.

 

50/someintlength is probably zero because someintlength is probably > 50, and 1/2 is 0 since you're using integer division. you'd probably want to do this instead:

 

someintvar *= 1/pow(2,50/VectorLength(vec3_t))

 

since vectorlength returns a float, it should force the 50/vectorlength to use floating point division - same with pow.

  • 1 month later...
Posted

Is there some form of client data that has a players speed, the 3 things I've tried seem to be their max speed depending on their circumstances (whether they're swinging, running backwards, etc). Is there something that holds their actual movement speed?

Posted

That's just their "base" speed and not their current speed.

 

You're actually going to want to look for the length of the player's velocity vector. It depends on where in the code you're looking.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...