mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-06-30 13:29:36 +00:00
Coding done on big item and flag refactor. Now for testing.
This commit is contained in:
parent
865c2fe8f2
commit
dbc94d707c
|
@ -25,6 +25,7 @@ import java.util.LinkedHashMap
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import javax.xml.bind.DatatypeConverter
|
import javax.xml.bind.DatatypeConverter
|
||||||
import groovy.json.JsonOutput
|
import groovy.json.JsonOutput
|
||||||
|
import groovy.util.Node
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -82,6 +83,7 @@ class A2PackPartitions
|
||||||
def modules = [:] // module name to module.num, module.buf
|
def modules = [:] // module name to module.num, module.buf
|
||||||
def bytecodes = [:] // module name to bytecode.num, bytecode.buf
|
def bytecodes = [:] // module name to bytecode.num, bytecode.buf
|
||||||
def fixups = [:] // module name to fixup.num, fixup.buf
|
def fixups = [:] // module name to fixup.num, fixup.buf
|
||||||
|
def gameFlags = [:] // flag name to number
|
||||||
|
|
||||||
def itemNameToFunc = [:]
|
def itemNameToFunc = [:]
|
||||||
def playerNameToFunc = [:]
|
def playerNameToFunc = [:]
|
||||||
|
@ -2027,6 +2029,7 @@ class A2PackPartitions
|
||||||
compileModule("gen_enemies", "src/plasma/")
|
compileModule("gen_enemies", "src/plasma/")
|
||||||
compileModule("gen_items", "src/plasma/")
|
compileModule("gen_items", "src/plasma/")
|
||||||
compileModule("gen_players", "src/plasma/")
|
compileModule("gen_players", "src/plasma/")
|
||||||
|
compileModule("gen_flags", "src/plasma/")
|
||||||
globalScripts.each { name, nArgs ->
|
globalScripts.each { name, nArgs ->
|
||||||
compileModule("gs_"+name, "src/plasma/")
|
compileModule("gs_"+name, "src/plasma/")
|
||||||
}
|
}
|
||||||
|
@ -2062,6 +2065,40 @@ class A2PackPartitions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scan all the scripts looking for flags, and make a mapping of flag name to number.
|
||||||
|
*/
|
||||||
|
def numberGameFlags(data)
|
||||||
|
{
|
||||||
|
String name = data.name().toString()
|
||||||
|
if (name == "{outlaw}gameData") {
|
||||||
|
gameFlags = [] as Set // temporary, until we have them all
|
||||||
|
data.global.scripts.script.each { numberGameFlags(it) }
|
||||||
|
data.map.scripts.script.each { numberGameFlags(it) }
|
||||||
|
|
||||||
|
// Now that we have them all, sort and assign numbers
|
||||||
|
def flagSet = gameFlags
|
||||||
|
gameFlags = [:]
|
||||||
|
flagSet.sort().each { flg -> gameFlags[flg] = gameFlags.size() }
|
||||||
|
}
|
||||||
|
else if (name == "{outlaw}block" &&
|
||||||
|
(data.@type == "interaction_get_flag" || data.@type == "interaction_set_flag"))
|
||||||
|
{
|
||||||
|
def els = data.field
|
||||||
|
assert els.size() == 1
|
||||||
|
def first = els[0]
|
||||||
|
assert first.@name == "NAME"
|
||||||
|
def flg = first.text().toLowerCase()
|
||||||
|
gameFlags << flg
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.iterator().each {
|
||||||
|
if (it instanceof Node)
|
||||||
|
numberGameFlags(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def readCache()
|
def readCache()
|
||||||
{
|
{
|
||||||
File cacheFile = new File("build/world.cache")
|
File cacheFile = new File("build/world.cache")
|
||||||
|
@ -2292,6 +2329,9 @@ class A2PackPartitions
|
||||||
// Number all the maps and record them with names
|
// Number all the maps and record them with names
|
||||||
numberMaps(dataIn)
|
numberMaps(dataIn)
|
||||||
|
|
||||||
|
// Assign a number to each game flag
|
||||||
|
numberGameFlags(dataIn)
|
||||||
|
|
||||||
// Form the translation from item name to function name (and ditto
|
// Form the translation from item name to function name (and ditto
|
||||||
// for players)
|
// for players)
|
||||||
allItemFuncs(dataIn.global.sheets.sheet)
|
allItemFuncs(dataIn.global.sheets.sheet)
|
||||||
|
@ -2648,6 +2688,47 @@ end
|
||||||
return parseDice(val)
|
return parseDice(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def genAllFlags()
|
||||||
|
{
|
||||||
|
// Make constants
|
||||||
|
new File("build/src/plasma/gen_flags.plh.new").withWriter { out ->
|
||||||
|
out.println("// Generated code - DO NOT MODIFY BY HAND\n")
|
||||||
|
out.println("const flags_nameForNumber = 0\n")
|
||||||
|
gameFlags.each { name, num ->
|
||||||
|
out.println("const GF_${humanNameToSymbol(name, true)} = $num")
|
||||||
|
}
|
||||||
|
out.println("const NUM_GAME_FLAGS = ${gameFlags.size()}")
|
||||||
|
}
|
||||||
|
replaceIfDiff("build/src/plasma/gen_flags.plh")
|
||||||
|
|
||||||
|
// Generate code
|
||||||
|
new File("build/src/plasma/gen_flags.pla.new").withWriter { out ->
|
||||||
|
out.println("// Generated code - DO NOT MODIFY BY HAND")
|
||||||
|
out.println()
|
||||||
|
out.println("include \"gamelib.plh\"")
|
||||||
|
out.println("include \"globalDefs.plh\"")
|
||||||
|
out.println("include \"gen_flags.plh\"")
|
||||||
|
out.println()
|
||||||
|
|
||||||
|
out.println("predef _flags_nameForNumber(num)#1")
|
||||||
|
out.println("word[] funcTbl = @_flags_nameForNumber\n")
|
||||||
|
out.println("def _flags_nameForNumber(num)#1")
|
||||||
|
out.println(" when num")
|
||||||
|
gameFlags.each { name, num ->
|
||||||
|
out.println(" is ${"GF_"+humanNameToSymbol(name, true)}; return(${escapeString(name.toUpperCase())})")
|
||||||
|
}
|
||||||
|
out.println(" wend")
|
||||||
|
out.println(" puts(num); fatal(\"flags_nameForNumber\")")
|
||||||
|
out.println(" return(0)")
|
||||||
|
out.println("end\n")
|
||||||
|
|
||||||
|
// Lastly, the outer module-level code
|
||||||
|
out.println("return @funcTbl")
|
||||||
|
out.println("done")
|
||||||
|
}
|
||||||
|
replaceIfDiff("build/src/plasma/gen_flags.pla")
|
||||||
|
}
|
||||||
|
|
||||||
def genWeapon(func, row, out)
|
def genWeapon(func, row, out)
|
||||||
{
|
{
|
||||||
out.println(
|
out.println(
|
||||||
|
@ -2679,26 +2760,21 @@ end
|
||||||
"${parseModifier(row, "bonus-value", "bonus-attribute")})")
|
"${parseModifier(row, "bonus-value", "bonus-attribute")})")
|
||||||
}
|
}
|
||||||
|
|
||||||
def genAmmo(func, row, out)
|
|
||||||
{
|
|
||||||
out.println(
|
|
||||||
" return makeStuff(" +
|
|
||||||
"${escapeString(parseStringAttr(row, "name"))}, " +
|
|
||||||
"${escapeString(parseStringAttr(row, "ammo-kind"))}, " +
|
|
||||||
"${parseWordAttr(row, "price")}, " +
|
|
||||||
"${parseWordAttr(row, "max")}, " +
|
|
||||||
"${parseWordAttr(row, "store-amount")}, " +
|
|
||||||
"${parseDiceAttr(row, "loot-amount")})")
|
|
||||||
}
|
|
||||||
|
|
||||||
def genItem(func, row, out)
|
def genItem(func, row, out)
|
||||||
{
|
{
|
||||||
out.println(
|
def name = parseStringAttr(row, "name")
|
||||||
" return makeItem(" +
|
def price = parseWordAttr(row, "price")
|
||||||
"${escapeString(parseStringAttr(row, "name"))}, " +
|
def modifier = parseModifier(row, "bonus-value", "bonus-attribute")
|
||||||
"${parseWordAttr(row, "price")}, " +
|
def kind = parseStringAttr(row, "ammo-kind")
|
||||||
"${parseModifier(row, "bonus-value", "bonus-attribute")}, " +
|
def count = parseWordAttr(row, "count")
|
||||||
"${parseByteAttr(row, "number-of-uses")})")
|
def storeAmount = parseWordAttr(row, "store-amount")
|
||||||
|
def lootAmount = parseDiceAttr(row, "loot-amount")
|
||||||
|
|
||||||
|
if ("$kind, $modifier, $count, $storeAmount, $lootAmount" != ", NULL, 0, 0, 0")
|
||||||
|
out.println(" return makeFancyItem(${escapeString(name)}, $price, " +
|
||||||
|
"${escapeString(kind)}, $modifier, $count, $storeAmount, $lootAmount)")
|
||||||
|
else
|
||||||
|
out.println(" return makePlainItem(${escapeString(name)}, $price)")
|
||||||
}
|
}
|
||||||
|
|
||||||
def genPlayer(func, row, out)
|
def genPlayer(func, row, out)
|
||||||
|
@ -2738,7 +2814,7 @@ end
|
||||||
def itemFunc = itemNameToFunc[name]
|
def itemFunc = itemNameToFunc[name]
|
||||||
assert itemFunc : "Can't locate item '$name'"
|
assert itemFunc : "Can't locate item '$name'"
|
||||||
if (num > 1)
|
if (num > 1)
|
||||||
out.println(" addToList(@p=>p_items, setStuffCount(itemScripts()=>$itemFunc(), $num))")
|
out.println(" addToList(@p=>p_items, setItemCount(itemScripts()=>$itemFunc(), $num))")
|
||||||
else
|
else
|
||||||
out.println(" addToList(@p=>p_items, itemScripts()=>$itemFunc())")
|
out.println(" addToList(@p=>p_items, itemScripts()=>$itemFunc())")
|
||||||
}
|
}
|
||||||
|
@ -2899,24 +2975,22 @@ def makeWeapon_pt2(p, attack0, attack1, attack2, weaponRange, combatText, single
|
||||||
return p
|
return p
|
||||||
end
|
end
|
||||||
|
|
||||||
def makeStuff(name, kind, price, count, storeAmount, lootAmount)
|
def makePlainItem(name, price)
|
||||||
word p; p = mmgr(HEAP_ALLOC, TYPE_STUFF)
|
word p; p = mmgr(HEAP_ALLOC, TYPE_PLAIN_ITEM)
|
||||||
p=>s_name = mmgr(HEAP_INTERN, name)
|
p=>s_name = mmgr(HEAP_INTERN, name)
|
||||||
p=>s_itemKind = mmgr(HEAP_INTERN, kind)
|
|
||||||
p=>w_price = price
|
p=>w_price = price
|
||||||
p=>w_count = count
|
|
||||||
p=>w_storeAmount = storeAmount
|
|
||||||
p=>r_lootAmount = lootAmount
|
|
||||||
return p
|
return p
|
||||||
end
|
end
|
||||||
|
|
||||||
def makeItem(name, price, modifier, maxUses)
|
def makeFancyItem(name, price, kind, modifiers, count, storeAmount, lootAmount)
|
||||||
word p; p = mmgr(HEAP_ALLOC, TYPE_ITEM)
|
word p; p = mmgr(HEAP_ALLOC, TYPE_FANCY_ITEM)
|
||||||
p=>s_name = mmgr(HEAP_INTERN, name)
|
p=>s_name = mmgr(HEAP_INTERN, name)
|
||||||
p=>w_price = price
|
p=>w_price = price
|
||||||
p=>p_modifiers = modifier
|
p=>s_itemKind = mmgr(HEAP_INTERN, kind)
|
||||||
p->b_maxUses = maxUses
|
p=>p_modifiers = modifiers
|
||||||
p->b_curUses = 0
|
p=>w_count = count
|
||||||
|
p=>w_storeAmount = storeAmount
|
||||||
|
p=>r_lootAmount = lootAmount
|
||||||
return p
|
return p
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2930,7 +3004,7 @@ end
|
||||||
switch (typeName) {
|
switch (typeName) {
|
||||||
case "weapon": genWeapon(func, row, out); break
|
case "weapon": genWeapon(func, row, out); break
|
||||||
case "armor": genArmor(func, row, out); break
|
case "armor": genArmor(func, row, out); break
|
||||||
case "ammo": genAmmo(func, row, out); break
|
case "ammo": genItem(func, row, out); break
|
||||||
case "item": genItem(func, row, out); break
|
case "item": genItem(func, row, out); break
|
||||||
default: assert false
|
default: assert false
|
||||||
}
|
}
|
||||||
|
@ -3043,11 +3117,11 @@ def makePlayer_pt2(p, health, level, aiming, handToHand, dodging, gender)#1
|
||||||
return p
|
return p
|
||||||
end
|
end
|
||||||
|
|
||||||
def setStuffCount(p, ct)#1
|
def setItemCount(p, ct)#1
|
||||||
if p->t_type == TYPE_STUFF
|
if p->t_type == TYPE_FANCY_ITEM
|
||||||
p->w_count = ct
|
p->w_count = ct
|
||||||
else
|
else
|
||||||
fatal(\"stuffct\")
|
fatal(\"itemct\")
|
||||||
fin
|
fin
|
||||||
return p // for chaining
|
return p // for chaining
|
||||||
end
|
end
|
||||||
|
@ -3191,6 +3265,9 @@ end
|
||||||
// Before we can generate global script code, we need to identify and number all the maps.
|
// Before we can generate global script code, we need to identify and number all the maps.
|
||||||
numberMaps(dataIn)
|
numberMaps(dataIn)
|
||||||
|
|
||||||
|
// Assign a number to each game flag
|
||||||
|
numberGameFlags(dataIn)
|
||||||
|
|
||||||
// Form the translation from item name to function name (and ditto
|
// Form the translation from item name to function name (and ditto
|
||||||
// for players)
|
// for players)
|
||||||
allItemFuncs(dataIn.global.sheets.sheet)
|
allItemFuncs(dataIn.global.sheets.sheet)
|
||||||
|
@ -3202,6 +3279,9 @@ end
|
||||||
genAllGlobalScripts(dataIn.global.scripts.script)
|
genAllGlobalScripts(dataIn.global.scripts.script)
|
||||||
curMapName = null
|
curMapName = null
|
||||||
|
|
||||||
|
// Generate a mapping of flags, for debugging purposes.
|
||||||
|
genAllFlags()
|
||||||
|
|
||||||
// Translate enemies, weapons, etc. to code
|
// Translate enemies, weapons, etc. to code
|
||||||
genAllItems(dataIn.global.sheets.sheet)
|
genAllItems(dataIn.global.sheets.sheet)
|
||||||
genAllEnemies(dataIn.global.sheets.sheet.find { it?.@name.equalsIgnoreCase("enemies") })
|
genAllEnemies(dataIn.global.sheets.sheet.find { it?.@name.equalsIgnoreCase("enemies") })
|
||||||
|
@ -3492,6 +3572,7 @@ end
|
||||||
out << "include \"../plasma/gamelib.plh\"\n"
|
out << "include \"../plasma/gamelib.plh\"\n"
|
||||||
out << "include \"../plasma/globalDefs.plh\"\n"
|
out << "include \"../plasma/globalDefs.plh\"\n"
|
||||||
out << "include \"../plasma/playtype.plh\"\n"
|
out << "include \"../plasma/playtype.plh\"\n"
|
||||||
|
out << "include \"../plasma/gen_flags.plh\"\n"
|
||||||
out << "include \"../plasma/gen_images.plh\"\n"
|
out << "include \"../plasma/gen_images.plh\"\n"
|
||||||
out << "include \"../plasma/gen_items.plh\"\n"
|
out << "include \"../plasma/gen_items.plh\"\n"
|
||||||
out << "include \"../plasma/gen_modules.plh\"\n"
|
out << "include \"../plasma/gen_modules.plh\"\n"
|
||||||
|
@ -3979,14 +4060,16 @@ end
|
||||||
|
|
||||||
def packGetFlag(blk)
|
def packGetFlag(blk)
|
||||||
{
|
{
|
||||||
def name = getSingle(blk.field, 'NAME').text()
|
def name = getSingle(blk.field, 'NAME').text().trim().toLowerCase()
|
||||||
out << "getGameFlag(${escapeString(name)})"
|
assert gameFlags.containsKey(name)
|
||||||
|
out << "getGameFlag(GF_${humanNameToSymbol(name, true)})"
|
||||||
}
|
}
|
||||||
|
|
||||||
def packChangeFlag(blk)
|
def packChangeFlag(blk)
|
||||||
{
|
{
|
||||||
def name = getSingle(blk.field, 'NAME').text()
|
def name = getSingle(blk.field, 'NAME').text().trim().toLowerCase()
|
||||||
outIndented("setGameFlag(${escapeString(name)}, ${blk.@type == 'interaction_set_flag' ? 1 : 0})\n")
|
assert gameFlags.containsKey(name)
|
||||||
|
outIndented("setGameFlag(GF_${humanNameToSymbol(name, true)}, ${blk.@type == 'interaction_set_flag' ? 1 : 0})\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
def isStringExpr(blk)
|
def isStringExpr(blk)
|
||||||
|
|
|
@ -301,7 +301,7 @@ def reload(pl, pWeapon, echo)#0
|
||||||
// Find matching ammo
|
// Find matching ammo
|
||||||
item = pl=>p_items
|
item = pl=>p_items
|
||||||
while item
|
while item
|
||||||
if item->t_type == TYPE_STUFF
|
if item->t_type == TYPE_FANCY_ITEM
|
||||||
if streqi(item=>s_itemKind, pWeapon=>s_ammoKind); break; fin
|
if streqi(item=>s_itemKind, pWeapon=>s_ammoKind); break; fin
|
||||||
fin
|
fin
|
||||||
item = item=>p_nextObj
|
item = item=>p_nextObj
|
||||||
|
@ -851,7 +851,7 @@ def addItem(pl, pItem)#1
|
||||||
word pComp
|
word pComp
|
||||||
pComp = scanForNamedObj(pl=>p_items, pItem=>s_name)
|
pComp = scanForNamedObj(pl=>p_items, pItem=>s_name)
|
||||||
if pComp
|
if pComp
|
||||||
if pItem->t_type == TYPE_STUFF
|
if pItem->t_type == TYPE_FANCY_ITEM
|
||||||
pComp=>w_count = min(30000, pComp=>w_count + pItem=>w_count)
|
pComp=>w_count = min(30000, pComp=>w_count + pItem=>w_count)
|
||||||
return TRUE
|
return TRUE
|
||||||
else
|
else
|
||||||
|
@ -882,11 +882,11 @@ def collectLootAndXP()#2
|
||||||
mmgr(FINISH_LOAD, 0)
|
mmgr(FINISH_LOAD, 0)
|
||||||
itemFunc = randomFromArray(pItemsModule()=>items_forLootCode(enemy=>s_lootCode))
|
itemFunc = randomFromArray(pItemsModule()=>items_forLootCode(enemy=>s_lootCode))
|
||||||
pItem = itemFunc()
|
pItem = itemFunc()
|
||||||
if pItem->t_type == TYPE_STUFF
|
if pItem->t_type == TYPE_FANCY_ITEM
|
||||||
pItem=>w_count = rollDiceWithLuck(pItem=>r_lootAmount, global=>p_players->b_luck)
|
pItem=>w_count = rollDiceWithLuck(pItem=>r_lootAmount, global=>p_players->b_luck)
|
||||||
fin
|
fin
|
||||||
if addItem(global=>p_players, pItem)
|
if addItem(global=>p_players, pItem)
|
||||||
if pItem->t_type == TYPE_STUFF and pItem=>w_count > 1
|
if pItem->t_type == TYPE_FANCY_ITEM and pItem=>w_count > 1
|
||||||
isPlural = TRUE
|
isPlural = TRUE
|
||||||
displayf2("You find %d %s! ", pItem=>w_count, pItem=>s_name)
|
displayf2("You find %d %s! ", pItem=>w_count, pItem=>s_name)
|
||||||
else
|
else
|
||||||
|
|
|
@ -2329,7 +2329,11 @@ def returnFromEngine(render)#0
|
||||||
if renderLoaded; texControl(1); texturesLoaded = TRUE; fin
|
if renderLoaded; texControl(1); texturesLoaded = TRUE; fin
|
||||||
mapNameHash = 0; showMapName(global=>s_mapName)
|
mapNameHash = 0; showMapName(global=>s_mapName)
|
||||||
clearTextWindow()
|
clearTextWindow()
|
||||||
if render; doRender(); fin
|
if render
|
||||||
|
doRender()
|
||||||
|
else
|
||||||
|
needRender = TRUE
|
||||||
|
fin
|
||||||
showParty()
|
showParty()
|
||||||
setWindow2() // in case we're mid-script
|
setWindow2() // in case we're mid-script
|
||||||
fin
|
fin
|
||||||
|
@ -2445,7 +2449,7 @@ def doCombat(mapCode, backUpOnFlee)#1
|
||||||
playerDeath()
|
playerDeath()
|
||||||
return 0
|
return 0
|
||||||
fin
|
fin
|
||||||
returnFromEngine(TRUE)
|
returnFromEngine(!inScript) // only re-render if outside script
|
||||||
|
|
||||||
// If the party fled the combat instead of winning, back up to previous square.
|
// If the party fled the combat instead of winning, back up to previous square.
|
||||||
if !result and backUpOnFlee
|
if !result and backUpOnFlee
|
||||||
|
@ -2983,28 +2987,23 @@ export def setStat(player, statName, val)#0
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
export def setGameFlag(flagName, val)#0
|
export def setGameFlag(flagNum, val)#0
|
||||||
word p_flag
|
byte byteNum, mask
|
||||||
p_flag = scanForNamedObj(global=>p_gameFlags, flagName)
|
byteNum = flagNum >> 3
|
||||||
if p_flag
|
mask = 1<<(flagNum & 7)
|
||||||
if val == 0 // setting flag to zero removes it
|
if val
|
||||||
removeFromList(@global=>p_gameFlags, p_flag)
|
global->ba_gameFlags[byteNum] = global->ba_gameFlags[byteNum] | mask
|
||||||
else
|
else
|
||||||
p_flag=>w_modValue = val
|
global->ba_gameFlags[byteNum] = global->ba_gameFlags[byteNum] & ~mask
|
||||||
fin
|
|
||||||
elsif val <> 0
|
|
||||||
addToList(@global=>p_gameFlags, makeModifier(flagName, val))
|
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
export def getGameFlag(flagName)#1
|
export def getGameFlag(flagNum)#1
|
||||||
word p_flag
|
byte byteNum, mask
|
||||||
p_flag = scanForNamedObj(global=>p_gameFlags, flagName)
|
byteNum = flagNum >> 3
|
||||||
if p_flag
|
mask = 1<<(flagNum & 7)
|
||||||
return p_flag=>w_modValue
|
return global->ba_gameFlags[byteNum] & mask
|
||||||
fin
|
|
||||||
return 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -376,10 +376,10 @@ def showItemMenu(item)#0
|
||||||
if type == TYPE_ARMOR or type == TYPE_WEAPON
|
if type == TYPE_ARMOR or type == TYPE_WEAPON
|
||||||
rawDisplayStr("E)quip/unequip, ")
|
rawDisplayStr("E)quip/unequip, ")
|
||||||
fin
|
fin
|
||||||
if type == TYPE_ITEM
|
if type == TYPE_PLAIN_ITEM or type == TYPE_FANCY_ITEM
|
||||||
rawDisplayStr("U)se, ")
|
rawDisplayStr("U)se, ")
|
||||||
fin
|
fin
|
||||||
rawDisplayStr("D)estroy or [Esc]")
|
rawDisplayStr("D)rop or [Esc]")
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -413,10 +413,7 @@ def doUse(player, item)#1
|
||||||
rawDisplayStr("^V000\n^J^J^J")
|
rawDisplayStr("^V000\n^J^J^J")
|
||||||
if player=>w_health < player=>w_maxHealth
|
if player=>w_health < player=>w_maxHealth
|
||||||
player=>w_health = min(player=>w_health + item=>p_modifiers=>w_modValue, player=>w_maxHealth)
|
player=>w_health = min(player=>w_health + item=>p_modifiers=>w_modValue, player=>w_maxHealth)
|
||||||
item->b_curUses++
|
|
||||||
if item->b_curUses >= item->b_maxUses // all used up
|
|
||||||
removeFromList(@player=>p_items, item)
|
removeFromList(@player=>p_items, item)
|
||||||
fin
|
|
||||||
rawDisplayf2("Healed to %d/%d", player=>w_health, player=>w_maxHealth)
|
rawDisplayf2("Healed to %d/%d", player=>w_health, player=>w_maxHealth)
|
||||||
else
|
else
|
||||||
rawDisplayStr("No healing needed.")
|
rawDisplayStr("No healing needed.")
|
||||||
|
@ -431,7 +428,7 @@ end
|
||||||
// Select an item and drop it. Returns TRUE if anything changed
|
// Select an item and drop it. Returns TRUE if anything changed
|
||||||
def doDestroy(player, item)#1
|
def doDestroy(player, item)#1
|
||||||
clearMenuRect()
|
clearMenuRect()
|
||||||
rawDisplayStr("Destroy ")
|
rawDisplayStr("Drop ")
|
||||||
_displayItemName(item)
|
_displayItemName(item)
|
||||||
rawDisplayStr(" (Y/N)?")
|
rawDisplayStr(" (Y/N)?")
|
||||||
if getYN()
|
if getYN()
|
||||||
|
@ -491,7 +488,7 @@ def interactWithItem(player, item)#1
|
||||||
break
|
break
|
||||||
// Use an item
|
// Use an item
|
||||||
is 'U'
|
is 'U'
|
||||||
if item->t_type == TYPE_ITEM
|
if item->t_type == TYPE_PLAIN_ITEM or item->t_type == TYPE_FANCY_ITEM
|
||||||
return doUse(player, item) // general 'use' handled by outer engine, because it might involve graphics
|
return doUse(player, item) // general 'use' handled by outer engine, because it might involve graphics
|
||||||
else
|
else
|
||||||
beep
|
beep
|
||||||
|
@ -814,7 +811,6 @@ end
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def displayWeaponStats(pItem1, pItem2)#0
|
def displayWeaponStats(pItem1, pItem2)#0
|
||||||
displayTwoCol("Equip'd", pItem1, pItem2, b_flags, @equippedField, @formatEquipped)
|
displayTwoCol("Equip'd", pItem1, pItem2, b_flags, @equippedField, @formatEquipped)
|
||||||
displayTwoCol("Uses", pItem1, pItem2, b_maxUses, @byteField, @formatNum)
|
|
||||||
displayTwoCol("Ammo", pItem1, pItem2, s_ammoKind, @wordField, @formatStr)
|
displayTwoCol("Ammo", pItem1, pItem2, s_ammoKind, @wordField, @formatStr)
|
||||||
displayTwoCol("Clip", pItem1, pItem2, b_clipSize, @byteField, @formatNum)
|
displayTwoCol("Clip", pItem1, pItem2, b_clipSize, @byteField, @formatNum)
|
||||||
displayTwoCol("Melee", pItem1, pItem2, r_meleeDmg, @wordField, @formatDice)
|
displayTwoCol("Melee", pItem1, pItem2, r_meleeDmg, @wordField, @formatDice)
|
||||||
|
@ -828,25 +824,19 @@ end
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def displayArmorStats(pItem1, pItem2)#0
|
def displayArmorStats(pItem1, pItem2)#0
|
||||||
displayTwoCol("Equip'd", pItem1, pItem2, b_flags, @equippedField, @formatEquipped)
|
displayTwoCol("Equip'd", pItem1, pItem2, b_flags, @equippedField, @formatEquipped)
|
||||||
displayTwoCol("Uses", pItem1, pItem2, b_maxUses, @byteField, @formatNum)
|
|
||||||
displayTwoCol("Protec", pItem1, pItem2, b_armorValue, @byteField, @formatNum)
|
displayTwoCol("Protec", pItem1, pItem2, b_armorValue, @byteField, @formatNum)
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
def displayStuffStats(pItem1, pItem2)#0
|
|
||||||
// Nothing special
|
|
||||||
end
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def _displayItemStats(pItem1, pItem2)#1
|
def _displayItemStats(pItem1, pItem2)#1
|
||||||
word pMod1, pMod2
|
word pMod1, pMod2
|
||||||
|
|
||||||
// First, show the item type and name
|
// First, show the item type and name
|
||||||
when pItem1->t_type
|
when pItem1->t_type
|
||||||
is TYPE_ITEM; rawDisplayStr("\nItem"); break
|
is TYPE_PLAIN_ITEM
|
||||||
|
is TYPE_FANCY_ITEM; rawDisplayStr("\nItem"); break
|
||||||
is TYPE_WEAPON; rawDisplayStr("\nWeapon"); break
|
is TYPE_WEAPON; rawDisplayStr("\nWeapon"); break
|
||||||
is TYPE_ARMOR; rawDisplayStr("\nArmor"); break
|
is TYPE_ARMOR; rawDisplayStr("\nArmor"); break
|
||||||
is TYPE_STUFF; rawDisplayStr("\nSupply"); break
|
|
||||||
otherwise fatal("tItem")
|
otherwise fatal("tItem")
|
||||||
wend
|
wend
|
||||||
tabTo(STATS_COL_1); _displayItemName(pItem1)
|
tabTo(STATS_COL_1); _displayItemName(pItem1)
|
||||||
|
@ -858,15 +848,14 @@ def _displayItemStats(pItem1, pItem2)#1
|
||||||
when pItem1->t_type
|
when pItem1->t_type
|
||||||
is TYPE_WEAPON; displayWeaponStats(pItem1, pItem2); break
|
is TYPE_WEAPON; displayWeaponStats(pItem1, pItem2); break
|
||||||
is TYPE_ARMOR; displayArmorStats(pItem1, pItem2); break
|
is TYPE_ARMOR; displayArmorStats(pItem1, pItem2); break
|
||||||
is TYPE_STUFF; displayStuffStats(pItem1, pItem2); break
|
|
||||||
wend
|
wend
|
||||||
|
|
||||||
// If either item has modifiers, show them
|
// If either item has modifiers, show them
|
||||||
pMod1 = NULL
|
pMod1 = NULL
|
||||||
if pItem1->t_type <> TYPE_STUFF; pMod1 = pItem1=>p_modifiers; fin
|
if pItem1->t_type <> TYPE_PLAIN_ITEM; pMod1 = pItem1=>p_modifiers; fin
|
||||||
pMod2 = NULL
|
pMod2 = NULL
|
||||||
if pItem2
|
if pItem2
|
||||||
if pItem2->t_type <> TYPE_STUFF; pMod2 = pItem2=>p_modifiers; fin
|
if pItem2->t_type <> TYPE_PLAIN_ITEM; pMod2 = pItem2=>p_modifiers; fin
|
||||||
fin
|
fin
|
||||||
if pMod1 or pMod2
|
if pMod1 or pMod2
|
||||||
rawDisplayStr("\nSpecial")
|
rawDisplayStr("\nSpecial")
|
||||||
|
@ -889,10 +878,12 @@ end
|
||||||
// For countable "stuff" (e.g. ammo), display the count and appropriate singular or plural name.
|
// For countable "stuff" (e.g. ammo), display the count and appropriate singular or plural name.
|
||||||
def _displayItemName(pItem)#1
|
def _displayItemName(pItem)#1
|
||||||
isPlural = FALSE
|
isPlural = FALSE
|
||||||
if pItem->t_type == TYPE_STUFF
|
if pItem->t_type == TYPE_FANCY_ITEM
|
||||||
isPlural = pItem=>w_count <> 1
|
if pItem=>w_count > 0
|
||||||
|
isPlural = pItem=>w_count > 1
|
||||||
rawDisplayf1("%d ", pItem=>w_count)
|
rawDisplayf1("%d ", pItem=>w_count)
|
||||||
fin
|
fin
|
||||||
|
fin
|
||||||
buildString(@addToString)
|
buildString(@addToString)
|
||||||
printf1("%s", pItem=>s_name) // need proper plural processing
|
printf1("%s", pItem=>s_name) // need proper plural processing
|
||||||
rawDisplayStr(finishString(isPlural))
|
rawDisplayStr(finishString(isPlural))
|
||||||
|
|
|
@ -9,19 +9,17 @@
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Garbage collection pointer offsets within each type
|
// Garbage collection pointer offsets within each type
|
||||||
byte typeTbl_Global[] = Global, p_players, p_benched, p_enemyGroups, p_combatFirst, p_encounterZones, s_mapName, p_gameFlags, 0
|
byte typeTbl_Global[] = Global, p_players, p_benched, p_enemyGroups, p_combatFirst, p_encounterZones, s_mapName, 0
|
||||||
byte typeTbl_Player[] = Player, p_nextObj, s_name, p_combatNext, p_skills, p_items, p_effects, 0
|
byte typeTbl_Player[] = Player, p_nextObj, s_name, p_combatNext, p_skills, p_items, 0
|
||||||
byte typeTbl_Modifier[] = Modifier, p_nextObj, s_name, 0
|
byte typeTbl_Modifier[] = Modifier, p_nextObj, s_name, 0
|
||||||
byte typeTbl_Effect[] = Effect, p_nextObj, s_name, 0
|
byte typeTbl_PlainItem[] = PlainItem, p_nextObj, s_name, 0
|
||||||
byte typeTbl_Item[] = Item, p_nextObj, s_name, s_itemKind, p_modifiers, 0
|
byte typeTbl_FancyItem[] = FancyItem, p_nextObj, s_name, s_itemKind, p_modifiers, 0
|
||||||
byte typeTbl_Weapon[] = Weapon, p_nextObj, s_name, s_itemKind, p_modifiers, s_ammoKind, s_combatText, 0
|
byte typeTbl_Weapon[] = Weapon, p_nextObj, s_name, s_itemKind, p_modifiers, s_ammoKind, s_combatText, 0
|
||||||
byte typeTbl_Armor[] = Armor, p_nextObj, s_name, s_itemKind, p_modifiers, 0
|
byte typeTbl_Armor[] = Armor, p_nextObj, s_name, s_itemKind, p_modifiers, 0
|
||||||
byte typeTbl_Stuff[] = Stuff, p_nextObj, s_name, s_itemKind, 0
|
|
||||||
byte typeTbl_Enemy[] = Enemy, p_nextObj, s_name, p_combatNext, s_attackText, 0
|
byte typeTbl_Enemy[] = Enemy, p_nextObj, s_name, p_combatNext, s_attackText, 0
|
||||||
byte typeTbl_EnemyGroup[] = EnemyGroup, p_nextObj, p_enemies, 0
|
byte typeTbl_EnemyGroup[] = EnemyGroup, p_nextObj, p_enemies, 0
|
||||||
byte typeTbl_EncounterZone[] = EncounterZone, p_nextObj, s_name, 0
|
byte typeTbl_EncounterZone[] = EncounterZone, p_nextObj, s_name, 0
|
||||||
|
|
||||||
word typeTbls = @typeTbl_Global, @typeTbl_Player, @typeTbl_Modifier, @typeTbl_Effect, @typeTbl_Item
|
word typeTbls = @typeTbl_Global, @typeTbl_Player, @typeTbl_Modifier, @typeTbl_PlainItem, @typeTbl_FancyItem
|
||||||
word = @typeTbl_Weapon, @typeTbl_Armor, @typeTbl_Stuff, @typeTbl_Enemy, @typeTbl_EnemyGroup
|
word = @typeTbl_Weapon, @typeTbl_Armor, @typeTbl_Enemy, @typeTbl_EnemyGroup, @typeTbl_EncounterZone
|
||||||
word = @typeTbl_EncounterZone
|
|
||||||
word = 0
|
word = 0
|
||||||
|
|
|
@ -36,8 +36,7 @@ struc Global
|
||||||
word w_heapSize
|
word w_heapSize
|
||||||
word w_typeHash
|
word w_typeHash
|
||||||
|
|
||||||
// General flags maintained by scripts. Linked list of Modifiers.
|
byte[32] ba_gameFlags // General flags maintained by scripts (array of 256 bits = 32 bytes)
|
||||||
word p_gameFlags
|
|
||||||
byte b_curAvatar
|
byte b_curAvatar
|
||||||
|
|
||||||
// god mode flag
|
// god mode flag
|
||||||
|
@ -86,7 +85,6 @@ struc Player
|
||||||
// Lists
|
// Lists
|
||||||
word p_skills // list:Modifier
|
word p_skills // list:Modifier
|
||||||
word p_items // list:Item
|
word p_items // list:Item
|
||||||
word p_effects // list:Effect
|
|
||||||
end
|
end
|
||||||
|
|
||||||
// Combat skills, weapon modifiers, etc.
|
// Combat skills, weapon modifiers, etc.
|
||||||
|
@ -98,27 +96,29 @@ struc Modifier
|
||||||
word w_modValue
|
word w_modValue
|
||||||
end
|
end
|
||||||
|
|
||||||
// Buffs and debuffs, that last until a specified time
|
// Plain items are for things that don't stack or have stat effects,
|
||||||
const TYPE_EFFECT = $83
|
// but may have meaning to scenario logic (e.g. keys, tokens, etc.)
|
||||||
struc Effect
|
const TYPE_PLAIN_ITEM = $83
|
||||||
byte t_type
|
struc PlainItem
|
||||||
word p_nextObj
|
|
||||||
byte s_name
|
|
||||||
word w_modValue
|
|
||||||
word w_endTurn
|
|
||||||
end
|
|
||||||
|
|
||||||
const TYPE_ITEM = $84
|
|
||||||
struc Item
|
|
||||||
byte t_type
|
byte t_type
|
||||||
word p_nextObj
|
word p_nextObj
|
||||||
word s_name
|
word s_name
|
||||||
word s_itemKind
|
|
||||||
word w_price
|
word w_price
|
||||||
word p_modifiers // list:modifier
|
end
|
||||||
// Usables properties
|
|
||||||
byte b_maxUses
|
const TYPE_FANCY_ITEM = $84
|
||||||
byte b_curUses
|
struc FancyItem
|
||||||
|
// Plain item properties
|
||||||
|
byte t_type
|
||||||
|
word p_nextObj
|
||||||
|
word s_name
|
||||||
|
word w_price
|
||||||
|
// Fancy properties
|
||||||
|
word s_itemKind // for ammo
|
||||||
|
word p_modifiers // list:modifier, e.g. boost health, etc.
|
||||||
|
word w_count // zero for singular items, 1+ for countables
|
||||||
|
word w_storeAmount
|
||||||
|
word r_lootAmount
|
||||||
end
|
end
|
||||||
|
|
||||||
const ITEM_FLAG_EQUIP = $80 // only one weapon/armor equipped (in use) at a time
|
const ITEM_FLAG_EQUIP = $80 // only one weapon/armor equipped (in use) at a time
|
||||||
|
@ -127,19 +127,16 @@ const WEAPON_FLAG_SINGLE_USE = $01
|
||||||
|
|
||||||
const TYPE_WEAPON = $85
|
const TYPE_WEAPON = $85
|
||||||
struc Weapon
|
struc Weapon
|
||||||
// Item properties
|
// Plain item properties
|
||||||
byte t_type
|
byte t_type
|
||||||
word p_nextObj
|
word p_nextObj
|
||||||
word s_name
|
word s_name
|
||||||
word s_itemKind
|
|
||||||
word w_price
|
word w_price
|
||||||
word p_modifiers // list:modifier
|
|
||||||
// Usables properties
|
|
||||||
byte b_maxUses
|
|
||||||
byte b_curUses
|
|
||||||
// Weapon properties
|
// Weapon properties
|
||||||
|
word s_itemKind // for skill matching
|
||||||
|
word p_modifiers // list:modifier
|
||||||
byte b_flags // WEAPON_FLAG_* above
|
byte b_flags // WEAPON_FLAG_* above
|
||||||
word s_ammoKind
|
word s_ammoKind // for matching to Stackable ammo
|
||||||
byte b_clipSize
|
byte b_clipSize
|
||||||
byte b_clipCurrent
|
byte b_clipCurrent
|
||||||
word r_meleeDmg // 3 hex digits: num dice, die size, add. E.g. $361 = 3d6+1
|
word r_meleeDmg // 3 hex digits: num dice, die size, add. E.g. $361 = 3d6+1
|
||||||
|
@ -151,37 +148,19 @@ end
|
||||||
|
|
||||||
const TYPE_ARMOR = $86
|
const TYPE_ARMOR = $86
|
||||||
struc Armor
|
struc Armor
|
||||||
// General item properties
|
// Plain item properties
|
||||||
byte t_type
|
byte t_type
|
||||||
word p_nextObj
|
word p_nextObj
|
||||||
word s_name
|
word s_name
|
||||||
word s_itemKind
|
|
||||||
word w_price
|
word w_price
|
||||||
word p_modifiers // list:modifier
|
|
||||||
// Usables properties
|
|
||||||
byte b_maxUses
|
|
||||||
byte b_curUses
|
|
||||||
// Armor properties
|
// Armor properties
|
||||||
|
word s_itemKind
|
||||||
|
word p_modifiers // list:modifier
|
||||||
byte b_flags // ARMOR_FLAG_* above
|
byte b_flags // ARMOR_FLAG_* above
|
||||||
byte b_armorValue
|
byte b_armorValue
|
||||||
end
|
end
|
||||||
|
|
||||||
// Countable things, e.g. ammo and pelts
|
const TYPE_ENEMY = $87
|
||||||
const TYPE_STUFF = $87
|
|
||||||
struc Stuff
|
|
||||||
// General item properties
|
|
||||||
byte t_type
|
|
||||||
word p_nextObj
|
|
||||||
word s_name
|
|
||||||
word s_itemKind
|
|
||||||
word w_price
|
|
||||||
// Stuff properties
|
|
||||||
word w_count
|
|
||||||
word w_storeAmount
|
|
||||||
word r_lootAmount
|
|
||||||
end
|
|
||||||
|
|
||||||
const TYPE_ENEMY = $88
|
|
||||||
struc Enemy
|
struc Enemy
|
||||||
byte t_type
|
byte t_type
|
||||||
word p_nextObj
|
word p_nextObj
|
||||||
|
@ -204,7 +183,7 @@ struc Enemy
|
||||||
word r_goldLoot // monetary loot when killed, as 3 hex digits for dice
|
word r_goldLoot // monetary loot when killed, as 3 hex digits for dice
|
||||||
end
|
end
|
||||||
|
|
||||||
const TYPE_ENEMY_GROUP = $89
|
const TYPE_ENEMY_GROUP = $88
|
||||||
struc EnemyGroup
|
struc EnemyGroup
|
||||||
byte t_type
|
byte t_type
|
||||||
word p_nextObj
|
word p_nextObj
|
||||||
|
@ -212,7 +191,7 @@ struc EnemyGroup
|
||||||
byte b_enemyGroupRange
|
byte b_enemyGroupRange
|
||||||
end
|
end
|
||||||
|
|
||||||
const TYPE_ENCOUNTER_ZONE = $8A
|
const TYPE_ENCOUNTER_ZONE = $89
|
||||||
struc EncounterZone
|
struc EncounterZone
|
||||||
byte t_type
|
byte t_type
|
||||||
word p_nextObj
|
word p_nextObj
|
||||||
|
|
|
@ -89,7 +89,7 @@ def displayBuyPage(pItemTbl, markupRatio, pageNum, nPages)#1
|
||||||
for itemNum = 0 to PAGE_SIZE-1
|
for itemNum = 0 to PAGE_SIZE-1
|
||||||
if !(*pFunc); break; fin
|
if !(*pFunc); break; fin
|
||||||
pItem = (*pFunc)()
|
pItem = (*pFunc)()
|
||||||
if pItem->t_type == TYPE_STUFF
|
if pItem->t_type == TYPE_FANCY_ITEM
|
||||||
pItem=>w_count = pItem=>w_storeAmount
|
pItem=>w_count = pItem=>w_storeAmount
|
||||||
fin
|
fin
|
||||||
pageItems[itemNum] = pItem
|
pageItems[itemNum] = pItem
|
||||||
|
@ -185,7 +185,7 @@ def browseItem(num)#0
|
||||||
matchEquipped(pItem, compSkip) // to set pMatchPlayer
|
matchEquipped(pItem, compSkip) // to set pMatchPlayer
|
||||||
pComp = scanForNamedObj(pMatchPlayer=>p_items, pItem=>s_name)
|
pComp = scanForNamedObj(pMatchPlayer=>p_items, pItem=>s_name)
|
||||||
if pComp
|
if pComp
|
||||||
if pItem->t_type == TYPE_STUFF
|
if pItem->t_type == TYPE_FANCY_ITEM
|
||||||
pComp=>w_count = min(30000, pComp=>w_count + pItem=>w_count)
|
pComp=>w_count = min(30000, pComp=>w_count + pItem=>w_count)
|
||||||
else
|
else
|
||||||
rawDisplayStr("\nDuplicate item.")
|
rawDisplayStr("\nDuplicate item.")
|
||||||
|
@ -271,8 +271,8 @@ def iterateSellables(skipItems, markdownRatio)#1
|
||||||
pItem = pPlayer=>p_items
|
pItem = pPlayer=>p_items
|
||||||
while pItem
|
while pItem
|
||||||
ok = pItem=>w_price > 0
|
ok = pItem=>w_price > 0
|
||||||
if pItem->t_type == TYPE_STUFF
|
if pItem->t_type == TYPE_FANCY_ITEM
|
||||||
ok = FALSE // too much trouble to figure out stuff prices
|
ok = pItem=>w_count > 0 // too much trouble to figure out prices of stackables
|
||||||
elsif pItem->t_type == TYPE_WEAPON or pItem->t_type == TYPE_ARMOR
|
elsif pItem->t_type == TYPE_WEAPON or pItem->t_type == TYPE_ARMOR
|
||||||
if pItem->b_flags & ITEM_FLAG_EQUIP; ok = FALSE; fin
|
if pItem->b_flags & ITEM_FLAG_EQUIP; ok = FALSE; fin
|
||||||
fin
|
fin
|
||||||
|
|
Loading…
Reference in New Issue
Block a user