mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-05 19:54:38 +00:00
Added a god-mode cheat for adding an NPC to the party.
This commit is contained in:
parent
d81e5ff8c0
commit
d7d2ae3bbb
@ -2760,6 +2760,7 @@ end
|
||||
funcs.each { func, index, row ->
|
||||
out.println("const ${func} = ${(index+1)*2}")
|
||||
}
|
||||
out.println("const NUM_PLAYERS = ${funcs.size()}")
|
||||
}
|
||||
replaceIfDiff("build/src/plasma/gen_players.plh")
|
||||
|
||||
@ -3497,14 +3498,14 @@ end
|
||||
def name = getSingle(blk.field, 'NAME').text().trim()
|
||||
def itemFunc = itemNameToFunc[name.toLowerCase()]
|
||||
assert itemFunc : "Can't locate item '$name'"
|
||||
outIndented("giveItemToPlayer($itemFunc)\n")
|
||||
outIndented("giveItemToPlayer(@global=>p_players, $itemFunc)\n")
|
||||
}
|
||||
|
||||
def packTakeItem(blk)
|
||||
{
|
||||
def name = getSingle(blk.field, 'NAME').text().trim()
|
||||
assert itemNameToFunc.containsKey(name.toLowerCase()) : "Can't locate item '$name'"
|
||||
outIndented("takeItemFromPlayer(${escapeString(name)})\n")
|
||||
outIndented("takeItemFromPlayer(@global=>p_players, ${escapeString(name)})\n")
|
||||
}
|
||||
|
||||
def packAddPlayer(blk)
|
||||
|
@ -29,7 +29,7 @@ import gamelib
|
||||
predef setGameFlag, getGameFlag, scriptSetAvatar, parseDecWithDefault, readStr
|
||||
predef addPlayerToParty, removePlayerFromParty, partyHasPlayer, loadFrameImg, loadMainFrameImg
|
||||
predef scriptSwapTile, setIntimateMode, fontCmd, setIntimateMode
|
||||
predef callGlobalFunc, getCharResponse, memcpy, checkEncounter, finalWin
|
||||
predef callGlobalFunc, getCharResponse, memcpy, checkEncounter, finalWin, addUnique
|
||||
|
||||
// This pointer is the root of all heap-tracked (and garbage collected) objects.
|
||||
// See playtype.plh for definitions of all the datastructures and how they interconnect.
|
||||
@ -41,6 +41,7 @@ import gamelib
|
||||
word skyNum
|
||||
word groundNum
|
||||
byte portraitNum
|
||||
word pGodModule
|
||||
|
||||
/////////// Shared string constants //////////////
|
||||
|
||||
|
@ -84,7 +84,7 @@ word curEngine = NULL
|
||||
word pIntimate = NULL
|
||||
word pResourceIndex = NULL
|
||||
byte curMapPartition = 0
|
||||
word pGodModule = NULL
|
||||
export word pGodModule = NULL
|
||||
|
||||
// Queue setMap / teleport / start_encounter, since otherwise script might be replaced while executing
|
||||
byte q_mapIs3D = 0
|
||||
@ -2433,6 +2433,13 @@ export def scanForNamedObj(p_obj, name)
|
||||
return NULL
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def addUnique(pList, p_thing)
|
||||
if !scanForNamedObj(*pList, p_thing=>s_name)
|
||||
addToList(pList, p_thing)
|
||||
fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def createAndAddUnique(moduleID, creationFuncNum, pList)
|
||||
word p_module, funcTbl, func, p_thing
|
||||
@ -2448,12 +2455,10 @@ export def createAndAddUnique(moduleID, creationFuncNum, pList)
|
||||
// Figure out which creation function to call there, and create the thing
|
||||
funcTbl = p_module()
|
||||
func = *(funcTbl + creationFuncNum)
|
||||
p_thing = func()
|
||||
p_thing = func() // full
|
||||
|
||||
// Avoid adding duplicate things.
|
||||
if !scanForNamedObj(*pList, p_thing=>s_name)
|
||||
addToList(pList, p_thing)
|
||||
fin
|
||||
addUnique(pList, p_thing)
|
||||
|
||||
// Finished with the module now.
|
||||
mmgr(FREE_MEMORY, p_module)
|
||||
@ -2461,8 +2466,8 @@ export def createAndAddUnique(moduleID, creationFuncNum, pList)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def giveItemToPlayer(itemFuncNum)
|
||||
createAndAddUnique(MOD_GEN_ITEMS, itemFuncNum, @global=>p_players=>p_items) // def: 1st player
|
||||
export def giveItemToPlayer(p_player, itemFuncNum)
|
||||
createAndAddUnique(MOD_GEN_ITEMS, itemFuncNum, @p_player=>p_items)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -2489,8 +2494,8 @@ export def removeNamed(name, pList)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def takeItemFromPlayer(itemName)
|
||||
removeNamed(itemName, @global=>p_players=>p_items) // default to first player
|
||||
export def takeItemFromPlayer(p_player, itemName)
|
||||
removeNamed(itemName, @p_player=>p_items) // default to first player
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -13,11 +13,14 @@ include "globalDefs.plh"
|
||||
include "godmode.plh"
|
||||
include "playtype.plh"
|
||||
include "gen_images.plh"
|
||||
include "gen_modules.plh"
|
||||
include "gen_items.plh"
|
||||
include "gen_players.plh"
|
||||
|
||||
// Exported functions go here. First a predef for each one, then a table with function pointers
|
||||
// in the same order as the constants are defined in the the header.
|
||||
predef setCheatCmds
|
||||
word[] funcTbl = @setCheatCmds
|
||||
predef setCheatCmds, addItem, addPlayer
|
||||
word[] funcTbl = @setCheatCmds, @addItem, @addPlayer
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -127,6 +130,69 @@ def setCheatCmds()
|
||||
setCmd('_', @finalWin)
|
||||
end
|
||||
|
||||
// Abstract code for adding from a list of things (players, items, etc.)
|
||||
def selectThing(moduleNum, nThings, nSkip, prompt)
|
||||
word pModule, funcTbl, nFunc, pFunc, p_thing, n_thing, n2, pstr
|
||||
nFunc = -1
|
||||
pstr = "%d: %s\n"
|
||||
|
||||
flipToPage1()
|
||||
textHome()
|
||||
^$c051
|
||||
|
||||
mmgr(START_LOAD, 1) // code is in partition 1
|
||||
pModule = mmgr(QUEUE_LOAD, moduleNum<<8 | RES_TYPE_MODULE)
|
||||
mmgr(FINISH_LOAD, 0)
|
||||
funcTbl = pModule()
|
||||
|
||||
for n_thing = 1 to nThings
|
||||
nFunc = (n_thing-1+nSkip) << 1
|
||||
pFunc = *(funcTbl + nFunc)
|
||||
p_thing = pFunc()
|
||||
printf2(pstr, n_thing, p_thing=>s_name)
|
||||
if (n_thing % 22) == 0 or n_thing == nThings
|
||||
mmgr(HEAP_COLLECT, 0)
|
||||
puts(prompt)
|
||||
n2 = parseDecWithDefault(readStr(), 0)
|
||||
if n2 >= 1 and n2 <= nThings
|
||||
nFunc = (n2-1+nSkip) << 1
|
||||
pFunc = *(funcTbl + nFunc)
|
||||
p_thing = pFunc()
|
||||
printf1("Adding '%s'\n", p_thing=>s_name)
|
||||
break
|
||||
else
|
||||
nFunc = -1
|
||||
textHome()
|
||||
fin
|
||||
fin
|
||||
next
|
||||
|
||||
mmgr(FREE_MEMORY, pModule)
|
||||
return nFunc
|
||||
end
|
||||
|
||||
// Add an item cheat
|
||||
def addItem(player)
|
||||
word funcNum
|
||||
funcNum = selectThing(MOD_GEN_ITEMS, NUM_ITEMS, 2, "Add item #: ")
|
||||
if funcNum >= 0
|
||||
giveItemToPlayer(player, funcNum)
|
||||
rdkey()
|
||||
fin
|
||||
^$c050
|
||||
end
|
||||
|
||||
// Add a player cheat
|
||||
def addPlayer()
|
||||
word funcNum
|
||||
funcNum = selectThing(MOD_GEN_PLAYERS, NUM_PLAYERS, 1, "Add player #: ")
|
||||
if funcNum >= 0
|
||||
addPlayerToParty(funcNum)
|
||||
rdkey()
|
||||
fin
|
||||
^$c050
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Boilerplate module initialization code
|
||||
return @funcTbl
|
||||
|
@ -10,3 +10,5 @@
|
||||
|
||||
// Each module-exported function needs its own constant, 0..n
|
||||
const godmode_setCheatCmds = 0
|
||||
const godmode_addItem = 2
|
||||
const godmode_addPlayer = 4
|
||||
|
@ -19,6 +19,7 @@ include "playtype.plh"
|
||||
include "globalDefs.plh"
|
||||
include "gen_modules.plh"
|
||||
include "gen_items.plh"
|
||||
include "godmode.plh"
|
||||
|
||||
// Definition of constants for functions exported by this module
|
||||
include "party.plh"
|
||||
@ -232,47 +233,6 @@ def showPlayerSheet(num, i_page, i_rows)
|
||||
return player
|
||||
end
|
||||
|
||||
// Add an item cheat
|
||||
def addItem(player)
|
||||
word pModule, funcTbl, func, p_item, n_item, n2, pstr, pstr2
|
||||
pstr = "%d: %s\n"
|
||||
pstr2 = "Add item #: "
|
||||
|
||||
flipToPage1()
|
||||
textHome()
|
||||
^$c051
|
||||
|
||||
mmgr(START_LOAD, 1) // code is in partition 1
|
||||
pModule = mmgr(QUEUE_LOAD, MOD_GEN_ITEMS<<8 | RES_TYPE_MODULE)
|
||||
mmgr(FINISH_LOAD, 0)
|
||||
funcTbl = pModule()
|
||||
|
||||
for n_item = 1 to NUM_ITEMS
|
||||
func = *(funcTbl + (n_item+1) * 2)
|
||||
p_item = func()
|
||||
printf2(pstr, n_item, p_item=>s_name)
|
||||
if (n_item % 22) == 0 or n_item == NUM_ITEMS
|
||||
mmgr(HEAP_COLLECT, 0)
|
||||
puts(pstr2)
|
||||
n2 = parseDecWithDefault(readStr(), 0)
|
||||
if n2 >= 1 and n2 <= NUM_ITEMS
|
||||
func = *(funcTbl + (n2+1) * 2)
|
||||
p_item = func()
|
||||
printf1("Adding '%s'\n", p_item=>s_name)
|
||||
addToList(@player=>p_items, p_item)
|
||||
rdkey()
|
||||
break
|
||||
else
|
||||
textHome()
|
||||
fin
|
||||
fin
|
||||
next
|
||||
|
||||
mmgr(FREE_MEMORY, pModule)
|
||||
^$c050
|
||||
return
|
||||
end
|
||||
|
||||
// Show player sheet and accept command. If using an item (not just for stats gain)
|
||||
// the item is returned; else NULL is returned.
|
||||
def _party_doPlayerSheet(num)
|
||||
@ -377,19 +337,24 @@ def _party_doPlayerSheet(num)
|
||||
fin
|
||||
break
|
||||
// Other operations...
|
||||
is '&' // health cheat
|
||||
is '&' // add health cheat
|
||||
if global->b_godmode
|
||||
player=>w_health = player=>w_health + 50
|
||||
fin
|
||||
break
|
||||
is '$' // gold cheat
|
||||
is '$' // add gold cheat
|
||||
if global->b_godmode
|
||||
addGold(500)
|
||||
fin
|
||||
break
|
||||
is '%' // item cheat
|
||||
is '%' // add item cheat
|
||||
if global->b_godmode
|
||||
addItem(player)
|
||||
pGodModule=>godmode_addItem(player)
|
||||
fin
|
||||
break
|
||||
is '9' // add player cheat
|
||||
if global->b_godmode
|
||||
pGodModule=>godmode_addPlayer()
|
||||
fin
|
||||
break
|
||||
// All done
|
||||
|
Loading…
Reference in New Issue
Block a user