Fixed bugs with using items and salves.

This commit is contained in:
Martin Haye 2017-08-30 09:27:10 -07:00
parent ddbeebd9b0
commit acc78864bf
2 changed files with 53 additions and 40 deletions

View File

@ -971,7 +971,8 @@ export asm streqi(a, b)#1
bne -- ; abort on inequality bne -- ; abort on inequality
dex dex
bne - bne -
ldy #0 ; okay, they're equal. Return non-zero (A is guaranteed to be a character already) lda #1
ldy #0 ; okay, they're equal. Return 1 (not just any char; so that PLASMA when...is can work)
rts rts
end end
@ -2367,13 +2368,21 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Load the Party engine and show data for the given player // Load the Party engine and show data for the given player
def showPlayerSheet(num)#1 def showPlayerSheet(num)#1
word pItemToUse word pItemToUse, oldFlg
if num+1 > countList(global=>p_players); beep; return 0; fin if num+1 > countList(global=>p_players); beep; return 0; fin
pItemToUse = loadEngine(MOD_PARTY)=>party_showPlayerSheet(num) pItemToUse = loadEngine(MOD_PARTY)=>party_showPlayerSheet(num)
returnFromEngine(TRUE) returnFromEngine(TRUE)
// General 'use' handled here in case it triggers graphical effects // General 'use' handled here in case it triggers graphical effects
if pItemToUse if pItemToUse
oldFlg = textDrawn
textDrawn = FALSE
scriptEvent(@S_USE, pItemToUse=>s_name) scriptEvent(@S_USE, pItemToUse=>s_name)
if !textDrawn
displayStr("\nNothing happened.")
textDrawn = TRUE
else
textDrawn = oldFlg
fin
fin fin
return 0 return 0
end end
@ -2932,29 +2941,29 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def getStat(player, statName)#1 export def getStat(player, statName)#1
word pSkill word pSkill
when statName when 1
is @S_INTELLIGENCE; return player->b_intelligence is streqi(statName, @S_INTELLIGENCE); return player->b_intelligence
is @S_STRENGTH; return player->b_strength is streqi(statName, @S_STRENGTH); return player->b_strength
is @S_AGILITY; return player->b_agility is streqi(statName, @S_AGILITY); return player->b_agility
is @S_STAMINA; return player->b_stamina is streqi(statName, @S_STAMINA); return player->b_stamina
is @S_CHARISMA; return player->b_charisma is streqi(statName, @S_CHARISMA); return player->b_charisma
is @S_SPIRIT; return player->b_spirit is streqi(statName, @S_SPIRIT); return player->b_spirit
is @S_LUCK; return player->b_luck is streqi(statName, @S_LUCK); return player->b_luck
is @S_HEALTH; return player=>w_health is streqi(statName, @S_HEALTH); return player=>w_health
is @S_MAX_HEALTH; return player=>w_maxHealth is streqi(statName, @S_MAX_HEALTH); return player=>w_maxHealth
is @S_AIMING; return player->b_aiming is streqi(statName, @S_AIMING); return player->b_aiming
is @S_HAND_TO_HAND; return player->b_handToHand is streqi(statName, @S_HAND_TO_HAND); return player->b_handToHand
is @S_DODGING; return player->b_dodging is streqi(statName, @S_DODGING); return player->b_dodging
is @S_GOLD; return global=>w_gold is streqi(statName, @S_GOLD); return global=>w_gold
is @S_XP; return player=>w_curXP is streqi(statName, @S_XP); return player=>w_curXP
is @S_SP; return player->b_skillPoints is streqi(statName, @S_SP); return player->b_skillPoints
wend wend
pSkill = player=>p_skills pSkill = player=>p_skills
while pSkill while pSkill
if streqi(statName, pSkill=>s_name); return pSkill=>w_modValue; fin if streqi(statName, pSkill=>s_name); return pSkill=>w_modValue; fin
pSkill = pSkill=>p_nextObj pSkill = pSkill=>p_nextObj
loop loop
puts(statName); return fatal("Unknown stat") puts(statName); return fatal("getStat")
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -2973,22 +2982,22 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def setStat(player, statName, val)#0 export def setStat(player, statName, val)#0
word pSkill word pSkill
when statName when 1
is @S_INTELLIGENCE; player->b_intelligence = clampByte(val); break is streqi(statName, @S_INTELLIGENCE); player->b_intelligence = clampByte(val); break
is @S_STRENGTH; player->b_strength = clampByte(val); break is streqi(statName, @S_STRENGTH); player->b_strength = clampByte(val); break
is @S_AGILITY; player->b_agility = clampByte(val); break is streqi(statName, @S_AGILITY); player->b_agility = clampByte(val); break
is @S_STAMINA; player->b_stamina = clampByte(val); break is streqi(statName, @S_STAMINA); player->b_stamina = clampByte(val); break
is @S_CHARISMA; player->b_charisma = clampByte(val); break is streqi(statName, @S_CHARISMA); player->b_charisma = clampByte(val); break
is @S_SPIRIT; player->b_spirit = clampByte(val); break is streqi(statName, @S_SPIRIT); player->b_spirit = clampByte(val); break
is @S_LUCK; player->b_luck = clampByte(val); break is streqi(statName, @S_LUCK); player->b_luck = clampByte(val); break
is @S_HEALTH; player=>w_health = max(0, min(player=>w_maxHealth, val)); needShowParty = TRUE; break is streqi(statName, @S_HEALTH); player=>w_health = max(0, min(player=>w_maxHealth, val)); needShowParty = TRUE; break
is @S_MAX_HEALTH; player=>w_maxHealth = max(0, val); break is streqi(statName, @S_MAX_HEALTH); player=>w_maxHealth = max(0, val); break
is @S_AIMING; player->b_aiming = clampByte(val); break is streqi(statName, @S_AIMING); player->b_aiming = clampByte(val); break
is @S_HAND_TO_HAND; player->b_handToHand = clampByte(val); break is streqi(statName, @S_HAND_TO_HAND); player->b_handToHand = clampByte(val); break
is @S_DODGING; player->b_dodging = clampByte(val); break is streqi(statName, @S_DODGING); player->b_dodging = clampByte(val); break
is @S_GOLD; global=>w_gold = max(0, val); needShowParty = TRUE; break is streqi(statName, @S_GOLD); global=>w_gold = max(0, val); needShowParty = TRUE; break
is @S_XP; player=>w_curXP = max(player=>w_curXP, val); needShowParty = TRUE; break is streqi(statName, @S_XP); player=>w_curXP = max(player=>w_curXP, val); needShowParty = TRUE; break
is @S_SP; player->b_skillPoints = max(0, val); needShowParty = TRUE; break is streqi(statName, @S_SP); player->b_skillPoints = max(0, val); needShowParty = TRUE; break
otherwise otherwise
pSkill = player=>p_skills pSkill = player=>p_skills
while pSkill while pSkill
@ -2998,7 +3007,7 @@ export def setStat(player, statName, val)#0
fin fin
pSkill = pSkill=>p_nextObj pSkill = pSkill=>p_nextObj
loop loop
puts(statName); fatal("Unknown stat") puts(statName); fatal("setStat")
wend wend
end end

