Implemented initial character naming, gender assignment, and XP/SP init.

This commit is contained in:
Martin Haye 2017-07-08 16:36:08 -07:00
parent bf4e3c7792
commit 30a5881f24
9 changed files with 139 additions and 66 deletions

View File

@ -2889,9 +2889,12 @@ def makePlayer_pt2(p, health, level, aiming, handToHand, dodging)#1
p=>w_health = health
p->b_level = level
p=>w_maxHealth = health
// Non-first players are NPCs
if global=>p_players; p->b_playerFlags = PLAYER_FLAG_NPC; fin
p->b_aiming = aiming
p->b_handToHand = handToHand
p->b_dodging = dodging
initPlayerXP(p)
return p
end
""")

View File

@ -123,11 +123,8 @@ DisplayStr JMP DoParse ; API call address
;Does not do line breaking
CalcWidth JMP DoCWdth
;Save the cursor position
SaveCursor JMP SvCurs
;Restore the cursor position
RestCursor JMP RsCurs
;Get the cursor position
GetCursor JMP GtCurs
;To get a string of text up to 40 chars long using a
;flashing cursor use GetStr. It allows use of either
@ -549,25 +546,22 @@ WtL_Prs LDA #0 ; if wait interrupted then do
STA ChBflip
RTS
;Routine: Save the cursor position. There is exactly one save slot.
BCursColL !byte 0 ;Saved Lo-byte of 16-bit horz X-pos value
BCursColH !byte 0 ;Saved Hi-byte X-position {0..279}
BCursRow !byte 0 ;Saved vertical Y-position {0..191}
SvCurs LDA CursColL
STA BCursColL
;Routine: Get the cursor position (relative to the current window)
GtCurs DEX
LDA CursColL
SEC
SBC CursXl
STA evalStkL,X
LDA CursColH
STA BCursColH
SBC CursXh
STA evalStkH,X
DEX
LDA CursRow
STA BCursRow
RTS
;Routine: Restore the cursor position. There is exactly one save slot.
RsCurs LDA BCursColL
STA CursColL
LDA BCursColH
STA CursColH
LDA BCursRow
STA CursRow
SEC
SBC CursY
STA evalStkL,X
LDA #0
STA evalStkH,X
RTS
;Routine: Set window boundaries. Paramaters are pushed on the PLASMA

View File

@ -40,8 +40,7 @@ CopyWindow = ClearWindow+3
DisplayChar = CopyWindow+3
DisplayStr = DisplayChar+3
CalcWidth = DisplayStr+3
SaveCursor = CalcWidth+3
RestCursor = SaveCursor+3
GetStr = RestCursor+3
GetCursor = CalcWidth+3
GetStr = GetCursor+3
GetScreenLine = GetStr+3
NextScreenLine = GetScreenLine+3

View File

@ -344,10 +344,11 @@ def playerCombatChoose(pl)#0
word p, pWeapon
byte nWeapons, key
byte canShoot, canReload, canChange, canAdvance
word cursX, cursY
// Before we start, save the cursor location so we can
// later restore it for the next player's choice.
saveCursor()
cursX, cursY = getCursor()
// Count all weapons and get currently equipped
canShoot = FALSE
@ -365,7 +366,7 @@ def playerCombatChoose(pl)#0
loop
// Let them know their options
restoreCursor()
setCursor(cursX, cursY)
rawDisplayf1("^D%s", pl=>s_name)
displayOption('M', "Melee")
if pWeapon

View File

@ -12,6 +12,7 @@ include "gamelib.plh"
include "globalDefs.plh"
include "playtype.plh"
include "diskops.plh"
include "party.plh"
include "gen_modules.plh"
include "gen_players.plh"
@ -268,19 +269,45 @@ def _loadGame()#1
return 0
end
def getCharacterName()#0
word cursX, cursY
displayStr("\nCharacter name?\n")
cursX, cursY = getCursor()
printf2("cursX=%d cursY=%d\n", cursX, cursY)
setWindow(cursY+24, cursY+24+18, cursX+154, cursX+154+62)
clearWindow()
global=>p_players=>s_name = getStringResponse()
setWindow2()
setCursor(cursX, cursY)
end
def getCharacterGender()#0
displayStr("\n\nGender? (M/F/N/...) \n")
global=>p_players->c_gender = getUpperKey()
displayChar(global=>p_players->c_gender)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def newGame()#0
word playersModule, newGameModule
word playersModule, newGameModule, partyModule
initHeap(0) // initially empty heap
global->b_curAvatar = 0
global=>w_combatPauseCt = DEFAULT_COMBAT_PAUSE_CT
mmgr(START_LOAD, 1) // players module and new game module both in partition 1
playersModule = mmgr(QUEUE_LOAD, MOD_GEN_PLAYERS<<8 | RES_TYPE_MODULE)
newGameModule = mmgr(QUEUE_LOAD, GS_NEW_GAME<<8 | RES_TYPE_MODULE)
partyModule = mmgr(QUEUE_LOAD, MOD_PARTY<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 0)
playersModule()=>makeInitialParty()
addXP(0) // to set initial skill pts
loadMainFrameImg()
showMapName("New game")
setWindow2()
newGameModule()()
getCharacterName()
getCharacterGender()
if global=>p_players->b_skillPoints
partyModule()=>party_showPlayerSheet(0)
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -50,6 +50,7 @@ import gamelib
predef finishString(isPlural)#1
predef flipToPage1()#0
predef getCharResponse()#1
predef getCursor()#2
predef getDir()#1
predef getGameFlag(flagName)#1
predef getPos(px, py)#0
@ -59,6 +60,7 @@ import gamelib
predef getYN()#1
predef giveItemToPlayer(p_player, itemFuncNum)#0
predef initHeap(loadedSize)#0
predef initPlayerXP(player)#0
predef loadFrameImg(img)#0
predef loadMainFrameImg()#0
predef makeModifier(name, value)#1
@ -92,11 +94,9 @@ import gamelib
predef readStr()#1
predef removeFromList(pList, toRemove)#0
predef removePlayerFromParty(playerName)#0
predef restoreCursor()#0
predef rightJustifyNum(num, rightX)#0
predef rightJustifyStr(str, rightX)#0
predef rollDice(encoded)#1
predef saveCursor()#0
predef scanForNamedObj(p_obj, name)#1
predef scriptCombat(mapCode)#1
predef scriptDisplayStr(str)#0
@ -105,6 +105,7 @@ import gamelib
predef scriptSetAvatar(avatarTileNum)#0
predef scriptSwapTile(fromX, fromY, toX, toY)#0
predef setCmd(key, func)#0
predef setCursor(x, y)#0
predef setGameFlag(flagName, val)#0
predef setGround(num)#0
predef setIntimateMode(enable)#0

View File

@ -66,7 +66,7 @@ predef showParty()#0
///////////////////////////////////////////////////////////////////////////////////////////////////
// Global variables
export byte mapNum = -1
export byte mapIs3D = -1
export byte mapIs3D = 0
word mapNameHash = 0
word totalMapWidth
word totalMapHeight
@ -804,17 +804,10 @@ export asm setWindow(top, bottom, left, right)#0
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Save the cursor position (1 save slot)
export asm saveCursor()#0
+asmPlasmNoRet 0
jmp SaveCursor
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Restore the cursor position (1 save slot)
export asm restoreCursor()#0
+asmPlasmNoRet 0
jmp RestCursor
// Get the cursor position - returns X, Y
export asm getCursor()#2
bit setLcRW+lcBank2
jmp GetCursor
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -1184,6 +1177,12 @@ export def rawDisplayf1(str, arg1)#0; rawDisplayStr(sprintf3(str, arg1, 0, 0));
export def rawDisplayf2(str, arg1, arg2)#0; rawDisplayStr(sprintf3(str, arg1, arg2, 0)); end
export def rawDisplayf3(str, arg1, arg2, arg3)#0; rawDisplayStr(sprintf3(str, arg1, arg2, arg3)); end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set the cursor position in the font engine
export def setCursor(x, y)#0
rawDisplayf2("^V%D^T%D", y, x)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def parseDec(str)#1
word n
@ -1404,8 +1403,8 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Window for the large upper right bar
export def setWindow2()#0
displayChar('N'-$40) // Set normal mode - clear all special modes (like underline, etc.)
setWindow(24, 132, 154, 267) // Top, Bottom, Left, Right
displayChar('N'-$40) // Set normal mode - clear all special modes (like underline, etc.)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -1471,9 +1470,9 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Display the party data on the screen
export def showParty()#0
word p
word p, cursX, cursY
saveCursor()
cursX, cursY = getCursor()
setWindow3()
clearWindow()
@ -1484,7 +1483,7 @@ export def showParty()#0
p = p=>p_nextObj
loop
if p
rawDisplayStr("^Y^I LEVEL UP ^N\n")
rawDisplayStr("^Y^I LEVEL U)P ^N\n")
else
rawDisplayStr("^LName")
rightJustifyStr(@S_HEALTH, CHAR_WND_HEALTH_X) // begin underline mode
@ -1506,7 +1505,7 @@ export def showParty()#0
copyWindow()
fin
setWindow2()
restoreCursor()
setCursor(cursX, cursY)
needShowParty = FALSE
end
@ -1994,7 +1993,7 @@ export def scriptDisplayStr(str)#0
pIntimate=>intimate_displayStr(str)
else
textDrawn = TRUE
flipToPage1()
if renderLoaded; flipToPage1(); fin
displayStr(str)
fin
^kbdStrobe
@ -2086,12 +2085,12 @@ end
// Display a portrait drawing (typically called from scripts)
export def setPortrait(portraitNum)#0
word srcData
byte part, cx, cy
byte part, cx, cy, cursX, cursY
clearPortrait()
// We're going to switch windows. Save the cursor pos in the text window.
saveCursor()
cursX, cursY = getCursor()
// Make room by unloading the textures (only if renderer is loaded)
unloadTextures()
@ -2102,7 +2101,7 @@ export def setPortrait(portraitNum)#0
// Restore the cursor position
setWindow2()
restoreCursor()
setCursor(cursX, cursY)
// Load the portrait image and display it
part = lookupResourcePart(3, portraitNum)
@ -2302,6 +2301,24 @@ def showPlayer3()#1
return showPlayerSheet(2)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Level up the first character that's applicable
def levelUp()#1
word player
byte n
player = global=>p_players
n = 0
while player
if player->b_skillPoints
showPlayerSheet(n)
return 0
fin
player = player=>p_nextObj
loop
beep
return 0
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def addEncounterZone(code, x, y, dist, chance)#0
word p
@ -2450,6 +2467,7 @@ def initCmds()#0
cmdTbl['1'] = @showPlayer1
cmdTbl['2'] = @showPlayer2
cmdTbl['3'] = @showPlayer3
cmdTbl['U'] = @levelUp
cmdTbl[$13] = @saveGame // ctrl-S
cmdTbl[$0c] = @loadGame // ctrl-L
cmdTbl['?'] = @help
@ -2715,14 +2733,12 @@ export def addXP(val)#1
player=>w_curXP = 29999
fin
while player=>w_curXP >= player=>w_nextXP
if player=>w_curXP > 0
// Level up!
player->b_level++
player->b_skillPoints = player->b_skillPoints + callGlobalFunc(GS_LEVEL_S_P, player->b_level, 0, 0)
player=>w_maxHealth = player=>w_maxHealth + player->b_stamina + rollDice($2600) // stam + 2d6
player=>w_health = player=>w_maxHealth // let's make leveling up an extra nice thing
needShowParty = TRUE
fin
// Level up!
player->b_level++
player->b_skillPoints = player->b_skillPoints + callGlobalFunc(GS_LEVEL_S_P, player->b_level, 0, 0)
player=>w_maxHealth = player=>w_maxHealth + player->b_stamina + rollDice($2600) // stam + 2d6
player=>w_health = player=>w_maxHealth // let's make leveling up an extra nice thing
needShowParty = TRUE
// Check XP for next level, and enforce level cap if any
n = callGlobalFunc(GS_LEVEL_X_P, player->b_level + 1, 0, 0)
@ -2738,6 +2754,14 @@ export def addXP(val)#1
return val
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize XP (and skill pts) for newly created character
export def initPlayerXP(player)#0
player->b_skillPoints = callGlobalFunc(GS_LEVEL_S_P, player->b_level, 0, 0)
player=>w_curXP = callGlobalFunc(GS_LEVEL_X_P, player->b_level, 0, 0)
player=>w_nextXP = callGlobalFunc(GS_LEVEL_X_P, player->b_level + 1, 0, 0)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def addPlayerToParty(playerFuncNum)#0
word p

View File

@ -279,6 +279,13 @@ def showSkills(player, numToBump)#1
clearLittleArea(x2, y+9)
fin
displaySkill(player, NULL, @y, x2, 0, "Skill points", player+b_skillPoints)
if player->c_gender > ' '
vspace()
rawDisplayf2("\n^T%D%s", x2+32, "Gender")
rightJustifyStr(sprintf1("%c", player->c_gender), x2+26)
fin
return skillNum-1
end
@ -471,13 +478,19 @@ end
// the item is returned; else NULL is returned.
def _showPlayerSheet(player_num)#1 // funcTbl functions always have to return a value
word player, item
byte i_page, totalItems, itemsOnPage, redisplay, sel, mode
byte i_page, totalItems, itemsOnPage, redisplay, sel, mode, noRepeatMenu
setBigWindow()
i_page = 0
redisplay = 2
mode = 'I' // 'I' for inventory, 'S' for skills
noRepeatMenu = FALSE
player = numToPlayer(player_num)
if player->b_skillPoints
mode = 'S' // go straight to level up if applicable
else
mode = 'I' // otherwise default to inventory mode
fin
repeat
player = numToPlayer(player_num)
if !player; beep; return NULL; fin
@ -499,11 +512,14 @@ def _showPlayerSheet(player_num)#1 // funcTbl functions always have to return a
redisplay = 0
fin
if mode == 'I'
showInvMenu(player, totalItems, i_page, itemsOnPage)
else // 'S'
showSkillsMenu(player, itemsOnPage)
if !noRepeatMenu
if mode == 'I'
showInvMenu(player, totalItems, i_page, itemsOnPage)
else // 'S'
showSkillsMenu(player, itemsOnPage)
fin
fin
noRepeatMenu = FALSE
// Get a key, do something
sel = getUpperKey()
@ -585,6 +601,13 @@ def _showPlayerSheet(player_num)#1 // funcTbl functions always have to return a
sel = sel - 'A'
if sel >= 0 and sel < itemsOnPage and player->b_skillPoints
showSkills(player, sel+1)
// Redisplay when last pt allocated
if !player->b_skillPoints
clearWindow()
redisplay = 1
else
noRepeatMenu = TRUE
fin
else
beep
fin

View File

@ -51,6 +51,7 @@ struc Player
byte t_type
word p_nextObj
word s_name
byte c_gender
byte b_combatOrder
word p_combatNext
word w_health