Jump to content

Home

[CODE] Torso/Leg animation separation


Leen_Qualant

Recommended Posts

Greetings.

 

Have a question about animation code.

 

Specifically when you are holding a lit lightsaber. When walking backwards or back left/right (observe! walking not running) they keep their saber stance. I.E not lowering the arms letting the saber scorch the ground. Same when crouching and moving in any direction; they keep the saber stance. Keeping it ready so to speak.

 

Now; I am wondering what do I have to set to get the game to understand that even when I walk in any Forward direction I want it to remain the saber in a ready stance position just like the examples above?

 

I suppose it is a int setAnimParts thing but I cant seem to find it. Is it in bg_pmove.c or bg_panimate.c?

I dont wish to change the animation for when the player are in running mode, just walk.

I know there is a animation in "animation.cfg" that does the "forward saber ready walk", but I do not wish to use that, I am using my own set stances and not the games original so I need to change it in the code I suppose.

 

 

Second question I just thought of;

Is there any way to delay the time it takes for the score/Hud to pop up upon death event. I'd like to delay it perhaps 1 or 2 seconds so that you get a clearer view of how the player got killed instead of always getting the ground/floor view and Scoreboard pop up at the exact moment you get killed.

Just a thought.

 

Anyways, great going out there RazorAce, Wudan, Ask and all of you persistant dudes. Think I read all your post still I need to ask =). No hurt in that now is there.

 

Stay thinking.

Link to comment
Share on other sites

Hello again.

 

Now I tried to mess around with 3 files;

/game/bg_pmove.c

/game/bg_panimate.c

/game/bg_saber.c

 

First a few things to clarify:

There is already a code/animation.cfg for Walking backwards while holding saber Lit in ready position. There is also one animation sequence in animation.cfg that does a Forward Walk with Saber Lit at chest height (fixed) position. This animationis called "BOTH_WALK2"

But I have yet to been able to pull it of in Multiplayer. I have only seen it done by NPC's in Single Player.

 

So what did I do, I scanned all the code for "BOTH_WALK2" and found that it's mostly called upon in "bg_saber.c"

Example from bg_saber.c:

from line 1634


if ( pm->ps->weaponstate == WEAPON_RAISING )
{//Just selected the weapon
	pm->ps->weaponstate = WEAPON_IDLE;
	if((pm->ps->legsAnim & ~ANIM_TOGGLEBIT) == BOTH_WALK1 )
	{
		PM_SetAnim(SETANIM_TORSO,BOTH_WALK1,SETANIM_FLAG_NORMAL, 100);
	}
	else if((pm->ps->legsAnim & ~ANIM_TOGGLEBIT) == BOTH_RUN2 )
	{
		PM_SetAnim(SETANIM_TORSO,BOTH_RUN2,SETANIM_FLAG_NORMAL, 100);
	}
	else if((pm->ps->legsAnim & ~ANIM_TOGGLEBIT) == BOTH_WALK2 )
	{
		PM_SetAnim(SETANIM_TORSO,BOTH_WALK1,SETANIM_FLAG_NORMAL, 100);
	}
	else
	{
		PM_SetAnim(SETANIM_TORSO,PM_GetSaberStance(),SETANIM_FLAG_NORMAL, 100);
	}

	if (pm->ps->weaponstate == WEAPON_RAISING)
	{
		return;
	}

}

if (checkOnlyWeap)
{
	return;
}

And the next segment in the same file:

from line 1817

