mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-01-06 16:29:40 +00:00
Better support for forcing combat, not backing up as far when fleeing / exiting a building.
This commit is contained in:
parent
8dc394cf43
commit
0fad632eee
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user