gzdoom-gles/src/g_strife/a_sentinel.cpp
Christoph Oelckers 51b05d331d - replaced AActor::vel and player_t::Vel with a floating point version.
- Converted P_MovePlayer and all associated variables to floating point because this wasn't working well with a mixture between float and fixed.

Like the angle commit this has just been patched up to compile, the bulk of work is yet to be done.
2016-03-20 00:54:18 +01:00

95 lines
1.9 KiB
C++

/*
#include "actor.h"
#include "p_enemy.h"
#include "a_action.h"
#include "p_local.h"
#include "m_random.h"
#include "thingdef/thingdef.h"
*/
static FRandom pr_sentinelrefire ("SentinelRefire");
DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob)
{
PARAM_ACTION_PROLOGUE;
fixed_t minz, maxz;
if (self->flags & MF_INFLOAT)
{
self->Vel.Z = 0;
return 0;
}
if (self->threshold != 0)
return 0;
maxz = self->ceilingz - self->height - 16*FRACUNIT;
minz = self->floorz + 96*FRACUNIT;
if (minz > maxz)
{
minz = maxz;
}
if (minz < self->_f_Z())
{
self->Vel.Z -= 1;
}
else
{
self->Vel.Z += 1;
}
self->reactiontime = (minz >= self->_f_Z()) ? 4 : 0;
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack)
{
PARAM_ACTION_PROLOGUE;
AActor *missile, *trail;
// [BB] Without a target the P_SpawnMissileZAimed call will crash.
if (!self->target)
{
return 0;
}
missile = P_SpawnMissileZAimed (self, self->_f_Z() + 32*FRACUNIT, self->target, PClass::FindActor("SentinelFX2"));
if (missile != NULL && (missile->Vel.X != 0 || missile->Vel.Y != 0))
{
for (int i = 8; i > 1; --i)
{
trail = Spawn("SentinelFX1",
self->_f_Vec3Angle(missile->radius*i, missile->_f_angle(), (missile->_f_velz() / 4 * i)), ALLOW_REPLACE);
if (trail != NULL)
{
trail->target = self;
trail->Vel = missile->Vel;
P_CheckMissileSpawn (trail, self->radius);
}
}
missile->_f_AddZ(missile->_f_velz() >> 2);
}
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_SentinelRefire)
{
PARAM_ACTION_PROLOGUE;
A_FaceTarget (self);
if (pr_sentinelrefire() >= 30)
{
if (self->target == NULL ||
self->target->health <= 0 ||
!P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES) ||
P_HitFriend(self) ||
(self->MissileState == NULL && !self->CheckMeleeRange()) ||
pr_sentinelrefire() < 40)
{
self->SetState (self->SeeState);
}
}
return 0;
}