A_CPosRefire
Jump to navigation
Jump to search
void A_CPosRefire()
Usage
Used by ChaingunGuy and WolfensteinSS. 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 40 out of 255 chance. Also aborts if the monster hit its ally.
Examples
From ChaingunGuy's code:
Missile:
CPOS E 10 A_FaceTarget;
CPOS FE 4 BRIGHT A_CPosAttack;
CPOS F 1 A_CPosRefire; //goes back to See if attack is to be aborted
Goto Missile+1; //otherwise goes back to Missile but skips the first 10-tic-long state
ZScript definition
| Note: The ZScript definition below is for reference and may be different in the current version of UZDoom. The most up-to-date version of this code can be found on UZDoom GitHub. |
void A_CPosRefire()
{
if (HitFriend())
{
SetState(SeeState);
return;
}
// keep firing unless target got out of sight
A_FaceTarget();
if (Random[CPosRefire](0, 255) >= 40)
{
if (!target
|| target.health <= 0
|| !CheckSight(target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES))
{
SetState(SeeState);
}
}
}