From 3a234d9e9263f3f2c0b116ef4263b121d1461a26 Mon Sep 17 00:00:00 2001 From: captainurist <73941350+captainurist@users.noreply.github.com> Date: Sun, 15 Oct 2023 13:03:28 +0100 Subject: [PATCH] Renamings as requested in PR --- src/Engine/Objects/Character.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Engine/Objects/Character.cpp b/src/Engine/Objects/Character.cpp index e4b61bb7491b..4caab115406a 100644 --- a/src/Engine/Objects/Character.cpp +++ b/src/Engine/Objects/Character.cpp @@ -108,14 +108,16 @@ static constexpr IndexedArray StealingRandomBonuses = { -200, -100, 0, 100, 200 }; // dword_4EDEB4 -static constexpr IndexedArray StealingEnchantmentBonusForSkill = { - // {CHARACTER_SKILL_MASTERY_NONE, 0}, +/** + * The amount of gold that a character can steal in one go is determined as `[skill_level]d[mastery_die]`, where + * `skill_level` is the level of stealing skill, and `mastery_die` is picked from the table below. + */ +static constexpr IndexedArray goldStealingDieSidesByMastery = { {CHARACTER_SKILL_MASTERY_NOVICE, 2}, {CHARACTER_SKILL_MASTERY_EXPERT, 4}, {CHARACTER_SKILL_MASTERY_MASTER, 6}, {CHARACTER_SKILL_MASTERY_GRANDMASTER, 10} -}; // dword_4EDEC4 //the zeroth element isn't accessed, it just - // helps avoid -1 indexing, originally 4 element array off by one +}; static constexpr IndexedArray pEquipTypeToBodyAnchor = { // 4E8398 {ITEM_TYPE_SINGLE_HANDED, ITEM_SLOT_MAIN_HAND}, @@ -1537,21 +1539,21 @@ StealResult Character::StealFromActor(unsigned int uActorID, int _steal_perm, in return STEAL_NOTHING; } - int enchBonusSum = grng->randomDice(stealingSkill.level(), StealingEnchantmentBonusForSkill[stealingSkill.mastery()]); + int stolenGold = grng->randomDice(stealingSkill.level(), goldStealingDieSidesByMastery[stealingSkill.mastery()]); int *goldPtr = &actroPtr->items[3].goldAmount; // actor has this amount of gold - if (enchBonusSum >= *goldPtr) { // steal all the gold - enchBonusSum = *goldPtr; + if (stolenGold >= *goldPtr) { // steal all the gold + stolenGold = *goldPtr; actroPtr->items[3].uItemID = ITEM_NULL; *goldPtr = 0; } else { - *goldPtr -= enchBonusSum; // steal some of the gold + *goldPtr -= stolenGold; // steal some of the gold } - if (enchBonusSum) { - pParty->partyFindsGold(enchBonusSum, GOLD_RECEIVE_NOSHARE_SILENT); - engine->_statusBar->setEvent(LSTR_FMT_S_STOLE_D_GOLD, this->name, enchBonusSum); + if (stolenGold) { + pParty->partyFindsGold(stolenGold, GOLD_RECEIVE_NOSHARE_SILENT); + engine->_statusBar->setEvent(LSTR_FMT_S_STOLE_D_GOLD, this->name, stolenGold); } else { engine->_statusBar->setEvent(LSTR_FMT_S_FAILED_TO_STEAL, this->name); }