mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-08-15 21:27:22 +00:00
Better support for forcing combat, not backing up as far when fleeing / exiting a building.
This commit is contained in:
@@ -525,7 +525,7 @@ def startCombat(mapCode)
|
|||||||
displayStr("\n\nFleeing... \n")
|
displayStr("\n\nFleeing... \n")
|
||||||
return 0
|
return 0
|
||||||
// Secret option for testing: just win
|
// Secret option for testing: just win
|
||||||
elsif n == '#'
|
elsif n == '#' and global->b_godmode
|
||||||
return 99
|
return 99
|
||||||
fin
|
fin
|
||||||
beep()
|
beep()
|
||||||
@@ -533,6 +533,27 @@ def startCombat(mapCode)
|
|||||||
|
|
||||||
end
|
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
|
// Returns: zero if fled, non-zero if won
|
||||||
def _combat_zoneEncounter(s_encZone)
|
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)
|
// Show portrait and threat details, find out if player wants to fight (vs. run)
|
||||||
answer = startCombat(s_encZone)
|
answer = startCombat(s_encZone)
|
||||||
if answer == 99
|
if answer == 99
|
||||||
global=>p_enemyGroups = NULL // results in no living enemies, or "win"
|
killAllEnemies()
|
||||||
nEnemiesFighting = 0
|
|
||||||
elsif !answer
|
elsif !answer
|
||||||
isFleeing = TRUE
|
isFleeing = TRUE
|
||||||
fin
|
fin
|
||||||
|
@@ -1419,7 +1419,7 @@ def moveBackward()
|
|||||||
end
|
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.
|
// building or fleeing combat, so we don't want to generate any random encounters.
|
||||||
export def moveWayBackward()
|
export def moveWayBackward()
|
||||||
adjustDir(8)
|
adjustDir(8)
|
||||||
@@ -1427,7 +1427,6 @@ export def moveWayBackward()
|
|||||||
moveForward()
|
moveForward()
|
||||||
if mapIs3D
|
if mapIs3D
|
||||||
moveForward()
|
moveForward()
|
||||||
moveForward()
|
|
||||||
fin
|
fin
|
||||||
skipEncounterCheck = FALSE
|
skipEncounterCheck = FALSE
|
||||||
adjustDir(8)
|
adjustDir(8)
|
||||||
@@ -1873,10 +1872,11 @@ def returnFromEngine()
|
|||||||
curEngine = NULL
|
curEngine = NULL
|
||||||
clearPortrait()
|
clearPortrait()
|
||||||
if renderLoaded; texControl(1); fin
|
if renderLoaded; texControl(1); fin
|
||||||
setWindow2(); clearWindow()
|
|
||||||
mapNameHash = 0; showMapName(global=>s_mapName)
|
mapNameHash = 0; showMapName(global=>s_mapName)
|
||||||
|
setWindow2(); clearWindow()
|
||||||
doRender()
|
doRender()
|
||||||
showParty()
|
showParty()
|
||||||
|
setWindow2() // in case we're mid-script
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1933,7 +1933,7 @@ end
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Called by user-defined map scripts to initiate a combat encounter.
|
// Called by user-defined map scripts to initiate a combat encounter.
|
||||||
export def scriptCombat(mapCode)
|
export def scriptCombat(mapCode)
|
||||||
return doCombat(mapCode)
|
return doCombat(mapCode, TRUE)
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -1945,7 +1945,7 @@ def playerDeath()
|
|||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def doCombat(mapCode)
|
def doCombat(mapCode, backUpOnFlee)
|
||||||
word result
|
word result
|
||||||
// Handled in a separate module. Clear enemies out of the heap when finished.
|
// Handled in a separate module. Clear enemies out of the heap when finished.
|
||||||
result = loadEngine(MODULE_COMBAT)=>combat_zoneEncounter(mapCode)
|
result = loadEngine(MODULE_COMBAT)=>combat_zoneEncounter(mapCode)
|
||||||
@@ -1959,7 +1959,7 @@ def doCombat(mapCode)
|
|||||||
returnFromEngine()
|
returnFromEngine()
|
||||||
|
|
||||||
// If the party fled the combat instead of winning, back up to previous square.
|
// If the party fled the combat instead of winning, back up to previous square.
|
||||||
if (!result)
|
if !result and backUpOnFlee
|
||||||
moveWayBackward()
|
moveWayBackward()
|
||||||
fin
|
fin
|
||||||
return result
|
return result
|
||||||
@@ -1989,7 +1989,7 @@ def checkEncounter(x, y, force)
|
|||||||
d = rand16() % 1000
|
d = rand16() % 1000
|
||||||
if p_bestZone and (d < p_bestZone=>w_encChance or force)
|
if p_bestZone and (d < p_bestZone=>w_encChance or force)
|
||||||
// Encounter!
|
// Encounter!
|
||||||
doCombat(p_bestZone=>s_name)
|
doCombat(p_bestZone=>s_name, !force)
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user