View File

@ -872,11 +872,15 @@ def _displayItemStats(pItem1, pItem2)#1
rawDisplayStr("\nSpecial") rawDisplayStr("\nSpecial")
while pMod1 or pMod2 while pMod1 or pMod2
if pMod1 if pMod1
rawDisplayf3("^T%D%d %s", STATS_COL_1, pMod1=>w_modValue, pMod1=>s_name) rawDisplayf1("^T%D", STATS_COL_1)
if pMod1=>w_modValue >= 999; rawDisplayStr("Full "); else rawDisplayf1("%d ", pMod1=>w_modValue); fin
rawDisplayStr(pMod1=>s_name)
pMod1 = pMod1=>p_nextObj pMod1 = pMod1=>p_nextObj
fin fin
if pMod2 if pMod2
rawDisplayf3("^T%D%d %s", STATS_COL_2, pMod2=>w_modValue, pMod2=>s_name) rawDisplayf1("^T%D", STATS_COL_2)
if pMod2=>w_modValue >= 999; rawDisplayStr("Full "); else rawDisplayf1("%d ", pMod2=>w_modValue); fin
rawDisplayStr(pMod2=>s_name)
pMod2 = pMod2=>p_nextObj pMod2 = pMod2=>p_nextObj
fin fin
loop loop
@ -889,8 +893,8 @@ end
// For countable "stuff" (e.g. ammo), display the count and appropriate singular or plural name. // For countable "stuff" (e.g. ammo), display the count and appropriate singular or plural name.
def _displayItemName(pItem)#1 def _displayItemName(pItem)#1
isPlural = FALSE isPlural = FALSE
if pItem->t_type == TYPE_FANCY_ITEM and pItem=>w_count > 0 if pItem->t_type == TYPE_FANCY_ITEM and pItem=>w_count > 1
isPlural = pItem=>w_count > 1 isPlural = TRUE
rawDisplayf1("%d ", pItem=>w_count) rawDisplayf1("%d ", pItem=>w_count)
fin fin
buildString(@addToString) buildString(@addToString)