if ( !pm->cmd.forwardmove && !pm->cmd.rightmove && pm->cmd.upmove >= 0 && pm->ps->groundEntityNum != ENTITYNUM_NONE )
			{//not moving at all, so set the anim on entire body
				both = qtrue;
			}

		}

		if ( anim == -1)
		{
			if((pm->ps->legsAnim & ~ANIM_TOGGLEBIT) == BOTH_WALK1 )
			{
				anim = BOTH_WALK1;
			}
			else if((pm->ps->legsAnim & ~ANIM_TOGGLEBIT) == BOTH_RUN2 )
			{
				anim = BOTH_RUN2;
			}
			else if((pm->ps->legsAnim & ~ANIM_TOGGLEBIT) == BOTH_WALK2 )
			{
				anim = BOTH_WALK2;
			}
			else
			{
				anim = PM_GetSaberStance();
			}

			if (anim == BOTH_RUN2 && !pm->cmd.forwardmove && !pm->cmd.rightmove)
			{ //semi-hacky (if not moving on x-y and still playing the running anim, force the player out of it)
				anim = PM_GetSaberStance();
			}
			newmove = LS_READY;
		}

		if ( !pm->ps->saberActive )
		{//turn on the saber if it's not on
			pm->ps->saberActive = qtrue;
		}

		PM_SetSaberMove( newmove );

		if ( both )
		{
			PM_SetAnim(SETANIM_LEGS,anim,SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD, 100);
		}

 

What I did was to change some of the BOTH_WALK1 anims to BOTH_WALK2 to see wich handled wich animation, so ok Im a noob coder but one can only trial and error if not all that smart :p

In one case though I got it to do some jerky clipping movement between BOTH_WALK1 and BOTH_WALK2 when I tested it walking forward ingame. It was like the animation was jumping between animation 1 and 2 each 1/10th of a second. So I tried to go back and alter some of my changes but I was so tired I lost myself in what I was doing.

 

What I am wondering is what part "PM_GetSaberStance()" has. Cant I tell the game that while walking Forward in either left or right or straight direction that it should GetSaberStance and actually SHOW that animation instead of always lowering the stance and walk with the saber by your side?

Or is it set so in the animation.cfg/glm so that you cant seperate these movements/animations.

 

In other words; is it possible to use a Different TORSO animation on a already running BOTH animation. Can they be mixed I mean?

Link to comment
Share on other sites

Oh dear, you're going all over the place. It's a simple task :D

 

In bg_pmove.c (PM_Footsteps) find:

else {
if ((pm->ps->legsAnim&~ANIM_TOGGLEBIT) != BOTH_WALK1)
{
	PM_SetAnim(SETANIM_LEGS, BOTH_WALK1, setAnimFlags, 100);
}
else
{
	PM_ContinueLegsAnim( BOTH_WALK1 );
}
}

 

 

...and replace it with:

else
{
//If we're armed with a lightsaber and it's not holstered
if (pm->ps->weapon == WP_SABER && !pm->ps->saberHolstered)
{
	if ((pm->ps->legsAnim&~ANIM_TOGGLEBIT) != BOTH_WALK2)
	{
		PM_SetAnim(SETANIM_LEGS, BOTH_WALK2, setAnimFlags, 100);
	}
	else
	{
		PM_ContinueLegsAnim( BOTH_WALK2 );
	}
}
//Otherwise, do default
else
{
	if ((pm->ps->legsAnim&~ANIM_TOGGLEBIT) != BOTH_WALK1)
	{
		PM_SetAnim(SETANIM_LEGS, BOTH_WALK1, setAnimFlags, 100);
	}
	else
	{
		PM_ContinueLegsAnim( BOTH_WALK1 );
	}
}
}

 

Now this will only apply for forward, left, and right movement. When moving backward you'll still do what you've been doing.. there isn't a backward version of BOTH_WALK2 so, i hadn't bothered doing that myself.

 

It's much more elegent this way, no? :)

Link to comment
Share on other sites

Thank you Scarlett.

 

I will try as soon as I get home, hope it does the trick.

 

And yes the backwards animation is just the way I want it so there is no need altering it. The backwards version is as we all know already using a ready stance position wich dont need any changing.

 

Again, thanks Scarlett.

Link to comment
Share on other sites

Sorry Scarlett, but that doesnt work.

I tried it, put the code where you said, compiled succesfully, fired up the game and it did the same thing as I wrote above here:

 

In one case though I got it to do some jerky clipping movement between BOTH_WALK1 and BOTH_WALK2 when I tested it walking forward ingame. It was like the animation was jumping between animation 1 and 2 each 1/10th of a second.

 

The Legs are walking but the Torso part is acting like it's having a epileptic episode. Flipping betwen the 2 animations BOTH_WALK1 and BOTH_WALK2. Jumping between them each like ten times for each step the legs take.

 

