Description
In campaign Level 1, a normally attracted Goblin can crawl out of a newly claimed Portal before the mission's scripted introductory Goblin. The camera sequence then runs for the scripted Goblin, which appears to the player as the second Goblin.
This was exposed while testing the cooldown fix for #494.
Reproduction
- Start campaign Level 1.
- Dig to and claim the Portal.
- Watch the Portal and creature count.
Expected
The scripted Goblin is the first creature to appear, and the camera path introduces that creature. Normal Portal attraction remains delayed until the mission enables it.
Actual
A Goblin is first spawned by CreatureSpawnSystem. The map later generates its scripted Goblin and starts the intended camera path, so the camera introduction happens for the second visible Goblin.
Runtime evidence
The first automatic Portal spawn was:
kind=PORTAL, gameTime=109.501, creatureId=7,
cachedCreatureCount=0, timeSinceLastSpawn=109.501,
requiredCooldown=18, lastSpawnTimeBefore=0
The next automatic spawn occurred at game time 151.253 with cachedCreatureCount=2, proving that another creature was created between the two automatic spawns through a separate path.
Level 1 trigger data
When the player owns a Portal, the map:
- initializes timer 4;
- at timer 4 >= 12, runs
Generate Creature for creature 7, level 1, followed by camera path 61 at action point 19;
- after the GUI transition, closes the Portal;
- at timer 4 >= 40, opens the Portal.
The initial creature and camera are therefore map-scripted. This is handled by the generic GENERATE_CREATURE trigger action, which directly calls spawnCreature(..., SpawnType.ENTRANCE). It is separate from automatic attraction in CreatureSpawnSystem.
Likely cause
A newly constructed Portal initializes CreatureGenerator.lastSpawnTime with Double.MIN_VALUE, effectively zero. CreatureSpawnSystem compares that value with absolute elapsed level time. If the Portal is built after the configured cooldown, it is immediately eligible to spawn.
Portals also default to open, leaving a window before the tutorial trigger closes the Portal.
Possible fix
Initialize a newly built/registered entrance's cooldown using the current game time so the first automatic attraction delay is measured from Portal construction rather than level start. Test this with:
- dynamically built/claimed Portals;
- Portals present at level start;
- Portal capture;
- multiple Portals;
- Dungeon Heart free-Imp generation;
- scripted
GENERATE_CREATURE and SET_PORTAL_STATUS actions.
The scripted spawn should remain independent and should not be replaced with Level 1-specific hardcoded logic.
Description
In campaign Level 1, a normally attracted Goblin can crawl out of a newly claimed Portal before the mission's scripted introductory Goblin. The camera sequence then runs for the scripted Goblin, which appears to the player as the second Goblin.
This was exposed while testing the cooldown fix for #494.
Reproduction
Expected
The scripted Goblin is the first creature to appear, and the camera path introduces that creature. Normal Portal attraction remains delayed until the mission enables it.
Actual
A Goblin is first spawned by
CreatureSpawnSystem. The map later generates its scripted Goblin and starts the intended camera path, so the camera introduction happens for the second visible Goblin.Runtime evidence
The first automatic Portal spawn was:
The next automatic spawn occurred at game time 151.253 with
cachedCreatureCount=2, proving that another creature was created between the two automatic spawns through a separate path.Level 1 trigger data
When the player owns a Portal, the map:
Generate Creaturefor creature 7, level 1, followed by camera path 61 at action point 19;The initial creature and camera are therefore map-scripted. This is handled by the generic
GENERATE_CREATUREtrigger action, which directly callsspawnCreature(..., SpawnType.ENTRANCE). It is separate from automatic attraction inCreatureSpawnSystem.Likely cause
A newly constructed Portal initializes
CreatureGenerator.lastSpawnTimewithDouble.MIN_VALUE, effectively zero.CreatureSpawnSystemcompares that value with absolute elapsed level time. If the Portal is built after the configured cooldown, it is immediately eligible to spawn.Portals also default to open, leaving a window before the tutorial trigger closes the Portal.
Possible fix
Initialize a newly built/registered entrance's cooldown using the current game time so the first automatic attraction delay is measured from Portal construction rather than level start. Test this with:
GENERATE_CREATUREandSET_PORTAL_STATUSactions.The scripted spawn should remain independent and should not be replaced with Level 1-specific hardcoded logic.