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)
|
|
|
|
{
|
|
|
|
self->momz = 0;
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
self->momz -= FRACUNIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->momz += FRACUNIT;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
|
|
|
if (missile != NULL && (missile->momx|missile->momy) != 0)
|
|
|
|
{
|
|
|
|
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]),
|
2006-07-16 09:10:45 +00:00
|
|
|
missile->z + (missile->momz / 4 * i), ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (trail != NULL)
|
|
|
|
{
|
|
|
|
trail->target = self;
|
|
|
|
trail->momx = missile->momx;
|
|
|
|
trail->momy = missile->momy;
|
|
|
|
trail->momz = missile->momz;
|
|
|
|
P_CheckMissileSpawn (trail);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
missile->z += missile->momz >> 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 ||
|
|
|
|
!P_CheckSight (self, self->target) ||
|
2006-04-10 21:54:50 +00:00
|
|
|
P_HitFriend(self) ||
|
2006-02-24 04:48:15 +00:00
|
|
|
pr_sentinelrefire() < 40)
|
|
|
|
{
|
|
|
|
self->SetState (self->SeeState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|