Skip to content

Commit a99e7bc

Browse files
committed
Modified hellspawn so that it checks for nearby enemies before teleporting itself back to its owner. It also won't follow so closely, making it easier to be positioned for defensive purposes.
1 parent 3927a96 commit a99e7bc

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/combat/abilities/flying_skull.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,17 @@ void skull_remove (edict_t *self)
425425
gi.unlinkentity(self);
426426
}
427427

428+
#define SKULL_FOLLOW_DISTANCE 512 // skull will move towards activator if this range is exceeded
429+
428430
void skull_return (edict_t *self)
429431
{
430432
self->enemy = NULL;
431433

432434
// is our activator visible?
433435
if (visible(self, self->activator))
434436
{
435-
// follow within 128 units
436-
if (entdist(self, self->activator) > 128)
437+
// follow within defined range
438+
if (entdist(self, self->activator) > SKULL_FOLLOW_DISTANCE)
437439
{
438440
skull_movetogoal(self, self->activator);
439441
return;
@@ -492,8 +494,8 @@ void skull_think (edict_t *self)
492494
M_CheckGround(self);
493495
}
494496

495-
if (!self->enemy)
496-
skull_findtarget(self);
497+
//if (!self->enemy)
498+
// skull_findtarget(self);
497499
if (G_ValidTarget(self, self->enemy, false) // is the target still valid?
498500
&& entdist(self->activator, self->enemy) <= SKULL_MAX_RANGE) // make sure the target isn't too far from activator (don't wander)
499501
{
@@ -518,7 +520,15 @@ void skull_think (edict_t *self)
518520
skull_attack(self);
519521
}
520522
else
521-
skull_return(self);//skull_idle(self);
523+
{
524+
// no target or target isn't valid
525+
self->enemy = NULL;
526+
// try to find another target, otherwise return to the activator
527+
if (skull_findtarget(self))
528+
skull_attack(self);
529+
else
530+
skull_return(self);//skull_idle(self);
531+
}
522532

523533
skull_runframes(self);
524534
M_SetEffects(self);

0 commit comments

Comments
 (0)