qzdoom/src/g_hexen/a_wraith.cpp
Christoph Oelckers bc63b70d88 Merge branch 'master' into scripting
Conflicts:
	src/actor.h
	src/fragglescript/t_func.cpp
	src/g_doom/a_bossbrain.cpp
	src/g_doom/a_revenant.cpp
	src/g_heretic/a_hereticartifacts.cpp
	src/g_heretic/a_hereticweaps.cpp
	src/g_heretic/a_knight.cpp
	src/g_hexen/a_bishop.cpp
	src/g_hexen/a_clericholy.cpp
	src/g_hexen/a_dragon.cpp
	src/g_hexen/a_firedemon.cpp
	src/g_hexen/a_flechette.cpp
	src/g_hexen/a_heresiarch.cpp
	src/g_hexen/a_hexenspecialdecs.cpp
	src/g_hexen/a_iceguy.cpp
	src/g_hexen/a_korax.cpp
	src/g_hexen/a_magelightning.cpp
	src/g_hexen/a_serpent.cpp
	src/g_hexen/a_spike.cpp
	src/g_hexen/a_wraith.cpp
	src/g_raven/a_minotaur.cpp
	src/g_shared/a_bridge.cpp
	src/g_shared/a_pickups.cpp
	src/g_shared/a_randomspawner.cpp
	src/g_strife/a_alienspectres.cpp
	src/g_strife/a_crusader.cpp
	src/g_strife/a_entityboss.cpp
	src/g_strife/a_inquisitor.cpp
	src/g_strife/a_loremaster.cpp
	src/g_strife/a_programmer.cpp
	src/g_strife/a_sentinel.cpp
	src/g_strife/a_spectral.cpp
	src/g_strife/a_strifestuff.cpp
	src/g_strife/a_strifeweapons.cpp
	src/g_strife/a_thingstoblowup.cpp
	src/p_local.h
	src/r_utility.cpp
2016-01-19 13:43:11 +01:00

271 lines
6.1 KiB
C++

/*
#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"
#include "thingdef/thingdef.h"
*/
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
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_WraithInit)
{
PARAM_ACTION_PROLOGUE;
self->AddZ(48<<FRACBITS);
// [RH] Make sure the wraith didn't go into the ceiling
if (self->Top() > self->ceilingz)
{
self->SetZ(self->ceilingz - self->height);
}
self->special1 = 0; // index into floatbob
return 0;
}
//============================================================================
//
// A_WraithRaiseInit
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_WraithRaiseInit)
{
PARAM_ACTION_PROLOGUE;
self->renderflags &= ~RF_INVISIBLE;
self->flags2 &= ~MF2_NONSHOOTABLE;
self->flags3 &= ~MF3_DONTBLAST;
self->flags |= MF_SHOOTABLE|MF_SOLID;
self->floorclip = self->height;
return 0;
}
//============================================================================
//
// A_WraithRaise
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_WraithRaise)
{
PARAM_ACTION_PROLOGUE;
if (A_RaiseMobj (self, 2*FRACUNIT))
{
// Reached it's target height
// [RH] Once a buried wraith is fully raised, it should be
// morphable, right?
self->flags3 &= ~(MF3_DONTMORPH|MF3_SPECIALFLOORCLIP);
self->SetState (self->FindState("Chase"));
// [RH] Reset PainChance to a normal wraith's.
self->PainChance = GetDefaultByName ("Wraith")->PainChance;
}
P_SpawnDirt (self, self->radius);
return 0;
}
//============================================================================
//
// A_WraithMelee
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_WraithMelee)
{
PARAM_ACTION_PROLOGUE;
int amount;
// Steal health from target and give to self
if (self->CheckMeleeRange() && (pr_stealhealth()<220))
{
amount = pr_stealhealth.HitDice (2);
P_DamageMobj (self->target, self, self, amount, NAME_Melee);
self->health += amount;
}
return 0;
}
//============================================================================
//
// A_WraithFX2 - spawns sparkle tail of missile
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2)
{
PARAM_ACTION_PROLOGUE;
AActor *mo;
angle_t angle;
int i;
for (i = 2; i; --i)
{
mo = Spawn ("WraithFX2", self->Pos(), ALLOW_REPLACE);
if(mo)
{
if (pr_wraithfx2 ()<128)
{
angle = self->angle+(pr_wraithfx2()<<22);
}
else
{
angle = self->angle-(pr_wraithfx2()<<22);
}
mo->velz = 0;
mo->velx = FixedMul((pr_wraithfx2()<<7)+FRACUNIT,
finecosine[angle>>ANGLETOFINESHIFT]);
mo->vely = FixedMul((pr_wraithfx2()<<7)+FRACUNIT,
finesine[angle>>ANGLETOFINESHIFT]);
mo->target = self;
mo->floorclip = 10*FRACUNIT;
}
}
return 0;
}
//============================================================================
//
// A_WraithFX3
//
// Spawn an FX3 around the self during attacks
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_WraithFX3)
{
PARAM_ACTION_PROLOGUE;
AActor *mo;
int numdropped = pr_wraithfx3()%15;
while (numdropped-- > 0)
{
fixedvec3 pos = self->Vec3Offset(
(pr_wraithfx3()-128)<<11,
(pr_wraithfx3()-128)<<11,
(pr_wraithfx3()<<10));
mo = Spawn ("WraithFX3", pos, ALLOW_REPLACE);
if (mo)
{
mo->floorz = self->floorz;
mo->ceilingz = self->ceilingz;
mo->target = self;
}
}
return 0;
}
//============================================================================
//
// A_WraithFX4
//
// Spawn an FX4 during movement
//
//============================================================================
void A_WraithFX4 (AActor *self)
{
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)
{
fixedvec3 pos = self->Vec3Offset(
(pr_wraithfx4()-128)<<12,
(pr_wraithfx4()-128)<<12,
(pr_wraithfx4()<<10));
mo = Spawn ("WraithFX4", pos, ALLOW_REPLACE);
if (mo)
{
mo->floorz = self->floorz;
mo->ceilingz = self->ceilingz;
mo->target = self;
}
}
if (spawn5)
{
fixedvec3 pos = self->Vec3Offset(
(pr_wraithfx4()-128)<<12,
(pr_wraithfx4()-128)<<12,
(pr_wraithfx4()<<10));
mo = Spawn ("WraithFX5", pos, ALLOW_REPLACE);
if (mo)
{
mo->floorz = self->floorz;
mo->ceilingz = self->ceilingz;
mo->target = self;
}
}
}
//============================================================================
//
// A_WraithChase
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_WraithChase)
{
PARAM_ACTION_PROLOGUE;
int weaveindex = self->special1;
self->AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 8);
self->special1 = (weaveindex + 2) & 63;
// if (self->floorclip > 0)
// {
// P_SetMobjState(self, S_WRAITH_RAISE2);
// return;
// }
A_Chase (stack, self);
A_WraithFX4 (self);
return 0;
}