A MonsterRefire: Difference between revisions

From ZDoom Wiki
Jump to navigation Jump to search
m (A CposRefire moved to A CPosRefire)
No edit summary
 
(25 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:A_MonsterRefire}}
'''A_CposRefire'''


'''A_SpidRefire'''
'''{{class|Actor}}'''


{{c|native State '''A_MonsterRefire''' (int ''chance'', statelabel ''label'')}}
'''A_SentinelRefire'''


== Usage ==
Calls [[A_FaceTarget]] and then checks whether the monster should abort its attack sequence and go to a different [[Actor states|state]]. If the target is out of sight or dead, has a '''chance'''/255 chance to not jump to the ''label'' state sequence. Also aborts the attack if it hit the monster's ally.


Monster-specific functions such as [[A_CPosRefire]], [[A_CrusaderRefire]], [[A_SpidRefire]] and [[A_SentinelRefire]], are variations of this function with predetermined chances (they also all jump to the "See" state sequence if the attack is to be aborted).
(no parameters)


=== Parameters ===
*{{c|int '''chance'''}}
:Chance in the 0-255 range that the actor will ''continue'' attacking even if its target is dead or out of sight.
*{{c|StateLabel '''label'''}}
:Name of the state sequence to go to if the actor aborts its attack, for example {{c|"See"}}.


== Example ==
Checks whether the monster should loop its attack sequence. If the target is out of sight the attack is terminated with a small random factor to continue it. This random factor is slightly higher for A_CposRefire than for A_SpidRefire.
Class SuperZombie : {{Class|ZombieMan}}
{
States
{
Missile:
POSS E 10 [[A_FaceTarget]];
MissileLoop: {{comment|Intentional fall-through}}
POSS FE 2 Bright [[A_PosAttack]];
POSS F 1 [[A_MonsterRefire]](128, "See"); {{comment|50% chance to jump to "See" if target is out of sight.}}
loop; {{comment|If the jump ''doesn't'' happen, loops back to the start of MissileLoop}}
}
}


[[category:Decorate Generic Attack functions]]{{DEFAULTSORT:MonsterRefire}}
A_SentinelRefire is similar but it also has a small change of the attack being terminated even if the target is still visible.

All these functions jump to the See state if the attack is to be aborted. The loop has to be explicitly coded in the actor definition.

Latest revision as of 12:18, 30 November 2024


Actor

native State A_MonsterRefire (int chance, statelabel label)

Usage

Calls A_FaceTarget and then checks whether the monster should abort its attack sequence and go to a different state. If the target is out of sight or dead, has a chance/255 chance to not jump to the label state sequence. Also aborts the attack if it hit the monster's ally.

Monster-specific functions such as A_CPosRefire, A_CrusaderRefire, A_SpidRefire and A_SentinelRefire, are variations of this function with predetermined chances (they also all jump to the "See" state sequence if the attack is to be aborted).

Parameters

  • int chance
Chance in the 0-255 range that the actor will continue attacking even if its target is dead or out of sight.
  • StateLabel label
Name of the state sequence to go to if the actor aborts its attack, for example "See".

Example

Class SuperZombie : ZombieMan
{
	States
	{
	Missile:
		POSS E 10 A_FaceTarget;
	MissileLoop: // Intentional fall-through
		POSS FE 2 Bright A_PosAttack;
		POSS F 1 A_MonsterRefire(128, "See"); // 50% chance to jump to "See" if target is out of sight.
		loop; // If the jump doesn't happen, loops back to the start of MissileLoop
	}
}