Jump to content

Home

A little help?


Jman3ooo

Recommended Posts

My Vectorsubstract dosent seem to be working properly, nor does my changing of speeds. This is from my g_main file:

 


void G_RunFrame( int levelTime ) {
int			i;
gentity_t	*ent;
int			msec;
int         start, end;
int         count;
int         radius;
vec3_t      a;
long        distcheck;
float animSpeedScale = 1;
playerState_t *ps;

for ( count = 0 ; count < MAX_GENTITIES ; count++ ) 
	{
		if (g_entities[count].client && g_entities[count].client->ps.clientNum != ent->client->ps.clientNum)
		{   

                  VectorSubtract( ent->client->ps.origin, g_entities[count].client->ps.origin, a ); 
		       if (VectorLength(a) < 1000)
  			       {
  			                    ps->speed = .1;
  			                    animSpeedScale = .1;
  			                    G_Printf("Go Slow Mo\n");
  			                    break;
                  }
                  else if (VectorLength(a) < 2000)
                  {
                               ps->speed = .2;      
                               animSpeedScale = .5;  
                               G_Printf("Semi Slow Mo\n");          
                  }        
                  else 
                  {
                               ps->speed = 1;      
                               animSpeedScale = 1;  
                               G_Printf("No Slow Mo\n");          
                  }                      
		}
	}

 

The vector substact will say things like, No Slow Mo when I am about 2 inches from opponents, and It never changes speeds. I am probally doing sumpthing horribly wrong and horribly obvious but I still dont see it.

Link to comment
Share on other sites

Tchouky's right - that function is called constantly, so your speed changes are erased because it reapplies a base speed to each character each time.

 

What you might try to do is flag the person you want to slow down, give them something like "slowMoIndex" in their player state, and update that value to a multiplier (like 0.01) of just how slow you want them to go when in proximity to you.

Then update this value on their person when they get within range using the function you've posted, and change BG_AdjustClientSpeed() to multiply the character's speed against the slowMoIndex value.

Just make sure to reset it to 1 when they're out of range so noone is stuck in slowmo after they leave your "bubble".

 

Does that make sense?

Link to comment
Share on other sites

else if (VectorLength(a) < 2000)

{

ps->sloMo = 0.2;

}

else

{

ps->sloMo = 1;

}

. . . .

 

typedef struct playerState_s {

int commandTime; // cmd->serverTime of last

float sloMo;

 

. . . .

 

void BG_AdjustClientSpeed(){

if (ps->sloMo > 0)

{

ps->speed *= ps->sloMo;

}

 

. . . .

 

 

Good luck.

Link to comment
Share on other sites

indeed, you can NOT modify playerstate_t (well you can.. but only if you remove other values).. also, if you for example replace an unused integer, be aware that any integer in playerstate_t gets clipped at 16 bits instead of 32! so floats won't work and get ****ed up after being sent to the client.

 

but the structure is hardcoded in the exe, so impossible to change in any way.. you should probably use a integer in the stats array and convert it to and from integers (2 decimals is good enough ;))

just keep it under 16bit!

Link to comment
Share on other sites

do I see a modification of playerstate_t struct?

you do know that it is a big big no-no in q3 modding

 

Oops....i had NO idea. I had modified it just recently to try something new, with no problems, though i had tried to change the forceData_t struct some time back and realized how much it can screw up the game.

Thanks for the tip, ASk, Eternal. Sorry to lead you the wrong way, Jman. This is my first-time modding, first-time with the Q3 code.

Link to comment
Share on other sites

Originally posted by Kyle098

man, this mod is going to make the server have a huge ping.

 

why ?? are you thinking that the server will run slow with a little vector subtraction in the mainloop ??

I realized that most people think that everything you can actually SEE in the mainloop slows down the game, but they don't realise that there are 10,000 more calculations like that in the game that are executed in the mainloop but with function calls.

I don't know if you mean this, sorry if you mean another thing, but I also read something like this in another post.

Link to comment
Share on other sites

a few addition to playerstate_t wouldn't slow it down too much either, but you can't so that's not an option...

 

search for STAT_ in the game.. you see them defined somewhere. you can use a total of 16 stats. and only like 8 are used so you can use one for that variable...

 

also playerstate_t is the typedef struct playerstate_s..

so basically

 

playerstate_t ps;

equals

struct playerstate_s ps;

basically ;)

 

if you don't know a structure from a typedef structure you should read up some more c i guess...

 

typedefs enable you to write alot shorter definitions....

 

 

typedef unsigned char uchr; for example

 

uchr *test; == unsigned char *test; :) but seeee and fear the tidyness ;)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...