コード例 #1
0
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem)
{
	PARAM_ACTION_PROLOGUE;
	PARAM_CLASS		(cls, AActor);
	PARAM_INT_OPT	(fail_sp) { fail_sp = 0; }
	PARAM_INT_OPT	(fail_co) { fail_co = 0; }
	PARAM_INT_OPT	(fail_dm) { fail_dm = 0; }

	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(RUNTIME_CLASS(AInventory)))
		{
			static_cast<AInventory*>(spawned)->SpawnPointClass = self->GetClass();
		}
	}
	return 0;
}
コード例 #2
0
ファイル: a_pickups.cpp プロジェクト: Accusedbold/zdoom
bool AInventory::DoRespawn ()
{
	if (SpawnPointClass != NULL)
	{
		AActor *spot = NULL;
		DSpotState *state = DSpotState::GetSpotState();

		if (state != NULL) spot = state->GetRandomSpot(SpawnPointClass);
		if (spot != NULL) 
		{
			SetOrigin (spot->Pos(), false);
			SetZ(floorz);
		}
	}
	return true;
}