A_JumpIf extensions

Moderator: GZDoom Developers

User avatar
Major Cooke
Posts: 8206
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town

A_JumpIf extensions

Post by Major Cooke »

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
	}
}
Last edited by Major Cooke on Sun Mar 13, 2011 11:33 am, edited 2 times in total.
Gez
 
 
Posts: 17938
Joined: Fri Jul 06, 2007 3:22 pm

Re: A_JumpIf extensions

Post by Gez »

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...
User avatar
Major Cooke
Posts: 8206
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town

Re: A_JumpIf extensions

Post by Major Cooke »

Edited the post. Thanks Gez.

Return to “Closed Feature Suggestions [GZDoom]”