PDA

View Full Version : A little help?


Jman3ooo
09-07-2002, 06:47 PM
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.

Tchouky
09-07-2002, 10:58 PM
well i didn't look your vectors (it's 5am ,i m stoned and tired .....)

but i know for the speed :

all the speed setings are recalculated in the
BG_AdjustClientSpeed

func in the bg_pmove.c

Azymn
09-08-2002, 12:57 AM
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?

Jman3ooo
09-08-2002, 01:01 AM
It makes sense but I dont know how to do it....

Azymn
09-08-2002, 04:44 AM
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.

ASk
09-08-2002, 06:05 AM
do I see a modification of playerstate_t struct?

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

The Eternal
09-08-2002, 09:39 AM
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!

Jman3ooo
09-08-2002, 10:19 AM
Wait.... Can I not edit playerState_s or playerState_t... or both?

:confused:

NickR
09-08-2002, 07:48 PM
If its located in q_shared.c/.h then you can't modify it. Those files MUST stay untouched!!!

Jman3ooo
09-08-2002, 08:39 PM
So what unused stat value should I use, and how?

Kyle098
09-08-2002, 10:58 PM
man, this mod is going to make the server have a huge ping.

Azymn
09-09-2002, 11:08 AM
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.

AZraEL|jitd
09-09-2002, 12:49 PM
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.

The Eternal
09-09-2002, 01:14 PM
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 ;)

The Eternal
09-09-2002, 01:16 PM
and nickr.. SURE you can modify them :)
but anyone can predict it ****s up the game after that ;)

NickR
09-09-2002, 01:33 PM
Errr, Yeah.

Azymn
09-09-2002, 06:12 PM
Hey, is the 16bit struct limits the basis for the zippy netcode for q3?