diff --git a/Platform/Apple/virtual/src/plasma/combat.pla b/Platform/Apple/virtual/src/plasma/combat.pla index de57afb9..97762bd3 100644 --- a/Platform/Apple/virtual/src/plasma/combat.pla +++ b/Platform/Apple/virtual/src/plasma/combat.pla @@ -525,7 +525,7 @@ def startCombat(mapCode) displayStr("\n\nFleeing... \n") return 0 // Secret option for testing: just win - elsif n == '#' + elsif n == '#' and global->b_godmode return 99 fin beep() @@ -533,6 +533,27 @@ def startCombat(mapCode) end +/////////////////////////////////////////////////////////////////////////////////////////////////// +// For cheating in god mode, kill all enemies. This is better than just setting nEnemiesFighting +// to zero, because we'll still get loot. +def killAllEnemies() + word pGroup, pEnemy + pGroup = global=>p_enemyGroups + // For every group... + while pGroup + pEnemy = pGroup=>p_enemies + // For every enemy in the group... + while pEnemy + pEnemy=>w_health = 0 // kill em + pEnemy = pEnemy=>p_nextObj + loop + pGroup = pGroup=>p_nextObj + loop + + // Update nEnemiesFighting + determineCombatOrder() +end + /////////////////////////////////////////////////////////////////////////////////////////////////// // Returns: zero if fled, non-zero if won def _combat_zoneEncounter(s_encZone) @@ -542,8 +563,7 @@ def _combat_zoneEncounter(s_encZone) // Show portrait and threat details, find out if player wants to fight (vs. run) answer = startCombat(s_encZone) if answer == 99 - global=>p_enemyGroups = NULL // results in no living enemies, or "win" - nEnemiesFighting = 0 + killAllEnemies() elsif !answer isFleeing = TRUE fin diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index fe963126..631090f8 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -1419,7 +1419,7 @@ def moveBackward() end /////////////////////////////////////////////////////////////////////////////////////////////////// -// Move backward three steps (3D mode), or one step (2D mode). This is often used when exiting a +// Move backward two steps (3D mode), or one step (2D mode). This is often used when exiting a // building or fleeing combat, so we don't want to generate any random encounters. export def moveWayBackward() adjustDir(8) @@ -1427,7 +1427,6 @@ export def moveWayBackward() moveForward() if mapIs3D moveForward() - moveForward() fin skipEncounterCheck = FALSE adjustDir(8) @@ -1873,10 +1872,11 @@ def returnFromEngine() curEngine = NULL clearPortrait() if renderLoaded; texControl(1); fin - setWindow2(); clearWindow() mapNameHash = 0; showMapName(global=>s_mapName) + setWindow2(); clearWindow() doRender() showParty() + setWindow2() // in case we're mid-script fin end @@ -1933,7 +1933,7 @@ end /////////////////////////////////////////////////////////////////////////////////////////////////// // Called by user-defined map scripts to initiate a combat encounter. export def scriptCombat(mapCode) - return doCombat(mapCode) + return doCombat(mapCode, TRUE) end /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1945,7 +1945,7 @@ def playerDeath() end /////////////////////////////////////////////////////////////////////////////////////////////////// -def doCombat(mapCode) +def doCombat(mapCode, backUpOnFlee) word result // Handled in a separate module. Clear enemies out of the heap when finished. result = loadEngine(MODULE_COMBAT)=>combat_zoneEncounter(mapCode) @@ -1959,7 +1959,7 @@ def doCombat(mapCode) returnFromEngine() // If the party fled the combat instead of winning, back up to previous square. - if (!result) + if !result and backUpOnFlee moveWayBackward() fin return result @@ -1989,7 +1989,7 @@ def checkEncounter(x, y, force) d = rand16() % 1000 if p_bestZone and (d < p_bestZone=>w_encChance or force) // Encounter! - doCombat(p_bestZone=>s_name) + doCombat(p_bestZone=>s_name, !force) fin end