mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-11-18 23:07:53 +00:00
Now processes 'leave' events on map scripts.
This commit is contained in:
parent
a2c8008755
commit
ce7bf1d6cc
@ -2804,13 +2804,15 @@ end
|
||||
if (name != null)
|
||||
scriptNames[script] = "sc_${humanNameToSymbol(name, false)}"
|
||||
}
|
||||
|
||||
// Even if there were no scripts, we still need an init to display
|
||||
// the map name.
|
||||
|
||||
// Generate the table of triggers, and code for each script.
|
||||
makeTriggerTbl(scripts, xRange, yRange)
|
||||
scripts.each { script ->
|
||||
packScript(script)
|
||||
}
|
||||
|
||||
// Even if there were no scripts, we still need an init to display
|
||||
// the map name.
|
||||
makeInit(mapName, initScript, maxX, maxY)
|
||||
|
||||
out.close()
|
||||
@ -2826,12 +2828,26 @@ end
|
||||
withContext(scriptNames[script])
|
||||
{
|
||||
if (script.block.size() == 0) {
|
||||
printWarning("empty script '${script?.@name}' found; skipping.")
|
||||
printWarning("empty script found; skipping.")
|
||||
return
|
||||
}
|
||||
def proc = script.block[0]
|
||||
|
||||
// Record the function's name and start its definition
|
||||
out << "def ${scriptNames[script]}()\n"
|
||||
out << "def ${scriptNames[script]}("
|
||||
|
||||
// If the script takes arguments, mark those and add them to the definition
|
||||
def args = [] as Set
|
||||
if (proc.mutation) {
|
||||
proc.mutation.arg.eachWithIndex { arg, idx ->
|
||||
if (idx > 0)
|
||||
out << ", "
|
||||
def name = "v_" + humanNameToSymbol(arg.@name, false)
|
||||
out << name
|
||||
args << name
|
||||
}
|
||||
}
|
||||
out << ")\n"
|
||||
indent = 1
|
||||
|
||||
// Need to queue up the script, to find out what variables need
|
||||
@ -2842,7 +2858,6 @@ end
|
||||
variables = [] as Set
|
||||
|
||||
// Process the code inside it
|
||||
def proc = script.block[0]
|
||||
assert proc.@type == "procedures_defreturn"
|
||||
if (proc.statement.size() > 0) {
|
||||
assert proc.statement.size() == 1
|
||||
@ -2853,13 +2868,13 @@ end
|
||||
else
|
||||
printWarning "empty statement found; skipping."
|
||||
|
||||
// Define all the variables that were mentioned
|
||||
// Define all the variables that were mentioned (except the args)
|
||||
out.close()
|
||||
out = outerOutput
|
||||
variables.each { var ->
|
||||
(variables - args).each { var ->
|
||||
outIndented("word $var\n")
|
||||
}
|
||||
variables.each { var ->
|
||||
(variables - args).each { var ->
|
||||
outIndented("$var = 0\n")
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
import gamelib
|
||||
|
||||
// Shared library routines
|
||||
//////////// Shared library routines ////////////
|
||||
predef setScriptInfo, scriptDisplayStr, scriptDisplayStrNL, getYN, queue_setMap
|
||||
predef setSky, setGround, queue_teleport, setPortrait, clearPortrait, moveWayBackward
|
||||
predef getUpperKey, clearWindow, getGlobals, rand16, printf1, printf2, printf3
|
||||
@ -28,13 +28,13 @@ import gamelib
|
||||
predef setGameFlag, getGameFlag, scriptSetAvatar
|
||||
predef addPlayerToParty, removePlayerFromParty, partyHasPlayer
|
||||
|
||||
// Shared string constants
|
||||
/////////// Shared string constants //////////////
|
||||
|
||||
// First: attributes
|
||||
byte[] S_INTELLIGENCE, S_STRENGTH, S_AGILITY, S_STAMINA, S_CHARISMA, S_SPIRIT, S_LUCK
|
||||
byte[] S_HEALTH, S_MAX_HEALTH, S_AIMING, S_HAND_TO_HAND, S_DODGING, S_GOLD
|
||||
|
||||
// Next: common events
|
||||
byte[] S_ENTER, S_USE
|
||||
byte[] S_ENTER, S_LEAVE, S_USE
|
||||
|
||||
end
|
||||
|
@ -1212,8 +1212,8 @@ def getArgCount(pFunc)
|
||||
word pBytecode
|
||||
|
||||
// skip over JMP to plasma interp, get addr in aux mem
|
||||
pBytecode = pFunc=>3
|
||||
|
||||
pBytecode = pFunc=>3
|
||||
|
||||
// Check if the function starts with ENTER op
|
||||
if readAuxByte(pBytecode) == $58
|
||||
return readAuxByte(pBytecode+2)
|
||||
@ -1226,7 +1226,7 @@ end
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Send an event to the scripts on the current map square
|
||||
def scriptEvent(event, param)
|
||||
byte i
|
||||
byte i, argCount
|
||||
word script
|
||||
if !nMapScripts; return; fin
|
||||
|
||||
@ -1235,10 +1235,13 @@ def scriptEvent(event, param)
|
||||
|
||||
for i = 0 to nMapScripts-1
|
||||
script = mapScripts[i]
|
||||
if getArgCount(script) == 2
|
||||
script(event, param)
|
||||
elsif event == @S_ENTER // zero-param scripts are assumed to be strictly 'enter' handlers
|
||||
argCount = getArgCount(script)
|
||||
if argCount == 0 and event == @S_ENTER // zero-param scripts are assumed to be strictly 'enter' handlers
|
||||
script()
|
||||
elsif argCount == 1
|
||||
script(event)
|
||||
elsif argCount == 2
|
||||
script(event, param)
|
||||
fin
|
||||
|
||||
// Some scripts need to suppress running of any further scripts on the square
|
||||
|
Loading…
Reference in New Issue
Block a user