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_enemy.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "s_sound.h"
|
2008-04-15 10:04:41 +00:00
|
|
|
#include "m_bbox.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_thrustraise ("ThrustRaise");
|
|
|
|
|
|
|
|
// Spike (thrust floor) -----------------------------------------------------
|
|
|
|
|
|
|
|
// AThrustFloor is just a container for all the spike states.
|
|
|
|
// All the real spikes subclass it.
|
|
|
|
|
|
|
|
class AThrustFloor : public AActor
|
|
|
|
{
|
2008-08-10 11:29:19 +00:00
|
|
|
DECLARE_CLASS (AThrustFloor, AActor)
|
2008-08-11 19:18:48 +00:00
|
|
|
HAS_OBJECT_POINTERS
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
void Serialize (FArchive &arc);
|
|
|
|
|
|
|
|
void Activate (AActor *activator);
|
|
|
|
void Deactivate (AActor *activator);
|
|
|
|
|
2008-08-10 11:29:19 +00:00
|
|
|
TObjPtr<AActor> DirtClump;
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-08-11 19:18:48 +00:00
|
|
|
IMPLEMENT_POINTY_CLASS (AThrustFloor)
|
|
|
|
DECLARE_POINTER (DirtClump)
|
|
|
|
END_POINTERS
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void AThrustFloor::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
|
|
|
arc << DirtClump;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AThrustFloor::Activate (AActor *activator)
|
|
|
|
{
|
2006-07-16 09:10:45 +00:00
|
|
|
if (args[0] == 0)
|
|
|
|
{
|
|
|
|
S_Sound (this, CHAN_BODY, "ThrustSpikeLower", 1, ATTN_NORM);
|
|
|
|
renderflags &= ~RF_INVISIBLE;
|
|
|
|
if (args[1])
|
2008-08-10 11:29:19 +00:00
|
|
|
SetState (FindState ("BloodThrustRaise"));
|
2006-07-16 09:10:45 +00:00
|
|
|
else
|
2008-08-10 11:29:19 +00:00
|
|
|
SetState (FindState ("ThrustRaise"));
|
2006-07-16 09:10:45 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AThrustFloor::Deactivate (AActor *activator)
|
|
|
|
{
|
2006-07-16 09:10:45 +00:00
|
|
|
if (args[0] == 1)
|
|
|
|
{
|
|
|
|
S_Sound (this, CHAN_BODY, "ThrustSpikeRaise", 1, ATTN_NORM);
|
|
|
|
if (args[1])
|
2008-08-10 11:29:19 +00:00
|
|
|
SetState (FindState ("BloodThrustLower"));
|
2006-07-16 09:10:45 +00:00
|
|
|
else
|
2008-08-10 11:29:19 +00:00
|
|
|
SetState (FindState ("ThrustLower"));
|
2006-07-16 09:10:45 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Thrust floor stuff
|
|
|
|
//
|
|
|
|
// Thrust Spike Variables
|
|
|
|
// DirtClump pointer to dirt clump actor
|
|
|
|
// special2 speed of raise
|
|
|
|
// args[0] 0 = lowered, 1 = raised
|
|
|
|
// args[1] 0 = normal, 1 = bloody
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ThrustInitUp)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special2 = 5; // Raise speed
|
|
|
|
self->args[0] = 1; // Mark as up
|
|
|
|
self->floorclip = 0;
|
|
|
|
self->flags = MF_SOLID;
|
|
|
|
self->flags2 = MF2_NOTELEPORT|MF2_FLOORCLIP;
|
|
|
|
self->special1 = 0L;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ThrustInitDn)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special2 = 5; // Raise speed
|
|
|
|
self->args[0] = 0; // Mark as down
|
|
|
|
self->floorclip = self->GetDefault()->height;
|
|
|
|
self->flags = 0;
|
|
|
|
self->flags2 = MF2_NOTELEPORT|MF2_FLOORCLIP;
|
|
|
|
self->renderflags = RF_INVISIBLE;
|
|
|
|
static_cast<AThrustFloor *>(self)->DirtClump =
|
|
|
|
Spawn("DirtClump", self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ThrustRaise)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AThrustFloor *actor = static_cast<AThrustFloor *>(self);
|
|
|
|
|
2008-08-10 11:29:19 +00:00
|
|
|
if (A_RaiseMobj (actor, self->special2*FRACUNIT))
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Reached it's target height
|
|
|
|
actor->args[0] = 1;
|
|
|
|
if (actor->args[1])
|
2010-04-19 02:46:50 +00:00
|
|
|
actor->SetState (actor->FindState ("BloodThrustInit2"), true);
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2010-04-19 02:46:50 +00:00
|
|
|
actor->SetState (actor->FindState ("ThrustInit2"), true);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lose the dirt clump
|
|
|
|
if ((actor->floorclip < actor->height) && actor->DirtClump)
|
|
|
|
{
|
|
|
|
actor->DirtClump->Destroy ();
|
|
|
|
actor->DirtClump = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Spawn some dirt
|
|
|
|
if (pr_thrustraise()<40)
|
|
|
|
P_SpawnDirt (actor, actor->radius);
|
|
|
|
actor->special2++; // Increase raise speed
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ThrustLower)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (A_SinkMobj (self, 6*FRACUNIT))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->args[0] = 0;
|
|
|
|
if (self->args[1])
|
2010-04-19 02:46:50 +00:00
|
|
|
self->SetState (self->FindState ("BloodThrustInit1"), true);
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2010-04-19 02:46:50 +00:00
|
|
|
self->SetState (self->FindState ("ThrustInit1"), true);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ThrustImpale)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-04-07 21:14:28 +00:00
|
|
|
AActor *thing;
|
2008-08-10 20:48:55 +00:00
|
|
|
FBlockThingsIterator it(FBoundingBox(self->x, self->y, self->radius));
|
2008-04-07 21:14:28 +00:00
|
|
|
while ((thing = it.Next()))
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (!thing->intersects(self))
|
2008-04-15 10:04:41 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-04-07 21:14:28 +00:00
|
|
|
if (!(thing->flags & MF_SHOOTABLE) )
|
|
|
|
continue;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (thing == self)
|
2008-04-07 21:14:28 +00:00
|
|
|
continue; // don't clip against self
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_DamageMobj (thing, self, self, 10001, NAME_Crush);
|
2008-04-07 21:14:28 +00:00
|
|
|
P_TraceBleed (10001, thing);
|
2008-08-10 20:48:55 +00:00
|
|
|
self->args[1] = 1; // Mark thrust thing as bloody
|
2008-04-07 21:14:28 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|