SecretChord Posted January 8, 2007 Share Posted January 8, 2007 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 More sharing options...
Tinny Posted January 8, 2007 Share Posted January 8, 2007 Which two did you try? ->s.origin should usually work I thought . Link to comment Share on other sites More sharing options...
SecretChord Posted January 8, 2007 Author Share Posted January 8, 2007 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.. Link to comment Share on other sites More sharing options...
SecretChord Posted January 9, 2007 Author Share Posted January 9, 2007 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 More sharing options...
XycaleTh Posted January 9, 2007 Share Posted January 9, 2007 Take a look at the TeleportPlayer function in g_misc.c i think? And you can scale vectors using the VectorScale function Link to comment Share on other sites More sharing options...
SecretChord Posted January 9, 2007 Author Share Posted January 9, 2007 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 More sharing options...
Tinny Posted January 9, 2007 Share Posted January 9, 2007 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 More sharing options...
razorace Posted January 10, 2007 Share Posted January 10, 2007 '^' 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. Link to comment Share on other sites More sharing options...
dumbledore Posted January 10, 2007 Share Posted January 10, 2007 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 More sharing options...
SecretChord Posted January 10, 2007 Author Share Posted January 10, 2007 Thanks for the help, works perfectly now. I'll also have a look for SetOrigin and see if I can get it to work. Link to comment Share on other sites More sharing options...
SecretChord Posted March 6, 2007 Author Share Posted March 6, 2007 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 More sharing options...
XycaleTh Posted March 6, 2007 Share Posted March 6, 2007 Maybe ent->client->ps.speed? It gets its speed from g_speed. Link to comment Share on other sites More sharing options...
razorace Posted March 6, 2007 Share Posted March 6, 2007 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.