Created
November 6, 2022 02:23
-
-
Save disasteroftheuniverse/cf7f3012e2d8d7257663676d828112b1 to your computer and use it in GitHub Desktop.
an example of how to use the zdoom pathfinding library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void A_PathChase(statelabel MeleeState = null, statelabel MissileState = null) | |
{ | |
if (bInChase) return; | |
if (bInConversation) return; | |
bInChase = true; | |
if (!target || (target && target.health <= 0) || (target && !target.bShootable) ) | |
{ // look for a new target | |
bInChase = false; | |
SetIdle(); | |
return; | |
} | |
reactiontime = 0; | |
// Melee attack | |
if (MeleeState && CheckMeleeRange ()) | |
{ | |
if (AttackSound) | |
{ | |
A_StartSound (AttackSound, CHAN_WEAPON); | |
} | |
bInChase = false; | |
SetStateLabel (MeleeState); | |
return; | |
} | |
// Missile attack | |
if (MissileState && CheckMissileRange()) | |
{ | |
bInChase = false; | |
SetStateLabel (MissileState); | |
return; | |
} | |
// chase towards target | |
A_MoveToEx (); | |
// Active sound | |
if (random[MinotaurChase]() < 6) | |
{ | |
PlayActiveSound (); | |
} | |
bInChase=false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment