Add godmode setting.

This commit is contained in:
David Schmenk 2016-07-16 10:27:28 -07:00
parent 25901b9f01
commit 0e4b8ca8f8
3 changed files with 102 additions and 91 deletions

View File

@ -1312,8 +1312,8 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Send an event to the script
export def scriptEvent(event, param)
if global=>w_mapScript
return global=>w_mapScript(event, param)
if global=>p_mapScript
return global=>p_mapScript(event, param)
fin
return -1
end
@ -1327,7 +1327,7 @@ def checkScripts(x, y)
byte anyTriggered
scriptEvent(EVENT_LEAVE, 0)
global=>w_mapScript = 0
global=>p_mapScript = 0
anyTriggered = FALSE
x = x - triggerOriginX
y = y - triggerOriginY
@ -1550,54 +1550,6 @@ def setMap(is3D, num, x, y, dir)
//NO:checkScripts()
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def kbdTeleport()
byte d3, num
word x, y
byte dir
flipToPage1()
^$c053
if ^$25 < 23; ^$25 = 23; fin
getPos(@x, @y)
dir = getDir()
printf3("\nCurrent: X=%d Y=%d Facing=%d\n", x, y, dir)
printf1("3D [%d]: ", mapIs3D)
d3 = parseDecWithDefault(readStr(), mapIs3D)
if d3 > 1; d3 = 1; fin
printf1("Map [%d]: ", mapNum)
num = parseDecWithDefault(readStr(), mapNum)
printf1("X [%d] : ", x)
x = parseDecWithDefault(readStr(), x)
printf1("Y [%d] : ", y)
y = parseDecWithDefault(readStr(), y)
printf1("Facing [%d]: ", dir)
dir = parseDecWithDefault(readStr(), dir)
^$c052
setMap(d3, num, x, y, dir)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def showPos()
word x, y
byte dir
flipToPage1()
^$c053
if ^$25 < 23; ^$25 = 23; fin
getPos(@x, @y)
printf2("\nX=%d Y=%d ", x, y)
if mapIs3D
printf3("Facing=%d Sky=%d Ground=%d", getDir(), skyNum, groundNum)
fin
puts("\nHit any key.\n")
getUpperKey()
^$c052
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def queue_setMap(is3D, num, x, y, dir)
q_mapIs3D = is3D
@ -1837,23 +1789,6 @@ export def setPortrait(portraitNum)
needRender = FALSE
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Test out portrait drawing
def nextPortrait()
portraitNum = portraitNum + 1
printf1("Portrait #%d\n", portraitNum)
setPortrait(portraitNum)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Test out portrait drawing
def prevPortrait()
if portraitNum > 1
portraitNum = portraitNum - 1
fin
setPortrait(portraitNum)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def countList(p)
byte n
@ -2080,13 +2015,6 @@ def checkEncounter(x, y, force)
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def testCombat
word x, y
getPos(@x, @y)
checkEncounter(x, y, TRUE)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def saveGame
loadEngine(MODULE_DISKOPS)=>diskops_saveGame()
@ -2112,7 +2040,83 @@ def help
scriptDisplayStr("Help not available.\n")
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Godmode cheats
def kbdTeleport()
byte d3, num
word x, y
byte dir
flipToPage1()
^$c053
if ^$25 < 23; ^$25 = 23; fin
getPos(@x, @y)
dir = getDir()
printf3("\nCurrent: X=%d Y=%d Facing=%d\n", x, y, dir)
printf1("3D [%d]: ", mapIs3D)
d3 = parseDecWithDefault(readStr(), mapIs3D)
if d3 > 1; d3 = 1; fin
printf1("Map [%d]: ", mapNum)
num = parseDecWithDefault(readStr(), mapNum)
printf1("X [%d] : ", x)
x = parseDecWithDefault(readStr(), x)
printf1("Y [%d] : ", y)
y = parseDecWithDefault(readStr(), y)
printf1("Facing [%d]: ", dir)
dir = parseDecWithDefault(readStr(), dir)
^$c052
setMap(d3, num, x, y, dir)
end
def showPos()
word x, y
byte dir
flipToPage1()
^$c053
if ^$25 < 23; ^$25 = 23; fin
getPos(@x, @y)
printf2("\nX=%d Y=%d ", x, y)
if mapIs3D
printf3("Facing=%d Sky=%d Ground=%d", getDir(), skyNum, groundNum)
fin
puts("\nHit any key.\n")
getUpperKey()
^$c052
end
def nextPortrait()
portraitNum = portraitNum + 1
printf1("Portrait #%d\n", portraitNum)
setPortrait(portraitNum)
end
def prevPortrait()
if portraitNum > 1
portraitNum = portraitNum - 1
fin
setPortrait(portraitNum)
end
def testCombat
word x, y
getPos(@x, @y)
checkEncounter(x, y, TRUE)
end
def enableGodMode()
if ^$C061 >= 128 and ^$C062 >= 128
global->b_godmode = 1
// install cheat commands
cmdTbl['T'] = @kbdTeleport
cmdTbl['P'] = @showPos
cmdTbl['>'] = @nextPortrait
cmdTbl['<'] = @prevPortrait
cmdTbl['!'] = @testCombat
cmdTbl['Y'] = @nextSky
cmdTbl['G'] = @nextGround
beep; beep // A little audio feedback
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set up the command table for 3D mode
@ -2125,17 +2129,13 @@ def initCmds()
next
// Commands common to both 2D and 3D
cmdTbl['T'] = @kbdTeleport
cmdTbl['P'] = @showPos
cmdTbl['/'] = @nextPortrait
cmdTbl['?'] = @prevPortrait
cmdTbl['!'] = @testCombat
cmdTbl['1'] = @showPlayer1
cmdTbl['2'] = @showPlayer2
cmdTbl['3'] = @showPlayer3
cmdTbl[$13] = @saveGame // ctrl-S
cmdTbl[$0c] = @loadGame // ctrl-L
cmdTbl['?'] = @help
cmdTbl['!'] = @enableGodMode
// Commands handled differently in 3D vs 2D
if mapIs3D
@ -2154,9 +2154,6 @@ def initCmds()
cmdTbl[','] = @moveBackward
cmdTbl['M'] = @strafeLeft
cmdTbl['.'] = @strafeRight
cmdTbl['Y'] = @nextSky
cmdTbl['G'] = @nextGround
else
cmdTbl['W'] = @moveNorth
cmdTbl['D'] = @moveEast

