Fix NPC spawning at initial player position

NPCs were not spawning when the player first entered the world because
spawnNpcs() was defined but never called. Added call to spawnNpcs() in
Application::update() when in IN_GAME state.

The function has a guard (npcsSpawned flag) so it only runs once. NPCs now
appear immediately at spawn instead of requiring the player to walk away first.

Added logging to help debug spawn preconditions.
This commit is contained in:
Kelsi 2026-02-09 21:59:00 -08:00
parent 96c1def041
commit 5e0d62c2a4
3 changed files with 51 additions and 4 deletions

View file

@ -3689,6 +3689,19 @@ void GameScreen::renderTrainerWindow(game::GameHandler& gameHandler) {
bool canTrain = !alreadyKnown && spell->state == 1
&& prereqsMet && levelMet
&& (money >= spell->spellCost);
// Debug logging for first spell to see why buttons are disabled
static bool logged = false;
if (!logged) {
LOG_INFO("Trainer button debug: spellId=", spell->spellId,
" alreadyKnown=", alreadyKnown, " state=", (int)spell->state,
" prereqsMet=", prereqsMet, " levelMet=", levelMet,
" canAfford=", (money >= spell->spellCost),
" money=", money, " cost=", spell->spellCost,
" canTrain=", canTrain);
logged = true;
}
if (!canTrain) ImGui::BeginDisabled();
if (ImGui::SmallButton("Train")) {
gameHandler.trainSpell(spell->spellId);