Really reload game when player dies. Also, they can now be killed by a script.

This commit is contained in:
Martin Haye 2016-07-18 16:47:49 -07:00
parent ae119a1240
commit d034b0530d
4 changed files with 35 additions and 20 deletions

View File

@ -527,6 +527,9 @@ j_aux_dispatch:
; Print fatal error message then halt.
inlineFatal:
!if DEBUG {
jsr printMem
}
pla
tax
pla

View File

@ -560,18 +560,7 @@ def _combat_zoneEncounter(s_encZone)
p = global=>p_combatFirst
while p
if !nPlayersFighting
setPortrait(POdeath)
when rand16() % 2
is 0
displayStr("\nYou bought the farm, with your life! Thanks for playing! Reload last save?\n"); break
otherwise
displayStr("\nDidn't see that coming... to see a fine player like you slaughtered like a common rodent... Well, let's reload and try that again, ok?\n")
wend
if !getYN()
displayStr("Ah, okay. Well... just hit a key when you're ready then.")
getUpperKey()
fin
reboot()
return -99 // special code for death
elsif !nEnemiesFighting
setPortrait(POcombatwin)
when rand16() % 3

View File

@ -281,13 +281,18 @@ def gameExists()
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def _newOrLoadGame()
def _newOrLoadGame(ask)
byte key
if !gameExists()
newGame(); return 1
fin
if !ask
loadInternal()
return 0
fin
home()
^$c053
^$25 = 20

View File

@ -53,7 +53,7 @@ word global // the global heap object, from which all live objects must be reac
///////////////////////////////////////////////////////////////////////////////////////////////////
// Predefined functions, for circular calls or out-of-order calls
predef setWindow2, initCmds, nextAnimFrame, checkEncounter, doCombat, clearPortrait, showMapName
predef doRender
predef doRender, playerDeath, startGame
///////////////////////////////////////////////////////////////////////////////////////////////////
// Global variables
@ -1328,9 +1328,14 @@ def checkScripts(x, y)
fin
p = pNext
loop
scriptEvent(EVENT_ENTER, 0)
if needShowParty
showParty()
if anyTriggered
scriptEvent(EVENT_ENTER, 0)
if global=>p_players=>w_health == 0
playerDeath()
fin
if needShowParty
showParty()
fin
fin
return anyTriggered
end
@ -1943,6 +1948,14 @@ export def scriptCombat(mapCode)
return result
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def playerDeath()
displayStr("You have died. Press any key to reload.")
setPortrait(POdeath)
getUpperKey()
startGame(FALSE) // don't ask, just load
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def doCombat(mapCode)
word result
@ -1950,6 +1963,11 @@ def doCombat(mapCode)
result = loadEngine(MODULE_COMBAT)=>combat_zoneEncounter(mapCode)
global=>p_enemyGroups = NULL
mmgr(HEAP_COLLECT, 0)
if (result == -99)
playerDeath()
return
fin
restoreMapPos()
// If the party fled the combat instead of winning, back up to previous square.
@ -2433,14 +2451,14 @@ export def getGameFlag(flagName)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def startGame()
def startGame(ask)
word p_module
// Create a new game or load an existing one
mmgr(START_LOAD, 1) // code is in partition 1
p_module = mmgr(QUEUE_LOAD, MODULE_DISKOPS<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, LEAVE_OPEN)
if p_module()=>diskops_newOrLoadGame()
if p_module()=>diskops_newOrLoadGame(ask)
mapIs3D = q_mapIs3D
mapNum = q_mapNum
q_mapNum = 0
@ -2459,7 +2477,7 @@ end
// Main code.
//
loadTitle()
startGame()
startGame(TRUE) // ask whether new or load
kbdLoop()
done