Skip to content

Instantly share code, notes, and snippets.

@disasteroftheuniverse
Created November 6, 2022 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disasteroftheuniverse/cf7f3012e2d8d7257663676d828112b1 to your computer and use it in GitHub Desktop.
Save disasteroftheuniverse/cf7f3012e2d8d7257663676d828112b1 to your computer and use it in GitHub Desktop.
an example of how to use the zdoom pathfinding library
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