mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-06-28 14:30:04 +00:00
Fix clearEncounterZones and setAvatar to be (more) persistent.
This commit is contained in:
parent
a3ed0e93a2
commit
d4525a9571
|
@ -2567,7 +2567,7 @@ end
|
|||
if (inst.nWarnings > 0) {
|
||||
warningFile.withWriter { out ->
|
||||
out.println "Packing warnings:\n"
|
||||
out.println str
|
||||
out.println inst.warningBuf.toString()
|
||||
out.write()
|
||||
}
|
||||
watcher.warnings(inst.nWarnings, inst.warningBuf.toString())
|
||||
|
@ -3129,7 +3129,7 @@ end
|
|||
println(avatars)
|
||||
throw new Exception("Can't find avatar '$tileName'")
|
||||
}
|
||||
outIndented("setAvatar(${avatars[tileName.toLowerCase()]})\n")
|
||||
outIndented("scriptSetAvatar(${avatars[tileName.toLowerCase()]})\n")
|
||||
}
|
||||
|
||||
def packSetSky(blk)
|
||||
|
|
|
@ -29,7 +29,7 @@ MAX_SEGS = 96
|
|||
|
||||
DO_COMP_CHECKSUMS = 0 ; during compression debugging
|
||||
DEBUG_DECOMP = 0
|
||||
DEBUG = 0
|
||||
DEBUG = 1
|
||||
SANITY_CHECK = 0 ; also prints out request data
|
||||
|
||||
; Zero page temporary variables
|
||||
|
|
|
@ -25,7 +25,7 @@ import gamelib
|
|||
predef addGold, countGold, payGold
|
||||
predef calcPlayerArmor, diskActivity, rdkey, initHeap, scriptCombat
|
||||
predef giveItemToPlayer, takeItemFromPlayer, playerHasItem, getStat, setStat
|
||||
predef setGameFlag, getGameFlag, setAvatar
|
||||
predef setGameFlag, getGameFlag, scriptSetAvatar
|
||||
|
||||
// Shared string constants
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@ word cmdTbl[96] // ASCII $00..$5F
|
|||
byte frameLoaded = 0
|
||||
byte heapLocked = FALSE
|
||||
byte skipScripts = FALSE
|
||||
byte allowZoneInit = FALSE
|
||||
byte curAvatar = 0
|
||||
|
||||
// Queue setMap / teleport / start_encounter, since otherwise script might be replaced while executing
|
||||
byte q_mapIs3D = 0
|
||||
|
@ -1257,7 +1259,9 @@ def initMap(x, y, dir)
|
|||
clearWindow()
|
||||
|
||||
// Clear the list of encounter zones from any previous maps
|
||||
if allowZoneInit
|
||||
global=>p_encounterZones = NULL
|
||||
fin
|
||||
|
||||
// Start up the display engine with map data and starting position. This will also load and
|
||||
// init the script module, if any, which will end up calling us back at the setScriptInfo
|
||||
|
@ -1267,11 +1271,18 @@ def initMap(x, y, dir)
|
|||
needRender = FALSE
|
||||
textDrawn = FALSE
|
||||
curPortrait = 0
|
||||
setAvatar(curAvatar)
|
||||
|
||||
// Display the party characters
|
||||
showParty()
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def scriptSetAvatar(avatarTileNum)
|
||||
curAvatar = avatarTileNum
|
||||
setAvatar(avatarTileNum)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Send an event to the script
|
||||
export def scriptEvent(event, param)
|
||||
|
@ -1375,12 +1386,12 @@ def moveForward()
|
|||
getPos(@x, @y)
|
||||
if !checkScripts(x, y)
|
||||
if global=>p_encounterZones
|
||||
checkEncounter(x, y)
|
||||
checkEncounter(x, y, FALSE)
|
||||
fin
|
||||
fin
|
||||
elsif val >= 2 and global=>p_encounterZones
|
||||
getPos(@x, @y)
|
||||
checkEncounter(x, y)
|
||||
checkEncounter(x, y, FALSE)
|
||||
fin
|
||||
end
|
||||
|
||||
|
@ -1501,7 +1512,10 @@ def setMap(is3D, num, x, y, dir)
|
|||
setWindow2(); clearWindow()
|
||||
mapIs3D = is3D
|
||||
mapNum = num
|
||||
allowZoneInit = TRUE
|
||||
curAvatar = 0
|
||||
initMap(x, y, dir)
|
||||
allowZoneInit = FALSE
|
||||
fin
|
||||
// Don't check scripts, because we often land on an "Exit to wilderness?" script
|
||||
//NO:checkScripts()
|
||||
|
@ -1634,7 +1648,9 @@ export def setScriptInfo(mapName, trigTbl, wdt, hgt)
|
|||
showMapName(mapName)
|
||||
|
||||
// Get ready for new encounter zones
|
||||
if allowZoneInit
|
||||
global=>p_encounterZones = NULL
|
||||
fin
|
||||
|
||||
// Back to the main text window.
|
||||
setWindow2()
|
||||
|
@ -1929,19 +1945,21 @@ end
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def addEncounterZone(code, x, y, dist, chance)
|
||||
word p; p = mmgr(HEAP_ALLOC, TYPE_ENCOUNTER_ZONE)
|
||||
word p
|
||||
if allowZoneInit
|
||||
p = mmgr(HEAP_ALLOC, TYPE_ENCOUNTER_ZONE)
|
||||
p=>s_name = mmgr(HEAP_INTERN, code)
|
||||
p=>w_encX = x
|
||||
p=>w_encY = y
|
||||
p=>w_encMaxDist = dist
|
||||
p=>w_encChance = chance
|
||||
addToList(@global=>p_encounterZones, p)
|
||||
fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def clearEncounterZones()
|
||||
global=>p_encounterZones = NULL
|
||||
mmgr(HEAP_COLLECT, 0)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2007,7 +2025,7 @@ end
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Check for a random encounter at this position
|
||||
def checkEncounter(x, y)
|
||||
def checkEncounter(x, y, force)
|
||||
word p
|
||||
word p_bestZone, bestDist
|
||||
word d
|
||||
|
@ -2027,17 +2045,19 @@ def checkEncounter(x, y)
|
|||
|
||||
// Roll for an encounter in the zone.
|
||||
d = rand16() % 1000
|
||||
if p_bestZone and d < p_bestZone=>w_encChance
|
||||
if p_bestZone and (d < p_bestZone=>w_encChance or force)
|
||||
// Encounter!
|
||||
printf1("Encounter: %s\n", p_bestZone=>s_name)
|
||||
doCombat(p_bestZone=>s_name)
|
||||
puts("Encounter complete.\n")
|
||||
fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def testCombat
|
||||
if global=>p_encounterZones
|
||||
doCombat(global=>p_encounterZones=>s_name)
|
||||
fin
|
||||
word x, y
|
||||
getPos(@x, @y)
|
||||
checkEncounter(x, y, TRUE)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2391,7 +2411,9 @@ def startGame()
|
|||
mapIs3D = q_mapIs3D
|
||||
mapNum = q_mapNum
|
||||
q_mapNum = 0
|
||||
allowZoneInit = TRUE
|
||||
initMap(q_x, q_y, q_dir)
|
||||
allowZoneInit = FALSE
|
||||
else
|
||||
q_mapNum = 0
|
||||
restoreMapPos()
|
||||
|
|
Loading…
Reference in New Issue
Block a user