2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** Decorations that do special things
|
|
|
|
*/
|
|
|
|
|
2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "info.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_lnspec.h"
|
- Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from
ParseActorProperties().
- Fixed: The decorate FindFlag() function returned flags from ActorFlags
instead of the passed flags set.
- Fixed: The CHT_CHAINSAW, CHT_POWER, CHT_HEALTH, and CHT_RESSURECT needed
NULL player->mo checks.
- Fixed: The "give all" command didn't give the backpack in Doom, and it
must give the backpack before giving ammo.
- Fixed: P_SetPsprite() must not call the action function if the player is
not attached to an actor. This can happen, for instance, if the level is
destroyed while the player is holding a powered-up Phoenix Rod. As part
of its EndPowerup() function, it sets the psprite to the regular version,
but the player actor has already been destroyed.
- Fixed: FinishThingdef() needs to check for valid names, because weapons
could have inherited valid pointers from their superclass.
- Fixed: fuglyname didn't work.
- Fixed: Redefining $ambient sounds leaked memory.
- Added Jim's crashcatcher.c fix for better shell support.
- VC7.1 seems to have no trouble distinguishing between passing a (const
TypeInfo *) reference to operator<< and the generic, templated (object *)
version, so a few places that can benefit from it now use it. I believe
VC6 had problems with this, which is why I didn't do it all along. The
function's implementation was also moved out of dobject.cpp and into
farchive.cpp.
- Fixed: UnpackPixels() unpacked all chunks in a byte, which is wrong for the
last byte in a row if the image width is not an even multiple of the number
pixels per byte.
- Fixed: P_TranslateLineDef() should only clear monster activation for secret
useable lines, not crossable lines.
- Fixed: Some leftover P_IsHostile() calls still needed to be rewritten.
- Fixed: AWeaponHolder::Serialize() wrote the class type in all circumstances.
SVN r20 (trunk)
2006-03-14 06:11:39 +00:00
|
|
|
#include "a_hexenglobal.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"
|
|
|
|
#include "doomstat.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_pottery ("PotteryExplode");
|
|
|
|
static FRandom pr_bit ("PotteryChooseBit");
|
|
|
|
static FRandom pr_drip ("CorpseBloodDrip");
|
|
|
|
static FRandom pr_foo ("CorpseExplode");
|
|
|
|
static FRandom pr_leaf ("LeafSpawn");
|
|
|
|
static FRandom pr_leafthrust ("LeafThrust");
|
|
|
|
static FRandom pr_leafcheck ("LeafCheck");
|
|
|
|
static FRandom pr_shroom ("PoisonShroom");
|
|
|
|
static FRandom pr_soaexplode ("SoAExplode");
|
|
|
|
|
|
|
|
// Pottery1 ------------------------------------------------------------------
|
|
|
|
|
|
|
|
void A_PotteryExplode (AActor *);
|
|
|
|
void A_PotteryChooseBit (AActor *);
|
|
|
|
void A_PotteryCheck (AActor *);
|
|
|
|
|
|
|
|
class APottery1 : public AActor
|
|
|
|
{
|
2008-08-08 15:18:23 +00:00
|
|
|
DECLARE_CLASS (APottery1, AActor)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
void HitFloor ();
|
|
|
|
};
|
|
|
|
|
2008-08-08 15:18:23 +00:00
|
|
|
IMPLEMENT_CLASS (APottery1)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void APottery1::HitFloor ()
|
|
|
|
{
|
|
|
|
Super::HitFloor ();
|
2006-10-31 14:53:21 +00:00
|
|
|
P_DamageMobj (this, NULL, NULL, 25, NAME_None);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_PotteryExplode
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = (pr_pottery()&3)+3; i; i--)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("PotteryBit", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
mo->SetState (mo->SpawnState + (pr_pottery()%5));
|
|
|
|
if (mo)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
mo->velz = ((pr_pottery()&7)+5)*(3*FRACUNIT/4);
|
|
|
|
mo->velx = (pr_pottery.Random2())<<(FRACBITS-6);
|
|
|
|
mo->vely = (pr_pottery.Random2())<<(FRACBITS-6);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
S_Sound (mo, CHAN_BODY, "PotteryExplode", 1, ATTN_NORM);
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->args[0]>=0 && self->args[0]<=255 && SpawnableThings[self->args[0]])
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Spawn an item
|
2009-02-03 19:11:43 +00:00
|
|
|
if (!((level.flags2 & LEVEL2_NOMONSTERS) || (dmflags & DF_NO_MONSTERS))
|
2008-08-10 20:48:55 +00:00
|
|
|
|| !(GetDefaultByType (SpawnableThings[self->args[0]])->flags3 & MF3_ISMONSTER))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Only spawn monsters if not -nomonsters
|
2008-08-10 20:48:55 +00:00
|
|
|
Spawn (SpawnableThings[self->args[0]],
|
|
|
|
self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_PotteryChooseBit
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_PotteryChooseBit)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->FindState(NAME_Death) + 1 + 2*(pr_bit()%5));
|
|
|
|
self->tics = 256+(pr_bit()<<1);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_PotteryCheck
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_PotteryCheck)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
|
|
|
{
|
|
|
|
AActor *pmo = players[i].mo;
|
2008-08-10 20:48:55 +00:00
|
|
|
if (P_CheckSight (self, pmo) && (abs (R_PointToAngle2 (pmo->x,
|
|
|
|
pmo->y, self->x, self->y) - pmo->angle) <= ANGLE_45))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Previous state (pottery bit waiting state)
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->state - 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lynched corpse (no heart) ------------------------------------------------
|
|
|
|
|
|
|
|
class AZCorpseLynchedNoHeart : public AActor
|
|
|
|
{
|
2008-08-08 15:18:23 +00:00
|
|
|
DECLARE_CLASS (AZCorpseLynchedNoHeart, AActor)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
void PostBeginPlay ();
|
|
|
|
};
|
|
|
|
|
2008-08-08 15:18:23 +00:00
|
|
|
IMPLEMENT_CLASS (AZCorpseLynchedNoHeart)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void AZCorpseLynchedNoHeart::PostBeginPlay ()
|
|
|
|
{
|
|
|
|
Super::PostBeginPlay ();
|
2009-01-03 18:09:33 +00:00
|
|
|
Spawn ("BloodPool", x, y, floorz, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CorpseBloodDrip
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CorpseBloodDrip)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (pr_drip() <= 128)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
Spawn ("CorpseBloodDrip", self->x, self->y, self->z + self->height/2, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CorpseExplode
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CorpseExplode)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = (pr_foo()&3)+3; i; i--)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("CorpseBit", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
2008-08-12 23:00:48 +00:00
|
|
|
mo->SetState (mo->SpawnState + (pr_foo()%3));
|
2009-06-30 20:57:51 +00:00
|
|
|
mo->velz = ((pr_foo()&7)+5)*(3*FRACUNIT/4);
|
|
|
|
mo->velx = pr_foo.Random2()<<(FRACBITS-6);
|
|
|
|
mo->vely = pr_foo.Random2()<<(FRACBITS-6);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Spawn a skull
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("CorpseBit", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
2008-08-12 23:00:48 +00:00
|
|
|
mo->SetState (mo->SpawnState + 3);
|
2009-06-30 20:57:51 +00:00
|
|
|
mo->velz = ((pr_foo()&7)+5)*(3*FRACUNIT/4);
|
|
|
|
mo->velx = pr_foo.Random2()<<(FRACBITS-6);
|
|
|
|
mo->vely = pr_foo.Random2()<<(FRACBITS-6);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_BODY, self->DeathSound, 1, ATTN_IDLE);
|
|
|
|
self->Destroy ();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_LeafSpawn
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_LeafSpawn)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = (pr_leaf()&3)+1; i; i--)
|
|
|
|
{
|
2008-08-08 15:18:23 +00:00
|
|
|
mo = Spawn (pr_leaf()&1 ? PClass::FindClass ("Leaf1") : PClass::FindClass ("Leaf2"),
|
2008-08-10 20:48:55 +00:00
|
|
|
self->x + (pr_leaf.Random2()<<14),
|
|
|
|
self->y + (pr_leaf.Random2()<<14),
|
|
|
|
self->z + (pr_leaf()<<14), ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
P_ThrustMobj (mo, self->angle, (pr_leaf()<<9)+3*FRACUNIT);
|
|
|
|
mo->target = self;
|
2006-02-24 04:48:15 +00:00
|
|
|
mo->special1 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_LeafThrust
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_LeafThrust)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (pr_leafthrust() <= 96)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velz += (pr_leafthrust()<<9)+FRACUNIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_LeafCheck
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_LeafCheck)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1++;
|
|
|
|
if (self->special1 >= 20)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
angle_t ang = self->target ? self->target->angle : self->angle;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (pr_leafcheck() > 64)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
if (!self->velx && !self->vely)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
P_ThrustMobj (self, ang, (pr_leafcheck()<<9)+FRACUNIT);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->SpawnState + 7);
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velz = (pr_leafcheck()<<9)+FRACUNIT;
|
2008-08-10 20:48:55 +00:00
|
|
|
P_ThrustMobj (self, ang, (pr_leafcheck()<<9)+2*FRACUNIT);
|
|
|
|
self->flags |= MF_MISSILE;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_PoisonShroom
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_PoisonShroom)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->tics = 128+(pr_shroom()<<1);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SoAExplode - Suit of Armor Explode
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SoAExplode)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn ("ZArmorChunk", self->x+((pr_soaexplode()-128)<<12),
|
|
|
|
self->y+((pr_soaexplode()-128)<<12),
|
|
|
|
self->z+(pr_soaexplode()*self->height/256), ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
2008-08-12 23:00:48 +00:00
|
|
|
mo->SetState (mo->SpawnState + i);
|
2009-06-30 20:57:51 +00:00
|
|
|
mo->velz = ((pr_soaexplode()&7)+5)*FRACUNIT;
|
|
|
|
mo->velx = pr_soaexplode.Random2()<<(FRACBITS-6);
|
|
|
|
mo->vely = pr_soaexplode.Random2()<<(FRACBITS-6);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->args[0]>=0 && self->args[0]<=255 && SpawnableThings[self->args[0]])
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Spawn an item
|
2009-02-03 19:11:43 +00:00
|
|
|
if (!((level.flags2 & LEVEL2_NOMONSTERS) || (dmflags & DF_NO_MONSTERS))
|
2008-08-10 20:48:55 +00:00
|
|
|
|| !(GetDefaultByType (SpawnableThings[self->args[0]])->flags3 & MF3_ISMONSTER))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Only spawn monsters if not -nomonsters
|
2008-08-10 20:48:55 +00:00
|
|
|
Spawn (SpawnableThings[self->args[0]],
|
|
|
|
self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_BODY, self->DeathSound, 1, ATTN_NORM);
|
|
|
|
self->Destroy ();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bell ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
class AZBell : public AActor
|
|
|
|
{
|
2008-08-08 15:18:23 +00:00
|
|
|
DECLARE_CLASS (AZBell, AActor)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
void Activate (AActor *activator);
|
|
|
|
};
|
|
|
|
|
2008-08-08 15:18:23 +00:00
|
|
|
IMPLEMENT_CLASS (AZBell)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void AZBell::Activate (AActor *activator)
|
|
|
|
{
|
|
|
|
if (health > 0)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
P_DamageMobj (this, activator, activator, 10, NAME_Melee); // 'ring' the bell
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_BellReset1
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BellReset1)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags |= MF_NOGRAVITY;
|
|
|
|
self->height <<= 2;
|
|
|
|
if (self->special)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Initiate death action
|
2008-08-10 20:48:55 +00:00
|
|
|
LineSpecials[self->special] (NULL, NULL, false, self->args[0],
|
|
|
|
self->args[1], self->args[2], self->args[3], self->args[4]);
|
|
|
|
self->special = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_BellReset2
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BellReset2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags |= MF_SHOOTABLE;
|
|
|
|
self->flags &= ~MF_CORPSE;
|
2009-12-25 11:09:56 +00:00
|
|
|
self->flags6 &= ~MF6_KILLED;
|
2008-08-10 20:48:55 +00:00
|
|
|
self->health = 5;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|