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 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.
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
}
}