Finished the item-generation split refactor.

This commit is contained in:
Martin Haye 2020-01-22 09:44:18 -08:00
parent 691fc35c40
commit 562a1bf285
6 changed files with 25 additions and 37 deletions

View File

@ -3217,6 +3217,7 @@ class A2PackPartitions
def mapCode = row.@"map-code"; assert mapCode
def groupSize = row.@"group-size"; assert groupSize
def lootChance = row.@"loot-chance"; // optional, defaults to 10%
lootChance = "100"; println("FIXME: setting lootChance to 100")
def lootCode = row.@"loot-code" // optional
def goldLoot = row.@"gold-loot"; assert goldLoot
def gangChance = row.@"gang-chance"; // optional

View File

@ -1127,7 +1127,7 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def collectLootAndXP()#2
word group, enemy, gold, xp, pItemsModule, itemFunc, pItem
word group, enemy, gold, xp, pItemTblModule, itemNum, pItem
byte lootedItem
gold = 0
@ -1142,15 +1142,15 @@ def collectLootAndXP()#2
if !lootedItem and enemy=>s_lootCode and enemy->b_lootChance
if rollPercentileWithLuck(-(global=>p_players->b_luck)) < enemy->b_lootChance
mmgr(START_LOAD, 1) // code is in partition 1
pItemsModule = mmgr(QUEUE_LOAD, MOD_GEN_ITEMS<<8 | RES_TYPE_MODULE)
pItemTblModule = mmgr(QUEUE_LOAD, MOD_GEN_ITEM_TABLES<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 0)
itemFunc = randomFromArray(pItemsModule()=>items_forLootCode(enemy=>s_lootCode), NULL)
pItem = itemFunc()
itemNum = randomFromArray(pItemTblModule()=>items_forLootCode(enemy=>s_lootCode), NULL)
pItem = createItem(itemNum)
if pItem->t_type == TYPE_FANCY_ITEM
pItem=>w_count = rollDiceWithLuck(pItem=>r_lootAmount, global=>p_players->b_luck)
fin
addItem(pItem)
mmgr(FREE_MEMORY, pItemsModule)
mmgr(FREE_MEMORY, pItemTblModule)
lootedItem = TRUE
fin
fin
@ -1276,10 +1276,8 @@ def processWin()#0
clearWindow
fin
// Make max space avail for item tables. Really oughta break them up sometime.
// Make max space avail for item tables.
freePreloaded
freePortrait
needRender = FALSE
// Grab the loot
gold, xp = collectLootAndXP()

View File

@ -55,7 +55,6 @@ import gamelib
predef first(p, sel)#1
predef forEach(p, do)#0
predef forSome(p, sel, do)#0
predef freePortrait()#0
predef getCharResponse()#1
predef getCursor()#2
predef getDir()#1

View File

@ -2152,19 +2152,13 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Display a portrait drawing (typically called from scripts)
export def freePortrait()#0
export def clearPortrait()#0
if curPortrait
auxMmgr(FREE_MEMORY, curPortrait)
curPortrait = NULL
curPortraitNum = 0
needRender = TRUE
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Display a portrait drawing (typically called from scripts)
export def clearPortrait()#0
freePortrait
if curFullscreenImg
auxMmgr(FREE_MEMORY, curFullscreenImg)
curFullscreenImg = NULL

View File

@ -92,7 +92,3 @@ const EMUSIG_2D_MAP = $C022 // e.g. wilderness
const EMUSIG_3D_MAP = $C023 // e.g. in town
const EMUSIG_AUTOMAP = $C024 // all color except the map title
const EMUSIG_STORY = $C025 // all text except a portrait
// FIXME FOO
const MOD_GEN_ITEMS = 99 // FIXME

View File

@ -27,7 +27,7 @@ predef _buyFromStore(storeCode, profitPercent)#1
predef _sellToStore(profitPercent)#1
word[] funcTbl = @_buyFromStore, @_sellToStore
word pItemsModule, pItemutilModule
word pItemTblModule, pItemutilModule
const MAX_PAGE_ITEMS = 20 // should be plenty
word pageItems[MAX_PAGE_ITEMS]
word pagePrices[MAX_PAGE_ITEMS]
@ -60,14 +60,14 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def loadExtraModules()#0
mmgr(START_LOAD, 1) // code is in partition 1
pItemsModule = mmgr(QUEUE_LOAD, MOD_GEN_ITEMS<<8 | RES_TYPE_MODULE)
pItemTblModule = mmgr(QUEUE_LOAD, MOD_GEN_ITEM_TABLES<<8 | RES_TYPE_MODULE)
pItemutilModule = mmgr(QUEUE_LOAD, MOD_ITEMUTIL<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 0)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def unloadExtraModules()#0
mmgr(FREE_MEMORY, pItemsModule)
mmgr(FREE_MEMORY, pItemTblModule)
mmgr(FREE_MEMORY, pItemutilModule)
end
@ -76,7 +76,7 @@ def displayTitle(titleAction, columnAction, pageNum, nPages)#0
clearWindow()
rawDisplayf2("^I %s %s ", pPlayer=>s_name, titleAction)
if (nPages > 1)
rawDisplayf2("p.%d/%d ", pageNum+1, nPages)
rawDisplayf2("p. %d/%d ", pageNum+1, nPages)
fin
rightJustifyStr(sprintf1(" %d party gold ", global=>w_gold), BIGWIN_RIGHT - 15)
rawDisplayf1("^N\n^V014^L%s^T046Price^T085Item^L", columnAction)
@ -114,27 +114,27 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def displayBuyPage(pItemTbl, markupRatio, pageNum, nPages)#1
byte itemNum
word pFunc, pItem
byte numOnPage
word pItemNum, pItem
// Clear stuff from previous page
heapCollect()
displayTitle("buying", "Browse", pageNum, nPages)
pFunc = pItemTbl + ((pageNum*PAGE_SIZE) << 1)
for itemNum = 0 to PAGE_SIZE-1
if !(*pFunc); break; fin
pItem = (*pFunc)()
pItemNum = pItemTbl + ((pageNum*PAGE_SIZE) << 1)
for numOnPage = 0 to PAGE_SIZE-1
if !(*pItemNum); break; fin
pItem = createItem(*pItemNum)
if pItem->t_type == TYPE_FANCY_ITEM
pItem=>w_count = pItem=>w_storeAmount
fin
pageItems[itemNum] = pItem
pagePrices[itemNum] = max(1, pItem=>w_price + addRatio(pItem=>w_price, markupRatio))
displayItemLine(itemNum)
pFunc = pFunc + 2
pageItems[numOnPage] = pItem
pagePrices[numOnPage] = max(1, pItem=>w_price + addRatio(pItem=>w_price, markupRatio))
displayItemLine(numOnPage)
pItemNum = pItemNum + 2
next
displayPaging("Browse", itemNum, pageNum, nPages)
return itemNum
displayPaging("Browse", numOnPage, pageNum, nPages)
return numOnPage
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -259,7 +259,7 @@ def _buyFromStore(storeCode, profitPercent)#1
byte nItemsOnPage, pageNum, nPages, redisplay
storeSetup()
pItemTbl = pItemsModule()=>items_forStoreCode(storeCode)
pItemTbl = pItemTblModule()=>items_forStoreCode(storeCode)
nPages = (countArray(pItemTbl) + PAGE_SIZE - 1) / PAGE_SIZE
pageNum = 0