Permalink
Browse files

- scriptified A_SpawnSingleItem, which was the last piece of native c…

…ode still referencing AInventory
  • Loading branch information...
coelckers committed Dec 4, 2018
1 parent 2459b27 commit d66516ec82fb137d4ffe36c5703dea82f7151c81
@@ -40,7 +40,6 @@
#include "vm.h"
static FRandom pr_spot ("SpecialSpot");
static FRandom pr_spawnmace ("SpawnMace");
IMPLEMENT_CLASS(DSpotState, false, false)
IMPLEMENT_CLASS(ASpecialSpot, false, false)
@@ -74,7 +73,7 @@ struct FSpotList
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -90,15 +89,15 @@ struct FSpotList
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
bool Remove(ASpecialSpot *spot)
{
for(unsigned i = 0; i < Spots.Size(); i++)
{
if (Spots[i] == spot)
if (Spots[i] == spot)
{
Spots.Delete(i);
if (Index > i) Index--;
@@ -110,7 +109,7 @@ struct FSpotList
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -130,7 +129,7 @@ struct FSpotList
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -157,7 +156,7 @@ struct FSpotList
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -175,7 +174,7 @@ struct FSpotList
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -195,7 +194,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FSpotList &list, FSpot
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -214,7 +213,7 @@ DSpotState::DSpotState ()
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -229,17 +228,17 @@ void DSpotState::OnDestroy ()
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
void DSpotState::Tick ()
void DSpotState::Tick ()
{
}
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -257,7 +256,7 @@ DEFINE_ACTION_FUNCTION(DSpotState, GetSpotState)
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -273,7 +272,7 @@ FSpotList *DSpotState::FindSpotList(PClassActor *type)
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -286,7 +285,7 @@ bool DSpotState::AddSpot(ASpecialSpot *spot)
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -299,7 +298,7 @@ bool DSpotState::RemoveSpot(ASpecialSpot *spot)
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -311,7 +310,7 @@ void DSpotState::Serialize(FSerializer &arc)
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -332,7 +331,7 @@ DEFINE_ACTION_FUNCTION(DSpotState, GetNextInList)
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -357,7 +356,7 @@ DEFINE_ACTION_FUNCTION(DSpotState, GetSpotWithMinMaxDistance)
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -378,7 +377,7 @@ DEFINE_ACTION_FUNCTION(DSpotState, GetRandomSpot)
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -390,7 +389,7 @@ void ASpecialSpot::BeginPlay()
//----------------------------------------------------------------------------
//
//
//
//
//----------------------------------------------------------------------------
@@ -400,63 +399,3 @@ void ASpecialSpot::OnDestroy()
if (state != NULL) state->RemoveSpot(this);
Super::OnDestroy();
}
// 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.
DEFINE_ACTION_FUNCTION(ASpecialSpot, A_SpawnSingleItem)
{
PARAM_SELF_PROLOGUE(ASpecialSpot);
PARAM_CLASS_NOT_NULL(cls, AActor);
PARAM_INT (fail_sp)
PARAM_INT (fail_co)
PARAM_INT (fail_dm)
AActor *spot = NULL;
DSpotState *state = DSpotState::GetSpotState();
if (state != NULL) spot = state->GetRandomSpot(self->GetClass(), true);
if (spot == NULL) return 0;
if (!multiplayer && pr_spawnmace() < fail_sp)
{ // Sometimes doesn't show up if not in deathmatch
return 0;
}
if (multiplayer && !deathmatch && pr_spawnmace() < fail_co)
{
return 0;
}
if (deathmatch && pr_spawnmace() < fail_dm)
{
return 0;
}
if (cls == NULL)
{
return 0;
}
AActor *spawned = Spawn(cls, self->Pos(), ALLOW_REPLACE);
if (spawned)
{
spawned->SetOrigin (spot->Pos(), false);
spawned->SetZ(spawned->floorz);
// We want this to respawn.
if (!(self->flags & MF_DROPPED))
{
spawned->flags &= ~MF_DROPPED;
}
if (spawned->IsKindOf(NAME_Inventory))
{
static_cast<AInventory*>(spawned)->SpawnPointClass = self->GetClass();
}
}
return 0;
}
@@ -1601,7 +1601,7 @@ class PlayerPawn : Actor native
//
// APlayerPawn :: PickNewWeapon
//
// Picks a new weapon for self player. Used mostly for running out of ammo,
// Picks a new weapon for this player. Used mostly for running out of ammo,
// but it also works when an ACS script explicitly takes the ready weapon
// away or the player picks up some ammo they had previously run out of.
//
@@ -1,5 +1,59 @@
class SpecialSpot : Actor native
{
native void A_SpawnSingleItem(class<Actor> type, int fail_sp = 0, int fail_co = 0, int fail_dm = 0);
// 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(class<Actor> cls, int fail_sp = 0, int fail_co = 0, int fail_dm = 0)
{
Actor spot = NULL;
let state = SpotState.GetSpotState();
if (state != NULL) spot = state.GetRandomSpot(GetClass(), true);
if (spot == NULL) return;
if (!multiplayer && random[SpawnMace]() < fail_sp)
{ // Sometimes doesn't show up if not in deathmatch
return;
}
if (multiplayer && !deathmatch && random[SpawnMace]() < fail_co)
{
return;
}
if (deathmatch && random[SpawnMace]() < fail_dm)
{
return;
}
if (cls == NULL)
{
return;
}
let spawned = Spawn(cls, self.Pos, ALLOW_REPLACE);
if (spawned)
{
// Setting z in two steps is necessary to proper initialize floorz before using it.
spawned.SetOrigin (spot.Pos, false);
spawned.SetZ(spawned.floorz);
// We want this to respawn.
if (!bDropped)
{
spawned.bDropped = false;
}
let inv = Inventory(spawned);
if (inv)
{
inv.SpawnPointClass = GetClass();
}
}
}
}

0 comments on commit d66516e

Please sign in to comment.