PDA

View Full Version : How to check for player turns?


Scarlett
03-27-2003, 11:17 AM
Being a complete amature at programming, i need some help with something. I need to make a statement that'll check to see if the player is turning, and if so do a function in bg_pmove.c...

I've studied the code for hours trying to figure out how to do this. In bg_pmove.c i thought maybe i could check it in, i think it's called, PM_ViewAngleUpdate or something.. but i don't understand the code that's in there at all, there's a line like:

for (i=0 ; i<3 ; <something>)

then it does a check for "i":

if (i == PITCH)

So then i thought maybe if i did a check for "i == YAW" under there... i don't know. So lost, so confused...

If anyone could help, i'd be most greatful.

razorace
03-27-2003, 01:28 PM
uuuhhh...What are you trying to do? The ViewAngle is almost always changing...

Scarlett
03-27-2003, 06:06 PM
Trying to do animations when we turn... the footstep anims. So we move our feet when we're turning and have no velocity.

Here's the code i wrote for that, but as i said i just don't know where to put it, or to call upon it the way i need to:

//If we're grounded, and not moving
if (!pm->ps->groundEntityNum == ENTITYNUM_NONE &&
pm->ps->velocity[0] == 0 && pm->ps->velocity[1] == 0 && pm->ps->velocity[2] == 0)
{
//If we're crouched
if ( (pm->ps->legsAnim&~ANIM_TOGGLEBIT) == BOTH_CROUCH1 ||
(pm->ps->legsAnim&~ANIM_TOGGLEBIT) == BOTH_CROUCH1IDLE)
{
anim = BOTH_TURNCROUCH1;
}
//Otherwise we must be standing
else
{
//If we're in the lightsaber stance
if ( (pm->ps->legsAnim&~ANIM_TOGGLEBIT) == BOTH_STAND2)
{
anim = BOTH_TURNSTAND2;
}
//If we're in a double-handed weapon stance
else if ( (pm->ps->legsAnim&~ANIM_TOGGLEBIT) == BOTH_STAND3)
{
anim = BOTH_TURNSTAND3;
}
//Otherwise, do the default
else
{
anim = BOTH_TURNSTAND1;
}
}

//If we're not in footstep animation, set us to it
if ( (pm->ps->legsAnim&~ANIM_TOGGLEBIT) != anim)
{
PM_SetAnim(SETANIM_LEGS, anim, SETANIM_FLAG_OVERRIDE, 0);
}
//Otherwise, continue doing animation
else
{
PM_ContinueLegsAnim( anim );
}
}

razorace
03-28-2003, 12:20 AM
Good Idea. :) I'm not sure how off the out of my head. Try file searching for the ViewAngle varible and figure out how it's created.

Technically you don't really need to do the PM_ContinueLegsAnim( anim ) (it's redudent in this case). PM_SetAnim is powerful enough by itself to do all the stuff you want. I think Raven made the PM_Continue____Anim functions to be lazy about setting the right flags for PM_SetAnim. Unfortunately, those code shortcuts make it much harder to change animations cause you can't just use PM_SetAnim and automatically assume it'll work right (since the PM_Continue____Anim and PM_Set___Anim ignore all the important ___Timer stuff.)