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 "p_enemy.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "gstrings.h"
|
2008-07-20 14:42:54 +00:00
|
|
|
#include "a_specialspot.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "g_level.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_s2fx1 ("S2FX1");
|
|
|
|
static FRandom pr_scrc1atk ("Srcr1Attack");
|
|
|
|
static FRandom pr_dst ("D'SparilTele");
|
|
|
|
static FRandom pr_s2d ("Srcr2Decide");
|
|
|
|
static FRandom pr_s2a ("Srcr2Attack");
|
|
|
|
static FRandom pr_bluespark ("BlueSpark");
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_Sor1Pain
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Sor1Pain)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = 20; // Number of steps to walk fast
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_Pain, self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_Sor1Chase
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Sor1Chase)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
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->special1--;
|
|
|
|
self->tics -= 3;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
A_Chase(self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_Srcr1Attack
|
|
|
|
//
|
|
|
|
// Sorcerer demon attack.
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Srcr1Attack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
2009-06-30 20:57:51 +00:00
|
|
|
fixed_t velz;
|
2006-02-24 04:48:15 +00:00
|
|
|
angle_t angle;
|
|
|
|
|
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_scrc1atk.HitDice (8);
|
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-07-21 17:03:30 +00:00
|
|
|
|
|
|
|
const PClass *fx = PClass::FindClass("SorcererFX1");
|
2009-07-04 18:17:44 +00:00
|
|
|
if (self->health > (self->SpawnHealth()/3)*2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Spit one fireball
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnMissileZ (self, self->z + 48*FRACUNIT, self->target, fx );
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Spit three fireballs
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = P_SpawnMissileZ (self, self->z + 48*FRACUNIT, self->target, fx);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo != NULL)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
velz = mo->velz;
|
2006-02-24 04:48:15 +00:00
|
|
|
angle = mo->angle;
|
2009-06-30 20:57:51 +00:00
|
|
|
P_SpawnMissileAngleZ (self, self->z + 48*FRACUNIT, fx, angle-ANGLE_1*3, velz);
|
|
|
|
P_SpawnMissileAngleZ (self, self->z + 48*FRACUNIT, fx, angle+ANGLE_1*3, velz);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-07-04 18:17:44 +00:00
|
|
|
if (self->health < self->SpawnHealth()/3)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Maybe attack again
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->special1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Just attacked, so don't attack again
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Set state to attack again
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = 1;
|
|
|
|
self->SetState (self->FindState("Missile2"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_SorcererRise
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SorcererRise)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags &= ~MF_SOLID;
|
|
|
|
mo = Spawn("Sorcerer2", self->x, self->y, self->z, ALLOW_REPLACE);
|
2008-07-21 17:03:30 +00:00
|
|
|
mo->SetState (mo->FindState("Rise"));
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->angle = self->angle;
|
|
|
|
mo->CopyFriendliness (self, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC P_DSparilTeleport
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void P_DSparilTeleport (AActor *actor)
|
|
|
|
{
|
|
|
|
fixed_t prevX;
|
|
|
|
fixed_t prevY;
|
|
|
|
fixed_t prevZ;
|
|
|
|
AActor *mo;
|
2008-07-20 14:42:54 +00:00
|
|
|
AActor *spot;
|
|
|
|
|
|
|
|
DSpotState *state = DSpotState::GetSpotState();
|
|
|
|
if (state == NULL) return;
|
|
|
|
|
2008-07-21 17:03:30 +00:00
|
|
|
spot = state->GetSpotWithMinDistance(PClass::FindClass("BossSpot"), actor->x, actor->y, 128*FRACUNIT);
|
2008-07-20 14:42:54 +00:00
|
|
|
if (spot == NULL) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
prevX = actor->x;
|
|
|
|
prevY = actor->y;
|
|
|
|
prevZ = actor->z;
|
|
|
|
if (P_TeleportMove (actor, spot->x, spot->y, spot->z, false))
|
|
|
|
{
|
2008-07-21 17:03:30 +00:00
|
|
|
mo = Spawn("Sorcerer2Telefade", prevX, prevY, prevZ, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
S_Sound (mo, CHAN_BODY, "misc/teleport", 1, ATTN_NORM);
|
2008-07-21 17:03:30 +00:00
|
|
|
actor->SetState (actor->FindState("Teleport"));
|
2006-02-24 04:48:15 +00:00
|
|
|
S_Sound (actor, CHAN_BODY, "misc/teleport", 1, ATTN_NORM);
|
|
|
|
actor->z = actor->floorz;
|
|
|
|
actor->angle = spot->angle;
|
2009-06-30 20:57:51 +00:00
|
|
|
actor->velx = actor->vely = actor->velz = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_Srcr2Decide
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Decide)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
static const int chance[] =
|
|
|
|
{
|
|
|
|
192, 120, 120, 120, 64, 64, 32, 16, 0
|
|
|
|
};
|
|
|
|
|
2009-07-04 18:17:44 +00:00
|
|
|
unsigned int chanceindex = self->health / ((self->SpawnHealth()/8 == 0) ? 1 : self->SpawnHealth()/8);
|
- Fixed compilation with mingw again.
- Added multiple-choice sound sequences. These overcome one of the major
deficiences of the Hexen-inherited SNDSEQ system while still being Hexen
compatible: Custom door sounds can now use different opening and closing
sequences, for both normal and blazing speeds.
- Added a serializer for TArray.
- Added a countof macro to doomtype.h. See the1's blog to find out why
it's implemented the way it is.
<http://blogs.msdn.com/the1/articles/210011.aspx>
- Added a new method to FRandom for getting random numbers larger than 255,
which lets me:
- Fixed: SNDSEQ delayrand commands could delay for no more than 255 tics.
- Fixed: If you're going to have sector_t.SoundTarget, then they need to
be included in the pointer cleanup scans.
- Ported back newer name code from 2.1.
- Fixed: Using -warp with only one parameter in Doom and Heretic to
select a map on episode 1 no longer worked.
- New: Loading a multiplayer save now restores the players based on
their names rather than on their connection order. Using connection
order was sensible when -net was the only way to start a network game,
but with -host/-join, it's not so nice. Also, if there aren't enough
players in the save, then the extra players will be spawned normally,
so you can continue a saved game with more players than you started it
with.
- Added some new SNDSEQ commands to make it possible to define Heretic's
ambient sounds in SNDSEQ: volumerel, volumerand, slot, randomsequence,
delayonce, and restart. With these, it is basically possible to obsolete
all of the $ambient SNDINFO commands.
- Fixed: Sound sequences would only execute one command each time they were
ticked.
- Fixed: No bounds checking was done on the volume sound sequences played at.
- Fixed: The tic parameter to playloop was useless and caused it to
act like a redundant playrepeat. I have removed all the logic that
caused playloop to play repeating sounds, and now it acts like an
infinite sequence of play/delay commands until the sequence is
stopped.
- Fixed: Sound sequences were ticked every frame, not every tic, so all
the delay commands were timed incorrectly and varied depending on your
framerate. Since this is useful for restarting looping sounds that got
cut off, I have not changed this. Instead, the delay commands now
record the tic when execution should resume, not the number of tics
left to delay.
SVN r57 (trunk)
2006-04-21 01:22:55 +00:00
|
|
|
if (chanceindex >= countof(chance))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
- Fixed compilation with mingw again.
- Added multiple-choice sound sequences. These overcome one of the major
deficiences of the Hexen-inherited SNDSEQ system while still being Hexen
compatible: Custom door sounds can now use different opening and closing
sequences, for both normal and blazing speeds.
- Added a serializer for TArray.
- Added a countof macro to doomtype.h. See the1's blog to find out why
it's implemented the way it is.
<http://blogs.msdn.com/the1/articles/210011.aspx>
- Added a new method to FRandom for getting random numbers larger than 255,
which lets me:
- Fixed: SNDSEQ delayrand commands could delay for no more than 255 tics.
- Fixed: If you're going to have sector_t.SoundTarget, then they need to
be included in the pointer cleanup scans.
- Ported back newer name code from 2.1.
- Fixed: Using -warp with only one parameter in Doom and Heretic to
select a map on episode 1 no longer worked.
- New: Loading a multiplayer save now restores the players based on
their names rather than on their connection order. Using connection
order was sensible when -net was the only way to start a network game,
but with -host/-join, it's not so nice. Also, if there aren't enough
players in the save, then the extra players will be spawned normally,
so you can continue a saved game with more players than you started it
with.
- Added some new SNDSEQ commands to make it possible to define Heretic's
ambient sounds in SNDSEQ: volumerel, volumerand, slot, randomsequence,
delayonce, and restart. With these, it is basically possible to obsolete
all of the $ambient SNDINFO commands.
- Fixed: Sound sequences would only execute one command each time they were
ticked.
- Fixed: No bounds checking was done on the volume sound sequences played at.
- Fixed: The tic parameter to playloop was useless and caused it to
act like a redundant playrepeat. I have removed all the logic that
caused playloop to play repeating sounds, and now it acts like an
infinite sequence of play/delay commands until the sequence is
stopped.
- Fixed: Sound sequences were ticked every frame, not every tic, so all
the delay commands were timed incorrectly and varied depending on your
framerate. Since this is useful for restarting looping sounds that got
cut off, I have not changed this. Instead, the delay commands now
record the tic when execution should resume, not the number of tics
left to delay.
SVN r57 (trunk)
2006-04-21 01:22:55 +00:00
|
|
|
chanceindex = countof(chance) - 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pr_s2d() < chance[chanceindex])
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
P_DSparilTeleport (self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_Srcr2Attack
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Attack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int chance;
|
|
|
|
|
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_NONE);
|
|
|
|
if (self->CheckMeleeRange())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int damage = pr_s2a.HitDice (20);
|
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;
|
|
|
|
}
|
2009-07-04 18:17:44 +00:00
|
|
|
chance = self->health < self->SpawnHealth()/2 ? 96 : 48;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (pr_s2a() < chance)
|
|
|
|
{ // Wizard spawners
|
2008-07-21 17:03:30 +00:00
|
|
|
|
|
|
|
const PClass *fx = PClass::FindClass("Sorcerer2FX2");
|
|
|
|
if (fx)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnMissileAngle (self, fx, self->angle-ANG45, FRACUNIT/2);
|
|
|
|
P_SpawnMissileAngle (self, fx, self->angle+ANG45, FRACUNIT/2);
|
2008-07-21 17:03:30 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Blue bolt
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnMissile (self, self->target, PClass::FindClass("Sorcerer2FX1"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_BlueSpark
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BlueSpark)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
AActor *mo;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn("Sorcerer2FXSpark", self->x, self->y, self->z, ALLOW_REPLACE);
|
2009-06-30 20:57:51 +00:00
|
|
|
mo->velx = pr_bluespark.Random2() << 9;
|
|
|
|
mo->vely = pr_bluespark.Random2() << 9;
|
|
|
|
mo->velz = FRACUNIT + (pr_bluespark()<<8);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_GenWizard
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_GenWizard)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn("Wizard", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo != NULL)
|
|
|
|
{
|
2008-07-21 17:03:30 +00:00
|
|
|
mo->z -= mo->GetDefault()->height/2;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (!P_TestMobjLocation (mo))
|
|
|
|
{ // Didn't fit
|
|
|
|
mo->Destroy ();
|
|
|
|
level.total_monsters--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // [RH] Make the new wizards inherit D'Sparil's target
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->CopyFriendliness (self->target, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velx = self->vely = self->velz = 0;
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->FindState(NAME_Death));
|
|
|
|
self->flags &= ~MF_MISSILE;
|
|
|
|
mo->master = self->target;
|
2006-02-24 04:48:15 +00:00
|
|
|
// Heretic did not offset it by TELEFOGHEIGHT, so I won't either.
|
2008-08-10 20:48:55 +00:00
|
|
|
Spawn<ATeleportFog> (self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_Sor2DthInit
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Sor2DthInit)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = 7; // Animation loop counter
|
2006-02-24 04:48:15 +00:00
|
|
|
P_Massacre (); // Kill monsters early
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PROC A_Sor2DthLoop
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Sor2DthLoop)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (--self->special1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Need to loop
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->FindState("DeathLoop"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|