2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "info.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "statnums.h"
|
2008-07-20 14:42:54 +00:00
|
|
|
#include "a_specialspot.h"
|
2008-06-22 09:13:19 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "doomstat.h"
|
|
|
|
#include "g_level.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_brainscream ("BrainScream");
|
|
|
|
static FRandom pr_brainexplode ("BrainExplode");
|
|
|
|
static FRandom pr_spawnfly ("SpawnFly");
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BrainAwake)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2006-02-24 04:48:15 +00:00
|
|
|
// killough 3/26/98: only generates sound now
|
2008-03-21 05:13:59 +00:00
|
|
|
S_Sound (self, CHAN_VOICE, "brain/sight", 1, ATTN_NONE);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BrainPain)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2008-03-21 05:13:59 +00:00
|
|
|
S_Sound (self, CHAN_VOICE, "brain/pain", 1, ATTN_NONE);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BrainishExplosion (fixed_t x, fixed_t y, fixed_t z)
|
|
|
|
{
|
2007-04-28 09:06:32 +00:00
|
|
|
AActor *boom = Spawn("Rocket", x, y, z, NO_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (boom != NULL)
|
|
|
|
{
|
2008-06-15 02:25:09 +00:00
|
|
|
boom->DeathSound = "misc/brainexplode";
|
2009-06-30 20:57:51 +00:00
|
|
|
boom->velz = pr_brainscream() << 9;
|
2008-07-20 14:42:54 +00:00
|
|
|
|
2010-03-24 02:49:37 +00:00
|
|
|
PClassActor *cls = PClass::FindActor("BossBrain");
|
2008-07-20 14:42:54 +00:00
|
|
|
if (cls != NULL)
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
FState *state = cls->FindState(NAME_Brainexplode);
|
2008-07-20 14:42:54 +00:00
|
|
|
if (state != NULL)
|
|
|
|
boom->SetState (state);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
boom->effects = 0;
|
2008-01-10 11:02:07 +00:00
|
|
|
boom->Damage = 0; // disables collision detection which is not wanted here
|
2006-02-24 04:48:15 +00:00
|
|
|
boom->tics -= pr_brainscream() & 7;
|
|
|
|
if (boom->tics < 1)
|
|
|
|
boom->tics = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BrainScream)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t x;
|
|
|
|
|
|
|
|
for (x = self->x - 196*FRACUNIT; x < self->x + 320*FRACUNIT; x += 8*FRACUNIT)
|
|
|
|
{
|
|
|
|
BrainishExplosion (x, self->y - 320*FRACUNIT,
|
|
|
|
128 + (pr_brainscream() << (FRACBITS + 1)));
|
|
|
|
}
|
2008-03-21 05:13:59 +00:00
|
|
|
S_Sound (self, CHAN_VOICE, "brain/death", 1, ATTN_NONE);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BrainExplode)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t x = self->x + pr_brainexplode.Random2()*2048;
|
|
|
|
fixed_t z = 128 + pr_brainexplode()*2*FRACUNIT;
|
|
|
|
BrainishExplosion (x, self->y, z);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BrainDie)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] If noexit, then don't end the level.
|
|
|
|
if ((deathmatch || alwaysapplydmflags) && (dmflags & DF_NO_EXIT))
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-06-20 17:57:32 +00:00
|
|
|
// New dmflag: Kill all boss spawned monsters before ending the level.
|
|
|
|
if (dmflags2 & DF2_KILLBOSSMONST)
|
|
|
|
{
|
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor *mo;
|
|
|
|
while ((mo = it.Next()))
|
|
|
|
{
|
|
|
|
if (mo->flags4 & MF4_BOSSSPAWNED)
|
|
|
|
{
|
|
|
|
P_DamageMobj(mo, self, self, mo->health, NAME_None,
|
|
|
|
DMG_NO_ARMOR|DMG_FORCED|DMG_THRUSTLESS|DMG_NO_FACTOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
G_ExitLevel (0, false);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BrainSpit)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-10-27 02:37:40 +00:00
|
|
|
PARAM_CLASS_OPT(spawntype, AActor) { spawntype = NULL; }
|
2010-02-12 06:04:57 +00:00
|
|
|
|
2008-07-20 14:42:54 +00:00
|
|
|
DSpotState *state = DSpotState::GetSpotState();
|
2006-02-24 04:48:15 +00:00
|
|
|
AActor *targ;
|
|
|
|
AActor *spit;
|
2008-08-12 20:19:47 +00:00
|
|
|
bool isdefault = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// shoot a cube at current target
|
2008-07-20 14:42:54 +00:00
|
|
|
targ = state->GetNextInList(PClass::FindClass("BossTarget"), G_SkillProperty(SKILLP_EasyBossBrain));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (targ != NULL)
|
|
|
|
{
|
2008-08-12 20:19:47 +00:00
|
|
|
if (spawntype == NULL)
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
spawntype = PClass::FindActor("SpawnShot");
|
2008-08-12 20:19:47 +00:00
|
|
|
isdefault = true;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// spawn brain missile
|
2008-06-22 09:13:19 +00:00
|
|
|
spit = P_SpawnMissile (self, targ, spawntype);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-10-01 14:54:29 +00:00
|
|
|
// Boss cubes should move freely to their destination so it's
|
|
|
|
// probably best to disable all collision detection for them.
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (spit != NULL)
|
|
|
|
{
|
2011-08-30 15:34:40 +00:00
|
|
|
if (spit->flags & MF_NOCLIP) spit->flags5 |= MF5_NOINTERACTION;
|
2006-02-24 04:48:15 +00:00
|
|
|
spit->target = targ;
|
2008-06-22 09:13:19 +00:00
|
|
|
spit->master = self;
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Do this correctly for any trajectory. Doom would divide by 0
|
|
|
|
// if the target had the same y coordinate as the spitter.
|
2009-06-30 20:57:51 +00:00
|
|
|
if ((spit->velx | spit->vely) == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-08-02 03:56:03 +00:00
|
|
|
spit->special2 = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-06-30 20:57:51 +00:00
|
|
|
else if (abs(spit->vely) > abs(spit->velx))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-08-02 03:56:03 +00:00
|
|
|
spit->special2 = (targ->y - self->y) / spit->vely;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-02 03:56:03 +00:00
|
|
|
spit->special2 = (targ->x - self->x) / spit->velx;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-06-26 17:32:48 +00:00
|
|
|
// [GZ] Calculates when the projectile will have reached destination
|
2009-08-02 03:56:03 +00:00
|
|
|
spit->special2 += level.maptime;
|
2011-01-23 08:33:30 +00:00
|
|
|
spit->flags6 |= MF6_BOSSCUBE;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 20:19:47 +00:00
|
|
|
if (!isdefault)
|
2008-06-22 09:13:19 +00:00
|
|
|
{
|
|
|
|
S_Sound(self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NONE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// compatibility fallback
|
|
|
|
S_Sound (self, CHAN_WEAPON, "brain/spit", 1, ATTN_NONE);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-04-03 04:07:17 +00:00
|
|
|
static void SpawnFly(AActor *self, PClassActor *spawntype, FSoundID sound)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *newmobj;
|
|
|
|
AActor *fog;
|
2009-08-30 10:43:51 +00:00
|
|
|
AActor *eye = self->master; // The eye is the spawnshot's master, not the target!
|
|
|
|
AActor *targ = self->target; // Unlike other projectiles, the target is the intended destination.
|
2006-02-24 04:48:15 +00:00
|
|
|
int r;
|
|
|
|
|
2009-08-01 01:56:16 +00:00
|
|
|
// [GZ] Should be more viable than a countdown...
|
2009-08-02 03:56:03 +00:00
|
|
|
if (self->special2 != 0)
|
|
|
|
{
|
|
|
|
if (self->special2 > level.maptime)
|
|
|
|
return; // still flying
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (self->reactiontime == 0 || --self->reactiontime != 0)
|
|
|
|
return; // still flying
|
|
|
|
}
|
2009-08-30 10:43:51 +00:00
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
if (spawntype != NULL)
|
2008-06-22 09:13:19 +00:00
|
|
|
{
|
2008-08-12 14:30:07 +00:00
|
|
|
fog = Spawn (spawntype, targ->x, targ->y, targ->z, ALLOW_REPLACE);
|
|
|
|
if (fog != NULL) S_Sound (fog, CHAN_BODY, sound, 1, ATTN_NORM);
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FName SpawnName;
|
|
|
|
|
2010-03-25 20:38:00 +00:00
|
|
|
DDropItem *di; // di will be our drop item list iterator
|
|
|
|
DDropItem *drop; // while drop stays as the reference point.
|
2009-08-08 01:18:15 +00:00
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
// First see if this cube has its own actor list
|
|
|
|
drop = self->GetDropItems();
|
2008-06-22 09:13:19 +00:00
|
|
|
|
2009-08-08 01:18:15 +00:00
|
|
|
// If not, then default back to its master's list
|
2009-08-30 10:43:51 +00:00
|
|
|
if (drop == NULL && eye != NULL)
|
|
|
|
drop = eye->GetDropItems();
|
2009-08-08 01:18:15 +00:00
|
|
|
|
|
|
|
if (drop != NULL)
|
|
|
|
{
|
|
|
|
for (di = drop; di != NULL; di = di->Next)
|
2008-06-22 09:13:19 +00:00
|
|
|
{
|
2009-08-08 01:18:15 +00:00
|
|
|
if (di->Name != NAME_None)
|
2008-06-22 09:13:19 +00:00
|
|
|
{
|
2010-03-25 20:38:00 +00:00
|
|
|
if (di->Amount < 0)
|
2008-06-22 09:13:19 +00:00
|
|
|
{
|
2010-03-25 20:38:00 +00:00
|
|
|
di->Amount = 1; // default value is -1, we need a positive value.
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
2010-03-25 20:38:00 +00:00
|
|
|
n += di->Amount; // this is how we can weight the list.
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
2009-08-08 01:18:15 +00:00
|
|
|
}
|
|
|
|
di = drop;
|
|
|
|
n = pr_spawnfly(n);
|
2009-08-30 10:43:51 +00:00
|
|
|
while (n >= 0)
|
2009-08-08 01:18:15 +00:00
|
|
|
{
|
|
|
|
if (di->Name != NAME_None)
|
2008-06-22 09:13:19 +00:00
|
|
|
{
|
2010-03-25 20:38:00 +00:00
|
|
|
n -= di->Amount; // logically, none of the -1 values have survived by now.
|
2009-08-08 01:18:15 +00:00
|
|
|
}
|
|
|
|
if ((di->Next != NULL) && (n >= 0))
|
|
|
|
{
|
|
|
|
di = di->Next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n = -1;
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-08 01:18:15 +00:00
|
|
|
SpawnName = di->Name;
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
|
|
|
if (SpawnName == NAME_None)
|
|
|
|
{
|
|
|
|
// Randomly select monster to spawn.
|
|
|
|
r = pr_spawnfly ();
|
|
|
|
|
|
|
|
// Probability distribution (kind of :),
|
|
|
|
// decreasing likelihood.
|
2009-08-08 01:18:15 +00:00
|
|
|
if (r < 50) SpawnName = "DoomImp";
|
|
|
|
else if (r < 90) SpawnName = "Demon";
|
|
|
|
else if (r < 120) SpawnName = "Spectre";
|
|
|
|
else if (r < 130) SpawnName = "PainElemental";
|
|
|
|
else if (r < 160) SpawnName = "Cacodemon";
|
|
|
|
else if (r < 162) SpawnName = "Archvile";
|
|
|
|
else if (r < 172) SpawnName = "Revenant";
|
|
|
|
else if (r < 192) SpawnName = "Arachnotron";
|
|
|
|
else if (r < 222) SpawnName = "Fatso";
|
|
|
|
else if (r < 246) SpawnName = "HellKnight";
|
|
|
|
else SpawnName = "BaronOfHell";
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
2010-04-03 04:07:17 +00:00
|
|
|
spawntype = PClass::FindActor(SpawnName);
|
2008-06-22 09:13:19 +00:00
|
|
|
if (spawntype != NULL)
|
|
|
|
{
|
|
|
|
newmobj = Spawn (spawntype, targ->x, targ->y, targ->z, ALLOW_REPLACE);
|
|
|
|
if (newmobj != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-06-22 09:13:19 +00:00
|
|
|
// Make the new monster hate what the boss eye hates
|
|
|
|
if (eye != NULL)
|
|
|
|
{
|
|
|
|
newmobj->CopyFriendliness (eye, false);
|
|
|
|
}
|
2012-03-10 02:17:49 +00:00
|
|
|
// Make it act as if it was around when the player first made noise
|
|
|
|
// (if the player has made noise).
|
|
|
|
newmobj->LastHeard = newmobj->Sector->SoundTarget;
|
|
|
|
|
2009-09-16 15:54:04 +00:00
|
|
|
if (newmobj->SeeState != NULL && P_LookForPlayers (newmobj, true, NULL))
|
2012-03-10 02:17:49 +00:00
|
|
|
{
|
2008-06-22 09:13:19 +00:00
|
|
|
newmobj->SetState (newmobj->SeeState);
|
2012-03-10 02:17:49 +00:00
|
|
|
}
|
2008-06-22 09:13:19 +00:00
|
|
|
if (!(newmobj->ObjectFlags & OF_EuthanizeMe))
|
|
|
|
{
|
|
|
|
// telefrag anything in this spot
|
|
|
|
P_TeleportMove (newmobj, newmobj->x, newmobj->y, newmobj->z, true);
|
|
|
|
}
|
2010-06-20 17:57:32 +00:00
|
|
|
newmobj->flags4 |= MF4_BOSSSPAWNED;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove self (i.e., cube).
|
|
|
|
self->Destroy ();
|
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnFly)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS_OPT (spawntype, AActor) { spawntype = NULL; }
|
2008-08-12 14:30:07 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
FSoundID sound;
|
2008-08-12 20:19:47 +00:00
|
|
|
|
|
|
|
if (spawntype != NULL)
|
2008-08-12 14:30:07 +00:00
|
|
|
{
|
2008-08-12 20:19:47 +00:00
|
|
|
sound = GetDefaultByType(spawntype)->SeeSound;
|
2008-08-12 14:30:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
spawntype = PClass::FindActor("SpawnFire");
|
2008-08-12 14:30:07 +00:00
|
|
|
sound = "brain/spawn";
|
|
|
|
}
|
|
|
|
SpawnFly(self, spawntype, sound);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2008-08-12 14:30:07 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// travelling cube sound
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SpawnSound)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2006-02-24 04:48:15 +00:00
|
|
|
S_Sound (self, CHAN_BODY, "brain/cube", 1, ATTN_IDLE);
|
2010-04-03 04:07:17 +00:00
|
|
|
SpawnFly(self, PClass::FindActor("SpawnFire"), "brain/spawn");
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|