Jump to content

PM_SetSaberMove when not attacking?


Recommended Posts

Hi, I'm trying to set a saber blocking animation to be held in place serverside while a button is being pressed.

Using PM_SetSaberMove works, but only when I'm attacking as well as pressing the button. I don't want to mess with the code in that function too much, don't wanna break something..

 

What function should I use instead? My blocking function is currently in w_saber.c and called from g_active.c, but if you can think of a better place to call it from, do tell :) It's very unfinished, but want to sort out these animation issues before I make the controls properly.

 

@@ensiform, @@eezstreet, @@ent

 

http://pastebin.com/xU7dkDzd

Link to comment

If you want a blocking function, you should make it in the PM_GetSaberStance in bg_pmove, or in bg_saber.c before the PM_WeaponLightsaber and call a button call

above some where in the code. w_saber.c is for the action of how the saber needs to bahave for blocking like incomming attacks and special attacks and trace of the saber and more.

Boothand likes this
Link to comment

Moved from w_saber.c to bg_saber.c, still haven't found a new place to call from.

 

Updated code here: http://pastebin.com/WeEWBUJF

 

Locking now works, but still something keeps the animation idle when not attacking. Not sure if I should

- debug and look for places where it forces it to idle, then add condition?

- use another function more suited for the purpose?

 

@@Stoiss, GetSaberStance only sets the lightsaber styles.. I don't wanna make new stances.. but could you clarify what you meant about that function? :)

Link to comment

for what it sounds like to me, you are trying to make a Block button to handle idle anim for block or not

in Getsaberstance you can do that, as it is not just to add new stance but how the stance does idle anim for the saber stance

But GetSaberstance can also be coded to do Manual Block Anim also its a bit more tricky as you need to know the anim, you could look in JKG source code and see how that has been done. but a good places to start as to make  Manual Block would be in Bg_Saber.c you can look at that code i added in this post post here with PM_SetBlock function. and see how that works out :)

 

I have a old code here from one of my old code base i once did, you can freely use it if you want

int PM_GetSaberStance(void)
{
	int anim = BOTH_STAND2;
	saberInfo_t *saber1 = BG_MySaber( pm->ps->clientNum, 0 );
	saberInfo_t *saber2 = BG_MySaber( pm->ps->clientNum, 1 );

	if (!pm->ps->saberEntityNum)
	{ //lost it
		return BOTH_STAND1;
	}

	if ( BG_SabersOff( pm->ps ) )
	{
		return BOTH_STAND1;
	}

	if ( saber1
		&& saber1->readyAnim != -1 )
	{
		return saber1->readyAnim;
	}

	if ( saber2
		&& saber2->readyAnim != -1 )
	{
		return saber2->readyAnim;
	}

	if ( saber1 
		&& saber2
		&& !pm->ps->saberHolstered )
	{//dual sabers, both on
		return BOTH_SABERDUAL_STANCE;
	}

	switch ( pm->ps->fd.saberAnimLevel )
	{
	case SS_DUAL:
		if (pm->cmd.buttons & BUTTON_BLOCK)
		{
			anim = BOTH_SABERDUAL_STANCE;
		}
		else
			anim = BOTH_STAND1;	
		break;
	case SS_STAFF:
		if (pm->cmd.buttons & BUTTON_BLOCK)
		{
			anim = BOTH_SABERSTAFF_STANCE;
		}
		else
			anim = BOTH_STAND1;
		break;
	case SS_FAST:
		if (pm->cmd.buttons & BUTTON_BLOCK)
		{
			anim = BOTH_SABERFAST_STANCE;
		}
		else
			anim = BOTH_STAND1;			
		break;
	case SS_STRONG:
		if (pm->cmd.buttons & BUTTON_BLOCK)
		{
			anim = BOTH_SABERSLOW_STANCE;
		}
		else
			anim = BOTH_STAND1;		
		break;
	case SS_TAVION:
		if (pm->cmd.buttons & BUTTON_BLOCK)
		{
			anim = BOTH_SABERTAVION_STANCE;
		}
		else
			anim = BOTH_STAND1;	
		break;
	case SS_DESANN:
		if (pm->cmd.buttons & BUTTON_BLOCK)
		{
			anim = BOTH_SABERDESANN_STANCE;
		}
		else
			anim = BOTH_STAND1;		
		break;
	case SS_MEDIUM:
		if (pm->cmd.buttons & BUTTON_BLOCK)
		{
			anim = BOTH_STAND2;
		}
		else
			anim = BOTH_STAND1;
	case SS_NONE:
	default:
		if (pm->cmd.buttons & BUTTON_BLOCK)
		{
			anim = BOTH_STAND2;
		}
		else
			anim = BOTH_STAND1;
		break;
	}
	return anim;
}

int PM_SetBlock(void)

{
	int anim = BOTH_STAND2;

	if( pm->cmd.forwardmove < 0 ) 
	{//Upper Top block          
		if( pm->cmd.rightmove < 0 )
		{//upper left block
			pm->ps->saberBlocked = BLOCKED_UPPER_LEFT;
		}
		else if ( pm->cmd.rightmove > 0 )
		{//upper right block
			pm->ps->saberBlocked = BLOCKED_UPPER_RIGHT;
		}
		else
		{//Top Block
			pm->ps->saberBlocked = BLOCKED_TOP;
		}
	}
	else if ( pm->cmd.forwardmove > 0 )//Walking Forward BLOCK 
	{				
		if( pm->cmd.rightmove < 0 )
		{//lower left block
			pm->ps->saberBlocked = BLOCKED_LOWER_LEFT;
		}
		else if ( pm->cmd.rightmove > 0 )
		{//lower right block
			pm->ps->saberBlocked = BLOCKED_LOWER_RIGHT;
		}
		else
		{
			pm->ps->saberBlocked = BLOCKED_TOP;
		}
	}
	else
	{
		if( pm->cmd.rightmove < 0 )//left block
		{
			pm->ps->saberBlocked = BLOCKED_UPPER_LEFT;
		}
		else if ( pm->cmd.rightmove > 0 )//right block
		{
			pm->ps->saberBlocked = BLOCKED_UPPER_RIGHT;
		}
		else
		{//not moving just holding button block.
			anim = BOTH_STAND2; 
		}
	}
	return anim; 
}

Put int PM_SetBlock(void) Before PM_WeaponLightsaber

 

Go to // Now we react to a block action by the player's lightsaber. In Bg_Saber.c

 

above there you can add

 if (( pm->ps->"put you Block button call here")
		   && !(pm->ps->weaponstate == WEAPON_DROPPING 
			|| pm->ps->weaponstate == WEAPON_RAISING))
		   && PM_SetBlock())
	    { //keep him in the blocking pose until he can attack again
		return;
		}
	}
	else
	{
		pm->ps->weaponstate = WEAPON_READY;
	}
Boothand likes this
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...