2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "m_random.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_sentinelrefire ("SentinelRefire");
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
fixed_t minz, maxz;
|
|
|
|
|
|
|
|
if (self->flags & MF_INFLOAT)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velz = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (self->threshold != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
maxz = self->ceilingz - self->height - 16*FRACUNIT;
|
|
|
|
minz = self->floorz + 96*FRACUNIT;
|
|
|
|
if (minz > maxz)
|
|
|
|
{
|
|
|
|
minz = maxz;
|
|
|
|
}
|
|
|
|
if (minz < self->z)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velz -= FRACUNIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velz += FRACUNIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
self->reactiontime = (minz >= self->z) ? 4 : 0;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *missile, *trail;
|
|
|
|
|
2009-07-12 12:19:11 +00:00
|
|
|
// [BB] Without a target the P_SpawnMissileZAimed call will crash.
|
|
|
|
if (!self->target)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-05 17:58:38 +00:00
|
|
|
missile = P_SpawnMissileZAimed (self, self->z + 32*FRACUNIT, self->target, PClass::FindClass("SentinelFX2"));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-06-30 20:57:51 +00:00
|
|
|
if (missile != NULL && (missile->velx | missile->vely) != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
for (int i = 8; i > 1; --i)
|
|
|
|
{
|
2008-08-05 17:58:38 +00:00
|
|
|
trail = Spawn("SentinelFX1",
|
2006-02-24 04:48:15 +00:00
|
|
|
self->x + FixedMul (missile->radius * i, finecosine[missile->angle >> ANGLETOFINESHIFT]),
|
|
|
|
self->y + FixedMul (missile->radius * i, finesine[missile->angle >> ANGLETOFINESHIFT]),
|
2009-06-30 20:57:51 +00:00
|
|
|
missile->z + (missile->velz / 4 * i), ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (trail != NULL)
|
|
|
|
{
|
|
|
|
trail->target = self;
|
2009-06-30 20:57:51 +00:00
|
|
|
trail->velx = missile->velx;
|
|
|
|
trail->vely = missile->vely;
|
|
|
|
trail->velz = missile->velz;
|
2013-03-21 03:06:04 +00:00
|
|
|
P_CheckMissileSpawn (trail, self->radius);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-30 20:57:51 +00:00
|
|
|
missile->z += missile->velz >> 2;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SentinelRefire)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
A_FaceTarget (self);
|
|
|
|
|
|
|
|
if (pr_sentinelrefire() >= 30)
|
|
|
|
{
|
|
|
|
if (self->target == NULL ||
|
|
|
|
self->target->health <= 0 ||
|
2010-04-03 07:10:52 +00:00
|
|
|
!P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES) ||
|
2006-04-10 21:54:50 +00:00
|
|
|
P_HitFriend(self) ||
|
2012-09-06 03:36:25 +00:00
|
|
|
(self->MissileState == NULL && !self->CheckMeleeRange()) ||
|
2006-02-24 04:48:15 +00:00
|
|
|
pr_sentinelrefire() < 40)
|
|
|
|
{
|
|
|
|
self->SetState (self->SeeState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|