Skip to content

Commit

Permalink
Rewards can now scale with curse difficulty.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnchyDev committed Oct 28, 2023
1 parent 57526cf commit 230d31b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
21 changes: 12 additions & 9 deletions data/sql/db-world/base/tos_world_base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,20 @@ INSERT INTO `gameobject_template` (`entry`, `type`, `displayId`, `name`, `IconNa

CREATE TABLE IF NOT EXISTS `tos_reward_template` (
`id` int DEFAULT NULL,
`item_entry` int DEFAULT NULL,
`count_min` int DEFAULT NULL,
`count_max` int DEFAULT NULL,
`chance` float DEFAULT NULL,
`note` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL
`item_entry` int DEFAULT '0',
`count_min` int DEFAULT '1',
`count_max` int DEFAULT '1',
`count_cap` int DEFAULT NULL,
`chance` float DEFAULT '100',
`curse_scalar` float DEFAULT '0',
`note` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

DELETE FROM `tos_reward_template` WHERE `id`=1 AND `item_entry`=37711 AND `count_min`=250 AND `count_max`=300 AND `chance`=100 AND `note`='Test Currency 1';
INSERT INTO `tos_reward_template` (`id`, `item_entry`, `count_min`, `count_max`, `chance`, `note`) VALUES (1, 37711, 250, 300, 100, 'Test Currency 1');
DELETE FROM `tos_reward_template` WHERE `id`=1 AND `item_entry`=16073 AND `count_min`=1 AND `count_max`=3 AND `chance`=100 AND `note`='Book of Knowledge';
INSERT INTO `tos_reward_template` (`id`, `item_entry`, `count_min`, `count_max`, `chance`, `note`) VALUES (1, 16073, 1, 3, 100, 'Book of Knowledge');

DELETE FROM `tos_reward_template` WHERE `id`=1 AND `item_entry`=21215 AND `count_min`=5 AND `count_max`=10 AND `count_cap`=20 AND `chance`=50 AND `curse_scalar`=0 AND `note`='Graccu\'s Fruitcake';
INSERT INTO `tos_reward_template` (`id`, `item_entry`, `count_min`, `count_max`, `count_cap`, `chance`, `curse_scalar`, `note`) VALUES (1, 21215, 5, 10, 20, 50, 0, 'Graccu\'s Fruitcake');
DELETE FROM `tos_reward_template` WHERE `id`=1 AND `item_entry`=37711 AND `count_min`=250 AND `count_max`=300 AND `count_cap`=500 AND `chance`=100 AND `curse_scalar`=0 AND `note`='Test Currency 1';
INSERT INTO `tos_reward_template` (`id`, `item_entry`, `count_min`, `count_max`, `count_cap`, `chance`, `curse_scalar`, `note`) VALUES (1, 37711, 250, 300, 500, 100, 0, 'Test Currency 1');


CREATE TABLE IF NOT EXISTS `tos_wave_groups` (
Expand Down
4 changes: 3 additions & 1 deletion src/TrialOfStrength.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ void LoadRewardTemplates()
rewardTemplate.itemEntry = fields[1].Get<uint32>();
rewardTemplate.countMin = fields[2].Get<uint32>();
rewardTemplate.countMax = fields[3].Get<uint32>();
rewardTemplate.chance = fields[4].Get<uint32>();
rewardTemplate.countCap = fields[4].Get<uint32>();
rewardTemplate.chance = fields[5].Get<uint32>();
rewardTemplate.curseScalar = fields[6].Get<float>();

auto templates = sToSMapMgr->GetRewardTemplates(rewardId);
if (!templates)
Expand Down
2 changes: 2 additions & 0 deletions src/TrialOfStrength.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ struct ToSRewardTemplate {
uint32 itemEntry;
uint32 countMin;
uint32 countMax;
uint32 countCap;
uint32 chance;
float curseScalar;
};

struct ToSCurseTemplate {
Expand Down
15 changes: 14 additions & 1 deletion src/scripts/ToSInstanceScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,11 @@ void ToSInstanceScript::PopulateRewardChest()
rewardChest->loot.items.reserve(MAX_NR_LOOT_ITEMS);

auto rewardTemplates = sToSMapMgr->GetRewardTemplates(rewardId);
if (!rewardTemplates || rewardTemplates->empty())
{
LOG_ERROR("module", "Failed to find trial of strength reward templates!");
return;
}

for (auto rewardTemplate = rewardTemplates->begin(); rewardTemplate != rewardTemplates->end(); ++rewardTemplate)
{
Expand All @@ -730,7 +735,15 @@ void ToSInstanceScript::PopulateRewardChest()
LootItem lootItem(*lootStoreItem);
lootItem.itemIndex = rewardChest->loot.items.size();
lootItem.itemid = rewardTemplate->itemEntry;
lootItem.count = urand(rewardTemplate->countMin, rewardTemplate->countMax);

uint32 itemCount = urand(rewardTemplate->countMin, rewardTemplate->countMax);
if (rewardTemplate->curseScalar)
{
itemCount = itemCount + ((GetCurseScaling() / 100) * rewardTemplate->curseScalar);
}

// hard cap the item count.
lootItem.count = itemCount > rewardTemplate->countCap ? rewardTemplate->countCap : itemCount;

rewardChest->loot.unlootedCount += 1;

Expand Down

0 comments on commit 230d31b

Please sign in to comment.