2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "s_sound.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_stalker ("Stalker");
|
|
|
|
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_StalkerChaseDecide)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (!(self->flags & MF_NOGRAVITY))
|
|
|
|
{
|
2008-08-07 20:16:07 +00:00
|
|
|
self->SetState (self->FindState("SeeFloor"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (self->ceilingz - self->height > self->z)
|
|
|
|
{
|
2008-08-07 20:16:07 +00:00
|
|
|
self->SetState (self->FindState("Drop"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_StalkerLookInit)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-07 20:16:07 +00:00
|
|
|
FState *state;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (self->flags & MF_NOGRAVITY)
|
|
|
|
{
|
2008-08-07 20:16:07 +00:00
|
|
|
state = self->FindState("LookCeiling");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-07 20:16:07 +00:00
|
|
|
state = self->FindState("LookFloor");
|
|
|
|
}
|
|
|
|
if (self->state->NextState != state)
|
|
|
|
{
|
|
|
|
self->SetState (state);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_StalkerDrop)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-07 20:16:07 +00:00
|
|
|
self->flags5 &= ~MF5_NOVERTICALMELEERANGE;
|
2006-02-24 04:48:15 +00:00
|
|
|
self->flags &= ~MF_NOGRAVITY;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_StalkerAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (self->flags & MF_NOGRAVITY)
|
|
|
|
{
|
2008-08-07 20:16:07 +00:00
|
|
|
self->SetState (self->FindState("Drop"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (self->target != NULL)
|
|
|
|
{
|
|
|
|
A_FaceTarget (self);
|
|
|
|
if (self->CheckMeleeRange ())
|
|
|
|
{
|
|
|
|
int damage = (pr_stalker() & 7) * 2 + 2;
|
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
P_DamageMobj (self->target, self, self, damage, NAME_Melee);
|
2006-02-24 04:48:15 +00:00
|
|
|
P_TraceBleed (damage, self->target, self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_StalkerWalk)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
S_Sound (self, CHAN_BODY, "stalker/walk", 1, ATTN_NORM);
|
|
|
|
A_Chase (self);
|
|
|
|
}
|
|
|
|
|