A_JumpIf extensions

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: A_JumpIf extensions

Re: A_JumpIf extensions

by Major Cooke » Sun Mar 13, 2011 11:33 am

Edited the post. Thanks Gez.

Re: A_JumpIf extensions

by Gez » Sun Mar 13, 2011 11:11 am

Keep in mind that you can oly add optional parameters to existing functions, and only to the end of the existing parameter list. If you were to add a parameter at the beginning, you'd break backward compatibility with all existing mods using this function...

A_JumpIf extensions

by Major Cooke » Sun Mar 13, 2011 10:18 am

Here are my intentions...

A_JumpIf(expression, state, who, flags)

Expression - Remains the same.
State - Remains the same.
Who - To whom does the actor check? Viable options are self, target, master, and tracer. Default is self.
Flags:
  • JI_CHECKWITHACTOR - Normally it just checks the current DECORATE expression and returns it as is. This flag changes it so the expression is measured against the actor calling it.
If you look at the example below, you'll see that I'm attempting to replicate the Team Fortress 2 Spy's behavior:
  • If the enemy is facing a certain amount away from the caller. If so, jump to the backstab prep state. This uses the flag to check against the current target's angle versus the player's, in this case.
  • It keeps checking to see if it's angles are still in the appropriate after readying for the backstab. If it is, it remains there. If not, it reverts back to the regular holding position.
EXAMPLE:

Code: Select all

Actor SpyKnife : Weapon
{
	Weapon.AmmoType "Knife"
	States
	{
	//...
	Ready:
		SPYK A 0 A_JumpIf(((angle>=160)||(angle<=200)),"RaiseForBackStab",target,JL_CHECKWITHACTOR)
		SPYK A 1 A_WeaponReady
		Loop
	RaiseForBackStab:
		SPYK B 0 A_GiveInventory("BackStabEnabled",1)
		SPYK BCDE 2 A_WeaponReady
	ReadyStab:
		SPYK E 0 A_JumpIf(((angle>=160)||(angle<=200)),1,target,JL_CHECKWITHACTOR)
		Goto "ReturnToNormal"
		SPYK E 1 A_WeaponReady
		Loop
	ReturnToNormal:
		SPYK E 0 A_TakeInventory("BackStabEnabled",1)
		SPYK EDCB 2 A_WeaponReady
		Goto Ready
	Fire:
		SPYK A 0 A_JumpIfInventory("BackStabEnabled",1,"BackStab")
		//Normal knife slash code here.
		Goto Ready
	BackStab:
		//BACKSTAB! code goes here. Takes BackStabEnabled inventory as well.
		Goto Ready
	}
}

Top