Jump to content

Home

SC's misc questions thread xD


SecretChord

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...

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?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...