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