mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-01-23 05:29:50 +00:00
Fixed some bugs introduced by refactoring, and also the portrait preview facility.
This commit is contained in:
parent
604857a4d2
commit
df901ee94f
@ -55,7 +55,6 @@ def playerMelee(pPlayer, pWeapon)
|
||||
// TODO: consider enemy dodge
|
||||
pEnemy=>w_health = pEnemy=>w_health - dmg
|
||||
|
||||
isPlural = FALSE
|
||||
buildString(@addToString)
|
||||
printf3("\n%s pummels %s for %d damage.", pPlayer=>s_name, pEnemy=>s_name, dmg)
|
||||
if pEnemy=>w_health <= 0
|
||||
@ -141,6 +140,7 @@ end
|
||||
def displayOpponents()
|
||||
word p
|
||||
byte count, first
|
||||
byte isPlural
|
||||
|
||||
buildString(@addToString)
|
||||
puts("\nYou face ")
|
||||
@ -284,10 +284,11 @@ def playerCombatTurn(pl)
|
||||
break
|
||||
is 'R'
|
||||
pWeapon->b_clipCurrent = pWeapon->b_clipSize
|
||||
setPlural(FALSE)
|
||||
displayf1("%s has reloaded.\n", pl=>s_name)
|
||||
break
|
||||
is 'C'
|
||||
isPlural = FALSE
|
||||
setPlural(FALSE)
|
||||
displayf2("%s changed to using %s.\n", pl=>s_name, pWeapon=>s_name)
|
||||
break
|
||||
wend
|
||||
@ -393,8 +394,8 @@ def startCombat()
|
||||
// set everything up so that the map gets redrawn when combat finishes.
|
||||
setWindow2()
|
||||
clearWindow()
|
||||
textDrawn = TRUE
|
||||
needRender = TRUE
|
||||
setTextDrawn(TRUE)
|
||||
setNeedRender(TRUE)
|
||||
|
||||
// Say who we're fighting
|
||||
when rand16() % 5
|
||||
@ -413,7 +414,7 @@ def startCombat()
|
||||
p = global=>p_enemyGroups
|
||||
while p
|
||||
n = countList(p=>p_enemies)
|
||||
isPlural = (n <> 1)
|
||||
setPlural(n <> 1)
|
||||
when rand16() % 5
|
||||
is 0
|
||||
s = "From out of nowhere comes/come %d %s to have their way with you!\n"; break
|
||||
@ -471,7 +472,7 @@ def doCombat()
|
||||
|
||||
p = global=>p_combatFirst
|
||||
while p
|
||||
if TRUE or !nPlayersFighting
|
||||
if !nPlayersFighting
|
||||
setPortrait(PORTRAIT_DEATH)
|
||||
when rand16() % 2
|
||||
is 0
|
||||
|
@ -14,11 +14,6 @@ const FALSE = 0
|
||||
const TRUE = 1
|
||||
const NULL = 0
|
||||
|
||||
// Library shared variables
|
||||
const textDrawn = $3CD
|
||||
const needRender = $3CE
|
||||
const isPlural = $3CF
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Memory manager definitions
|
||||
|
||||
@ -94,11 +89,11 @@ const clearWindow = gameLibVecs + 3*30
|
||||
const getYN = gameLibVecs + 3*31
|
||||
const reboot = gameLibVecs + 3*32
|
||||
const brk = gameLibVecs + 3*33
|
||||
const encodeDice = gameLibVecs + 3*34
|
||||
const rollDice = gameLibVecs + 3*35
|
||||
const FUNCN36 = gameLibVecs + 3*36
|
||||
const FUNCN37 = gameLibVecs + 3*37
|
||||
const FUNCN38 = gameLibVecs + 3*38
|
||||
const encodeDice = gameLibVecs + 3*34
|
||||
const rollDice = gameLibVecs + 3*35
|
||||
const setNeedRender = gameLibVecs + 3*36
|
||||
const setPlural = gameLibVecs + 3*37
|
||||
const setTextDrawn = gameLibVecs + 3*38
|
||||
const FUNCN39 = gameLibVecs + 3*39
|
||||
const FUNCN40 = gameLibVecs + 3*40
|
||||
const FUNCN41 = gameLibVecs + 3*41
|
||||
|
@ -34,7 +34,7 @@ const ANIM_FLAG_FWD = $20
|
||||
const ANIM_FLAG_FWD_BKWD = $40
|
||||
const ANIM_FLAG_RANDOM = $80
|
||||
|
||||
const ANIM_PAUSE_MAX = 250
|
||||
const ANIM_PAUSE_MAX = 300
|
||||
|
||||
include "playtype.plh"
|
||||
include "gen_images.plh"
|
||||
@ -54,6 +54,10 @@ word mapNameHash = 0
|
||||
word totalMapWidth
|
||||
word totalMapHeight
|
||||
|
||||
byte needRender = FALSE
|
||||
byte textDrawn = FALSE
|
||||
byte isPlural = FALSE
|
||||
|
||||
word skyNum = 9
|
||||
word groundNum = 10
|
||||
byte portraitNum = 1
|
||||
@ -79,6 +83,7 @@ byte tabBuf[5]
|
||||
word curPortrait = 0
|
||||
byte animFlags
|
||||
byte animDir
|
||||
byte animDirCt
|
||||
byte animNumFrames
|
||||
byte animFrame
|
||||
word animPauseCt
|
||||
@ -92,6 +97,7 @@ predef _puts, _min, _max
|
||||
predef _countList, _countListFiltered, _randomFromListFiltered, _addToList, _getUpperKey, _beep
|
||||
predef _showParty, _mmgr, _setPortrait, _setWindow1, _setWindow2, _setWindow3, _clearWindow
|
||||
predef _getYN, _reboot, _brk, _encodeDice, _rollDice
|
||||
predef _setNeedRender, _setPlural, _setTextDrawn
|
||||
|
||||
word gameLib_addrs = @_getGlobals, @_rand16
|
||||
word = @_printf1, @_printf2, @_printf3, @_printf4
|
||||
@ -101,6 +107,7 @@ word = @_puts, @_min, @_max
|
||||
word = @_countList, @_countListFiltered, @_randomFromListFiltered, @_addToList, @_getUpperKey, @_beep
|
||||
word = @_showParty, @_mmgr, @_setPortrait, @_setWindow1, @_setWindow2, @_setWindow3, @_clearWindow
|
||||
word = @_getYN, @_reboot, @_brk, @_encodeDice, @_rollDice
|
||||
word = @_setNeedRender, @_setPlural, @_setTextDrawn
|
||||
|
||||
word = 0 // end of library functions
|
||||
|
||||
@ -875,6 +882,20 @@ def _min(a, b)
|
||||
fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Setter functions for library use
|
||||
def _setNeedRender(flg)
|
||||
needRender = flg
|
||||
end
|
||||
|
||||
def _setPlural(flg)
|
||||
isPlural = flg
|
||||
end
|
||||
|
||||
def _setTextDrawn(flg)
|
||||
textDrawn = flg
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Convert signed decimal to string in decimalBuf
|
||||
def convertDec(n)
|
||||
@ -1459,12 +1480,14 @@ end
|
||||
// Get a key and dispatch it to a command. Then do it again, forever.
|
||||
def kbdLoop()
|
||||
word key, func
|
||||
word errMsg
|
||||
byte xreg, tmp
|
||||
errMsg = "Error: x reg changed from %x to %x\n"
|
||||
xreg = getXReg()
|
||||
while TRUE
|
||||
tmp = getXReg()
|
||||
if tmp <> xreg
|
||||
printf2("Error: x reg changed from %x to %x\n", xreg, tmp)
|
||||
printf2(errMsg, xreg, tmp)
|
||||
brk()
|
||||
fin
|
||||
key = getUpperKey()
|
||||
@ -1580,12 +1603,13 @@ def nextAnimFrame()
|
||||
if !curPortrait; return; fin
|
||||
oldAnimFrame = animFrame
|
||||
|
||||
// Choose a new direction based on the flags. Do this the first time, and about once per 4 frames.
|
||||
if !animDir or (rand16() % 4) == 0
|
||||
// Choose a new direction based on the flags. Do this the first time, and once every 3-7 frames.
|
||||
animDirCt = animDirCt - 1
|
||||
if !animDir or animDirCt == 0
|
||||
if animFlags & ANIM_FLAG_FWD
|
||||
animDir = 'F'
|
||||
elsif animFlags & ANIM_FLAG_FWD_BKWD
|
||||
if rand16() % 2
|
||||
if animDir == 'B'
|
||||
animDir = 'F'
|
||||
else
|
||||
animDir = 'B'
|
||||
@ -1595,13 +1619,21 @@ def nextAnimFrame()
|
||||
else
|
||||
animDir = 0
|
||||
fin
|
||||
animDirCt = (rand16() % 5) + 3
|
||||
fin
|
||||
|
||||
// Advance in the current direction
|
||||
if animDir == 'F' // forward
|
||||
animFrame = (animFrame+1) % animNumFrames
|
||||
animFrame = animFrame + 1
|
||||
if animFrame >= animNumFrames
|
||||
animFrame = 0
|
||||
fin
|
||||
elsif animDir == 'B' // backward
|
||||
animFrame = (animFrame-1) % animNumFrames
|
||||
if animFrame == 0
|
||||
animFrame = animNumFrames - 1
|
||||
else
|
||||
animFrame = animFrame - 1
|
||||
fin
|
||||
elsif animDir == 'R' // random
|
||||
animFrame = rand16() % animNumFrames
|
||||
fin
|
||||
@ -1622,6 +1654,11 @@ def _setPortrait(portraitNum)
|
||||
word srcData
|
||||
byte cx, cy
|
||||
|
||||
if curPortrait
|
||||
auxMmgr(FREE_MEMORY, curPortrait)
|
||||
curPortrait = 0
|
||||
fin
|
||||
|
||||
flipToPage1()
|
||||
|
||||
// We're going to switch windows. Save the cursor pos in the text window.
|
||||
@ -1642,6 +1679,7 @@ def _setPortrait(portraitNum)
|
||||
animFlags = readAuxByte(curPortrait)
|
||||
animNumFrames = animFlags & $F
|
||||
animDir = 0
|
||||
animDirCt = 1
|
||||
animPauseCt = ANIM_PAUSE_MAX
|
||||
|
||||
// And show the first frame
|
||||
@ -1658,8 +1696,8 @@ end
|
||||
// Test out portrait drawing
|
||||
def testPortrait()
|
||||
setPortrait(portraitNum)
|
||||
printf1("portraitNum=%d\n", portraitNum)
|
||||
portraitNum = portraitNum + 1
|
||||
needRender = FALSE
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user