2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "info.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "a_hexenglobal.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_boom ("BishopBoom");
|
|
|
|
static FRandom pr_atk ("BishopAttack");
|
|
|
|
static FRandom pr_decide ("BishopDecide");
|
|
|
|
static FRandom pr_doblur ("BishopDoBlur");
|
|
|
|
static FRandom pr_sblur ("BishopSpawnBlur");
|
|
|
|
static FRandom pr_pain ("BishopPainBlur");
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_BishopAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (!self->target)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_BODY, self->AttackSound, 1, ATTN_NORM);
|
|
|
|
if (self->CheckMeleeRange())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int damage = pr_atk.HitDice (4);
|
2008-08-10 20:48:55 +00:00
|
|
|
P_DamageMobj (self->target, self, self, damage, NAME_Melee);
|
|
|
|
P_TraceBleed (damage, self->target, self);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = (pr_atk() & 3) + 5;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_BishopAttack2
|
|
|
|
//
|
|
|
|
// Spawns one of a string of bishop missiles
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (!self->target || !self->special1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = 0;
|
|
|
|
self->SetState (self->SeeState);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = P_SpawnMissile (self, self->target, PClass::FindClass("BishopFX"));
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo != NULL)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->tracer = self->target;
|
2006-02-24 04:48:15 +00:00
|
|
|
mo->special2 = 16; // High word == x/y, Low word == z
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1--;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_BishopMissileWeave
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BishopMissileWeave)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
fixed_t newX, newY;
|
|
|
|
int weaveXY, weaveZ;
|
|
|
|
int angle;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->special2 == 0) self->special2 = 16;
|
2008-07-19 12:40:10 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
weaveXY = self->special2 >> 16;
|
|
|
|
weaveZ = self->special2 & 0xFFFF;
|
|
|
|
angle = (self->angle + ANG90) >> ANGLETOFINESHIFT;
|
|
|
|
newX = self->x - FixedMul (finecosine[angle], FloatBobOffsets[weaveXY]<<1);
|
|
|
|
newY = self->y - FixedMul (finesine[angle], FloatBobOffsets[weaveXY]<<1);
|
2006-02-24 04:48:15 +00:00
|
|
|
weaveXY = (weaveXY + 2) & 63;
|
|
|
|
newX += FixedMul (finecosine[angle], FloatBobOffsets[weaveXY]<<1);
|
|
|
|
newY += FixedMul (finesine[angle], FloatBobOffsets[weaveXY]<<1);
|
2008-08-10 20:48:55 +00:00
|
|
|
P_TryMove (self, newX, newY, true);
|
|
|
|
self->z -= FloatBobOffsets[weaveZ];
|
2006-02-24 04:48:15 +00:00
|
|
|
weaveZ = (weaveZ + 2) & 63;
|
2008-08-10 20:48:55 +00:00
|
|
|
self->z += FloatBobOffsets[weaveZ];
|
|
|
|
self->special2 = weaveZ + (weaveXY<<16);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_BishopDecide
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BishopDecide)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (pr_decide() < 220)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->FindState ("Blur"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_BishopDoBlur
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BishopDoBlur)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = (pr_doblur() & 3) + 3; // Random number of blurs
|
2006-02-24 04:48:15 +00:00
|
|
|
if (pr_doblur() < 120)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
P_ThrustMobj (self, self->angle + ANG90, 11*FRACUNIT);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (pr_doblur() > 125)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
P_ThrustMobj (self, self->angle - ANG90, 11*FRACUNIT);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Thrust forward
|
2008-08-10 20:48:55 +00:00
|
|
|
P_ThrustMobj (self, self->angle, 11*FRACUNIT);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_BODY, "BishopBlur", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_BishopSpawnBlur
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (!--self->special1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->momx = 0;
|
|
|
|
self->momy = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (pr_sblur() > 96)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->SeeState);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->MissileState);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("BishopBlur", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->angle = self->angle;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_BishopChase
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BishopChase)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->z -= FloatBobOffsets[self->special2] >> 1;
|
|
|
|
self->special2 = (self->special2 + 4) & 63;
|
|
|
|
self->z += FloatBobOffsets[self->special2] >> 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_BishopPuff
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BishopPuff)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("BishopPuff", self->x, self->y, self->z + 40*FRACUNIT, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->momz = FRACUNIT/2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_BishopPainBlur
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BishopPainBlur)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
|
|
|
|
if (pr_pain() < 64)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->FindState ("Blur"));
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
fixed_t x = self->x + (pr_pain.Random2()<<12);
|
|
|
|
fixed_t y = self->y + (pr_pain.Random2()<<12);
|
|
|
|
fixed_t z = self->z + (pr_pain.Random2()<<11);
|
2008-08-03 19:42:24 +00:00
|
|
|
mo = Spawn ("BishopPainBlur", x, y, z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->angle = self->angle;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|