From c02f9f8f830d37bdc74181a6d045fb8733ed5eb8 Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Sun, 6 Aug 2017 11:23:40 -0700 Subject: [PATCH] Allow scripts to add skills and XP. --- .../src/org/badvision/A2PackPartitions.groovy | 7 +++++++ Platform/Apple/virtual/src/plasma/gameloop.pla | 18 +++++++++++++++++- Platform/Apple/virtual/src/plasma/party.pla | 10 ++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy b/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy index aa6cc786..9e786644 100644 --- a/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy +++ b/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy @@ -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. diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 10c8e9cd..38bb8c19 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -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 diff --git a/Platform/Apple/virtual/src/plasma/party.pla b/Platform/Apple/virtual/src/plasma/party.pla index 56fcde70..3a1571eb 100644 --- a/Platform/Apple/virtual/src/plasma/party.pla +++ b/Platform/Apple/virtual/src/plasma/party.pla @@ -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