mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-27 22:31:07 +00:00
- scriptified A_SpawnSingleItem, which was the last piece of native code still referencing AInventory
This commit is contained in:
parent
2459b27895
commit
d66516ec82
3 changed files with 77 additions and 84 deletions
|
@ -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)
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue