Coding done on big item and flag refactor. Now for testing.

This commit is contained in:
Martin Haye 2017-08-29 09:06:53 -07:00
parent 865c2fe8f2
commit dbc94d707c
7 changed files with 206 additions and 156 deletions

View File

@ -25,6 +25,7 @@ import java.util.LinkedHashMap
import java.security.MessageDigest
import javax.xml.bind.DatatypeConverter
import groovy.json.JsonOutput
import groovy.util.Node
/**
*
@ -82,6 +83,7 @@ class A2PackPartitions
def modules = [:] // module name to module.num, module.buf
def bytecodes = [:] // module name to bytecode.num, bytecode.buf
def fixups = [:] // module name to fixup.num, fixup.buf
def gameFlags = [:] // flag name to number
def itemNameToFunc = [:]
def playerNameToFunc = [:]
@ -2027,6 +2029,7 @@ class A2PackPartitions
compileModule("gen_enemies", "src/plasma/")
compileModule("gen_items", "src/plasma/")
compileModule("gen_players", "src/plasma/")
compileModule("gen_flags", "src/plasma/")
globalScripts.each { name, nArgs ->
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()
{
File cacheFile = new File("build/world.cache")
@ -2292,6 +2329,9 @@ class A2PackPartitions
// Number all the maps and record them with names
numberMaps(dataIn)
// Assign a number to each game flag
numberGameFlags(dataIn)
// Form the translation from item name to function name (and ditto
// for players)
allItemFuncs(dataIn.global.sheets.sheet)
@ -2648,6 +2688,47 @@ end
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)
{
out.println(
@ -2679,26 +2760,21 @@ end
"${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)
{
out.println(
" return makeItem(" +
"${escapeString(parseStringAttr(row, "name"))}, " +
"${parseWordAttr(row, "price")}, " +
"${parseModifier(row, "bonus-value", "bonus-attribute")}, " +
"${parseByteAttr(row, "number-of-uses")})")
def name = parseStringAttr(row, "name")
def price = parseWordAttr(row, "price")
def modifier = parseModifier(row, "bonus-value", "bonus-attribute")
def kind = parseStringAttr(row, "ammo-kind")
def count = parseWordAttr(row, "count")
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)
@ -2738,7 +2814,7 @@ end
def itemFunc = itemNameToFunc[name]
assert itemFunc : "Can't locate item '$name'"
if (num > 1)
out.println(" addToList(@p=>p_items, setStuffCount(itemScripts()=>$itemFunc(), $num))")
out.println(" addToList(@p=>p_items, setItemCount(itemScripts()=>$itemFunc(), $num))")
else
out.println(" addToList(@p=>p_items, itemScripts()=>$itemFunc())")
}
@ -2899,24 +2975,22 @@ def makeWeapon_pt2(p, attack0, attack1, attack2, weaponRange, combatText, single
return p
end
def makeStuff(name, kind, price, count, storeAmount, lootAmount)
word p; p = mmgr(HEAP_ALLOC, TYPE_STUFF)
def makePlainItem(name, price)
word p; p = mmgr(HEAP_ALLOC, TYPE_PLAIN_ITEM)
p=>s_name = mmgr(HEAP_INTERN, name)
p=>s_itemKind = mmgr(HEAP_INTERN, kind)
p=>w_price = price
p=>w_count = count
p=>w_storeAmount = storeAmount
p=>r_lootAmount = lootAmount
return p
end
def makeItem(name, price, modifier, maxUses)
word p; p = mmgr(HEAP_ALLOC, TYPE_ITEM)
def makeFancyItem(name, price, kind, modifiers, count, storeAmount, lootAmount)
word p; p = mmgr(HEAP_ALLOC, TYPE_FANCY_ITEM)
p=>s_name = mmgr(HEAP_INTERN, name)
p=>w_price = price
p=>p_modifiers = modifier
p->b_maxUses = maxUses
p->b_curUses = 0
p=>s_itemKind = mmgr(HEAP_INTERN, kind)
p=>p_modifiers = modifiers
p=>w_count = count
p=>w_storeAmount = storeAmount
p=>r_lootAmount = lootAmount
return p
end
@ -2930,7 +3004,7 @@ end
switch (typeName) {
case "weapon": genWeapon(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
default: assert false
}
@ -3043,11 +3117,11 @@ def makePlayer_pt2(p, health, level, aiming, handToHand, dodging, gender)#1
return p
end
def setStuffCount(p, ct)#1
if p->t_type == TYPE_STUFF
def setItemCount(p, ct)#1
if p->t_type == TYPE_FANCY_ITEM
p->w_count = ct
else
fatal(\"stuffct\")
fatal(\"itemct\")
fin
return p // for chaining
end
@ -3191,6 +3265,9 @@ end
// Before we can generate global script code, we need to identify and number all the maps.
numberMaps(dataIn)
// Assign a number to each game flag
numberGameFlags(dataIn)
// Form the translation from item name to function name (and ditto
// for players)
allItemFuncs(dataIn.global.sheets.sheet)
@ -3202,6 +3279,9 @@ end
genAllGlobalScripts(dataIn.global.scripts.script)
curMapName = null
// Generate a mapping of flags, for debugging purposes.
genAllFlags()
// Translate enemies, weapons, etc. to code
genAllItems(dataIn.global.sheets.sheet)
genAllEnemies(dataIn.global.sheets.sheet.find { it?.@name.equalsIgnoreCase("enemies") })
@ -3492,6 +3572,7 @@ end
out << "include \"../plasma/gamelib.plh\"\n"
out << "include \"../plasma/globalDefs.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_items.plh\"\n"
out << "include \"../plasma/gen_modules.plh\"\n"
@ -3979,14 +4060,16 @@ end
def packGetFlag(blk)
{
def name = getSingle(blk.field, 'NAME').text()
out << "getGameFlag(${escapeString(name)})"
def name = getSingle(blk.field, 'NAME').text().trim().toLowerCase()
assert gameFlags.containsKey(name)
out << "getGameFlag(GF_${humanNameToSymbol(name, true)})"
}
def packChangeFlag(blk)
{
def name = getSingle(blk.field, 'NAME').text()
outIndented("setGameFlag(${escapeString(name)}, ${blk.@type == 'interaction_set_flag' ? 1 : 0})\n")
def name = getSingle(blk.field, 'NAME').text().trim().toLowerCase()
assert gameFlags.containsKey(name)
outIndented("setGameFlag(GF_${humanNameToSymbol(name, true)}, ${blk.@type == 'interaction_set_flag' ? 1 : 0})\n")
}
def isStringExpr(blk)

View File

@ -301,7 +301,7 @@ def reload(pl, pWeapon, echo)#0
// Find matching ammo
item = pl=>p_items
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
fin
item = item=>p_nextObj
@ -851,7 +851,7 @@ def addItem(pl, pItem)#1
word pComp
pComp = scanForNamedObj(pl=>p_items, pItem=>s_name)
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)
return TRUE
else
@ -882,11 +882,11 @@ def collectLootAndXP()#2
mmgr(FINISH_LOAD, 0)
itemFunc = randomFromArray(pItemsModule()=>items_forLootCode(enemy=>s_lootCode))
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)
fin
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
displayf2("You find %d %s! ", pItem=>w_count, pItem=>s_name)
else

View File

@ -2329,7 +2329,11 @@ def returnFromEngine(render)#0
if renderLoaded; texControl(1); texturesLoaded = TRUE; fin
mapNameHash = 0; showMapName(global=>s_mapName)
clearTextWindow()
if render; doRender(); fin
if render
doRender()
else
needRender = TRUE
fin
showParty()
setWindow2() // in case we're mid-script
fin
@ -2445,7 +2449,7 @@ def doCombat(mapCode, backUpOnFlee)#1
playerDeath()
return 0
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 !result and backUpOnFlee
@ -2983,28 +2987,23 @@ export def setStat(player, statName, val)#0
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def setGameFlag(flagName, val)#0
word p_flag
p_flag = scanForNamedObj(global=>p_gameFlags, flagName)
if p_flag
if val == 0 // setting flag to zero removes it
removeFromList(@global=>p_gameFlags, p_flag)
else
p_flag=>w_modValue = val
fin
elsif val <> 0
addToList(@global=>p_gameFlags, makeModifier(flagName, val))
export def setGameFlag(flagNum, val)#0
byte byteNum, mask
byteNum = flagNum >> 3
mask = 1<<(flagNum & 7)
if val
global->ba_gameFlags[byteNum] = global->ba_gameFlags[byteNum] | mask
else
global->ba_gameFlags[byteNum] = global->ba_gameFlags[byteNum] & ~mask
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def getGameFlag(flagName)#1
word p_flag
p_flag = scanForNamedObj(global=>p_gameFlags, flagName)
if p_flag
return p_flag=>w_modValue
fin
return 0
export def getGameFlag(flagNum)#1
byte byteNum, mask
byteNum = flagNum >> 3
mask = 1<<(flagNum & 7)
return global->ba_gameFlags[byteNum] & mask
end
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -376,10 +376,10 @@ def showItemMenu(item)#0
if type == TYPE_ARMOR or type == TYPE_WEAPON
rawDisplayStr("E)quip/unequip, ")
fin
if type == TYPE_ITEM
if type == TYPE_PLAIN_ITEM or type == TYPE_FANCY_ITEM
rawDisplayStr("U)se, ")
fin
rawDisplayStr("D)estroy or [Esc]")
rawDisplayStr("D)rop or [Esc]")
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -413,10 +413,7 @@ def doUse(player, item)#1
rawDisplayStr("^V000\n^J^J^J")
if player=>w_health < 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)
fin
removeFromList(@player=>p_items, item)
rawDisplayf2("Healed to %d/%d", player=>w_health, player=>w_maxHealth)
else
rawDisplayStr("No healing needed.")
@ -431,7 +428,7 @@ end
// Select an item and drop it. Returns TRUE if anything changed
def doDestroy(player, item)#1
clearMenuRect()
rawDisplayStr("Destroy ")
rawDisplayStr("Drop ")
_displayItemName(item)
rawDisplayStr(" (Y/N)?")
if getYN()
@ -491,7 +488,7 @@ def interactWithItem(player, item)#1
break
// Use an item
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
else
beep
@ -814,7 +811,6 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def displayWeaponStats(pItem1, pItem2)#0
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("Clip", pItem1, pItem2, b_clipSize, @byteField, @formatNum)
displayTwoCol("Melee", pItem1, pItem2, r_meleeDmg, @wordField, @formatDice)
@ -828,25 +824,19 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def displayArmorStats(pItem1, pItem2)#0
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)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def displayStuffStats(pItem1, pItem2)#0
// Nothing special
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def _displayItemStats(pItem1, pItem2)#1
word pMod1, pMod2
// First, show the item type and name
when pItem1->t_type
is TYPE_ITEM; rawDisplayStr("\nItem"); break
is TYPE_WEAPON; rawDisplayStr("\nWeapon"); break
is TYPE_ARMOR; rawDisplayStr("\nArmor"); break
is TYPE_STUFF; rawDisplayStr("\nSupply"); break
is TYPE_PLAIN_ITEM
is TYPE_FANCY_ITEM; rawDisplayStr("\nItem"); break
is TYPE_WEAPON; rawDisplayStr("\nWeapon"); break
is TYPE_ARMOR; rawDisplayStr("\nArmor"); break
otherwise fatal("tItem")
wend
tabTo(STATS_COL_1); _displayItemName(pItem1)
@ -858,15 +848,14 @@ def _displayItemStats(pItem1, pItem2)#1
when pItem1->t_type
is TYPE_WEAPON; displayWeaponStats(pItem1, pItem2); break
is TYPE_ARMOR; displayArmorStats(pItem1, pItem2); break
is TYPE_STUFF; displayStuffStats(pItem1, pItem2); break
wend
// If either item has modifiers, show them
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
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
if pMod1 or pMod2
rawDisplayStr("\nSpecial")
@ -889,9 +878,11 @@ end
// For countable "stuff" (e.g. ammo), display the count and appropriate singular or plural name.
def _displayItemName(pItem)#1
isPlural = FALSE
if pItem->t_type == TYPE_STUFF
isPlural = pItem=>w_count <> 1
rawDisplayf1("%d ", pItem=>w_count)
if pItem->t_type == TYPE_FANCY_ITEM
if pItem=>w_count > 0
isPlural = pItem=>w_count > 1
rawDisplayf1("%d ", pItem=>w_count)
fin
fin
buildString(@addToString)
printf1("%s", pItem=>s_name) // need proper plural processing

View File

@ -9,19 +9,17 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// 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_Player[] = Player, p_nextObj, s_name, p_combatNext, p_skills, p_items, p_effects, 0
byte typeTbl_Modifier[] = Modifier, p_nextObj, s_name, 0
byte typeTbl_Effect[] = Effect, p_nextObj, s_name, 0
byte typeTbl_Item[] = Item, 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_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_EnemyGroup[] = EnemyGroup, p_nextObj, p_enemies, 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, 0
byte typeTbl_Modifier[] = Modifier, p_nextObj, s_name, 0
byte typeTbl_PlainItem[] = PlainItem, p_nextObj, s_name, 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_Armor[] = Armor, p_nextObj, s_name, s_itemKind, p_modifiers, 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_EncounterZone[] = EncounterZone, p_nextObj, s_name, 0
word typeTbls = @typeTbl_Global, @typeTbl_Player, @typeTbl_Modifier, @typeTbl_Effect, @typeTbl_Item
word = @typeTbl_Weapon, @typeTbl_Armor, @typeTbl_Stuff, @typeTbl_Enemy, @typeTbl_EnemyGroup
word = @typeTbl_EncounterZone
word typeTbls = @typeTbl_Global, @typeTbl_Player, @typeTbl_Modifier, @typeTbl_PlainItem, @typeTbl_FancyItem
word = @typeTbl_Weapon, @typeTbl_Armor, @typeTbl_Enemy, @typeTbl_EnemyGroup, @typeTbl_EncounterZone
word = 0

View File

@ -36,8 +36,7 @@ struc Global
word w_heapSize
word w_typeHash
// General flags maintained by scripts. Linked list of Modifiers.
word p_gameFlags
byte[32] ba_gameFlags // General flags maintained by scripts (array of 256 bits = 32 bytes)
byte b_curAvatar
// god mode flag
@ -86,7 +85,6 @@ struc Player
// Lists
word p_skills // list:Modifier
word p_items // list:Item
word p_effects // list:Effect
end
// Combat skills, weapon modifiers, etc.
@ -98,27 +96,29 @@ struc Modifier
word w_modValue
end
// Buffs and debuffs, that last until a specified time
const TYPE_EFFECT = $83
struc Effect
byte t_type
word p_nextObj
byte s_name
word w_modValue
word w_endTurn
end
const TYPE_ITEM = $84
struc Item
// Plain items are for things that don't stack or have stat effects,
// but may have meaning to scenario logic (e.g. keys, tokens, etc.)
const TYPE_PLAIN_ITEM = $83
struc PlainItem
byte t_type
word p_nextObj
word s_name
word s_itemKind
word w_price
word p_modifiers // list:modifier
// Usables properties
byte b_maxUses
byte b_curUses
end
const TYPE_FANCY_ITEM = $84
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
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
struc Weapon
// Item properties
// Plain item properties
byte t_type
word p_nextObj
word s_name
word s_itemKind
word w_price
word p_modifiers // list:modifier
// Usables properties
byte b_maxUses
byte b_curUses
// Weapon properties
byte b_flags // WEAPON_FLAG_* above
word s_ammoKind
word s_itemKind // for skill matching
word p_modifiers // list:modifier
byte b_flags // WEAPON_FLAG_* above
word s_ammoKind // for matching to Stackable ammo
byte b_clipSize
byte b_clipCurrent
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
struc Armor
// General item properties
// Plain item properties
byte t_type
word p_nextObj
word s_name
word s_itemKind
word w_price
word p_modifiers // list:modifier
// Usables properties
byte b_maxUses
byte b_curUses
// Armor properties
word s_itemKind
word p_modifiers // list:modifier
byte b_flags // ARMOR_FLAG_* above
byte b_armorValue
end
// Countable things, e.g. ammo and pelts
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
const TYPE_ENEMY = $87
struc Enemy
byte t_type
word p_nextObj
@ -204,7 +183,7 @@ struc Enemy
word r_goldLoot // monetary loot when killed, as 3 hex digits for dice
end
const TYPE_ENEMY_GROUP = $89
const TYPE_ENEMY_GROUP = $88
struc EnemyGroup
byte t_type
word p_nextObj
@ -212,7 +191,7 @@ struc EnemyGroup
byte b_enemyGroupRange
end
const TYPE_ENCOUNTER_ZONE = $8A
const TYPE_ENCOUNTER_ZONE = $89
struc EncounterZone
byte t_type
word p_nextObj

View File

@ -89,7 +89,7 @@ def displayBuyPage(pItemTbl, markupRatio, pageNum, nPages)#1
for itemNum = 0 to PAGE_SIZE-1
if !(*pFunc); break; fin
pItem = (*pFunc)()
if pItem->t_type == TYPE_STUFF
if pItem->t_type == TYPE_FANCY_ITEM
pItem=>w_count = pItem=>w_storeAmount
fin
pageItems[itemNum] = pItem
@ -185,7 +185,7 @@ def browseItem(num)#0
matchEquipped(pItem, compSkip) // to set pMatchPlayer
pComp = scanForNamedObj(pMatchPlayer=>p_items, pItem=>s_name)
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)
else
rawDisplayStr("\nDuplicate item.")
@ -271,8 +271,8 @@ def iterateSellables(skipItems, markdownRatio)#1
pItem = pPlayer=>p_items
while pItem
ok = pItem=>w_price > 0
if pItem->t_type == TYPE_STUFF
ok = FALSE // too much trouble to figure out stuff prices
if pItem->t_type == TYPE_FANCY_ITEM
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
if pItem->b_flags & ITEM_FLAG_EQUIP; ok = FALSE; fin
fin