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 "p_enemy.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "a_sharedglobal.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_stealhealth ("StealHealth");
|
|
|
|
static FRandom pr_wraithfx2 ("WraithFX2");
|
|
|
|
static FRandom pr_wraithfx3 ("WraithFX3");
|
|
|
|
static FRandom pr_wraithfx4 ("WraithFX4");
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// Wraith Variables
|
|
|
|
//
|
|
|
|
// special1 Internal index into floatbob
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_WraithInit
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_WraithInit)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->z += 48<<FRACBITS;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Make sure the wraith didn't go into the ceiling
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->z + self->height > self->ceilingz)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->z = self->ceilingz - self->height;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = 0; // index into floatbob
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_WraithRaiseInit
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_WraithRaiseInit)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->renderflags &= ~RF_INVISIBLE;
|
|
|
|
self->flags2 &= ~MF2_NONSHOOTABLE;
|
|
|
|
self->flags3 &= ~MF3_DONTBLAST;
|
|
|
|
self->flags |= MF_SHOOTABLE|MF_SOLID;
|
|
|
|
self->floorclip = self->height;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_WraithRaise
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_WraithRaise)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (A_RaiseMobj (self, 2*FRACUNIT))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Reached it's target height
|
|
|
|
// [RH] Once a buried wraith is fully raised, it should be
|
|
|
|
// morphable, right?
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags3 &= ~(MF3_DONTMORPH|MF3_SPECIALFLOORCLIP);
|
|
|
|
self->SetState (self->FindState("Chase"));
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Reset PainChance to a normal wraith's.
|
2008-08-10 20:48:55 +00:00
|
|
|
self->PainChance = GetDefaultByName ("Wraith")->PainChance;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnDirt (self, self->radius);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_WraithMelee
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_WraithMelee)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int amount;
|
|
|
|
|
|
|
|
// Steal health from target and give to self
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->CheckMeleeRange() && (pr_stealhealth()<220))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
amount = pr_stealhealth.HitDice (2);
|
2008-08-10 20:48:55 +00:00
|
|
|
P_DamageMobj (self->target, self, self, amount, NAME_Melee);
|
|
|
|
self->health += amount;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_WraithFX2 - spawns sparkle tail of missile
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
angle_t angle;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 2; i; --i)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("WraithFX2", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if(mo)
|
|
|
|
{
|
|
|
|
if (pr_wraithfx2 ()<128)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
angle = self->angle+(pr_wraithfx2()<<22);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
angle = self->angle-(pr_wraithfx2()<<22);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
mo->momz = 0;
|
|
|
|
mo->momx = FixedMul((pr_wraithfx2()<<7)+FRACUNIT,
|
|
|
|
finecosine[angle>>ANGLETOFINESHIFT]);
|
|
|
|
mo->momy = FixedMul((pr_wraithfx2()<<7)+FRACUNIT,
|
|
|
|
finesine[angle>>ANGLETOFINESHIFT]);
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->target = self;
|
2006-02-24 04:48:15 +00:00
|
|
|
mo->floorclip = 10*FRACUNIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_WraithFX3
|
|
|
|
//
|
2008-08-10 20:48:55 +00:00
|
|
|
// Spawn an FX3 around the self during attacks
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_WraithFX3)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
int numdropped = pr_wraithfx3()%15;
|
|
|
|
|
|
|
|
while (numdropped-- > 0)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("WraithFX3", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->x += (pr_wraithfx3()-128)<<11;
|
|
|
|
mo->y += (pr_wraithfx3()-128)<<11;
|
|
|
|
mo->z += (pr_wraithfx3()<<10);
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->target = self;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_WraithFX4
|
|
|
|
//
|
|
|
|
// Spawn an FX4 during movement
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
void A_WraithFX4 (AActor *self)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
int chance = pr_wraithfx4();
|
|
|
|
bool spawn4, spawn5;
|
|
|
|
|
|
|
|
if (chance < 10)
|
|
|
|
{
|
|
|
|
spawn4 = true;
|
|
|
|
spawn5 = false;
|
|
|
|
}
|
|
|
|
else if (chance < 20)
|
|
|
|
{
|
|
|
|
spawn4 = false;
|
|
|
|
spawn5 = true;
|
|
|
|
}
|
|
|
|
else if (chance < 25)
|
|
|
|
{
|
|
|
|
spawn4 = true;
|
|
|
|
spawn5 = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spawn4 = false;
|
|
|
|
spawn5 = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spawn4)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("WraithFX4", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->x += (pr_wraithfx4()-128)<<12;
|
|
|
|
mo->y += (pr_wraithfx4()-128)<<12;
|
|
|
|
mo->z += (pr_wraithfx4()<<10);
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->target = self;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (spawn5)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("WraithFX5", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->x += (pr_wraithfx4()-128)<<11;
|
|
|
|
mo->y += (pr_wraithfx4()-128)<<11;
|
|
|
|
mo->z += (pr_wraithfx4()<<10);
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->target = self;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_WraithChase
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_WraithChase)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
int weaveindex = self->special1;
|
|
|
|
self->z += FloatBobOffsets[weaveindex];
|
|
|
|
self->special1 = (weaveindex+2)&63;
|
|
|
|
// if (self->floorclip > 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
// {
|
2008-08-10 20:48:55 +00:00
|
|
|
// P_SetMobjState(self, S_WRAITH_RAISE2);
|
2006-02-24 04:48:15 +00:00
|
|
|
// return;
|
|
|
|
// }
|
2008-08-10 20:48:55 +00:00
|
|
|
A_Chase (self);
|
|
|
|
A_WraithFX4 (self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|