Walking normal with a holstered Saber is all normal, likewise walking backwards with a lit saber, just as original, it's only forward/forward+left and right that freaks out. I had this before aswell but couldnt get wich part did it but now we know. It is in this peace of code apparently.

 

How can we fix it? It seems that even though we succesfully call the animation we want it still wants to run back to its original. Is there an additional call that interupts our new code that we overlooked? Or is there a Flagsetting that needs to be put on some Override setting so that it dont try to run home to momma again?

 

Leen

Link to comment
Share on other sites

Anyone else have an idea?

Been trying different settings but it remains. The same jumping between the 2 positions. I set the game to "timescale 0.1" to try and see what was going on and yeah; the saber flicks between BOTH_WALK1 and BOTH_WALK2 like 10 times for each step I take with my avatar. Like he is chopping air like a madman.

 

For some reason, despite the code Scarlett helped me with it STILL wants to use BOTH_WALK1 when walking forward with a lit saber. It tries to use BOTH_WALK2, but BOTH_WALK1 interupts it.

 

Help:confused:

 

Leen

Link to comment
Share on other sites

PROGRESS!!!

 

But only a small piece of the puzzle.

 

In the first part of the code Scarlett provided:

else
{
//If we're armed with a lightsaber and it's not holstered
if (pm->ps->weapon == WP_SABER && !pm->ps->saberHolstered)
{
	if ((pm->ps->legsAnim&~ANIM_TOGGLEBIT) != BOTH_WALK2)
	{
		PM_SetAnim(SETANIM_LEGS, BOTH_WALK2, setAnimFlags, 100);
	}
	else
	{
		PM_ContinueLegsAnim( BOTH_WALK2 );
	}
}

I experimented with the FLAGS changing the line:

PM_SetAnim(SETANIM_LEGS, BOTH_WALK2, setAnimFlags, 100);

to

PM_SetAnim(SETANIM_LEGS, BOTH_WALK2, SETANIM_FLAG_HOLD, 100);

and now instead of jumping directly into the spasmic movement directly it now playes the entire BOTH_WALK2 animation for 2 seconds BUT then unfortunatly falls back into the spasmic switch between the 2 animations.

 

Help on "SETANIM_FLAG_*****" could perhaps solve the puzzle.

 

So this is a humble *bump*

 

Leen

Link to comment
Share on other sites

Well, you could have PMed me. It takes a while for me to scan thru all the topics and help people.

 

Anyway, the problem you're having is that you're looking in the wrong part of the code. Remember the torso animations for the saber are handled seperately than the other animations.

 

All you have to do is add additional ORs (for the leg animations where you want the players to do the torso "in stance" animations) to the following if statement (PM_SetSaberMove; bg_saber.c)

if (anim == BOTH_WALKBACK1 || anim == BOTH_WALKBACK2)
{ //normal stance when walking backward so saber doesn't look like it's cutting through leg
anim = PM_GetSaberStance();
}

 

Remember that you need to be thinking and working in terms of leg animations (if leg animation == ___, then use ___ for the torso animation).

Link to comment
Share on other sites

Sorry but it didnt work.

 

as in your example above Racor I added this part:

 

if (anim == BOTH_WALK1 || anim == BOTH_WALK2)
	{ //LeenEd added testcode, saber forward walk
		anim = PM_GetSaberStance();
	}

Even tried with changing the second

anim == BOTH_WALK1

 

to

 

anim == BOTH_WALK2

 

but it wont affect the torso.

 

 

What about if I change the part from line 1824 in bg_saber.c

if ( anim == -1)
		{
			if((pm->ps->legsAnim & ~ANIM_TOGGLEBIT) == BOTH_WALK1 )
			{
				anim = BOTH_WALK1;
			}

to

if ( anim == -1)
		{
			if((pm->ps->legsAnim & ~ANIM_TOGGLEBIT) == BOTH_WALK1 )
			{
				anim = PM_GetSaberStance();
			}

 

Will that make a difference?

 

Man I must have compiled and tested this thing nearly 40 times tonight :confused:

Link to comment
Share on other sites

Correction: Technically it shouldn't been an issue since all the animations calls are handled server side. However, sometimes weird things happen due to the fact that you're now running different versions of the PM functions on the client and server sides. Giving it a try wouldn't hurt.

 

As for your suggestion, no, that won't do anything relavent.. The Leg animations shouldn't be -1 except (maybe) on the first frame of the game.

 

Wait, why did you add an additional if statement instead of using the one I suggested? Remember that the placement is critical.

Link to comment
Share on other sites

I'll explain....

 

This is basically what you're messing with. Note that I've cut out the non-relivent stuff inside main if statement shown. If you want me to explain that stuff too, just ask.

if ( BG_InSaberStandAnim(anim) || anim == BOTH_STAND1 )
{//racc - standing still or setting the animation to BOTH_STAND1 (meaning saber idle or ready)
	anim = (pm->ps->legsAnim & ~ANIM_TOGGLEBIT);
	if (anim == BOTH_WALKBACK1 || anim == BOTH_WALKBACK2)
	{ //normal stance when walking backward so saber doesn't look like it's cutting through leg
		anim = PM_GetSaberStance();
	}

At the beginning of this code set, anim is set to the animation desired by the saber animation code.

 

Step One: Check to see if the desired animation is a standing still animation. If so, proceed, otherwise skip this code.

 

Step Two: Change the desired animation to the animation of the legs. This is so if your other conditions aren't meet. The torso animation will be the same as the legs animation.

 

Yes, technically, this means that the torso animation was started at a different time than the legs animation but the engine seems to match up the animations if they are the same. (Otherwise, you'd have your torso walking out of sync with the legs.) I've noticed that the walk animation can get desynced sometimes but I don't know why as I don't have access to the ghoul2 animation code (which is probably way too advance for a pre-pro coder like myself).

 

Step Three: Check the desired animation (which now matches the legs animation) to see if it's in a backwards walking animation. If so, make the desired animation the standing idle animation of the current saber stance.

Link to comment
Share on other sites

Alright Ace, I'll try to read through that tomorrow, to tired now, lines get mixed up...

 

I'm not a pro coder at all, Im in my freshman process so perhaps my questions and examples seem crazy, but I simply wanna tell the game that when I am WALKING Forward/+left, right I DONT want it to lower it's saber, it should KEEP it in the pose the at the moment used Stance (blue, yellow, red) has it. I see in the code where it sets so that if you walk backwards it is held in stance, even if you crouch it's held in stance in all directions.

I just want to pass that info on to the WALKING Forward aswell. But now I am tired, 50+ compiles and tests later Im getting rather dizzy from all the reading.

 

Lets hope we can find a solution:)

 

Regards

Leen

 

 

Nighty night

Link to comment
Share on other sites

That should have worked for you, Leen... it does for me. Since you got that gittery effect, i'm thinking you just compiled game and not cgame as well. Whenever you update BG code, you need to compile both cgame and game (ui as well, but i don't think it'd be important for this). So try that, or in other words, just run that buildvms.bat file :)

 

You don't need to mess with the torso because, as Raven had it, when you're armed with the lightsaber, by default, the torso is set to match the legs. So that's why you often see the legs just set for the animation. For the lightsaber, standing is i think the only animation that has a torso override for the different saber stances.

Link to comment
Share on other sites

:D :D :D :D :D

 

JOY!

 

RacorAce, Scarlett with your help I managed to make it work;)

 

I added this to PM_SetSaberMove; bg_saber.c approc line 1950

     if (anim == BOTH_WALK1 || anim == BOTH_WALK1)
        { //LeenEd SaberStance inWalkForward
     anim = PM_GetSaberStance();
}

And did a game/cgame compile ( before I only did game compile since that was the only code I was working in so I thought it only nessesary to compile that part)

And now; when walking forward it holds what ever choosen stance I have in perfect balance (Blue/Yellow/Red).

 

So I am not using the BOTH_WALK2 animation, though your post taught me a few things Scarlett.

I never realized that if you didnt compile cgame even if you only edit game has such big effect.

 

Kudos to RacorAce and Scarlett :D You are benevolent indeed.

 

Stay well and have fun mateys.

 

Leen.:)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...