1171 lines
50 KiB
C++
1171 lines
50 KiB
C++
#include "entity_factory.h"
|
|
#include "entity_bomb.h"
|
|
#include "entity_effect.h"
|
|
#include "entity_familiar.h"
|
|
#include "entity_knife.h"
|
|
#include "entity_laser.h"
|
|
#include "entity_npc.h"
|
|
#include "entity_pickup.h"
|
|
#include "entity_player.h"
|
|
#include "entity_projectile.h"
|
|
#include "entity_slot.h"
|
|
#include "entity_tear.h"
|
|
#include "entity_text.h"
|
|
#include "game.h"
|
|
#include "grid_entity.h"
|
|
#include "lua_engine.h"
|
|
#include "manager.h"
|
|
#include "platform.h"
|
|
#include "room.h"
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
|
|
constexpr uint64_t NS_PER_MS = 1000000;
|
|
|
|
// An entity made by a Delirium form (by the original's use: Delirium's look and lowered thresholds), which its own
|
|
// spawns inherit.
|
|
constexpr int SPAWN_STATUS_FRAMES = 90;
|
|
|
|
// The entity types, variants and boss ids spawning and layouts single out.
|
|
constexpr int ENTITY_HORF = 12;
|
|
constexpr int ENTITY_GLOBIN = 24;
|
|
constexpr int ENTITY_MAW = 26;
|
|
constexpr int ENTITY_HOST = 27;
|
|
constexpr int ENTITY_STONEHEAD = 42;
|
|
constexpr int ENTITY_FLAMINGHOPPER = 54;
|
|
constexpr int ENTITY_MEMBRAIN = 57;
|
|
constexpr int ENTITY_PARA_BITE = 58;
|
|
constexpr int ENTITY_EYE = 60;
|
|
constexpr int ENTITY_WALKINGBOIL = 88;
|
|
constexpr int ENTITY_SKINNY = 226;
|
|
constexpr int ENTITY_NERVE_ENDING = 231;
|
|
constexpr int ENTITY_HUSH_GAPER = 297;
|
|
constexpr int ENTITY_GREED_GAPER = 299;
|
|
constexpr int ENTITY_MUSHROOM = 300;
|
|
constexpr int ENTITY_SUB_HORF = 812;
|
|
constexpr int ENTITY_STRIDER = 814;
|
|
constexpr int ENTITY_GYRO = 824;
|
|
constexpr int EFFECT_CRAWLSPACE_LADDER = 192;
|
|
constexpr int BOSS_SATAN = 24;
|
|
|
|
constexpr int CARD_SPECIAL_CHANCE = 25;
|
|
constexpr int CARD_RUNE_CHANCE = 10;
|
|
constexpr int PICKUP_RANDOM_CARD = 301;
|
|
constexpr int COLLECTIBLE_DIRTY_MIND = 576;
|
|
|
|
constexpr int SLOT_MACHINE = 1;
|
|
constexpr int SLOT_BEGGAR = 4;
|
|
constexpr int SLOT_DEVIL_BEGGAR = 5;
|
|
constexpr int SLOT_KEY_MASTER = 7;
|
|
constexpr int SLOT_SHELL_GAME = 6;
|
|
constexpr int SLOT_DONATION = 8;
|
|
constexpr int SLOT_CLOSET_TAINTED = 14;
|
|
constexpr int SLOT_HELL_GAME = 15;
|
|
constexpr int SLOT_CRANE_GAME = 16;
|
|
constexpr int SLOT_CONFESSIONAL = 17;
|
|
constexpr int SLOT_ROTTEN_BEGGAR = 18;
|
|
constexpr int SHOPKEEPER_SPECIAL = 3;
|
|
constexpr int SHOPKEEPER_SECRET_SPECIAL = 4;
|
|
constexpr int EFFECT_VARIANT_TRAPDOOR_MARKER = 39;
|
|
// The stairs a stage with no next one is left by, and the trapdoor to the Void.
|
|
constexpr int STAIRS_VARIANT_EXIT = 3;
|
|
constexpr int TRAPDOOR_VARIANT_VOID = 1;
|
|
// A Nerve Ending this close to a door stays plain, and the Boom Fly subtype that rolls its own.
|
|
constexpr int NERVE_DOOR_DISTANCE = 4;
|
|
constexpr int BOOMFLY_DRAGONFLY_SUBTYPE = 100;
|
|
|
|
// The layout entry types that are not entities: grid entities, their markers, rails and the trapdoor.
|
|
enum EntryType : int
|
|
{
|
|
ENTRY_EFFECT = 999,
|
|
ENTRY_ROCK = 1000,
|
|
ENTRY_ROCK_BOMB = 1001,
|
|
ENTRY_ROCK_ALT = 1002,
|
|
ENTRY_ROCK_TINTED = 1003,
|
|
ENTRY_ROCK_SUPER_TINTED = 1004,
|
|
ENTRY_ROCK_ALT2 = 1008,
|
|
ENTRY_ROCK_MARKED = 1009,
|
|
ENTRY_ROCK_SPIKED = 1010,
|
|
ENTRY_ROCK_GOLD = 1011,
|
|
ENTRY_TNT = 1300,
|
|
ENTRY_FIREPLACE = 1400,
|
|
ENTRY_FIREPLACE_RED = 1410,
|
|
ENTRY_POOP_RED = 1490,
|
|
ENTRY_POOP_RAINBOW = 1494,
|
|
ENTRY_POOP_CORN = 1495,
|
|
ENTRY_POOP_GOLDEN = 1496,
|
|
ENTRY_POOP_BLACK = 1497,
|
|
ENTRY_POOP_HOLY = 1498,
|
|
ENTRY_POOP_GIGA = 1499,
|
|
ENTRY_POOP = 1500,
|
|
ENTRY_POOP_CHARMING = 1501,
|
|
ENTRY_BLOCK = 1900,
|
|
ENTRY_PILLAR = 1901,
|
|
ENTRY_SPIKES = 1930,
|
|
ENTRY_SPIKES_ONOFF = 1931,
|
|
ENTRY_COBWEB = 1940,
|
|
ENTRY_WALL = 1999,
|
|
ENTRY_PIT = 3000,
|
|
ENTRY_PIT_CRAWLSPACE = 3001,
|
|
ENTRY_PIT_ALT = 3002,
|
|
ENTRY_PIT_MARKED = 3009,
|
|
ENTRY_LOCK = 4000,
|
|
ENTRY_PRESSURE_PLATE = 4500,
|
|
ENTRY_STATUE_DEVIL = 5000,
|
|
ENTRY_STATUE_ANGEL = 5001,
|
|
ENTRY_RAIL = 6000,
|
|
ENTRY_RAIL_PIT = 6001,
|
|
ENTRY_TELEPORTER = 6100,
|
|
ENTRY_TRAPDOOR = 9000,
|
|
ENTRY_STAIRS = 9100,
|
|
ENTRY_GRAVITY = 10000,
|
|
ENTRY_TRIGGER_OUTPUT = 969,
|
|
ENTRY_QUEST_DOOR = 970
|
|
};
|
|
|
|
// The poop variants a layout's poop can turn into (Lua's PoopVariant).
|
|
enum PoopVariant : int
|
|
{
|
|
POOP_NORMAL,
|
|
POOP_RED,
|
|
POOP_CORN,
|
|
POOP_GOLDEN,
|
|
POOP_RAINBOW,
|
|
POOP_BLACK,
|
|
POOP_HOLY,
|
|
POOP_GIGA,
|
|
POOP_CHARMING = 11
|
|
};
|
|
|
|
// The achievements a layout entry waits for.
|
|
enum EntryAchievement : int
|
|
{
|
|
ACHIEVEMENT_HEART_HALF_SOUL = 33,
|
|
ACHIEVEMENT_HEART_GOLDEN = 224,
|
|
ACHIEVEMENT_BOMB_GOLDEN = 226,
|
|
ACHIEVEMENT_COIN_STICKY = 240,
|
|
ACHIEVEMENT_COIN_LUCKY = 242,
|
|
ACHIEVEMENT_SHOPKEEPER_SECRET = 243,
|
|
ACHIEVEMENT_SHOPKEEPER_SPECIAL = 247,
|
|
ACHIEVEMENT_DARK_ROOM_END = 320,
|
|
ACHIEVEMENT_SUPER_TINTED_ROCK = 323,
|
|
ACHIEVEMENT_HEART_SCARED = 328,
|
|
ACHIEVEMENT_KEY_CHARGED = 333,
|
|
ACHIEVEMENT_ENEMY_VARIANTS = 348,
|
|
ACHIEVEMENT_HEART_BONE = 391,
|
|
ACHIEVEMENT_HEART_ROTTEN = 411,
|
|
ACHIEVEMENT_TAINTED_CLOSET = 434,
|
|
ACHIEVEMENT_WOODEN_CHEST = 601,
|
|
ACHIEVEMENT_GRAB_BAG_BLACK = 604,
|
|
ACHIEVEMENT_POOP_CHARMING = 605,
|
|
ACHIEVEMENT_CRANE_GAME = 607,
|
|
ACHIEVEMENT_HELL_GAME = 608,
|
|
ACHIEVEMENT_MIMIC_CHEST = 609,
|
|
ACHIEVEMENT_HAUNTED_CHEST = 611,
|
|
ACHIEVEMENT_ROCK_VARIANTS = 612,
|
|
ACHIEVEMENT_COIN_GOLDEN = 613,
|
|
ACHIEVEMENT_ROTTEN_BEGGAR = 614,
|
|
ACHIEVEMENT_LIL_BATTERY_GOLDEN = 615,
|
|
ACHIEVEMENT_CONFESSIONAL = 616
|
|
};
|
|
|
|
// The xorshifts layout spawning draws with, as their shift triples.
|
|
constexpr RNG ENTRY_RNG = {0, 5, 9, 7};
|
|
constexpr RNG TRANSFORM_RNG = {0, 1, 21, 20};
|
|
constexpr RNG SLOT_RNG = {0, 11, 17, 13};
|
|
constexpr RNG DIRTY_MIND_RNG = {0, 1, 5, 19};
|
|
constexpr RNG MECONIUM_RNG = {0, 2, 7, 25};
|
|
constexpr RNG ROCK_ELLIPSE_RNG = {0, 3, 3, 26};
|
|
|
|
// Dirty Mind's chance to turn a rock into a dip, by luck.
|
|
constexpr float DIRTY_MIND_CHANCE = 0.0625f;
|
|
constexpr float DIRTY_MIND_LUCK_CHANCE = 0.005f;
|
|
constexpr float DIRTY_MIND_CHANCE_MAX = 0.1f;
|
|
|
|
// The ellipse of golden rocks a room may get: its radii over two draws each, wider in the Mines.
|
|
constexpr float ELLIPSE_RADIUS_X = 0.5f;
|
|
constexpr float ELLIPSE_RADIUS_Y = 0.3f;
|
|
constexpr float ELLIPSE_SPREAD_X = 1.25f;
|
|
constexpr float ELLIPSE_SPREAD_Y = 0.3f;
|
|
constexpr float ELLIPSE_MINES_SPREAD_X = 1.8f;
|
|
constexpr float ELLIPSE_MINES_SPREAD_Y = 0.5f;
|
|
constexpr int STAGE_ID_MINES = 29;
|
|
constexpr int STAGE_ID_ASHPIT = 30;
|
|
constexpr float DEGREES_TO_RADIANS = 0.017453292f;
|
|
constexpr float FULL_TURN = 360;
|
|
|
|
// The odds layouts roll with (one in n).
|
|
constexpr int ROCK_ROLLS = 1001;
|
|
constexpr int ROCK_BOMB_ROLLS = 10;
|
|
constexpr int ROCK_ALT_ROLLS = 16;
|
|
constexpr int SUPER_TINTED_ODDS = 20;
|
|
constexpr int ELLIPSE_ODDS = 10;
|
|
constexpr int CORN_ODDS = 40;
|
|
constexpr int FIREPLACE_RED_ODDS = 40;
|
|
constexpr int CHARMING_ODDS = 100;
|
|
constexpr int ODDS_PERCENT = 100;
|
|
constexpr int TENTH = 10;
|
|
constexpr int MECONIUM_CHANCE = 33;
|
|
constexpr int MECONIUM_CHANCE_DOUBLE = 66;
|
|
constexpr int MECONIUM_CHANCE_TRIPLE = 100;
|
|
constexpr int SHOPKEEPER_ODDS_MASK = 3;
|
|
constexpr int PIT_MARKED_VARIANT = 128;
|
|
constexpr int ROCK_MARKED_VARIANT = 10000;
|
|
constexpr int TELEPORTER_STATE_ACTIVE = 2;
|
|
constexpr int MIRROR_DIMENSION = 1;
|
|
constexpr int TREASURE_SUBTYPE_MIRROR = 34;
|
|
constexpr int BOSS_SUBTYPE_MOTHER = 88;
|
|
constexpr int TREASURE_SUBTYPE_CHOICE = 1;
|
|
constexpr int TREASURE_SUBTYPE_CHOICE_ALT = 3;
|
|
constexpr uint32_t ROOM_CONFIG_FLAG_NO_TRANSFORMS = 1 << 0;
|
|
constexpr uint32_t ROOM_CONFIG_FLAG_NO_ALT_ROCKS = 1 << 1;
|
|
constexpr uint32_t ROOM_CONFIG_FLAG_AFTERBIRTH_HAZARDS = 1 << 3;
|
|
|
|
// The stages layouts tell apart (after Curse of the Labyrinth's and Greed's shifts).
|
|
constexpr int STAGE_GREED_LAST = 5;
|
|
constexpr int STAGE_GREED_SHOP = 10;
|
|
constexpr int STAGE_BACKWARDS_LAST = 6;
|
|
constexpr int STAGE_WOMB_2 = 8;
|
|
constexpr int STAGE_BLUE_WOMB = 9;
|
|
constexpr int STAGE_SHEOL = 10;
|
|
constexpr int STAGE_VOID_ENTRY = 12;
|
|
constexpr int STAGE_LABYRINTH_SHIFT = 1;
|
|
constexpr uint32_t CURSE_LABYRINTH = 1 << 1;
|
|
constexpr int SPECIAL_DAILY_GOLDEN_FATTY = 7;
|
|
constexpr int CHALLENGE_GOLDEN_FATTY = 32;
|
|
|
|
template <typename T> static std::unique_ptr<Entity> entity_make()
|
|
{
|
|
return std::make_unique<T>();
|
|
}
|
|
|
|
// The pools' classes, sizes and names, in PoolId order.
|
|
static constexpr std::array<PoolDesc, ENTITY_POOL_COUNT> POOL_DESCS = {{
|
|
{entity_make<Entity_Effect>, "Entity_Effect", 0x400},
|
|
{entity_make<Entity_Familiar>, "Entity_Familiar", 0x40},
|
|
{entity_make<Entity_Bomb>, "Entity_Bomb", 0x40},
|
|
{entity_make<Entity_Projectile>, "Entity_Projectile", 0x200},
|
|
{entity_make<Entity_Tear>, "Entity_Tear", 0x200},
|
|
{entity_make<Entity_Laser>, "Entity_Laser", 0x80},
|
|
{entity_make<Entity_Pickup>, "Entity_Pickup", 0x200},
|
|
{entity_make<Entity_Slot>, "Entity_Slot", 0x80},
|
|
{entity_make<Entity_NPC>, "Entity_NPC", 0x200},
|
|
{entity_make<Entity_Text>, "Entity_Text", 0x80},
|
|
{entity_make<Entity_Knife>, "Entity_Knife", 0x40},
|
|
}};
|
|
|
|
// 006f2a10 Sizes every pool. Their slots are made on first use.
|
|
EntityFactory::EntityFactory()
|
|
{
|
|
for (size_t i = 0; i < pools.size(); i++)
|
|
{
|
|
pools[i].desc = &POOL_DESCS[i];
|
|
pools[i].slots.resize(POOL_DESCS[i].size);
|
|
}
|
|
}
|
|
|
|
// 006f0090 A free entity of the type's class: the next one after the last handed out. A full pool hands out an entity
|
|
// it may overwrite, removing it first, unless mode keeps it.
|
|
Entity* EntityFactory::Create(int type, PoolMode mode)
|
|
{
|
|
PoolId pool = ENTITY_POOL_NPC;
|
|
switch (type)
|
|
{
|
|
case ENTITY_PLAYER: log_printf(LOG_ASSERT, "EntityFactory cannot spawn Entity_Player.\n"); return nullptr;
|
|
case ENTITY_TEAR: pool = ENTITY_POOL_TEAR; break;
|
|
case ENTITY_FAMILIAR: pool = ENTITY_POOL_FAMILIAR; break;
|
|
case ENTITY_BOMB: pool = ENTITY_POOL_BOMB; break;
|
|
case ENTITY_PICKUP: pool = ENTITY_POOL_PICKUP; break;
|
|
case ENTITY_SLOT: pool = ENTITY_POOL_SLOT; break;
|
|
case ENTITY_LASER: pool = ENTITY_POOL_LASER; break;
|
|
case ENTITY_KNIFE: pool = ENTITY_POOL_KNIFE; break;
|
|
case ENTITY_PROJECTILE: pool = ENTITY_POOL_PROJECTILE; break;
|
|
case ENTITY_EFFECT: pool = ENTITY_POOL_EFFECT; break;
|
|
case ENTITY_TEXT: pool = ENTITY_POOL_TEXT; break;
|
|
}
|
|
return pools[pool].Create(mode);
|
|
}
|
|
|
|
// The slot at the cursor, made when first reached.
|
|
Entity& EntityPool::slot_get()
|
|
{
|
|
std::unique_ptr<Entity>& slot = slots[cursor];
|
|
if (!slot) slot = desc->make();
|
|
return *slot;
|
|
}
|
|
|
|
// Moves the cursor to the next slot.
|
|
Entity& EntityPool::slot_next()
|
|
{
|
|
cursor = (cursor + 1) % slots.size();
|
|
return slot_get();
|
|
}
|
|
|
|
// The next free entity, or with every one in use (after two more tries than it has) one to overwrite: the first that
|
|
// allows it, else whichever the search stopped on.
|
|
Entity* EntityPool::Create(PoolMode mode)
|
|
{
|
|
uint32_t size = slots.size();
|
|
for (uint32_t tries = 0; tries < size + 2; tries++)
|
|
if (!slot_next().isValid) return &slot_get();
|
|
if (mode == POOL_KEEP) return nullptr;
|
|
|
|
bool isOverwritable = slot_get().CanOverwrite();
|
|
for (uint32_t tries = 0; !isOverwritable && tries <= size; tries++) isOverwritable = slot_next().CanOverwrite();
|
|
if (!isOverwritable) log_printf(LOG_WARN, "Overwritten an entity with don't overwrite flag at index %d!\n", cursor);
|
|
|
|
Entity& entity = slot_get();
|
|
log_printf(LOG_WARN,
|
|
"Entity pool array %s is full, overwriting at index %d! (frame "
|
|
"count: %d)\n",
|
|
desc->name, cursor, entity.FrameCount());
|
|
entity.isRemovedByFactory = true;
|
|
entity.Remove();
|
|
entity.ClearReferences();
|
|
entity.isRemovedByFactory = false;
|
|
return &entity;
|
|
}
|
|
|
|
// The enemy creeps (red, green, yellow, white, black) and the player's creeps a friendly spawner leaves instead.
|
|
constexpr int CREEP_ENEMY_FIRST = 22;
|
|
constexpr std::array<int, 5> CREEP_FRIENDLY = {46, 53, 204, 44, 45};
|
|
|
|
// The player's creep a friendly entity leaves instead of an enemy's.
|
|
static int creep_friendly_variant(int variant)
|
|
{
|
|
uint32_t creep = variant - CREEP_ENEMY_FIRST;
|
|
return creep < CREEP_FRIENDLY.size() ? CREEP_FRIENDLY[creep] : variant;
|
|
}
|
|
|
|
// What a spawn takes from the active enemy that made it: its Delirium form or friendliness, and from an enemy its
|
|
// marks, shrinking, scale and health multiplier.
|
|
static void spawner_inherit(Entity& entity, Entity& spawner, int type, int variant)
|
|
{
|
|
if (spawner.HasEntityFlags(FLAG_DELIRIUM_FORM))
|
|
{
|
|
entity.AddEntityFlags(FLAG_DELIRIUM_FORM);
|
|
if (type != ENTITY_PROJECTILE && type != ENTITY_LASER) entity.AddEntityFlags(FLAG_PERSISTENT);
|
|
entity.AddCharmed(EntityRef(spawner.charmSource.entity), -1, false, false);
|
|
if (type >= ENTITY_FIRST_ENEMY && type < ENTITY_EFFECT)
|
|
ANM2::LoadDeliriumForm(entity.sprite, type, variant, true);
|
|
}
|
|
else if (spawner.HasEntityFlags(FLAG_FRIENDLY)) entity.AddCharmed(EntityRef(), -1, false, false);
|
|
|
|
Entity_NPC* spawnerNpc = dynamic_cast<Entity_NPC*>(&spawner);
|
|
Entity_NPC* npc = dynamic_cast<Entity_NPC*>(&entity);
|
|
if (!spawnerNpc || !npc) return;
|
|
|
|
if (!npc->HasEntityFlags(FLAG_NO_STATUS_EFFECTS))
|
|
{
|
|
if (spawner.HasEntityFlags(FLAG_BRIMSTONE_MARKED)) npc->AddBrimstoneMark(EntityRef(), SPAWN_STATUS_FRAMES);
|
|
if (spawner.HasEntityFlags(FLAG_SHRINK))
|
|
{
|
|
npc->AddShrink(EntityRef(), SPAWN_STATUS_FRAMES, false);
|
|
if (npc->shrinkCountdown > 0)
|
|
{
|
|
npc->AddEntityFlags(FLAG_SHRINK);
|
|
npc->shrinkStatus1 = npc->shrinkStatus2;
|
|
}
|
|
}
|
|
}
|
|
|
|
npc->SetScale(npc->scale * spawnerNpc->scaleMulti);
|
|
npc->scaleMulti *= spawnerNpc->scaleMulti;
|
|
npc->hitPointsMulti *= spawnerNpc->hitPointsMulti;
|
|
npc->maxHitPoints *= spawnerNpc->hitPointsMulti;
|
|
npc->health *= spawnerNpc->hitPointsMulti;
|
|
// A boss also takes the spawner's link at 0xf54 (set_entity_ptr_f54), which Entity_NPC does not hold yet.
|
|
}
|
|
|
|
// 00428b20 Spawns an entity into the current room, overwriting one when its pool is full.
|
|
Entity* Game::Spawn(const EntitySpawn& spawn)
|
|
{
|
|
return game_spawn(spawn, POOL_OVERWRITE);
|
|
}
|
|
|
|
// 006fe410 Game::SpawnEx: takes an entity from its pool, places and inits it, and adds it to the room. A spawn of an
|
|
// active enemy inherits from it, an erased enemy vanishes in a poof, and a TMTRAINER item may react.
|
|
Entity* game_spawn(const EntitySpawn& request, PoolMode mode)
|
|
{
|
|
Game& game = *g_game;
|
|
EntitySpawn spawn = request;
|
|
lua_engine_get().Callback_PreEntitySpawn(spawn);
|
|
if (game.deathmatchManager.state >= DEATHMATCH_INTRO)
|
|
reconstruction_missing("Game::SpawnEx 006fe410: a versus match's "
|
|
"blacklisted pickups (0042b560)");
|
|
|
|
Entity* spawner = spawn.spawner;
|
|
int variant = spawn.variant;
|
|
if (spawner && spawner->IsFriendly() && spawn.type == ENTITY_EFFECT) variant = creep_friendly_variant(variant);
|
|
|
|
Entity* entity = game.entityFactory->Create(spawn.type, mode);
|
|
if (!entity) return nullptr;
|
|
uint64_t startMs = GetTimeNs() / NS_PER_MS;
|
|
|
|
entity->spawnerType = spawner ? spawner->type : 0;
|
|
entity->spawnerVariant = spawner ? spawner->variant : 0;
|
|
entity->spawnerEntity = spawner;
|
|
entity->pos = spawn.position;
|
|
entity->velocity = spawn.velocity;
|
|
entity->Init(spawn.type, variant, spawn.subType, spawn.seed);
|
|
entity->index = game.room->entityIndexCounter++;
|
|
game.room->entityList.AddEntity(entity);
|
|
|
|
if (spawner && spawner->IsActiveEnemy(DEAD_INCLUDED)) spawner_inherit(*entity, *spawner, spawn.type, variant);
|
|
if (entity_is_erased(*entity)) Entity::RemoveWithPoof(entity);
|
|
|
|
std::set<std::pair<uint32_t, int>>& triggers = game.proceduralItemManager.spawnTriggerTargets;
|
|
bool isTriggered = triggers.contains({entity->type, entity->variant}) || triggers.contains({entity->type, -1});
|
|
if (entity->isExists && !game.proceduralItemManager.proceduralItems.empty() && isTriggered &&
|
|
!game.playerManager.playerList.empty())
|
|
reconstruction_missing("trigger_set_dispatch 009e0680: a TMTRAINER item's spawn trigger");
|
|
|
|
g_entitySpawnTimeMs += GetTimeNs() / NS_PER_MS - startMs;
|
|
return entity;
|
|
}
|
|
|
|
// 007078f0 Game::ShouldEraseEnemy: whether Eraser erased the entity's kind this run. Dogma and a versus match's
|
|
// friendly enemies never are.
|
|
bool entity_is_erased(Entity& entity)
|
|
{
|
|
Game& game = *g_game;
|
|
bool isEnemy = entity.type == ENTITY_PLAYER ? game.deathmatchManager.state >= DEATHMATCH_INTRO
|
|
: entity.type >= ENTITY_FIRST_ENEMY && entity.type < ENTITY_EFFECT;
|
|
if (entity.type == ENTITY_DOGMA || (isEnemy && entity.IsFriendly()) || game.erasedEntities.empty()) return false;
|
|
|
|
int type = entity.type;
|
|
int variant = entity.variant;
|
|
int subType = entity.subtype;
|
|
erased_enemy_id_fix(type, variant, subType);
|
|
for (ErasedEnemy& erased : game.erasedEntities)
|
|
if (erased.type == type && (erased.variant < 0 || erased.variant == variant) &&
|
|
(erased.subtype < 0 || erased.subtype == subType))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
// 007076d0 Game::FixErasedEnemyID: the kind Eraser records for an enemy, folding champions and variants of one enemy
|
|
// together.
|
|
void erased_enemy_id_fix(int& type, int& variant, int& subType)
|
|
{
|
|
if (subType > 0) subType = 0;
|
|
switch (type)
|
|
{
|
|
case ENTITY_GAPER:
|
|
case ENTITY_HUSH_GAPER:
|
|
case ENTITY_GREED_GAPER:
|
|
type = ENTITY_GAPER;
|
|
if (variant > 0) variant = 0;
|
|
break;
|
|
case ENTITY_GUSHER:
|
|
case ENTITY_FATTY:
|
|
if (variant == 1) variant = 0;
|
|
break;
|
|
case ENTITY_BABY_LONG_LEGS:
|
|
case ENTITY_CRAZY_LONG_LEGS:
|
|
case ENTITY_DIP:
|
|
case ENTITY_GYRO:
|
|
if (variant > 0) variant = 0;
|
|
break;
|
|
case ENTITY_SUB_HORF: type = ENTITY_HORF; break;
|
|
case ENTITY_STRIDER: type = ENTITY_SPIDER; break;
|
|
}
|
|
}
|
|
|
|
// Whether an achievement is unlocked, as every one is in a daily or a debug run.
|
|
static bool unlocked(int achievement)
|
|
{
|
|
return g_manager->persistentGameData.Unlocked(achievement);
|
|
}
|
|
|
|
// The stage layouts read: one deeper under Curse of the Labyrinth, and Greed's floors mapped onto the normal ones.
|
|
static int stage_effective()
|
|
{
|
|
Game& game = *g_game;
|
|
uint32_t curses = (Seeds::GetForcedCurses() | game.debugCurses | game.curses) & ~Seeds::GetPreventedCurses();
|
|
int stage = (int)game.stage + (curses & CURSE_LABYRINTH ? STAGE_LABYRINTH_SHIFT : 0);
|
|
if (game.difficulty != DIFFICULTY_GREED && game.difficulty != DIFFICULTY_GREEDIER) return stage;
|
|
if (stage < STAGE_GREED_LAST) return stage * 2 - 1;
|
|
return stage == STAGE_GREED_LAST ? STAGE_GREED_SHOP : 0;
|
|
}
|
|
|
|
// A layout pickup or slot that waits for an achievement: matched by type, variant and subtype (-1 for any), and the
|
|
// variant or subtype it is until then (-1 keeps it).
|
|
struct LockedEntry
|
|
{
|
|
int type = 0;
|
|
int variant = 0;
|
|
int subtype = -1;
|
|
int achievement = 0;
|
|
int lockedVariant = -1;
|
|
int lockedSubtype = -1;
|
|
};
|
|
|
|
constexpr std::array<LockedEntry, 18> LOCKED_ENTRIES = {{
|
|
{ENTITY_PICKUP, PICKUP_BOMB, 4, ACHIEVEMENT_BOMB_GOLDEN, -1, 0},
|
|
{ENTITY_PICKUP, PICKUP_HEART, 7, ACHIEVEMENT_HEART_GOLDEN, -1, 0},
|
|
{ENTITY_PICKUP, PICKUP_HEART, 8, ACHIEVEMENT_HEART_HALF_SOUL, -1, HEART_SOUL},
|
|
{ENTITY_PICKUP, PICKUP_HEART, 9, ACHIEVEMENT_HEART_SCARED, -1, HEART_RED},
|
|
{ENTITY_PICKUP, PICKUP_HEART, 11, ACHIEVEMENT_HEART_BONE, -1, 2},
|
|
{ENTITY_PICKUP, PICKUP_HEART, 12, ACHIEVEMENT_HEART_ROTTEN, -1, 2},
|
|
{ENTITY_PICKUP, PICKUP_COIN, 5, ACHIEVEMENT_COIN_LUCKY, -1, 0},
|
|
{ENTITY_PICKUP, PICKUP_COIN, 6, ACHIEVEMENT_COIN_STICKY, -1, 0},
|
|
{ENTITY_PICKUP, PICKUP_COIN, 7, ACHIEVEMENT_COIN_GOLDEN, -1, 0},
|
|
{ENTITY_PICKUP, PICKUP_KEY, 4, ACHIEVEMENT_KEY_CHARGED, -1, 0},
|
|
{ENTITY_PICKUP, PICKUP_GRAB_BAG, 2, ACHIEVEMENT_GRAB_BAG_BLACK, -1, 0},
|
|
{ENTITY_PICKUP, PICKUP_LIL_BATTERY, 4, ACHIEVEMENT_LIL_BATTERY_GOLDEN, -1, 0},
|
|
{ENTITY_PICKUP, PICKUP_WOODENCHEST, -1, ACHIEVEMENT_MIMIC_CHEST, PICKUP_CHEST, -1},
|
|
{ENTITY_PICKUP, PICKUP_HAUNTEDCHEST, -1, ACHIEVEMENT_HAUNTED_CHEST, PICKUP_CHEST, -1},
|
|
{ENTITY_PICKUP, PICKUP_MEGACHEST, -1, ACHIEVEMENT_WOODEN_CHEST, PICKUP_LOCKEDCHEST, -1},
|
|
{ENTITY_SLOT, SLOT_HELL_GAME, -1, ACHIEVEMENT_HELL_GAME, SLOT_DEVIL_BEGGAR, -1},
|
|
{ENTITY_SLOT, SLOT_ROTTEN_BEGGAR, -1, ACHIEVEMENT_ROTTEN_BEGGAR, SLOT_KEY_MASTER, -1},
|
|
{ENTITY_SLOT, SLOT_CRANE_GAME, -1, ACHIEVEMENT_CRANE_GAME, SLOT_MACHINE, -1},
|
|
}};
|
|
|
|
// A locked card a layout names becomes a random unlocked one.
|
|
static void entry_card_replace(RoomEntry& entry, uint32_t seed)
|
|
{
|
|
std::vector<std::unique_ptr<ItemConfig_Card>>& cards = g_manager->itemConfig.cards;
|
|
if (entry.subtype == 0 || entry.subtype >= cards.size() || !cards[entry.subtype]) return;
|
|
int achievement = cards[entry.subtype]->achievementId;
|
|
if (achievement < 0 || unlocked(achievement)) return;
|
|
|
|
int card = ItemPool::GetCardEx((int)seed, CARD_SPECIAL_CHANCE, CARD_RUNE_CHANCE, CARD_RUNE_CHANCE, true);
|
|
RNG cardRng = {seed, ENTRY_RNG._shift1, ENTRY_RNG._shift2, ENTRY_RNG._shift3};
|
|
entry.subtype = lua_engine_get().GetCard({.rng = &cardRng, .card = card, .isPlaying = true, .isRunes = true});
|
|
}
|
|
|
|
// A pickup or slot a layout names that is not unlocked yet becomes its basic kind. The Confessional is a soul heart
|
|
// until then, and the closet's slot is Inner Child or a shopkeeper once the character's tainted self is unlocked.
|
|
static void entry_locked_replace(RoomEntry& entry, RNG& rng)
|
|
{
|
|
if (entry.type == ENTITY_PICKUP)
|
|
{
|
|
uint32_t cardSeed = rng.Next();
|
|
if (entry.variant == PICKUP_TAROTCARD) return entry_card_replace(entry, cardSeed);
|
|
}
|
|
else if (entry.type == ENTITY_SLOT && entry.variant == SLOT_CONFESSIONAL)
|
|
{
|
|
if (!unlocked(ACHIEVEMENT_CONFESSIONAL))
|
|
entry = {.type = ENTITY_PICKUP, .weight = entry.weight, .subtype = HEART_SOUL, .variant = PICKUP_HEART};
|
|
return;
|
|
}
|
|
else if (entry.type == ENTITY_SLOT && entry.variant == SLOT_CLOSET_TAINTED)
|
|
{
|
|
int playerType = g_game->GetPlayer(0)->playerType;
|
|
if (playerType < COMPLETION_PLAYER_TYPE_COUNT &&
|
|
!unlocked(COMPLETION_MARKS[playerType][COMPLETION_TAINTED].achievement))
|
|
return;
|
|
bool isInnerChild = unlocked(ACHIEVEMENT_TAINTED_CLOSET);
|
|
entry.type = isInnerChild ? ENTITY_PICKUP : ENTITY_SHOPKEEPER;
|
|
entry.variant = isInnerChild ? PICKUP_COLLECTIBLE : 0;
|
|
entry.subtype = isInnerChild ? COLLECTIBLE_INNER_CHILD : 0;
|
|
return;
|
|
}
|
|
|
|
for (const LockedEntry& locked : LOCKED_ENTRIES)
|
|
{
|
|
bool isMatch = (int)entry.type == locked.type && entry.variant == locked.variant &&
|
|
(locked.subtype < 0 || entry.subtype == locked.subtype);
|
|
if (!isMatch || unlocked(locked.achievement)) continue;
|
|
if (locked.lockedVariant >= 0) entry.variant = locked.lockedVariant;
|
|
if (locked.lockedSubtype >= 0) entry.subtype = locked.lockedSubtype;
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Where a layout's trapdoor leads instead: stairs up where no stage follows, the heavenly door on the Cathedral's road
|
|
// or the backwards path, or the Void's portal at the end of the Dark Room.
|
|
static void trapdoor_transform(Room& room, RoomEntry& entry, int stage, RNG& rng)
|
|
{
|
|
Game& game = *g_game;
|
|
auto stairs = [&] {
|
|
entry.type = ENTRY_STAIRS;
|
|
entry.variant = STAIRS_VARIANT_EXIT;
|
|
};
|
|
auto heaven = [&] {
|
|
entry.type = ENTRY_EFFECT;
|
|
entry.variant = EFFECT_VARIANT_TRAPDOOR_MARKER;
|
|
};
|
|
|
|
if (game.difficulty == DIFFICULTY_GREED || game.difficulty == DIFFICULTY_GREEDIER)
|
|
{
|
|
if (game.currentRoomIdx == ROOM_GENESIS_IDX && !game.IsNextStageAvailable()) stairs();
|
|
return;
|
|
}
|
|
bool isBackwards = game.gameStateFlags & 1ull << LEVEL_GAME_STATE_BACKWARDS_PATH;
|
|
if (game.stage >= 1 && game.stage <= STAGE_BACKWARDS_LAST && isBackwards) return heaven();
|
|
|
|
bool isInChallenge = game.challenge != 0 || game.dailyChallenge._id != 0;
|
|
bool isCathedralAllowed = !isInChallenge || game.GetChallengeParams().pathType == PATH_TYPE_CATHEDRAL;
|
|
bool isCathedralForced = isInChallenge && game.GetChallengeParams().pathType == PATH_TYPE_CATHEDRAL;
|
|
if (stage == STAGE_DARK_ROOM && room.roomType == ROOM_ERROR)
|
|
{
|
|
ChallengeParam& params = game.GetChallengeParams();
|
|
bool isVoidOpen =
|
|
params.endStage == STAGE_VOID_ENTRY || (!isInChallenge && unlocked(ACHIEVEMENT_DARK_ROOM_END));
|
|
int endStage = isVoidOpen ? STAGE_VOID_ENTRY : STAGE_DARK_ROOM;
|
|
if (params.isPathTypeSet && params.endStage != 0) endStage = params.endStage;
|
|
bool isHome = params.isPathTypeSet && params.pathType == PATH_TYPE_HOME;
|
|
if (!isHome && endStage >= STAGE_VOID_ENTRY)
|
|
{
|
|
entry.variant = TRAPDOOR_VARIANT_VOID;
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (room.roomType == ROOM_ERROR && !game.IsNextStageAvailable()) return stairs();
|
|
bool isHeavenward = room.roomType == ROOM_ANGEL;
|
|
if (!isHeavenward && room.roomType == ROOM_ERROR && (stage == STAGE_WOMB_2 || stage == STAGE_BLUE_WOMB))
|
|
isHeavenward = (rng.RandomInt(2) == 0 && isCathedralAllowed) || isCathedralForced;
|
|
if (!isHeavenward)
|
|
isHeavenward =
|
|
(stage >= STAGE_SHEOL && game.stageType != STAGETYPE_ORIGINAL) || game.currentRoomIdx == ROOM_GENESIS_IDX;
|
|
if (!isHeavenward) return;
|
|
if (!game.IsNextStageAvailable()) stairs();
|
|
else if (Level::IsStageWithinEnd(STAGE_SHEOL, true)) heaven();
|
|
}
|
|
|
|
// The enemy variants a stage's alternate floor, or a lucky roll, swaps into a layout. Returns whether one was swapped.
|
|
static bool enemy_variant_transform(Room& room, RoomEntry& entry, int stage, int gridIndex, RNG& rng)
|
|
{
|
|
Game& game = *g_game;
|
|
uint32_t stageType = game.stageType;
|
|
bool isAfterbirth = stageType == STAGETYPE_AFTERBIRTH;
|
|
bool isCavesOld =
|
|
(stage == 3 || stage == 4) && stageType != STAGETYPE_REPENTANCE && stageType != STAGETYPE_REPENTANCE_B;
|
|
bool isBurningBasement = isAfterbirth && (stage == 1 || stage == 2);
|
|
bool isFloodedCaves = isAfterbirth && (stage == 3 || stage == 4);
|
|
bool isDankDepths = isAfterbirth && (stage == 5 || stage == 6);
|
|
bool isScarredWomb = isAfterbirth && (stage == 7 || stage == 8);
|
|
bool isUnlocked = unlocked(ACHIEVEMENT_ENEMY_VARIANTS);
|
|
auto morph = [&](int type, int variant) {
|
|
entry.type = type;
|
|
entry.variant = variant;
|
|
return true;
|
|
};
|
|
auto roll = [&](bool isAllowed, int odds, int below, int variant) {
|
|
if (!isAllowed || rng.RandomInt(odds) >= (uint32_t)below) return false;
|
|
entry.variant = variant;
|
|
return true;
|
|
};
|
|
|
|
switch (entry.type)
|
|
{
|
|
case ENTITY_STONEY:
|
|
if (game.dailyChallenge._specialDailyId == SPECIAL_DAILY_GOLDEN_FATTY ||
|
|
game.challenge == CHALLENGE_GOLDEN_FATTY)
|
|
return roll(true, 5, 1, 10);
|
|
return false;
|
|
case ENTITY_GAPER: return roll(isBurningBasement, 5, 3, 2);
|
|
case ENTITY_HORF: return rng.RandomInt(60) == 0 && morph(ENTITY_SUB_HORF, 0);
|
|
case ENTITY_HIVE: return roll(isFloodedCaves, 2, 1, 1);
|
|
case ENTITY_CHARGER: return roll(isFloodedCaves, 2, 1, 1);
|
|
case ENTITY_GLOBIN: return roll(isDankDepths, 2, 1, 2);
|
|
case ENTITY_BOOMFLY: return roll(isFloodedCaves, 2, 1, 2);
|
|
case ENTITY_HOST: return isCavesOld && rng.RandomInt(5) == 0 && isUnlocked && morph(ENTITY_MUSHROOM, 0);
|
|
case ENTITY_HOPPER:
|
|
return entry.variant == 0 && isBurningBasement && rng.RandomInt(5) < 3 && morph(ENTITY_FLAMINGHOPPER, 0);
|
|
case ENTITY_MRMAW: return roll(true, 15, 1, 2);
|
|
case ENTITY_VIS: return roll(entry.variant != 2 && isScarredWomb, 2, 1, 3);
|
|
case ENTITY_GUTS:
|
|
case ENTITY_PARA_BITE: return roll(isScarredWomb, 2, 1, 1);
|
|
case ENTITY_KNIGHT: return roll(entry.variant == 0, 60, 1, 2);
|
|
case ENTITY_SPIDER:
|
|
{
|
|
bool isRepentance = stageType == STAGETYPE_REPENTANCE || stageType == STAGETYPE_REPENTANCE_B;
|
|
return isRepentance && (stage == 1 || stage == 2) && morph(ENTITY_STRIDER, 0);
|
|
}
|
|
case ENTITY_FATTY:
|
|
if (isUnlocked && entry.variant == 1 && rng.RandomInt(10) == 0) return morph(ENTITY_STONEY, 0);
|
|
return roll(isBurningBasement, 5, 3, 2);
|
|
case ENTITY_DEATHS_HEAD:
|
|
case ENTITY_SQUIRT: return roll(isDankDepths, 2, 1, 1);
|
|
case ENTITY_SKINNY: return roll(isBurningBasement, 5, 2, 2);
|
|
case ENTITY_NERVE_ENDING:
|
|
{
|
|
if (rng.RandomInt(5) != 0 || !isUnlocked) return false;
|
|
int column = (uint32_t)gridIndex % room.gridWidth;
|
|
int row = (uint32_t)gridIndex / room.gridWidth;
|
|
for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++)
|
|
{
|
|
int door = room.doorGridPositions[slot];
|
|
int distance = std::abs(door / room.gridWidth - row) + std::abs(door % room.gridWidth - column);
|
|
if ((room.descriptor->allowedDoors & 1 << slot) && distance < NERVE_DOOR_DISTANCE) return false;
|
|
}
|
|
entry.variant = 1;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// The rare variants a basic enemy of a layout may be: its alternate look (one in 21 or more), or its second variant
|
|
// (one in 100).
|
|
static void enemy_rare_variant_roll(RoomEntry& entry, int stage, RNG& rng)
|
|
{
|
|
bool isCommon = false;
|
|
bool isUncommon = false;
|
|
bool isRare = false;
|
|
if (entry.variant == 0)
|
|
{
|
|
switch (entry.type)
|
|
{
|
|
case ENTITY_POOTER:
|
|
case ENTITY_MULLIGAN:
|
|
case ENTITY_GLOBIN:
|
|
case ENTITY_MAW:
|
|
case ENTITY_HOST: isCommon = true; break;
|
|
case ENTITY_BOOMFLY: isCommon = stage > 2; break;
|
|
case ENTITY_HOPPER:
|
|
case ENTITY_BOIL:
|
|
case ENTITY_BABY:
|
|
case ENTITY_STONEHEAD:
|
|
case ENTITY_MEMBRAIN:
|
|
case ENTITY_SUCKER:
|
|
case ENTITY_WALKINGBOIL: isUncommon = true; break;
|
|
case ENTITY_VIS: isUncommon = (stage == 7 || stage == 8) && g_game->stageType == STAGETYPE_WOTL; break;
|
|
case ENTITY_KNIGHT:
|
|
case ENTITY_LEECH:
|
|
case ENTITY_EYE: isRare = true; break;
|
|
}
|
|
}
|
|
switch (entry.type)
|
|
{
|
|
case ENTITY_CLOTTY:
|
|
case ENTITY_MULLIGAN:
|
|
case ENTITY_MAW:
|
|
case ENTITY_BOIL:
|
|
case ENTITY_VIS:
|
|
case ENTITY_LEECH:
|
|
case ENTITY_WALKINGBOIL:
|
|
if (rng.RandomInt(ODDS_PERCENT) == 0) entry.variant = 2;
|
|
}
|
|
|
|
bool isAlternate = false;
|
|
if (isRare || ((isCommon || isUncommon) && rng.RandomInt(21) != 0))
|
|
isAlternate = !((isUncommon || rng.RandomInt(25) != 0) && rng.RandomInt(ODDS_PERCENT) != 0);
|
|
else isAlternate = isCommon || isUncommon;
|
|
if (isAlternate) entry.variant = 1;
|
|
|
|
if (entry.type == ENTITY_BOOMFLY && entry.variant == 3 && entry.subtype == BOOMFLY_DRAGONFLY_SUBTYPE)
|
|
entry.subtype = rng.RandomInt(2);
|
|
}
|
|
|
|
// 007ec100 Room::TransformEntry: what a layout entry really spawns: fireplaces and random cards resolved, locked
|
|
// pickups and slots swapped for unlocked ones, the trapdoor's destination, Devil treasure for sale, rare slots, enemy
|
|
// redirection, and the stage's enemy variants.
|
|
void room_entry_transform(Room& room, RoomEntry& entry, int gridIndex, uint32_t seed)
|
|
{
|
|
Game& game = *g_game;
|
|
RNG rng = {seed, TRANSFORM_RNG._shift1, TRANSFORM_RNG._shift2, TRANSFORM_RNG._shift3};
|
|
if (entry.type == ENTRY_FIREPLACE || entry.type == ENTRY_FIREPLACE_RED)
|
|
{
|
|
entry.variant = entry.type == ENTRY_FIREPLACE_RED || rng.Next() % FIREPLACE_RED_ODDS == 0;
|
|
entry.type = ENTITY_FIREPLACE;
|
|
}
|
|
lua_callback_check(MC_PRE_ROOM_ENTITY_SPAWN, "LuaEngine::PreRoomEntitySpawn 00866490");
|
|
if (entry.type == ENTITY_PICKUP && entry.variant == PICKUP_RANDOM_CARD)
|
|
{
|
|
entry.variant = PICKUP_TAROTCARD;
|
|
uint32_t cardSeed = rng.Next();
|
|
int card = ItemPool::GetCardEx((int)cardSeed, 0, 1, 0, true);
|
|
RNG cardRng = {cardSeed, ENTRY_RNG._shift1, ENTRY_RNG._shift2, ENTRY_RNG._shift3};
|
|
entry.subtype = lua_engine_get().GetCard({.rng = &cardRng, .card = card, .isOnlyRunes = true, .isRunes = true});
|
|
}
|
|
entry_locked_replace(entry, rng);
|
|
|
|
int stage = stage_effective();
|
|
if (entry.type == ENTRY_TRAPDOOR) trapdoor_transform(room, entry, stage, rng);
|
|
|
|
bool isDevilTreasure = room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_DEVIL_TREASURE;
|
|
if (room.roomType == ROOM_TREASURE && isDevilTreasure && entry.type == ENTITY_PICKUP &&
|
|
entry.variant == PICKUP_COLLECTIBLE && entry.subtype == 0)
|
|
entry.variant = PICKUP_SHOPITEM;
|
|
if (entry.type == ENTITY_SLOT)
|
|
{
|
|
RNG slotRng = {seed, SLOT_RNG._shift1, SLOT_RNG._shift2, SLOT_RNG._shift3};
|
|
bool isHellGame =
|
|
entry.variant == SLOT_SHELL_GAME && unlocked(ACHIEVEMENT_HELL_GAME) && game.devilRoomDeals > 0;
|
|
bool isRotten = entry.variant == SLOT_BEGGAR && unlocked(ACHIEVEMENT_ROTTEN_BEGGAR);
|
|
if (isHellGame && slotRng.RandomInt(4) == 0) entry.variant = SLOT_HELL_GAME;
|
|
else if (isRotten && slotRng.RandomInt(15) == 0) entry.variant = SLOT_ROTTEN_BEGGAR;
|
|
}
|
|
if (entry.type >= 1 && entry.type <= ENTRY_EFFECT)
|
|
{
|
|
int type = entry.type;
|
|
int variant = entry.variant;
|
|
Entity_NPC::Redirect(&type, &variant);
|
|
entry.type = type;
|
|
entry.variant = variant;
|
|
}
|
|
|
|
if (room.has_room_config_flag(ROOM_CONFIG_FLAG_NO_TRANSFORMS) || room.roomType == ROOM_SECRET_EXIT) return;
|
|
if (enemy_variant_transform(room, entry, stage, gridIndex, rng)) return;
|
|
enemy_rare_variant_roll(entry, stage, rng);
|
|
}
|
|
|
|
// 00822cf0 Room::add_trigger_output_index: adds a cell to one of the room's trigger output groups.
|
|
void room_trigger_output_index_add(Room& room, int group, int gridIndex)
|
|
{
|
|
if ((uint32_t)group < OUTPUT_GROUP_COUNT) room.outputGroupGridIndices[group].insert(gridIndex);
|
|
}
|
|
|
|
// 00822d20 Room::add_trigger_output_cell: adds the cell at a column and row, when it is inside the room.
|
|
void room_trigger_output_cell_add(Room& room, int group, int column, int row)
|
|
{
|
|
if (column >= 0 && row >= 0 && column < room.gridWidth && row < room.gridHeight)
|
|
room_trigger_output_index_add(room, group, room.GetGridIndexByTile(column, row));
|
|
}
|
|
|
|
// The grimaces, stone shooters and other hazards a cleared room still spawns (Poky only past its first variant).
|
|
constexpr std::array<int, 11> PERSISTENT_ENTITIES = {
|
|
ENTITY_STONEHEAD, 202, 203, 218, 235, 236, 804, 809, 852, 877, 893};
|
|
|
|
// 007ed2a0 Room::IsPersistentRoomEntity: whether a cleared room still spawns the entity.
|
|
bool room_entity_is_persistent(int type, int variant)
|
|
{
|
|
if (type == ENTITY_POKY) return variant != 0;
|
|
return type == ENTITY_MINECART ||
|
|
std::find(PERSISTENT_ENTITIES.begin(), PERSISTENT_ENTITIES.end(), type) != PERSISTENT_ENTITIES.end();
|
|
}
|
|
|
|
// Whether a layout entry is a rock that hazards and Dirty Mind may replace (not the room's tinted one).
|
|
static bool entry_is_plain_rock(Room& room, int type, int gridIndex)
|
|
{
|
|
return (type == ENTRY_ROCK && room.tintedRockIdx != gridIndex) || type == ENTRY_ROCK_BOMB || type == ENTRY_ROCK_ALT;
|
|
}
|
|
|
|
// Whether the room's golden rock ellipse covers a cell: one room in ten with the achievement, an ellipse placed and
|
|
// turned at random from the room's decoration seed.
|
|
static bool rock_ellipse_contains(Room& room, int gridIndex)
|
|
{
|
|
if (!unlocked(ACHIEVEMENT_ROCK_VARIANTS)) return false;
|
|
RNG rng = {room.descriptor->decorationSeed, ROCK_ELLIPSE_RNG._shift1, ROCK_ELLIPSE_RNG._shift2,
|
|
ROCK_ELLIPSE_RNG._shift3};
|
|
if (rng.RandomInt(ELLIPSE_ODDS) != 0) return false;
|
|
|
|
float centerY = rng.RandomFloat() * (float)room.gridHeight;
|
|
float centerX = rng.RandomFloat() * (float)room.gridWidth;
|
|
int stageId = g_game->GetStageID();
|
|
bool isMines = stageId == STAGE_ID_MINES || g_game->GetStageID() == STAGE_ID_ASHPIT;
|
|
float spreadX = isMines ? ELLIPSE_MINES_SPREAD_X : ELLIPSE_SPREAD_X;
|
|
float spreadY = isMines ? ELLIPSE_MINES_SPREAD_Y : ELLIPSE_SPREAD_Y;
|
|
float radiusY = (rng.RandomFloat() + rng.RandomFloat()) * spreadY + ELLIPSE_RADIUS_Y;
|
|
float radiusX = (rng.RandomFloat() + rng.RandomFloat()) * spreadX + ELLIPSE_RADIUS_X;
|
|
float angle = -(rng.RandomFloat() * FULL_TURN) * DEGREES_TO_RADIANS;
|
|
float cosine = (float)std::cos((double)angle);
|
|
float sine = (float)std::sin((double)angle);
|
|
|
|
float dx = (float)((uint32_t)gridIndex % room.gridWidth) - centerX;
|
|
float dy = (float)((uint32_t)gridIndex / room.gridWidth) - centerY;
|
|
float x = (dx * cosine - sine * dy) / radiusX;
|
|
float y = (dx * sine + cosine * dy) / radiusY;
|
|
return y * y + x * x <= 1;
|
|
}
|
|
|
|
// A layout poop's variant: the entry's, and for a plain or corny one the chance of a rarer kind, then Meconium's chance
|
|
// of black. Each counts toward the room's poops.
|
|
static int poop_variant_roll(Room& room, int variant, RNG& rng)
|
|
{
|
|
if (variant == POOP_NORMAL)
|
|
{
|
|
if (rng.RandomInt(CORN_ODDS) == 0) variant = POOP_CORN;
|
|
else if (rng.RandomInt(CHARMING_ODDS) == 0 && unlocked(ACHIEVEMENT_POOP_CHARMING)) variant = POOP_CHARMING;
|
|
}
|
|
if (variant == POOP_CORN)
|
|
{
|
|
uint32_t roll = rng.RandomInt(CORN_ODDS);
|
|
if (roll == 1 || roll == 2) variant = POOP_GOLDEN;
|
|
else if (roll >= 5 && roll <= 7) variant = POOP_RAINBOW;
|
|
}
|
|
|
|
Entity_Player* owner = g_game->playerManager.FirstTrinketOwner(TRINKET_MECONIUM);
|
|
if (owner)
|
|
{
|
|
RNG meconiumRng = {rng._seed, MECONIUM_RNG._shift1, MECONIUM_RNG._shift2, MECONIUM_RNG._shift3};
|
|
int multiplier = owner->GetTrinketMultiplier(TRINKET_MECONIUM);
|
|
int chance = multiplier == 2 ? MECONIUM_CHANCE_DOUBLE
|
|
: multiplier == 3 ? MECONIUM_CHANCE_TRIPLE
|
|
: MECONIUM_CHANCE;
|
|
if ((int)meconiumRng.RandomInt(ODDS_PERCENT) < chance) variant = POOP_BLACK;
|
|
}
|
|
room.descriptor->poopCount++;
|
|
return variant;
|
|
}
|
|
|
|
// The layout's plain rock: bomb rocks one in a hundred, golden ones in the room's ellipse, alternate ones rarely, and
|
|
// on the tinted rock's cell a tinted or super tinted rock.
|
|
static GridEntityType rock_type_roll(Room& room, int gridIndex, RNG& rng)
|
|
{
|
|
bool isGolden = rock_ellipse_contains(room, gridIndex);
|
|
uint32_t roll = rng.RandomInt(ROCK_ROLLS);
|
|
if (room.tintedRockIdx == gridIndex)
|
|
{
|
|
bool isSuper = rng.RandomInt(SUPER_TINTED_ODDS) == 0 && unlocked(ACHIEVEMENT_SUPER_TINTED_ROCK);
|
|
return isSuper ? GRID_ROCK_SS : GRID_ROCKT;
|
|
}
|
|
if (roll < ROCK_BOMB_ROLLS) return GRID_ROCK_BOMB;
|
|
if (isGolden) return GRID_ROCK_GOLD;
|
|
return roll < ROCK_ALT_ROLLS ? GRID_ROCK_ALT : GRID_ROCK;
|
|
}
|
|
|
|
// A layout entry's grid entity type that maps one to one, with its variant (-1 keeps the entry's).
|
|
struct GridEntry
|
|
{
|
|
int entryType = 0;
|
|
GridEntityType gridType = GRID_DECORATION;
|
|
int variant = -1;
|
|
};
|
|
|
|
constexpr std::array<GridEntry, 21> GRID_ENTRIES = {{
|
|
{ENTRY_ROCK_BOMB, GRID_ROCK_BOMB},
|
|
{ENTRY_ROCK_ALT, GRID_ROCK_ALT},
|
|
{ENTRY_ROCK_TINTED, GRID_ROCKT},
|
|
{ENTRY_ROCK_SUPER_TINTED, GRID_ROCK_SS},
|
|
{ENTRY_ROCK_ALT2, GRID_ROCK_ALT2},
|
|
{ENTRY_ROCK_MARKED, GRID_ROCK, ROCK_MARKED_VARIANT},
|
|
{ENTRY_ROCK_SPIKED, GRID_ROCK_SPIKED},
|
|
{ENTRY_TNT, GRID_TNT},
|
|
{ENTRY_FIREPLACE, GRID_FIREPLACE, 0},
|
|
{ENTRY_FIREPLACE_RED, GRID_FIREPLACE, 1},
|
|
{ENTRY_BLOCK, GRID_ROCKB},
|
|
{ENTRY_PILLAR, GRID_PILLAR},
|
|
{ENTRY_SPIKES, GRID_SPIKES},
|
|
{ENTRY_SPIKES_ONOFF, GRID_SPIKES_ONOFF},
|
|
{ENTRY_COBWEB, GRID_SPIDERWEB},
|
|
{ENTRY_WALL, GRID_WALL},
|
|
{ENTRY_LOCK, GRID_LOCK},
|
|
{ENTRY_PRESSURE_PLATE, GRID_PRESSURE_PLATE},
|
|
{ENTRY_STATUE_DEVIL, GRID_STATUE, 0},
|
|
{ENTRY_STATUE_ANGEL, GRID_STATUE, 1},
|
|
{ENTRY_GRAVITY, GRID_GRAVITY},
|
|
}};
|
|
|
|
// The poop entries' variants, from ENTRY_POOP_RED on (-1 for the gaps).
|
|
constexpr std::array<int, 12> POOP_ENTRY_VARIANTS = {POOP_RED, -1, -1, -1,
|
|
POOP_RAINBOW, POOP_CORN, POOP_GOLDEN, POOP_BLACK,
|
|
POOP_HOLY, POOP_GIGA, POOP_NORMAL, POOP_CHARMING};
|
|
|
|
// Places a layout's grid entity on a free cell: rocks and poops rolled, pits counted, the crawlspace's ladder spawned,
|
|
// the trapdoor's destination kept in its data.
|
|
static bool grid_entry_spawn(Room& room, RoomEntry& entry, int gridIndex, uint32_t seed, RNG& rng)
|
|
{
|
|
int type = entry.type;
|
|
int variant = entry.variant;
|
|
int varData = 0;
|
|
bool isPlain = !room.has_room_config_flag(ROOM_CONFIG_FLAG_NO_ALT_ROCKS) && entry.subtype == 0;
|
|
GridEntityType gridType = GRID_DECORATION;
|
|
if (type == ENTRY_ROCK) gridType = isPlain ? rock_type_roll(room, gridIndex, rng) : GRID_ROCK;
|
|
else if (type == ENTRY_ROCK_GOLD) gridType = unlocked(ACHIEVEMENT_ROCK_VARIANTS) ? GRID_ROCK_GOLD : GRID_ROCK;
|
|
else if (type >= ENTRY_POOP_RED && type <= ENTRY_POOP_CHARMING && POOP_ENTRY_VARIANTS[type - ENTRY_POOP_RED] >= 0)
|
|
{
|
|
gridType = GRID_POOP;
|
|
variant = POOP_ENTRY_VARIANTS[type - ENTRY_POOP_RED];
|
|
if (isPlain) variant = poop_variant_roll(room, variant, rng);
|
|
}
|
|
else if (type == ENTRY_PIT || type == ENTRY_PIT_ALT || type == ENTRY_PIT_MARKED || type == ENTRY_PIT_CRAWLSPACE)
|
|
{
|
|
gridType = GRID_PIT;
|
|
if (type == ENTRY_PIT_MARKED) variant = PIT_MARKED_VARIANT;
|
|
if (type == ENTRY_PIT_CRAWLSPACE)
|
|
{
|
|
Vector position = room.GetGridPosition(gridIndex);
|
|
g_game
|
|
->Spawn({.position = position,
|
|
.subType = entry.subtype,
|
|
.type = ENTITY_EFFECT,
|
|
.variant = EFFECT_CRAWLSPACE_LADDER,
|
|
.seed = rng.Next()})
|
|
->Update();
|
|
}
|
|
room.descriptor->pitsCount++;
|
|
}
|
|
else if (type == ENTRY_TRAPDOOR)
|
|
{
|
|
gridType = GRID_TRAPDOOR;
|
|
varData = variant;
|
|
variant = 0;
|
|
}
|
|
else if (type == ENTRY_STAIRS) gridType = GRID_STAIRS;
|
|
else if (type == ENTRY_TELEPORTER) gridType = GRID_TELEPORTER;
|
|
for (const GridEntry& grid : GRID_ENTRIES)
|
|
{
|
|
if (grid.entryType != type) continue;
|
|
gridType = grid.gridType;
|
|
if (grid.variant >= 0) variant = grid.variant;
|
|
}
|
|
|
|
GridEntity* grid = CreateGridEntity(gridType, gridIndex);
|
|
if (!grid) return false;
|
|
room.gridEntities[gridIndex] = grid;
|
|
grid->variant = variant;
|
|
grid->varData = varData;
|
|
if (gridType == GRID_TELEPORTER) grid->state = entry.subtype != 0 ? TELEPORTER_STATE_ACTIVE : 0;
|
|
grid->Init(seed);
|
|
return true;
|
|
}
|
|
|
|
// Spawns a layout entry's entity on its cell, unless the room was cleared and it is an enemy that stays dead. A pickup
|
|
// loses its wait, and in rooms of choices it joins the first group of options.
|
|
static bool entity_entry_spawn(Room& room, RoomEntry& entry, const RoomEntrySpawn& spawn, RNG& rng)
|
|
{
|
|
Game& game = *g_game;
|
|
int type = entry.type;
|
|
RoomDescriptor& descriptor = *room.descriptor;
|
|
bool isCleared = descriptor.flags & ROOM_DESCRIPTOR_FLAG_CLEAR;
|
|
if (!isCleared && room.roomType == ROOM_BOSS && (descriptor.flags & ROOM_DESCRIPTOR_FLAG_ROTGUT_CLEARED))
|
|
isCleared = type != ENTITY_ROTGUT;
|
|
if (type == ENTITY_PICKUP && game.IsMausoleumHeartStage()) return false;
|
|
if (type == ENTITY_MINECART && (descriptor.flags & ROOM_DESCRIPTOR_FLAG_SACRIFICE_DONE)) return false;
|
|
if (isCleared && !room_entity_is_persistent(type, entry.variant) &&
|
|
!game.seedEffects.HasSeedEffect(SEED_PACIFIST) && !game.seedEffects.HasSeedEffect(SEED_ENEMIES_RESPAWN) &&
|
|
spawn.mode == ENTRY_SPAWN && !entity_type_is_saved(type, entry.variant, entry.subtype, 0, true))
|
|
return false;
|
|
|
|
int gridIndex = spawn.gridIndex;
|
|
if ((uint32_t)gridIndex < ROOM_GRID_CELLS && room.gridEntities[gridIndex])
|
|
room.gridEntities[gridIndex]->Destroy(true, EntityRef());
|
|
Vector position = room.GetGridPosition(gridIndex);
|
|
Entity* entity = game.Spawn(
|
|
{.position = position, .subType = entry.subtype, .type = type, .variant = entry.variant, .seed = rng.Next()});
|
|
// The original writes through a failed spawn's null. It is not spawned then.
|
|
if (!entity) return false;
|
|
entity->spawnGridIndex = gridIndex;
|
|
|
|
Entity_Pickup* pickup = entity->type == ENTITY_PICKUP ? dynamic_cast<Entity_Pickup*>(entity) : nullptr;
|
|
if (pickup)
|
|
{
|
|
pickup->wait = 0;
|
|
bool isKnifePiece =
|
|
pickup->subtype == COLLECTIBLE_KNIFE_PIECE_1 || pickup->subtype == COLLECTIBLE_KNIFE_PIECE_2;
|
|
if (pickup->type == ENTITY_PICKUP && pickup->variant == PICKUP_COLLECTIBLE && isKnifePiece)
|
|
pickup->cycleCollectibleCount = 0;
|
|
bool isFlippable = Entity_Pickup::CanRerollVariant(pickup->variant, pickup->subtype) &&
|
|
(!Entity_Pickup::IsChest(pickup->variant) || pickup->subtype != 0) &&
|
|
pickup->variant == PICKUP_COLLECTIBLE;
|
|
if (game.playerManager.FirstCollectibleOwner(COLLECTIBLE_FLIP, LAZARUS_SHARE_CHECK) && !pickup->isDead &&
|
|
isFlippable)
|
|
reconstruction_missing("Room::SpawnEntry 007ed310: Flip's ghost item (EntitySaveState)");
|
|
pickup->altPedestalANM2.Reset();
|
|
}
|
|
if (entity_type_is_saved(type, entry.variant, entry.subtype, 0, false))
|
|
descriptor.restrictedGridIndexes.insert(gridIndex);
|
|
|
|
bool isTreasureChoice =
|
|
room.roomType == ROOM_TREASURE && (descriptor.data->subtype == TREASURE_SUBTYPE_CHOICE ||
|
|
descriptor.data->subtype == TREASURE_SUBTYPE_CHOICE_ALT || game.IsAltPath());
|
|
bool isChoiceRoom = room.roomType == ROOM_BOSSRUSH || isTreasureChoice || room.roomType == ROOM_PLANETARIUM ||
|
|
room.roomType == ROOM_ANGEL;
|
|
if (isChoiceRoom && type == ENTITY_PICKUP && entry.variant == PICKUP_COLLECTIBLE && entity->type == ENTITY_PICKUP)
|
|
static_cast<Entity_Pickup*>(entity)->optionsPickupIndex = 1;
|
|
|
|
// Online the line starts with the netplay frame, which offline play never has.
|
|
log_printf(LOG_INFO, "Spawn Entity with Type(%d), Variant(%d), Pos(%.2f,%.2f)\n", type, entry.variant,
|
|
(double)position.x, (double)position.y);
|
|
if (spawn.outEntity) *spawn.outEntity = entity;
|
|
return true;
|
|
}
|
|
|
|
// 007ed310 Room::SpawnEntry: spawns a layout entry on a cell after its transforms: an entity, a grid entity on a free
|
|
// cell, a rail, or a trigger output. Hazards of the Afterbirth floors, Dirty Mind's dips, TNT barrels, the trapdoor's
|
|
// replacements and the special shopkeepers are decided here. A respawn skips the grid entities.
|
|
bool room_entry_spawn(Room& room, RoomEntry entry, const RoomEntrySpawn& spawn)
|
|
{
|
|
Game& game = *g_game;
|
|
int gridIndex = spawn.gridIndex;
|
|
RNG rng = {spawn.seed, ENTRY_RNG._shift1, ENTRY_RNG._shift2, ENTRY_RNG._shift3};
|
|
room_entry_transform(room, entry, gridIndex, spawn.seed);
|
|
auto replace = [&](int type) {
|
|
entry.type = type;
|
|
entry.variant = 0;
|
|
entry.subtype = 0;
|
|
};
|
|
|
|
bool isPickup = entry.type == ENTITY_PICKUP;
|
|
if (game.currentRoomIdx == ROOM_GENESIS_IDX && isPickup && entry.variant == PICKUP_COLLECTIBLE) return false;
|
|
RoomConfig_Room* data = room.descriptor->data;
|
|
if (game.HasMirrorDimension() && spawn.mode == ENTRY_SPAWN && game.currentDimensionIdx == MIRROR_DIMENSION &&
|
|
isPickup && !(data->type == ROOM_TREASURE && data->subtype == TREASURE_SUBTYPE_MIRROR))
|
|
return false;
|
|
|
|
if (room.has_room_config_flag(ROOM_CONFIG_FLAG_AFTERBIRTH_HAZARDS) &&
|
|
entry_is_plain_rock(room, entry.type, gridIndex) && game.stageType == STAGETYPE_AFTERBIRTH &&
|
|
data->type == ROOM_DEFAULT && rng.Next() % TENTH == 0)
|
|
{
|
|
if (game.stage == 1 || game.stage == 2)
|
|
{
|
|
entry.type = ENTITY_FIREPLACE;
|
|
entry.variant = rng.RandomInt(FIREPLACE_RED_ODDS) == 0;
|
|
entry.subtype = 0;
|
|
}
|
|
else if (game.stage == 3 || game.stage == 4) replace(ENTRY_PIT);
|
|
else if (game.stage == 5 || game.stage == 6) replace(ENTRY_SPIKES);
|
|
else if (game.stage == 7 || game.stage == 8) replace(ENTRY_POOP_RED);
|
|
}
|
|
|
|
if (room.roomType == ROOM_SHOP && room.descriptor->gridIndex < 0 && entry.type == ENTITY_SLOT)
|
|
return entry.variant != SLOT_DONATION && entity_entry_spawn(room, entry, spawn, rng);
|
|
|
|
if (entry_is_plain_rock(room, entry.type, gridIndex) && room.roomType != ROOM_DUNGEON)
|
|
{
|
|
RNG dirtyRng = {spawn.seed, DIRTY_MIND_RNG._shift1, DIRTY_MIND_RNG._shift2, DIRTY_MIND_RNG._shift3};
|
|
Entity_Player* owner =
|
|
game.playerManager.RandomCollectibleOwner(COLLECTIBLE_DIRTY_MIND, dirtyRng.Next(), nullptr);
|
|
float chance =
|
|
owner ? std::min(owner->luck * DIRTY_MIND_LUCK_CHANCE + DIRTY_MIND_CHANCE, DIRTY_MIND_CHANCE_MAX) : 0;
|
|
if (owner && dirtyRng.RandomFloat() <= chance) replace(ENTRY_POOP);
|
|
}
|
|
if (entry.type == ENTRY_TNT && rng.Next() % TENTH == 0) replace(ENTITY_MOVABLE_TNT);
|
|
if (entry.type == ENTRY_TRAPDOOR || (entry.type == ENTRY_EFFECT && entry.variant == EFFECT_VARIANT_TRAPDOOR_MARKER))
|
|
{
|
|
bool isDeadEnd = room.roomType != ROOM_ERROR && room.roomType != ROOM_SECRET_EXIT &&
|
|
game.currentRoomIdx != ROOM_GENESIS_IDX &&
|
|
!(room.roomType == ROOM_BOSS && data->subtype == BOSS_SUBTYPE_MOTHER);
|
|
if (!game.IsNextStageAvailable() && isDeadEnd) replace(ENTRY_COBWEB);
|
|
else if (game.HasMirrorDimension() && game.currentDimensionIdx == MIRROR_DIMENSION) replace(0);
|
|
}
|
|
if (entry.type == ENTITY_SHOPKEEPER)
|
|
{
|
|
if (entry.variant == 0 && (rng.Next() & SHOPKEEPER_ODDS_MASK) == 0 && unlocked(ACHIEVEMENT_SHOPKEEPER_SPECIAL))
|
|
entry.variant = SHOPKEEPER_SPECIAL;
|
|
else if (entry.variant == 1 && (rng.Next() & SHOPKEEPER_ODDS_MASK) == 0 &&
|
|
unlocked(ACHIEVEMENT_SHOPKEEPER_SECRET))
|
|
entry.variant = SHOPKEEPER_SECRET_SPECIAL;
|
|
}
|
|
if (entry.type == ENTRY_STATUE_DEVIL && game.bossPool.removedBosses[BOSS_SATAN])
|
|
{
|
|
replace(ENTRY_ROCK);
|
|
entry.subtype = 1;
|
|
}
|
|
|
|
int type = entry.type;
|
|
bool isEntity = type >= 1 && type <= ENTRY_EFFECT;
|
|
if (!isEntity && spawn.mode == ENTRY_RESPAWN) return false;
|
|
if (type == ENTRY_QUEST_DOOR) return true;
|
|
if (type == ENTRY_TRIGGER_OUTPUT)
|
|
{
|
|
int column = (uint32_t)gridIndex % room.gridWidth;
|
|
int row = (uint32_t)gridIndex / room.gridWidth;
|
|
room_trigger_output_cell_add(room, entry.variant, column - 1, row);
|
|
room_trigger_output_cell_add(room, entry.variant, column + 1, row);
|
|
room_trigger_output_cell_add(room, entry.variant, column, row - 1);
|
|
room_trigger_output_cell_add(room, entry.variant, column, row + 1);
|
|
return true;
|
|
}
|
|
if (type == ENTRY_RAIL || type == ENTRY_RAIL_PIT) room.railManager.rails[gridIndex] = entry.variant;
|
|
if (type == ENTRY_RAIL) return true;
|
|
if (isEntity)
|
|
{
|
|
if (type == ENTRY_EFFECT) entry.type = ENTITY_EFFECT;
|
|
return entity_entry_spawn(room, entry, spawn, rng);
|
|
}
|
|
if (type == ENTRY_RAIL_PIT)
|
|
{
|
|
entry.type = ENTRY_PIT;
|
|
entry.variant = 0;
|
|
}
|
|
if (room.gridEntities[gridIndex]) return false;
|
|
return grid_entry_spawn(room, entry, gridIndex, spawn.seed, rng);
|
|
}
|