Fixed so some enemies get a crack at you when you're fleeing.

This commit is contained in:
Martin Haye 2016-07-01 16:32:57 -07:00
parent dab8bd2908
commit d89d9dfbad
4 changed files with 32 additions and 14 deletions

View File

@ -2925,7 +2925,7 @@ end
def packMoveBackward(blk)
{
assert blk.field.size() == 0
outIndented("moveBackward()\n")
outIndented("moveWayBackward()\n")
}
def makeTriggerTbl(scripts, xRange, yRange)

View File

@ -236,7 +236,7 @@ def playerCombatChoose(pl)
fin
if nWeapons >= 2
canChange = TRUE
displayOption('C', "Change weapon")
displayOption('C', "Chg weapon")
fin
fin
displayOption('D', "Dodge")
@ -492,7 +492,7 @@ def startCombat(mapCode)
displayStr("\n\nBattle! \n")
return 1
elsif n == 'F'
displayStr("\n\nCoward. ")
displayStr("\n\nFleeing... \n")
return 0
// Secret option for testing: just win
elsif n == '#'
@ -511,16 +511,17 @@ 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; return 0; fin
if answer == 99
global=>p_enemyGroups = NULL // results in no living enemies, or "win"
elsif !answer
isFleeing = TRUE
fin
// Do each round of combat until player wins, loses, or flees
while TRUE
p = global=>p_players
while p
if canFight(p) and nEnemiesFighting
if canFight(p) and nEnemiesFighting and !isFleeing
playerCombatChoose(p)
fin
p = p=>p_nextObj
@ -557,15 +558,16 @@ def _combat_zoneEncounter(s_encZone)
getUpperKey()
// Note: no need to clear heap -- the caller does that.
return 1
elsif isFleeing
displayStr("\nYou have fled.")
// Note: no need to clear heap -- the caller does that.
return 0
fin
if canFight(p)
when p->t_type
is TYPE_PLAYER
if isFleeing
displayStr("\nYou have fled.")
// Note: no need to clear heap -- the caller does that.
return 0
fin
playerCombatTurn(p)
combatPause()
break

View File

@ -80,7 +80,7 @@ const setGround = gameLibVecs + 3*6
const queue_teleport = gameLibVecs + 3*7
const setPortrait = gameLibVecs + 3*8
const clearPortrait = gameLibVecs + 3*9
const moveBackward = gameLibVecs + 3*10
const moveWayBackward = gameLibVecs + 3*10
const getUpperKey = gameLibVecs + 3*11
const clearWindow = gameLibVecs + 3*12
const getGlobals = gameLibVecs + 3*13

View File

@ -95,7 +95,7 @@ word animPauseCt
// Game library functions
predef _setScriptInfo, _scriptDisplayStr, _scriptDisplayStrNL, _getYN
predef _queue_setMap, _setSky, _setGround, _queue_teleport, _setPortrait, _clearPortrait
predef _moveBackward, _getUpperKey, _clearWindow, _setPortrait
predef _moveWayBackward, _getUpperKey, _clearWindow, _setPortrait
predef _getGlobals, _rand16
predef _printf1, _printf2, _printf3
predef _displayf1, _displayf2, _displayf3
@ -111,7 +111,7 @@ predef _rdkey, _initHeap, _scriptCombat
word gameLib_addrs = @_setScriptInfo, @_scriptDisplayStr, @_scriptDisplayStrNL, @_getYN
word = @_queue_setMap, @_setSky, @_setGround, @_queue_teleport, @_setPortrait, @_clearPortrait
word = @_moveBackward, @_getUpperKey, @_clearWindow
word = @_moveWayBackward, @_getUpperKey, @_clearWindow
word = @_getGlobals, @_rand16
word = @_printf1, @_printf2, @_printf3
word = @_displayf1, @_displayf2, @_displayf3
@ -1370,12 +1370,25 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Move backward one step (3D mode). Also actually works in 2D mode.
def _moveBackward()
def moveBackward()
adjustDir(8)
moveForward()
adjustDir(8)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Move backward four steps (3D mode), or one step (2D mode)
def _moveWayBackward()
adjustDir(8)
moveForward()
if mapIs3D
moveForward()
moveForward()
moveForward()
fin
adjustDir(8)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Turn left (3D mode)
def rotateLeft()
@ -1749,6 +1762,9 @@ def _setPortrait(portraitNum)
// And show the first frame
showAnimFrame()
// Clear the keyboard strobe in case the player was moving at high speed
^kbdStrobe
// Do not render over the portrait
needRender = FALSE
end
@ -1954,7 +1970,7 @@ def doCombat(mapCode)
// If the party fled the combat instead of winning, back up to previous square.
if (!result)
moveBackward()
moveWayBackward()
fin
return result
end