- Converted the mace and all related actors to DECORATE and generalized
the spawn function that only spawns one mace per level. - Moved Mace respawning code into AInventory so that it works properly for replacement actors. SVN r1107 (trunk)
This commit is contained in:
parent
11fbfc5b1f
commit
affd0e5034
11 changed files with 291 additions and 282 deletions
|
|
@ -37,12 +37,14 @@
|
|||
#include "p_local.h"
|
||||
#include "statnums.h"
|
||||
#include "i_system.h"
|
||||
#include "thingdef/thingdef.h"
|
||||
|
||||
static FRandom pr_spot ("SpecialSpot");
|
||||
static FRandom pr_spawnmace ("SpawnMace");
|
||||
|
||||
|
||||
IMPLEMENT_CLASS(DSpotState)
|
||||
IMPLEMENT_ABSTRACT_ACTOR (ASpecialSpot)
|
||||
IMPLEMENT_CLASS (ASpecialSpot)
|
||||
TObjPtr<DSpotState> DSpotState::SpotState;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
@ -371,3 +373,65 @@ void ASpecialSpot::Destroy()
|
|||
if (state != NULL) state->RemoveSpot(this);
|
||||
Super::Destroy();
|
||||
}
|
||||
|
||||
// Mace spawn spot ----------------------------------------------------------
|
||||
|
||||
|
||||
// Every mace spawn spot will execute this action. The first one
|
||||
// will build a list of all mace spots in the level and spawn a
|
||||
// mace. The rest of the spots will do nothing.
|
||||
|
||||
void A_SpawnSingleItem (AActor *self)
|
||||
{
|
||||
AActor *spot = NULL;
|
||||
DSpotState *state = DSpotState::GetSpotState();
|
||||
|
||||
if (state != NULL) spot = state->GetRandomSpot(RUNTIME_TYPE(self), true);
|
||||
if (spot == NULL) return;
|
||||
|
||||
int index=CheckIndex(4);
|
||||
if (index<0) return;
|
||||
|
||||
ENamedName SpawnType = (ENamedName)StateParameters[index];
|
||||
int fail_sp = EvalExpressionI (StateParameters[index+1], self);
|
||||
int fail_co = EvalExpressionI (StateParameters[index+2], self);
|
||||
int fail_dm = EvalExpressionI (StateParameters[index+3], self);
|
||||
|
||||
if (!multiplayer && pr_spawnmace() < fail_sp)
|
||||
{ // Sometimes doesn't show up if not in deathmatch
|
||||
return;
|
||||
}
|
||||
|
||||
if (multiplayer && !deathmatch && pr_spawnmace() < fail_co)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (deathmatch && pr_spawnmace() < fail_dm)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const PClass *cls = PClass::FindClass(SpawnType);
|
||||
if (cls == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AActor *spawned = Spawn(cls, self->x, self->y, self->z, ALLOW_REPLACE);
|
||||
|
||||
if (spawned)
|
||||
{
|
||||
spawned->SetOrigin (spot->x, spot->y, spot->z);
|
||||
spawned->z = spawned->floorz;
|
||||
// We want this to respawn.
|
||||
if (!(self->flags & MF_DROPPED))
|
||||
{
|
||||
spawned->flags &= ~MF_DROPPED;
|
||||
}
|
||||
if (spawned->IsKindOf(RUNTIME_CLASS(AInventory)))
|
||||
{
|
||||
static_cast<AInventory*>(spawned)->SpawnPointClass = RUNTIME_TYPE(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue