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_inq ("Inquisitor");
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_InquisitorWalk)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
S_Sound (self, CHAN_BODY, "inquisitor/walk", 1, ATTN_NORM);
|
|
|
|
A_Chase (self);
|
|
|
|
}
|
|
|
|
|
2006-04-10 21:54:50 +00:00
|
|
|
bool InquisitorCheckDistance (AActor *self)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (self->reactiontime == 0 && P_CheckSight (self, self->target))
|
|
|
|
{
|
|
|
|
return P_AproxDistance (self->x - self->target->x, self->y - self->target->y) < 264*FRACUNIT;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_InquisitorDecide)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (self->target == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
A_FaceTarget (self);
|
2006-04-10 21:54:50 +00:00
|
|
|
if (!InquisitorCheckDistance (self))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-05 22:51:51 +00:00
|
|
|
self->SetState (self->FindState("Grenade"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (self->target->z != self->z)
|
|
|
|
{
|
|
|
|
if (self->z + self->height + 54*FRACUNIT < self->ceilingz)
|
|
|
|
{
|
2008-08-05 22:51:51 +00:00
|
|
|
self->SetState (self->FindState("Jump"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_InquisitorAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *proj;
|
|
|
|
|
|
|
|
if (self->target == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
A_FaceTarget (self);
|
|
|
|
|
|
|
|
self->z += 32*FRACBITS;
|
|
|
|
self->angle -= ANGLE_45/32;
|
2008-08-05 22:51:51 +00:00
|
|
|
proj = P_SpawnMissileZAimed (self, self->z, self->target, PClass::FindClass("InquisitorShot"));
|
2006-02-24 04:48:15 +00:00
|
|
|
if (proj != NULL)
|
|
|
|
{
|
|
|
|
proj->momz += 9*FRACUNIT;
|
|
|
|
}
|
|
|
|
self->angle += ANGLE_45/16;
|
2008-08-05 22:51:51 +00:00
|
|
|
proj = P_SpawnMissileZAimed (self, self->z, self->target, PClass::FindClass("InquisitorShot"));
|
2006-02-24 04:48:15 +00:00
|
|
|
if (proj != NULL)
|
|
|
|
{
|
|
|
|
proj->momz += 16*FRACUNIT;
|
|
|
|
}
|
|
|
|
self->z -= 32*FRACBITS;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
fixed_t dist;
|
|
|
|
fixed_t speed;
|
|
|
|
angle_t an;
|
|
|
|
|
|
|
|
if (self->target == NULL)
|
|
|
|
return;
|
|
|
|
|
2008-03-25 04:42:26 +00:00
|
|
|
S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
self->z += 64*FRACUNIT;
|
|
|
|
A_FaceTarget (self);
|
|
|
|
an = self->angle >> ANGLETOFINESHIFT;
|
|
|
|
speed = self->Speed * 2/3;
|
|
|
|
self->momx += FixedMul (speed, finecosine[an]);
|
|
|
|
self->momy += FixedMul (speed, finesine[an]);
|
|
|
|
dist = P_AproxDistance (self->target->x - self->x, self->target->y - self->y);
|
|
|
|
dist /= speed;
|
|
|
|
if (dist < 1)
|
|
|
|
{
|
|
|
|
dist = 1;
|
|
|
|
}
|
|
|
|
self->momz = (self->target->z - self->z) / dist;
|
|
|
|
self->reactiontime = 60;
|
|
|
|
self->flags |= MF_NOGRAVITY;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_InquisitorCheckLand)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
self->reactiontime--;
|
|
|
|
if (self->reactiontime < 0 ||
|
|
|
|
self->momx == 0 ||
|
|
|
|
self->momy == 0 ||
|
|
|
|
self->z <= self->floorz)
|
|
|
|
{
|
|
|
|
self->SetState (self->SeeState);
|
|
|
|
self->reactiontime = 0;
|
|
|
|
self->flags &= ~MF_NOGRAVITY;
|
2008-08-05 22:51:51 +00:00
|
|
|
S_StopSound (self, CHAN_ITEM);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-08-31 00:16:12 +00:00
|
|
|
if (!S_IsActorPlayingSomething (self, CHAN_ITEM, -1))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-25 04:42:26 +00:00
|
|
|
S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_TossArm)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-05 22:51:51 +00:00
|
|
|
AActor *foo = Spawn("InquisitorArm", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
foo->angle = self->angle - ANGLE_90 + (pr_inq.Random2() << 22);
|
|
|
|
foo->momx = FixedMul (foo->Speed, finecosine[foo->angle >> ANGLETOFINESHIFT]) >> 3;
|
|
|
|
foo->momy = FixedMul (foo->Speed, finesine[foo->angle >> ANGLETOFINESHIFT]) >> 3;
|
|
|
|
foo->momz = pr_inq() << 10;
|
|
|
|
}
|
|
|
|
|