Skip to content

Commit

Permalink
Renamings as requested in PR
Browse files Browse the repository at this point in the history
  • Loading branch information
captainurist committed Oct 15, 2023
1 parent 0617544 commit 3a234d9
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/Engine/Objects/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,16 @@ static constexpr IndexedArray<int, CHARACTER_SKILL_MASTERY_FIRST, CHARACTER_SKIL
// helps avoid -1 indexing, originally 4 element array off by one
static constexpr std::array<int, 5> StealingRandomBonuses = { -200, -100, 0, 100, 200 }; // dword_4EDEB4

static constexpr IndexedArray<int, CHARACTER_SKILL_MASTERY_FIRST, CHARACTER_SKILL_MASTERY_LAST> 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<int, CHARACTER_SKILL_MASTERY_FIRST, CHARACTER_SKILL_MASTERY_LAST> 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<ItemSlot, ITEM_TYPE_FIRST, ITEM_TYPE_LAST> pEquipTypeToBodyAnchor = { // 4E8398
{ITEM_TYPE_SINGLE_HANDED, ITEM_SLOT_MAIN_HAND},
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 3a234d9

Please sign in to comment.