View File

@ -105,14 +105,17 @@ def showInventory(player, page, height, select)
word item
byte s_item, n_item, n_page
setMapWindow()
clearWindow()
rawDisplayStr("^T040^LInventory^L\n^T018")
displayf1("Group Gold: %d", countGold())
item = player=>p_items
s_item = 0
n_item = 0
n_page = page * height
item = player=>p_items
setMapWindow()
clearWindow()
if page; rawDisplayStr("^T008<"); fin
rawDisplayStr("^T040^LInventory^L")
if countList(item) > n_page + height; rawDisplayStr("^T114>"); fin
rawDisplayStr("\n^T018")
displayf1("Group Gold: %d", countGold())
if page
while item and n_item < n_page
item = item=>p_nextObj
@ -311,8 +314,16 @@ def _party_doPlayerSheet(num)
fin
break
// Other operations...
is '!'; player=>w_health = player=>w_health + 10; break
is '$'; addGold(10); break
is '&' // health cheat
if global->b_godmode
player=>w_health = player=>w_health + 50
fin
break
is '$' // gold cheat
if global->b_godmode
addGold(500)
fin
break
// All done
otherwise return
wend

View File

@ -25,7 +25,7 @@ struc Global
word w_mapX
word w_mapY
byte b_mapDir
word w_mapScript
word p_mapScript
// Shared player gold amount
word w_gold
@ -36,6 +36,9 @@ struc Global
// General flags maintained by scripts. Linked list of Modifiers.
word p_gameFlags
byte b_curAvatar
// god mode flag
byte b_godmode
end
const PLAYER_FLAG_NPC = $01