A_SpidRefire

From ZDoom Wiki
Jump to navigation Jump to search
Ktip.png This page describes a function made for one of the natively supported games. These functions are made with very specific purpose and provide no flexibility, so using them in custom projects is not recommended. Authors are encouraged to use one of the more generalized functions in custom projects. For example: A_MonsterRefire.

Actor

void A_SpidRefire()

Usage

Used by SpiderMastermind. Calls A_FaceTarget and then lets the monster refire. If the target is dead or out of sight, will abort the attack and go back to its "See" state sequence with a 10 out of 255 chance. Also aborts if the monster hit its ally.

Examples

From SpiderMastermind's code:

	Missile:
		SPID A 20 BRIGHT A_FaceTarget;
		SPID G 4 BRIGHT A_SPosAttackUseAtkSound;
		SPID H 4 BRIGHT A_SposAttackUseAtkSound;
		SPID H 1 BRIGHT A_SpidRefire;
		Goto Missile+1;

ZScript definition

Note: The ZScript definition below is for reference and may be different in the current version of GZDoom.The most up-to-date version of this code can be found on GZDoom GitHub.
	void A_SpidRefire()
	{
		if (HitFriend())
		{
			SetState(SeeState);
			return;
		}
		// keep firing unless target got out of sight
		A_FaceTarget();
		if (Random[CPosRefire](0, 255) >= 10)
		{
			if (!target
				|| target.health <= 0
				|| !CheckSight(target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES))
			{
				SetState(SeeState);
			}
		}
	}

See also