A_CPosRefire
Jump to navigation
Jump to search
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.
![Ktip.png](/w/images/9/98/Ktip.png)
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 GZDoom.The most up-to-date version of this code can be found on GZDoom 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);
}
}
}