mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-02 00:54:48 +00:00
Allow scripts to add skills and XP.
This commit is contained in:
parent
d3132cc318
commit
c02f9f8f83
@ -2906,6 +2906,13 @@ end
|
||||
sheets.find { it?.@name.equalsIgnoreCase("players") }.rows.row.each { row ->
|
||||
if (row.@name && row.@"starting-party")
|
||||
funcs << ["NPl_${humanNameToSymbol(row.@name, false)}", funcs.size, row]
|
||||
// While we're at it, add each skill to the set of stats that can be set/gotten
|
||||
row.attributes().sort().each { name, val ->
|
||||
if (name =~ /^skill-(.*)/) {
|
||||
name = titleCase(name.replace("skill-", ""))
|
||||
stats[name] = escapeString(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Global mapping of player name to function, so that add/remove functions can work.
|
||||
|
@ -2911,6 +2911,7 @@ end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def getStat(player, statName)#1
|
||||
word pSkill
|
||||
when statName
|
||||
is @S_INTELLIGENCE; return player->b_intelligence
|
||||
is @S_STRENGTH; return player->b_strength
|
||||
@ -2928,6 +2929,11 @@ export def getStat(player, statName)#1
|
||||
is @S_XP; return player=>w_curXP
|
||||
is @S_SP; return player->b_skillPoints
|
||||
wend
|
||||
pSkill = player=>p_skills
|
||||
while pSkill
|
||||
if streqi(statName, pSkill=>s_name); return pSkill=>w_modValue; fin
|
||||
pSkill = pSkill=>p_nextObj
|
||||
loop
|
||||
puts(statName); return fatal("Unknown stat")
|
||||
end
|
||||
|
||||
@ -2946,6 +2952,7 @@ end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export def setStat(player, statName, val)#0
|
||||
word pSkill
|
||||
when statName
|
||||
is @S_INTELLIGENCE; player->b_intelligence = clampByte(val); break
|
||||
is @S_STRENGTH; player->b_strength = clampByte(val); break
|
||||
@ -2960,8 +2967,17 @@ export def setStat(player, statName, val)#0
|
||||
is @S_HAND_TO_HAND; player->b_handToHand = clampByte(val); break
|
||||
is @S_DODGING; player->b_dodging = clampByte(val); break
|
||||
is @S_GOLD; global=>w_gold = max(0, val); needShowParty = TRUE; break
|
||||
is @S_SP; global->b_skillPoints = max(0, val); needShowParty = TRUE; break
|
||||
is @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
|
||||
otherwise
|
||||
pSkill = player=>p_skills
|
||||
while pSkill
|
||||
if streqi(statName, pSkill=>s_name)
|
||||
pSkill=>w_modValue = max(0, val)
|
||||
return
|
||||
fin
|
||||
pSkill = pSkill=>p_nextObj
|
||||
loop
|
||||
puts(statName); fatal("Unknown stat")
|
||||
wend
|
||||
end
|
||||
|
@ -257,12 +257,14 @@ def showSkills(player)#0
|
||||
x2 = STAT_X - 40
|
||||
fin
|
||||
showColumnTitle(25, "Skills", 0, 0)
|
||||
displaySkill(x1, @S_AIMING, player+b_aiming, TRUE)
|
||||
displaySkill(x1, @S_HAND_TO_HAND, player+b_handToHand, TRUE)
|
||||
displaySkill(x1, @S_DODGING, player+b_dodging, TRUE)
|
||||
if player->b_aiming; displaySkill(x1, @S_AIMING, @player->b_aiming, TRUE); fin
|
||||
if player->b_handToHand; displaySkill(x1, @S_HAND_TO_HAND, @player->b_handToHand, TRUE); fin
|
||||
if player->b_dodging; displaySkill(x1, @S_DODGING, @player->b_dodging, TRUE); fin
|
||||
skill = player=>p_skills
|
||||
while skill
|
||||
displaySkill(x1, skill=>s_name, skill+w_modValue, TRUE)
|
||||
if skill=>w_modValue > 0
|
||||
displaySkill(x1, skill=>s_name, skill+w_modValue, TRUE)
|
||||
fin
|
||||
skill = skill=>p_nextObj
|
||||
loop
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user