mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-15 08:06:11 +00:00
Improve gear initialization (#909)
* Druid and paladin rotation * Improve spell effect collector for gear init * Fix mount and hit stat calculator
This commit is contained in:
@@ -38,8 +38,6 @@
|
||||
#include "StatsWeightCalculator.h"
|
||||
#include "World.h"
|
||||
|
||||
#define PLAYER_SKILL_INDEX(x) (PLAYER_SKILL_INFO_1_1 + ((x)*3))
|
||||
|
||||
const uint64 diveMask = (1LL << 7) | (1LL << 44) | (1LL << 37) | (1LL << 38) | (1LL << 26) | (1LL << 30) | (1LL << 27) |
|
||||
(1LL << 33) | (1LL << 24) | (1LL << 34);
|
||||
uint32 PlayerbotFactory::tradeSkills[] = {SKILL_ALCHEMY, SKILL_ENCHANTING, SKILL_SKINNING, SKILL_TAILORING,
|
||||
@@ -79,14 +77,16 @@ void PlayerbotFactory::Init()
|
||||
|
||||
if (!quest->GetRequiredClasses() || quest->IsRepeatable() || quest->GetMinLevel() < 10)
|
||||
continue;
|
||||
|
||||
|
||||
if (quest->GetRewSpellCast() > 0)
|
||||
{
|
||||
int32 spellId = quest->GetRewSpellCast();
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
continue;
|
||||
} else if (quest->GetRewSpell() > 0) {
|
||||
}
|
||||
else if (quest->GetRewSpell() > 0)
|
||||
{
|
||||
int32 spellId = quest->GetRewSpell();
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
@@ -271,7 +271,8 @@ void PlayerbotFactory::Randomize(bool incremental)
|
||||
|
||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Talents");
|
||||
LOG_DEBUG("playerbots", "Initializing talents...");
|
||||
if (!incremental || !sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel)
|
||||
if (!incremental || !sPlayerbotAIConfig->equipmentPersistence ||
|
||||
bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel)
|
||||
{
|
||||
InitTalentsTree();
|
||||
}
|
||||
@@ -306,7 +307,8 @@ void PlayerbotFactory::Randomize(bool incremental)
|
||||
|
||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Equip");
|
||||
LOG_DEBUG("playerbots", "Initializing equipmemt...");
|
||||
if (!incremental || !sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel)
|
||||
if (!incremental || !sPlayerbotAIConfig->equipmentPersistence ||
|
||||
bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel)
|
||||
{
|
||||
InitEquipment(incremental, incremental ? false : sPlayerbotAIConfig->twoRoundsGearInit);
|
||||
}
|
||||
@@ -1559,27 +1561,16 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
||||
// int tab = AiFactory::GetPlayerSpecTab(bot);
|
||||
|
||||
uint32 blevel = bot->GetLevel();
|
||||
int32 delta = 2;
|
||||
if (blevel < 15)
|
||||
delta = std::min(blevel, 15u);
|
||||
else if (blevel < 40)
|
||||
delta = 10;
|
||||
else if (blevel < 60)
|
||||
delta = 6;
|
||||
else if (blevel < 70)
|
||||
delta = 9;
|
||||
else if (blevel < 80)
|
||||
delta = 9;
|
||||
else if (blevel == 80)
|
||||
delta = 9;
|
||||
int32 delta = std::min(blevel, 10u);
|
||||
|
||||
StatsWeightCalculator calculator(bot);
|
||||
for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; ++slot)
|
||||
// Reverse order may work better
|
||||
for (int32 slot = (int32)EQUIPMENT_SLOT_TABARD; slot >= (int32)EQUIPMENT_SLOT_START; slot--)
|
||||
{
|
||||
if (slot == EQUIPMENT_SLOT_TABARD || slot == EQUIPMENT_SLOT_BODY)
|
||||
continue;
|
||||
|
||||
if (level < 40 && (slot == EQUIPMENT_SLOT_TRINKET1 || slot == EQUIPMENT_SLOT_TRINKET2))
|
||||
if (level < 50 && (slot == EQUIPMENT_SLOT_TRINKET1 || slot == EQUIPMENT_SLOT_TRINKET2))
|
||||
continue;
|
||||
|
||||
if (level < 30 && slot == EQUIPMENT_SLOT_NECK)
|
||||
@@ -1670,8 +1661,6 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
||||
items[slot].push_back(itemId);
|
||||
}
|
||||
}
|
||||
if (items[slot].size() >= 25)
|
||||
break;
|
||||
}
|
||||
} while (items[slot].size() < 25 && desiredQuality-- > ITEM_QUALITY_NORMAL);
|
||||
|
||||
@@ -1719,8 +1708,6 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
||||
if (bestScoreForSlot < 1.2f * old_score)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (oldItem)
|
||||
{
|
||||
uint8 bagIndex = oldItem->GetBagSlot();
|
||||
@@ -1742,19 +1729,19 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
||||
// if (newItem)
|
||||
// {
|
||||
// newItem->AddToWorld();
|
||||
// newItem->AddToUpdateQueueOf(bot);
|
||||
// newItem->AddToUpdateQueueOf(bot);
|
||||
// }
|
||||
}
|
||||
// Secondary init for better equips
|
||||
/// @todo: clean up duplicate code
|
||||
if (second_chance)
|
||||
{
|
||||
for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; ++slot)
|
||||
for (int32 slot = (int32)EQUIPMENT_SLOT_TABARD; slot >= (int32)EQUIPMENT_SLOT_START; slot--)
|
||||
{
|
||||
if (slot == EQUIPMENT_SLOT_TABARD || slot == EQUIPMENT_SLOT_BODY)
|
||||
continue;
|
||||
|
||||
if (level < 40 && (slot == EQUIPMENT_SLOT_TRINKET1 || slot == EQUIPMENT_SLOT_TRINKET2))
|
||||
if (level < 50 && (slot == EQUIPMENT_SLOT_TRINKET1 || slot == EQUIPMENT_SLOT_TRINKET2))
|
||||
continue;
|
||||
|
||||
if (level < 30 && slot == EQUIPMENT_SLOT_NECK)
|
||||
@@ -2087,7 +2074,7 @@ bool PlayerbotFactory::CanEquipUnseenItem(uint8 slot, uint16& dest, uint32 item)
|
||||
if (Item* pItem = Item::CreateItem(item, 1, bot, false, 0, true))
|
||||
{
|
||||
InventoryResult result = botAI ? botAI->CanEquipItem(slot, dest, pItem, true, true)
|
||||
: bot->CanEquipItem(slot, dest, pItem, true, true);
|
||||
: bot->CanEquipItem(slot, dest, pItem, true, true);
|
||||
pItem->RemoveFromUpdateQueueOf(bot);
|
||||
delete pItem;
|
||||
return result == EQUIP_ERR_OK;
|
||||
@@ -2177,18 +2164,15 @@ void PlayerbotFactory::InitSkills()
|
||||
uint32 maxValue = level * 5;
|
||||
bot->UpdateSkillsForLevel();
|
||||
|
||||
uint16 step = bot->GetSkillValue(SKILL_RIDING) ? bot->GetSkillStep(SKILL_RIDING) : 1;
|
||||
|
||||
if (bot->GetLevel() >= 70)
|
||||
bot->SetSkill(SKILL_RIDING, step, 300, 300);
|
||||
else if (bot->GetLevel() >= 60)
|
||||
bot->SetSkill(SKILL_RIDING, step, 225, 225);
|
||||
else if (bot->GetLevel() >= 40)
|
||||
bot->SetSkill(SKILL_RIDING, step, 150, 150);
|
||||
else if (bot->GetLevel() >= 20)
|
||||
bot->SetSkill(SKILL_RIDING, step, 75, 75);
|
||||
else
|
||||
bot->SetSkill(SKILL_RIDING, 0, 0, 0);
|
||||
bot->SetSkill(SKILL_RIDING, 0, 0, 0);
|
||||
if (bot->GetLevel() >= sPlayerbotAIConfig->useGroundMountAtMinLevel)
|
||||
bot->learnSpell(33388);
|
||||
if (bot->GetLevel() >= sPlayerbotAIConfig->useFastGroundMountAtMinLevel)
|
||||
bot->learnSpell(33391);
|
||||
if (bot->GetLevel() >= sPlayerbotAIConfig->useFlyMountAtMinLevel)
|
||||
bot->learnSpell(34090);
|
||||
if (bot->GetLevel() >= sPlayerbotAIConfig->useFastFlyMountAtMinLevel)
|
||||
bot->learnSpell(34091);
|
||||
|
||||
uint32 skillLevel = bot->GetLevel() < 40 ? 0 : 1;
|
||||
uint32 dualWieldLevel = bot->GetLevel() < 20 ? 0 : 1;
|
||||
@@ -2360,8 +2344,6 @@ void PlayerbotFactory::InitAvailableSpells()
|
||||
trainerIdCache.push_back(trainerId);
|
||||
}
|
||||
}
|
||||
// uint32 learnedCounter = 0;
|
||||
// uint32 oktest = 0;
|
||||
for (uint32 trainerId : trainerIdCache)
|
||||
{
|
||||
TrainerSpellData const* trainer_spells = sObjectMgr->GetNpcTrainerSpells(trainerId);
|
||||
@@ -2379,7 +2361,7 @@ void PlayerbotFactory::InitAvailableSpells()
|
||||
if (!tSpell)
|
||||
continue;
|
||||
|
||||
if (!tSpell->learnedSpell[0] && !bot->IsSpellFitByClassAndRace(tSpell->learnedSpell[0]))
|
||||
if (tSpell->learnedSpell[0] && !bot->IsSpellFitByClassAndRace(tSpell->learnedSpell[0]))
|
||||
continue;
|
||||
|
||||
TrainerSpellState state = bot->GetTrainerSpellState(tSpell);
|
||||
@@ -2394,7 +2376,8 @@ void PlayerbotFactory::InitAvailableSpells()
|
||||
continue;
|
||||
|
||||
if (spellInfo->Effects[j].Effect == SPELL_EFFECT_PROFICIENCY ||
|
||||
spellInfo->Effects[j].Effect == SPELL_EFFECT_SKILL_STEP ||
|
||||
(spellInfo->Effects[j].Effect == SPELL_EFFECT_SKILL_STEP &&
|
||||
spellInfo->Effects[j].MiscValue != SKILL_RIDING) ||
|
||||
spellInfo->Effects[j].Effect == SPELL_EFFECT_DUAL_WIELD)
|
||||
{
|
||||
learn = false;
|
||||
@@ -2405,19 +2388,12 @@ void PlayerbotFactory::InitAvailableSpells()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// oktest++;
|
||||
if (tSpell->learnedSpell[0])
|
||||
{
|
||||
|
||||
if (tSpell->IsCastable())
|
||||
bot->CastSpell(bot, tSpell->spell, true);
|
||||
else
|
||||
bot->learnSpell(tSpell->learnedSpell[0], false);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// botAI->CastSpell(tSpell->spell, bot);
|
||||
// }
|
||||
}
|
||||
// LOG_INFO("playerbots", "C: {}, ok: {}", ++learnedCounter, oktest);
|
||||
// if (++learnedCounter > 20)
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2460,6 +2436,8 @@ void PlayerbotFactory::InitClassSpells()
|
||||
// to leave DK starting area
|
||||
bot->learnSpell(53428, false);
|
||||
bot->learnSpell(50977, false);
|
||||
bot->learnSpell(49142, false);
|
||||
bot->learnSpell(48778, false);
|
||||
break;
|
||||
case CLASS_HUNTER:
|
||||
bot->learnSpell(2973, true);
|
||||
@@ -3866,7 +3844,7 @@ void PlayerbotFactory::ApplyEnchantAndGemsNew(bool destoryOld)
|
||||
float bestGemScore[4] = {0, 0, 0, 0};
|
||||
std::vector<uint32> curCount = GetCurrentGemsCount();
|
||||
uint8 jewelersCount = 0;
|
||||
int requiredActive = bot->GetLevel() <= 70 ? 2 : 1;
|
||||
int requiredActive = 2;
|
||||
std::vector<uint32> availableGems;
|
||||
for (const uint32& enchantGem : enchantGemIdCache)
|
||||
{
|
||||
@@ -4007,7 +3985,7 @@ void PlayerbotFactory::ApplyEnchantAndGemsNew(bool destoryOld)
|
||||
bool isJewelersGem = gemTemplate->ItemLimitCategory == 2;
|
||||
if (isJewelersGem && jewelersCount >= 3)
|
||||
continue;
|
||||
|
||||
|
||||
const GemPropertiesEntry* gemProperties = sGemPropertiesStore.LookupEntry(gemTemplate->GemProperties);
|
||||
if (!gemProperties)
|
||||
continue;
|
||||
|
||||
@@ -5,11 +5,14 @@
|
||||
#include "DBCStores.h"
|
||||
#include "ItemTemplate.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "PlayerbotAI.h"
|
||||
#include "PlayerbotAIAware.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "SpellAuraDefines.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "UpdateFields.h"
|
||||
#include "Util.h"
|
||||
|
||||
StatsCollector::StatsCollector(CollectorType type, int32 cls) : type_(type), cls_(cls) { Reset(); }
|
||||
|
||||
@@ -52,12 +55,12 @@ void StatsCollector::CollectItemStats(ItemTemplate const* proto)
|
||||
CollectSpellStats(proto->Spells[j].SpellId, 1.0f, 0);
|
||||
break;
|
||||
case ITEM_SPELLTRIGGER_CHANCE_ON_HIT:
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
{
|
||||
if (proto->Spells[j].SpellPPMRate > 0.01f)
|
||||
CollectSpellStats(proto->Spells[j].SpellId, 1.0f, 60000 / proto->Spells[j].SpellPPMRate);
|
||||
else
|
||||
CollectSpellStats(proto->Spells[j].SpellId, 1.0f, 60000 / 1.8f); // Default PPM = 1.8
|
||||
CollectSpellStats(proto->Spells[j].SpellId, 1.0f, 60000 / 1.8f); // Default PPM = 1.8
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -67,7 +70,7 @@ void StatsCollector::CollectItemStats(ItemTemplate const* proto)
|
||||
|
||||
if (proto->socketBonus)
|
||||
{
|
||||
if (const SpellItemEnchantmentEntry *enchant = sSpellItemEnchantmentStore.LookupEntry(proto->socketBonus))
|
||||
if (const SpellItemEnchantmentEntry* enchant = sSpellItemEnchantmentStore.LookupEntry(proto->socketBonus))
|
||||
CollectEnchantStats(enchant);
|
||||
}
|
||||
}
|
||||
@@ -94,34 +97,50 @@ void StatsCollector::CollectSpellStats(uint32 spellId, float multiplier, int32 s
|
||||
procFlags = eventEntry->procFlags;
|
||||
else
|
||||
procFlags = spellInfo->ProcFlags;
|
||||
|
||||
|
||||
if (eventEntry && eventEntry->customChance)
|
||||
procChance = eventEntry->customChance;
|
||||
else
|
||||
procChance = spellInfo->ProcChance;
|
||||
bool lowChance = procChance <= 5;
|
||||
|
||||
bool lowChance = procChance <= 5;
|
||||
|
||||
if (lowChance || (procFlags && !CanBeTriggeredByType(spellInfo, procFlags)))
|
||||
canNextTrigger = false;
|
||||
|
||||
if (spellInfo->StackAmount)
|
||||
{
|
||||
// Heuristic multiplier for spell with stackAmount since high stackAmount may not be available
|
||||
if (spellInfo->StackAmount <= 10)
|
||||
multiplier *= spellInfo->StackAmount * 0.6;
|
||||
if (spellInfo->StackAmount <= 1)
|
||||
multiplier *= spellInfo->StackAmount * 1;
|
||||
else if (spellInfo->StackAmount <= 5)
|
||||
multiplier *= 1 + (spellInfo->StackAmount - 1) * 0.75;
|
||||
else if (spellInfo->StackAmount <= 10)
|
||||
multiplier *= 4 + (spellInfo->StackAmount - 5) * 0.6;
|
||||
else if (spellInfo->StackAmount <= 20)
|
||||
multiplier *= 6 + (spellInfo->StackAmount - 10) * 0.4;
|
||||
multiplier *= 7 + (spellInfo->StackAmount - 10) * 0.4;
|
||||
else
|
||||
multiplier *= 10;
|
||||
multiplier *= 11;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
|
||||
{
|
||||
const SpellEffectInfo& effectInfo = spellInfo->Effects[i];
|
||||
if (!effectInfo.Effect)
|
||||
continue;
|
||||
switch (effectInfo.Effect)
|
||||
{
|
||||
case SPELL_EFFECT_APPLY_AURA:
|
||||
{
|
||||
if (spellInfo->SpellFamilyName && /*effectInfo.ApplyAuraName != SPELL_AURA_DUMMY &&*/
|
||||
effectInfo.ApplyAuraName != SPELL_AURA_PROC_TRIGGER_SPELL)
|
||||
{
|
||||
if (!CheckSpellValidation(spellInfo->SpellFamilyName, effectInfo.SpellClassMask))
|
||||
return;
|
||||
|
||||
// Some dummy effects cannot be recognized, make some bonus to identify
|
||||
stats[STATS_TYPE_BONUS] += 1;
|
||||
}
|
||||
|
||||
/// @todo Handle negative spell
|
||||
if (!spellInfo->IsPositive())
|
||||
break;
|
||||
@@ -130,7 +149,8 @@ void StatsCollector::CollectSpellStats(uint32 spellId, float multiplier, int32 s
|
||||
if (spellCooldown <= 2000 || spellInfo->GetDuration() == -1)
|
||||
coverage = 1.0f;
|
||||
else
|
||||
coverage = std::min(1.0f, (float)spellInfo->GetDuration() / (spellInfo->GetDuration() + spellCooldown));
|
||||
coverage =
|
||||
std::min(1.0f, (float)spellInfo->GetDuration() / (spellInfo->GetDuration() + spellCooldown));
|
||||
|
||||
multiplier *= coverage;
|
||||
HandleApplyAura(effectInfo, multiplier, canNextTrigger, triggerCooldown);
|
||||
@@ -167,12 +187,12 @@ void StatsCollector::CollectSpellStats(uint32 spellId, float multiplier, int32 s
|
||||
break;
|
||||
float normalizedCd = std::max((float)spellCooldown / 1000, 5.0f);
|
||||
int32 val = AverageValue(effectInfo);
|
||||
if (type_ == CollectorType::MELEE || type_ == CollectorType::RANGED)
|
||||
if (type_ & (CollectorType::MELEE | CollectorType::RANGED))
|
||||
{
|
||||
float transfer_multiplier = 1;
|
||||
stats[STATS_TYPE_ATTACK_POWER] += (float)val / normalizedCd * multiplier * transfer_multiplier;
|
||||
}
|
||||
else if (type_ == CollectorType::SPELL_DMG)
|
||||
else if (type_ & CollectorType::SPELL_DMG)
|
||||
{
|
||||
float transfer_multiplier = 0.5;
|
||||
stats[STATS_TYPE_SPELL_POWER] += (float)val / normalizedCd * multiplier * transfer_multiplier;
|
||||
@@ -200,7 +220,7 @@ void StatsCollector::CollectEnchantStats(SpellItemEnchantmentEntry const* enchan
|
||||
{
|
||||
case ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL:
|
||||
{
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
CollectSpellStats(enchant_spell_id, 0.25f);
|
||||
break;
|
||||
}
|
||||
@@ -225,55 +245,60 @@ void StatsCollector::CollectEnchantStats(SpellItemEnchantmentEntry const* enchan
|
||||
}
|
||||
|
||||
/// @todo Special case for some spell that hard to calculate, like trinket, relic, etc.
|
||||
bool StatsCollector::SpecialSpellFilter(uint32 spellId) {
|
||||
bool StatsCollector::SpecialSpellFilter(uint32 spellId)
|
||||
{
|
||||
// trinket
|
||||
switch (spellId)
|
||||
{
|
||||
case 27521: // Insightful Earthstorm Diamond
|
||||
case 60764: // Totem of Splintering
|
||||
if (type_ & (CollectorType::SPELL))
|
||||
return true;
|
||||
break;
|
||||
case 27521: // Insightful Earthstorm Diamond
|
||||
stats[STATS_TYPE_MANA_REGENERATION] += 20;
|
||||
return true;
|
||||
case 55381: // Insightful Earthsiege Diamond
|
||||
case 55381: // Insightful Earthsiege Diamond
|
||||
stats[STATS_TYPE_MANA_REGENERATION] += 40;
|
||||
return true;
|
||||
case 39442: // Darkmoon Card: Wrath
|
||||
if (type_ != CollectorType::SPELL_HEAL)
|
||||
case 39442: // Darkmoon Card: Wrath
|
||||
if (!(type_ & CollectorType::SPELL_HEAL))
|
||||
stats[STATS_TYPE_CRIT] += 50;
|
||||
return true;
|
||||
case 59620: // Berserk
|
||||
if (type_ == CollectorType::MELEE)
|
||||
case 59620: // Berserk
|
||||
if (type_ & CollectorType::MELEE)
|
||||
stats[STATS_TYPE_ATTACK_POWER] += 120;
|
||||
return true;
|
||||
case 67702: // Death's Verdict
|
||||
case 67702: // Death's Verdict
|
||||
stats[STATS_TYPE_ATTACK_POWER] += 225;
|
||||
return true;
|
||||
case 67771: // Death's Verdict (heroic)
|
||||
case 67771: // Death's Verdict (heroic)
|
||||
stats[STATS_TYPE_ATTACK_POWER] += 260;
|
||||
return true;
|
||||
case 71406: // Tiny Abomination in a Jar
|
||||
case 71406: // Tiny Abomination in a Jar
|
||||
if (cls_ == CLASS_PALADIN)
|
||||
stats[STATS_TYPE_ATTACK_POWER] += 600;
|
||||
else
|
||||
stats[STATS_TYPE_ATTACK_POWER] += 150;
|
||||
return true;
|
||||
case 71545: // Tiny Abomination in a Jar (heroic)
|
||||
case 71545: // Tiny Abomination in a Jar (heroic)
|
||||
if (cls_ == CLASS_PALADIN)
|
||||
stats[STATS_TYPE_ATTACK_POWER] += 800;
|
||||
else
|
||||
stats[STATS_TYPE_ATTACK_POWER] += 200;
|
||||
return true;
|
||||
case 71519: // Deathbringer's Will
|
||||
return true;
|
||||
case 71519: // Deathbringer's Will
|
||||
stats[STATS_TYPE_ATTACK_POWER] += 350;
|
||||
return true;
|
||||
case 71562: // Deathbringer's Will (heroic)
|
||||
case 71562: // Deathbringer's Will (heroic)
|
||||
stats[STATS_TYPE_ATTACK_POWER] += 400;
|
||||
return true;
|
||||
case 71602: // Dislodged Foreign Object
|
||||
case 71602: // Dislodged Foreign Object
|
||||
/// @todo The item can be triggered by heal spell, which mismatch with it's description
|
||||
/// Noticing that heroic item can not be triggered, probably a bug to report to AC
|
||||
if (type_ == CollectorType::SPELL_HEAL)
|
||||
if (type_ & CollectorType::SPELL_HEAL)
|
||||
return true;
|
||||
break;
|
||||
case 71903: // Shadowmourne
|
||||
case 71903: // Shadowmourne
|
||||
stats[STATS_TYPE_STRENGTH] += 200;
|
||||
return true;
|
||||
default:
|
||||
@@ -295,26 +320,26 @@ bool StatsCollector::SpecialEnchantFilter(uint32 enchantSpellId)
|
||||
switch (enchantSpellId)
|
||||
{
|
||||
case 64440:
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
{
|
||||
stats[STATS_TYPE_PARRY] += 50;
|
||||
}
|
||||
return true;
|
||||
case 53365: // Rune of the Fallen Crusader
|
||||
if (type_ == CollectorType::MELEE)
|
||||
case 53365: // Rune of the Fallen Crusader
|
||||
if (type_ & CollectorType::MELEE)
|
||||
{
|
||||
stats[STATS_TYPE_STRENGTH] += 75;
|
||||
}
|
||||
return true;
|
||||
case 62157: // Rune of the Stoneskin Gargoyle
|
||||
if (type_ == CollectorType::MELEE)
|
||||
case 62157: // Rune of the Stoneskin Gargoyle
|
||||
if (type_ & CollectorType::MELEE)
|
||||
{
|
||||
stats[STATS_TYPE_DEFENSE] += 25;
|
||||
stats[STATS_TYPE_STAMINA] += 50;
|
||||
}
|
||||
return true;
|
||||
case 64571: // Blood draining
|
||||
if (type_ == CollectorType::MELEE)
|
||||
case 64571: // Blood draining
|
||||
if (type_ & CollectorType::MELEE)
|
||||
{
|
||||
stats[STATS_TYPE_STAMINA] += 50;
|
||||
}
|
||||
@@ -325,18 +350,34 @@ bool StatsCollector::SpecialEnchantFilter(uint32 enchantSpellId)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StatsCollector::CanBeTriggeredByType(SpellInfo const* spellInfo, uint32 procFlags)
|
||||
bool StatsCollector::CanBeTriggeredByType(SpellInfo const* spellInfo, uint32 procFlags, bool strict)
|
||||
{
|
||||
const SpellProcEventEntry* eventEntry = sSpellMgr->GetSpellProcEvent(spellInfo->Id);
|
||||
uint32 spellFamilyName = eventEntry ? eventEntry->spellFamilyName : 0;
|
||||
uint32 spellFamilyName = 0;
|
||||
if (eventEntry)
|
||||
{
|
||||
spellFamilyName = eventEntry->spellFamilyName;
|
||||
flag96 spellFamilyMask = eventEntry->spellFamilyMask;
|
||||
if (spellFamilyName != 0)
|
||||
{
|
||||
if (!CheckSpellValidation(spellFamilyName, spellFamilyMask, strict))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (spellFamilyName != 0)
|
||||
/// @todo Check specific trigger spell by spellFamilyMask
|
||||
return true;
|
||||
|
||||
uint32 triggerMask = TAKEN_HIT_PROC_FLAG_MASK; // Generic trigger mask
|
||||
switch (type_) {
|
||||
case CollectorType::MELEE:
|
||||
uint32 triggerMask = TAKEN_HIT_PROC_FLAG_MASK; // Generic trigger mask
|
||||
switch (type_)
|
||||
{
|
||||
case CollectorType::MELEE_DMG:
|
||||
{
|
||||
triggerMask |= MELEE_PROC_FLAG_MASK;
|
||||
triggerMask |= SPELL_PROC_FLAG_MASK;
|
||||
triggerMask |= PROC_FLAG_DONE_PERIODIC;
|
||||
if (procFlags & triggerMask)
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case CollectorType::MELEE_TANK:
|
||||
{
|
||||
triggerMask |= MELEE_PROC_FLAG_MASK;
|
||||
triggerMask |= SPELL_PROC_FLAG_MASK;
|
||||
@@ -349,7 +390,7 @@ bool StatsCollector::CanBeTriggeredByType(SpellInfo const* spellInfo, uint32 pro
|
||||
{
|
||||
triggerMask |= RANGED_PROC_FLAG_MASK;
|
||||
triggerMask |= SPELL_PROC_FLAG_MASK;
|
||||
triggerMask |= PERIODIC_PROC_FLAG_MASK;
|
||||
triggerMask |= PROC_FLAG_DONE_PERIODIC;
|
||||
if (procFlags & triggerMask)
|
||||
return true;
|
||||
break;
|
||||
@@ -357,6 +398,7 @@ bool StatsCollector::CanBeTriggeredByType(SpellInfo const* spellInfo, uint32 pro
|
||||
case CollectorType::SPELL_DMG:
|
||||
{
|
||||
triggerMask |= SPELL_PROC_FLAG_MASK;
|
||||
triggerMask |= PROC_FLAG_DONE_PERIODIC;
|
||||
// Healing spell cannot trigger
|
||||
triggerMask &= ~PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS;
|
||||
triggerMask &= ~PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS;
|
||||
@@ -367,10 +409,13 @@ bool StatsCollector::CanBeTriggeredByType(SpellInfo const* spellInfo, uint32 pro
|
||||
case CollectorType::SPELL_HEAL:
|
||||
{
|
||||
triggerMask |= SPELL_PROC_FLAG_MASK;
|
||||
triggerMask |= PROC_FLAG_DONE_PERIODIC;
|
||||
// Dmg spell should not trigger
|
||||
triggerMask &= ~PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG;
|
||||
triggerMask &= ~PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG;
|
||||
triggerMask &= ~PROC_FLAG_DONE_PERIODIC; // spellFamilyName = 0 and PROC_FLAG_DONE_PERIODIC -> it is a dmg spell
|
||||
if (!spellFamilyName)
|
||||
triggerMask &=
|
||||
~PROC_FLAG_DONE_PERIODIC; // spellFamilyName = 0 and PROC_FLAG_DONE_PERIODIC -> it is a dmg spell
|
||||
if (procFlags & triggerMask)
|
||||
return true;
|
||||
break;
|
||||
@@ -419,39 +464,39 @@ void StatsCollector::CollectByItemStatType(uint32 itemStatType, int32 val)
|
||||
stats[STATS_TYPE_BLOCK_RATING] += val;
|
||||
break;
|
||||
case ITEM_MOD_HIT_MELEE_RATING:
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
stats[STATS_TYPE_HIT] += val;
|
||||
break;
|
||||
case ITEM_MOD_HIT_RANGED_RATING:
|
||||
if (type_ == CollectorType::RANGED)
|
||||
if (type_ & CollectorType::RANGED)
|
||||
stats[STATS_TYPE_HIT] += val;
|
||||
break;
|
||||
case ITEM_MOD_HIT_SPELL_RATING:
|
||||
if (type_ == CollectorType::SPELL)
|
||||
if (type_ & CollectorType::SPELL)
|
||||
stats[STATS_TYPE_HIT] += val;
|
||||
break;
|
||||
case ITEM_MOD_CRIT_MELEE_RATING:
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
stats[STATS_TYPE_CRIT] += val;
|
||||
break;
|
||||
case ITEM_MOD_CRIT_RANGED_RATING:
|
||||
if (type_ == CollectorType::RANGED)
|
||||
if (type_ & CollectorType::RANGED)
|
||||
stats[STATS_TYPE_CRIT] += val;
|
||||
break;
|
||||
case ITEM_MOD_CRIT_SPELL_RATING:
|
||||
if (type_ == CollectorType::SPELL)
|
||||
if (type_ & CollectorType::SPELL)
|
||||
stats[STATS_TYPE_CRIT] += val;
|
||||
break;
|
||||
case ITEM_MOD_HASTE_MELEE_RATING:
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
stats[STATS_TYPE_HASTE] += val;
|
||||
break;
|
||||
case ITEM_MOD_HASTE_RANGED_RATING:
|
||||
if (type_ == CollectorType::RANGED)
|
||||
if (type_ & CollectorType::RANGED)
|
||||
stats[STATS_TYPE_HASTE] += val;
|
||||
break;
|
||||
case ITEM_MOD_HASTE_SPELL_RATING:
|
||||
if (type_ == CollectorType::SPELL)
|
||||
if (type_ & CollectorType::SPELL)
|
||||
stats[STATS_TYPE_HASTE] += val;
|
||||
break;
|
||||
case ITEM_MOD_HIT_RATING:
|
||||
@@ -502,13 +547,14 @@ void StatsCollector::CollectByItemStatType(uint32 itemStatType, int32 val)
|
||||
}
|
||||
}
|
||||
|
||||
void StatsCollector::HandleApplyAura(const SpellEffectInfo& effectInfo, float multiplier, bool canNextTrigger, uint32 triggerCooldown)
|
||||
void StatsCollector::HandleApplyAura(const SpellEffectInfo& effectInfo, float multiplier, bool canNextTrigger,
|
||||
uint32 triggerCooldown)
|
||||
{
|
||||
if (effectInfo.Effect != SPELL_EFFECT_APPLY_AURA)
|
||||
return;
|
||||
|
||||
|
||||
int32 val = AverageValue(effectInfo);
|
||||
|
||||
|
||||
switch (effectInfo.ApplyAuraName)
|
||||
{
|
||||
case SPELL_AURA_MOD_DAMAGE_DONE:
|
||||
@@ -534,11 +580,11 @@ void StatsCollector::HandleApplyAura(const SpellEffectInfo& effectInfo, float mu
|
||||
break;
|
||||
}
|
||||
case SPELL_AURA_MOD_ATTACK_POWER:
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
stats[STATS_TYPE_ATTACK_POWER] += val * multiplier;
|
||||
break;
|
||||
case SPELL_AURA_MOD_RANGED_ATTACK_POWER:
|
||||
if (type_ == CollectorType::RANGED)
|
||||
if (type_ & CollectorType::RANGED)
|
||||
stats[STATS_TYPE_ATTACK_POWER] += val * multiplier;
|
||||
break;
|
||||
case SPELL_AURA_MOD_SHIELD_BLOCKVALUE:
|
||||
@@ -564,7 +610,7 @@ void StatsCollector::HandleApplyAura(const SpellEffectInfo& effectInfo, float mu
|
||||
case STAT_SPIRIT:
|
||||
stats[STATS_TYPE_SPIRIT] += val * multiplier;
|
||||
break;
|
||||
case -1: // Stat all
|
||||
case -1: // Stat all
|
||||
stats[STATS_TYPE_STRENGTH] += val * multiplier;
|
||||
stats[STATS_TYPE_AGILITY] += val * multiplier;
|
||||
stats[STATS_TYPE_STAMINA] += val * multiplier;
|
||||
@@ -579,7 +625,7 @@ void StatsCollector::HandleApplyAura(const SpellEffectInfo& effectInfo, float mu
|
||||
case SPELL_AURA_MOD_RESISTANCE:
|
||||
{
|
||||
int32 statType = effectInfo.MiscValue;
|
||||
if (statType & SPELL_SCHOOL_MASK_NORMAL) // physical
|
||||
if (statType & SPELL_SCHOOL_MASK_NORMAL) // physical
|
||||
stats[STATS_TYPE_ARMOR] += val * multiplier;
|
||||
break;
|
||||
}
|
||||
@@ -604,39 +650,39 @@ void StatsCollector::HandleApplyAura(const SpellEffectInfo& effectInfo, float mu
|
||||
stats[STATS_TYPE_BLOCK_RATING] += val * multiplier;
|
||||
break;
|
||||
case CR_HIT_MELEE:
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
stats[STATS_TYPE_HIT] += val * multiplier;
|
||||
break;
|
||||
case CR_HIT_RANGED:
|
||||
if (type_ == CollectorType::RANGED)
|
||||
if (type_ & CollectorType::RANGED)
|
||||
stats[STATS_TYPE_HIT] += val * multiplier;
|
||||
break;
|
||||
case CR_HIT_SPELL:
|
||||
if (type_ == CollectorType::SPELL)
|
||||
if (type_ & CollectorType::SPELL)
|
||||
stats[STATS_TYPE_HIT] += val * multiplier;
|
||||
break;
|
||||
case CR_CRIT_MELEE:
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
stats[STATS_TYPE_CRIT] += val * multiplier;
|
||||
break;
|
||||
case CR_CRIT_RANGED:
|
||||
if (type_ == CollectorType::RANGED)
|
||||
if (type_ & CollectorType::RANGED)
|
||||
stats[STATS_TYPE_CRIT] += val * multiplier;
|
||||
break;
|
||||
case CR_CRIT_SPELL:
|
||||
if (type_ == CollectorType::SPELL)
|
||||
if (type_ & CollectorType::SPELL)
|
||||
stats[STATS_TYPE_CRIT] += val * multiplier;
|
||||
break;
|
||||
case CR_HASTE_MELEE:
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
stats[STATS_TYPE_HASTE] += val * multiplier;
|
||||
break;
|
||||
case CR_HASTE_RANGED:
|
||||
if (type_ == CollectorType::RANGED)
|
||||
if (type_ & CollectorType::RANGED)
|
||||
stats[STATS_TYPE_HASTE] += val * multiplier;
|
||||
break;
|
||||
case CR_HASTE_SPELL:
|
||||
if (type_ == CollectorType::SPELL)
|
||||
if (type_ & CollectorType::SPELL)
|
||||
stats[STATS_TYPE_HASTE] += val * multiplier;
|
||||
break;
|
||||
case CR_EXPERTISE:
|
||||
@@ -675,12 +721,18 @@ void StatsCollector::HandleApplyAura(const SpellEffectInfo& effectInfo, float mu
|
||||
CollectSpellStats(effectInfo.TriggerSpell, multiplier, triggerCooldown);
|
||||
break;
|
||||
}
|
||||
case SPELL_AURA_ADD_TARGET_TRIGGER:
|
||||
{
|
||||
if (canNextTrigger)
|
||||
CollectSpellStats(effectInfo.TriggerSpell, multiplier, triggerCooldown);
|
||||
break;
|
||||
}
|
||||
case SPELL_AURA_MOD_CRIT_DAMAGE_BONUS:
|
||||
{
|
||||
if (type_ != CollectorType::SPELL_HEAL)
|
||||
{
|
||||
int32 statType = effectInfo.MiscValue;
|
||||
if (statType & SPELL_SCHOOL_MASK_NORMAL) // physical
|
||||
if (statType & SPELL_SCHOOL_MASK_NORMAL) // physical
|
||||
stats[STATS_TYPE_CRIT] += 30 * val * multiplier;
|
||||
}
|
||||
break;
|
||||
@@ -709,4 +761,73 @@ int32 StatsCollector::AverageValue(const SpellEffectInfo& effectInfo)
|
||||
break;
|
||||
}
|
||||
return basePoints;
|
||||
}
|
||||
|
||||
bool StatsCollector::CheckSpellValidation(uint32 spellFamilyName, flag96 spelFalimyFlags, bool strict)
|
||||
{
|
||||
if (PlayerbotAI::Class2SpellFamilyName(cls_) != spellFamilyName)
|
||||
return false;
|
||||
|
||||
bool isHealingSpell = PlayerbotAI::IsHealingSpell(spellFamilyName, spelFalimyFlags);
|
||||
// strict to healer
|
||||
if (strict && (type_ & CollectorType::SPELL_HEAL))
|
||||
{
|
||||
return isHealingSpell;
|
||||
}
|
||||
|
||||
if (!(type_ & CollectorType::SPELL_HEAL) && isHealingSpell)
|
||||
return false;
|
||||
|
||||
// spells for caster/melee/tank are ambiguous
|
||||
if (cls_ == CLASS_DRUID && spellFamilyName == SPELLFAMILY_DRUID && (type_ & CollectorType::MELEE))
|
||||
{
|
||||
uint32 castingFlagsA = 0x4 | 0x2 | 0x1 | 0x200000; // starfire | moonfire | wrath | insect swarm
|
||||
uint32 castingFlagsB = 0x0;
|
||||
uint32 castingFlagsC = 0x0;
|
||||
flag96 invalidFlags = {castingFlagsA, castingFlagsB, castingFlagsC};
|
||||
if (spelFalimyFlags & invalidFlags)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cls_ == CLASS_PALADIN && spellFamilyName == SPELLFAMILY_PALADIN && (type_ & CollectorType::MELEE_TANK))
|
||||
{
|
||||
uint32 retributionFlagsA = 0x0;
|
||||
uint32 retributionFlagsB = 0x8000; // crusader strike
|
||||
uint32 retributionFlagsC = 0x0;
|
||||
flag96 invalidFlags = {retributionFlagsA, retributionFlagsB, retributionFlagsC};
|
||||
if (spelFalimyFlags & invalidFlags)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cls_ == CLASS_PALADIN && spellFamilyName == SPELLFAMILY_PALADIN && (type_ & CollectorType::MELEE_DMG))
|
||||
{
|
||||
uint32 retributionFlagsA = 0x0;
|
||||
uint32 retributionFlagsB = 0x100000; // shield of righteouness
|
||||
uint32 retributionFlagsC = 0x0;
|
||||
flag96 invalidFlags = {retributionFlagsA, retributionFlagsB, retributionFlagsC};
|
||||
if (spelFalimyFlags & invalidFlags)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cls_ == CLASS_SHAMAN && spellFamilyName == SPELLFAMILY_SHAMAN && (type_ & CollectorType::SPELL_DMG))
|
||||
{
|
||||
uint32 meleeFlagsA = 0x0;
|
||||
uint32 meleeFlagsB = 0x1000010; // stromstrike
|
||||
uint32 meleeFlagsC = 0x4; // lava lash
|
||||
flag96 invalidFlags = {meleeFlagsA, meleeFlagsB, meleeFlagsC};
|
||||
if (spelFalimyFlags & invalidFlags)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cls_ == CLASS_SHAMAN && spellFamilyName == SPELLFAMILY_SHAMAN && (type_ & CollectorType::MELEE_DMG))
|
||||
{
|
||||
uint32 casterFlagsA = 0x0;
|
||||
uint32 casterFlagsB = 0x1000; // lava burst
|
||||
uint32 casterFlagsC = 0x0;
|
||||
flag96 invalidFlags = {casterFlagsA, casterFlagsB, casterFlagsC};
|
||||
if (spelFalimyFlags & invalidFlags)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -42,15 +42,19 @@ enum StatsType : uint8
|
||||
// Stats for weapon dps
|
||||
STATS_TYPE_MELEE_DPS,
|
||||
STATS_TYPE_RANGED_DPS,
|
||||
STATS_TYPE_MAX = 25
|
||||
// Bonus for unrecognized stats
|
||||
STATS_TYPE_BONUS,
|
||||
STATS_TYPE_MAX = 26
|
||||
};
|
||||
|
||||
enum CollectorType : uint8
|
||||
{
|
||||
MELEE = 1,
|
||||
RANGED = 2,
|
||||
SPELL_DMG = 4,
|
||||
SPELL_HEAL = 8,
|
||||
MELEE_DMG = 1,
|
||||
MELEE_TANK = 2,
|
||||
RANGED = 4,
|
||||
SPELL_DMG = 8,
|
||||
SPELL_HEAL = 16,
|
||||
MELEE = MELEE_DMG | MELEE_TANK,
|
||||
SPELL = SPELL_DMG | SPELL_HEAL
|
||||
};
|
||||
|
||||
@@ -63,19 +67,21 @@ public:
|
||||
void CollectItemStats(ItemTemplate const* proto);
|
||||
void CollectSpellStats(uint32 spellId, float multiplier = 1.0f, int32 spellCooldown = -1);
|
||||
void CollectEnchantStats(SpellItemEnchantmentEntry const* enchant);
|
||||
bool CanBeTriggeredByType(SpellInfo const* spellInfo, uint32 procFlags, bool strict = true);
|
||||
bool CheckSpellValidation(uint32 spellFamilyName, flag96 spelFalimyFlags, bool strict = true);
|
||||
|
||||
public:
|
||||
int32 stats[STATS_TYPE_MAX];
|
||||
|
||||
private:
|
||||
bool CanBeTriggeredByType(SpellInfo const* spellInfo, uint32 procFlags);
|
||||
void CollectByItemStatType(uint32 itemStatType, int32 val);
|
||||
bool SpecialSpellFilter(uint32 spellId);
|
||||
bool SpecialEnchantFilter(uint32 enchantSpellId);
|
||||
|
||||
void HandleApplyAura(const SpellEffectInfo& effectInfo, float multiplier, bool canNextTrigger, uint32 triggerCooldown);
|
||||
void HandleApplyAura(const SpellEffectInfo& effectInfo, float multiplier, bool canNextTrigger,
|
||||
uint32 triggerCooldown);
|
||||
int32 AverageValue(const SpellEffectInfo& effectInfo);
|
||||
|
||||
|
||||
private:
|
||||
CollectorType type_;
|
||||
uint32 cls_;
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "PlayerbotAI.h"
|
||||
#include "PlayerbotFactory.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "SpellAuraDefines.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "StatsCollector.h"
|
||||
#include "Unit.h"
|
||||
|
||||
@@ -23,15 +25,16 @@ StatsWeightCalculator::StatsWeightCalculator(Player* player) : player_(player)
|
||||
type_ = CollectorType::SPELL_HEAL;
|
||||
else if (PlayerbotAI::IsCaster(player))
|
||||
type_ = CollectorType::SPELL_DMG;
|
||||
else if (PlayerbotAI::IsTank(player))
|
||||
type_ = CollectorType::MELEE_TANK;
|
||||
else if (PlayerbotAI::IsMelee(player))
|
||||
type_ = CollectorType::MELEE;
|
||||
type_ = CollectorType::MELEE_DMG;
|
||||
else
|
||||
type_ = CollectorType::RANGED;
|
||||
cls = player->getClass();
|
||||
tab = AiFactory::GetPlayerSpecTab(player);
|
||||
collector_ = std::make_unique<StatsCollector>(type_, cls);
|
||||
|
||||
|
||||
if (cls == CLASS_DEATH_KNIGHT && tab == DEATHKNIGHT_TAB_UNHOLY)
|
||||
hitOverflowType_ = CollectorType::SPELL;
|
||||
else if (cls == CLASS_SHAMAN && tab == SHAMAN_TAB_ENHANCEMENT)
|
||||
@@ -79,7 +82,7 @@ float StatsWeightCalculator::CalculateItem(uint32 itemId)
|
||||
CalculateItemTypePenalty(proto);
|
||||
|
||||
if (enable_item_set_bonus_)
|
||||
CalculateItemSetBonus(player_, proto);
|
||||
CalculateItemSetMod(player_, proto);
|
||||
|
||||
CalculateSocketBonus(player_, proto);
|
||||
|
||||
@@ -125,6 +128,7 @@ void StatsWeightCalculator::GenerateBasicWeights(Player* player)
|
||||
// Basic weights
|
||||
stats_weights_[STATS_TYPE_STAMINA] += 0.01f;
|
||||
stats_weights_[STATS_TYPE_ARMOR] += 0.001f;
|
||||
stats_weights_[STATS_TYPE_BONUS] += 1.0f;
|
||||
|
||||
if (cls == CLASS_HUNTER && (tab == HUNTER_TAB_BEASTMASTER || tab == HUNTER_TAB_SURVIVAL))
|
||||
{
|
||||
@@ -259,8 +263,8 @@ void StatsWeightCalculator::GenerateBasicWeights(Player* player)
|
||||
stats_weights_[STATS_TYPE_MELEE_DPS] += 8.5f;
|
||||
}
|
||||
else if (cls == CLASS_WARLOCK || (cls == CLASS_MAGE && tab != MAGE_TAB_FIRE) ||
|
||||
(cls == CLASS_PRIEST && tab == PRIEST_TAB_SHADOW) || // shadow
|
||||
(cls == CLASS_DRUID && tab == DRUID_TAB_BALANCE)) // balance
|
||||
(cls == CLASS_PRIEST && tab == PRIEST_TAB_SHADOW) || // shadow
|
||||
(cls == CLASS_DRUID && tab == DRUID_TAB_BALANCE)) // balance
|
||||
{
|
||||
stats_weights_[STATS_TYPE_INTELLECT] += 0.3f;
|
||||
stats_weights_[STATS_TYPE_SPIRIT] += 0.6f;
|
||||
@@ -311,7 +315,7 @@ void StatsWeightCalculator::GenerateBasicWeights(Player* player)
|
||||
stats_weights_[STATS_TYPE_DEFENSE] += 2.5f;
|
||||
stats_weights_[STATS_TYPE_PARRY] += 2.0f;
|
||||
stats_weights_[STATS_TYPE_DODGE] += 2.0f;
|
||||
stats_weights_[STATS_TYPE_RESILIENCE] += 2.0f;
|
||||
// stats_weights_[STATS_TYPE_RESILIENCE] += 2.0f;
|
||||
stats_weights_[STATS_TYPE_BLOCK_RATING] += 1.0f;
|
||||
stats_weights_[STATS_TYPE_BLOCK_VALUE] += 0.5f;
|
||||
stats_weights_[STATS_TYPE_ARMOR] += 0.15f;
|
||||
@@ -330,7 +334,7 @@ void StatsWeightCalculator::GenerateBasicWeights(Player* player)
|
||||
stats_weights_[STATS_TYPE_DEFENSE] += 3.5f;
|
||||
stats_weights_[STATS_TYPE_PARRY] += 2.0f;
|
||||
stats_weights_[STATS_TYPE_DODGE] += 2.0f;
|
||||
stats_weights_[STATS_TYPE_RESILIENCE] += 2.0f;
|
||||
// stats_weights_[STATS_TYPE_RESILIENCE] += 2.0f;
|
||||
stats_weights_[STATS_TYPE_ARMOR] += 0.15f;
|
||||
stats_weights_[STATS_TYPE_HIT] += 2.0f;
|
||||
stats_weights_[STATS_TYPE_CRIT] += 0.5f;
|
||||
@@ -347,7 +351,7 @@ void StatsWeightCalculator::GenerateBasicWeights(Player* player)
|
||||
stats_weights_[STATS_TYPE_ATTACK_POWER] += 1.0f;
|
||||
stats_weights_[STATS_TYPE_DEFENSE] += 0.3f;
|
||||
stats_weights_[STATS_TYPE_DODGE] += 0.7f;
|
||||
stats_weights_[STATS_TYPE_RESILIENCE] += 1.0f;
|
||||
// stats_weights_[STATS_TYPE_RESILIENCE] += 1.0f;
|
||||
stats_weights_[STATS_TYPE_ARMOR] += 0.15f;
|
||||
stats_weights_[STATS_TYPE_HIT] += 3.0f;
|
||||
stats_weights_[STATS_TYPE_CRIT] += 1.3f;
|
||||
@@ -380,7 +384,7 @@ void StatsWeightCalculator::GenerateAdditionalWeights(Player* player)
|
||||
}
|
||||
}
|
||||
|
||||
void StatsWeightCalculator::CalculateItemSetBonus(Player* player, ItemTemplate const* proto)
|
||||
void StatsWeightCalculator::CalculateItemSetMod(Player* player, ItemTemplate const* proto)
|
||||
{
|
||||
uint32 itemSet = proto->ItemSet;
|
||||
if (!itemSet)
|
||||
@@ -466,7 +470,7 @@ void StatsWeightCalculator::CalculateItemTypePenalty(ItemTemplate const* proto)
|
||||
// enhancement, rogue, ice dk, unholy dk, shield tank, fury warrior without titan's grip but with duel wield
|
||||
if (isDoubleHand &&
|
||||
((cls == CLASS_SHAMAN && tab == SHAMAN_TAB_ENHANCEMENT && player_->CanDualWield()) ||
|
||||
(cls == CLASS_ROGUE) || (cls == CLASS_DEATH_KNIGHT && tab != DEATHKNIGHT_TAB_BLOOD) ||
|
||||
(cls == CLASS_ROGUE) || (cls == CLASS_DEATH_KNIGHT && tab == DEATHKNIGHT_TAB_FROST) ||
|
||||
(cls == CLASS_WARRIOR && tab == WARRIOR_TAB_FURY && !player_->CanTitanGrip() && player_->CanDualWield()) ||
|
||||
(cls == CLASS_WARRIOR && tab == WARRIOR_TAB_PROTECTION) ||
|
||||
(cls == CLASS_PALADIN && tab == PALADIN_TAB_PROTECTION)))
|
||||
@@ -486,14 +490,12 @@ void StatsWeightCalculator::CalculateItemTypePenalty(ItemTemplate const* proto)
|
||||
weight_ *= 0.1;
|
||||
}
|
||||
// fury with titan's grip
|
||||
if ((!isDoubleHand || proto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || proto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF) &&
|
||||
if ((!isDoubleHand || proto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM ||
|
||||
proto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF) &&
|
||||
(cls == CLASS_WARRIOR && tab == WARRIOR_TAB_FURY && player_->CanTitanGrip()))
|
||||
{
|
||||
weight_ *= 0.1;
|
||||
}
|
||||
}
|
||||
if (proto->Class == ITEM_CLASS_WEAPON)
|
||||
{
|
||||
if (cls == CLASS_HUNTER && proto->SubClass == ITEM_SUBCLASS_WEAPON_THROWN)
|
||||
{
|
||||
weight_ *= 0.1;
|
||||
@@ -512,6 +514,10 @@ void StatsWeightCalculator::CalculateItemTypePenalty(ItemTemplate const* proto)
|
||||
{
|
||||
weight_ *= 1.1;
|
||||
}
|
||||
if (cls == CLASS_DEATH_KNIGHT && player_->HasAura(50138) && !isDoubleHand)
|
||||
{
|
||||
weight_ *= 1.3;
|
||||
}
|
||||
bool slowDelay = proto->Delay > 2500;
|
||||
if (cls == CLASS_SHAMAN && tab == SHAMAN_TAB_ENHANCEMENT && slowDelay)
|
||||
weight_ *= 1.1;
|
||||
@@ -540,11 +546,10 @@ void StatsWeightCalculator::ApplyOverflowPenalty(Player* player)
|
||||
{
|
||||
float hit_current, hit_overflow;
|
||||
float validPoints;
|
||||
// m_modMeleeHitChance = (float)GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE);
|
||||
// m_modMeleeHitChance += GetRatingBonusValue(CR_HIT_MELEE);
|
||||
if (hitOverflowType_ == CollectorType::SPELL)
|
||||
if (hitOverflowType_ & CollectorType::SPELL)
|
||||
{
|
||||
hit_current = player->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE);
|
||||
hit_current += player->GetTotalAuraModifier(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT); // suppression (18176)
|
||||
hit_current += player->GetRatingBonusValue(CR_HIT_SPELL);
|
||||
hit_overflow = SPELL_HIT_OVERFLOW;
|
||||
if (hit_overflow > hit_current)
|
||||
@@ -552,7 +557,7 @@ void StatsWeightCalculator::ApplyOverflowPenalty(Player* player)
|
||||
else
|
||||
validPoints = 0;
|
||||
}
|
||||
else if (hitOverflowType_ == CollectorType::MELEE)
|
||||
else if (hitOverflowType_ & CollectorType::MELEE)
|
||||
{
|
||||
hit_current = player->GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE);
|
||||
hit_current += player->GetRatingBonusValue(CR_HIT_MELEE);
|
||||
@@ -576,7 +581,7 @@ void StatsWeightCalculator::ApplyOverflowPenalty(Player* player)
|
||||
}
|
||||
|
||||
{
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
{
|
||||
float expertise_current, expertise_overflow;
|
||||
expertise_current = player->GetUInt32Value(PLAYER_EXPERTISE);
|
||||
@@ -589,12 +594,13 @@ void StatsWeightCalculator::ApplyOverflowPenalty(Player* player)
|
||||
else
|
||||
validPoints = 0;
|
||||
|
||||
collector_->stats[STATS_TYPE_EXPERTISE] = std::min(collector_->stats[STATS_TYPE_EXPERTISE], (int)validPoints);
|
||||
collector_->stats[STATS_TYPE_EXPERTISE] =
|
||||
std::min(collector_->stats[STATS_TYPE_EXPERTISE], (int)validPoints);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if (type_ == CollectorType::MELEE)
|
||||
if (type_ & CollectorType::MELEE)
|
||||
{
|
||||
float defense_current, defense_overflow;
|
||||
defense_current = player->GetRatingBonusValue(CR_DEFENSE_SKILL);
|
||||
@@ -611,7 +617,7 @@ void StatsWeightCalculator::ApplyOverflowPenalty(Player* player)
|
||||
}
|
||||
|
||||
{
|
||||
if (type_ == CollectorType::MELEE || type_ == CollectorType::RANGED)
|
||||
if (type_ & (CollectorType::MELEE | CollectorType::RANGED))
|
||||
{
|
||||
float armor_penetration_current, armor_penetration_overflow;
|
||||
armor_penetration_current = player->GetRatingBonusValue(CR_ARMOR_PENETRATION);
|
||||
@@ -619,11 +625,13 @@ void StatsWeightCalculator::ApplyOverflowPenalty(Player* player)
|
||||
|
||||
float validPoints;
|
||||
if (armor_penetration_overflow > armor_penetration_current)
|
||||
validPoints = (armor_penetration_overflow - armor_penetration_current) / player->GetRatingMultiplier(CR_ARMOR_PENETRATION);
|
||||
validPoints = (armor_penetration_overflow - armor_penetration_current) /
|
||||
player->GetRatingMultiplier(CR_ARMOR_PENETRATION);
|
||||
else
|
||||
validPoints = 0;
|
||||
|
||||
collector_->stats[STATS_TYPE_ARMOR_PENETRATION] = std::min(collector_->stats[STATS_TYPE_ARMOR_PENETRATION], (int)validPoints);
|
||||
collector_->stats[STATS_TYPE_ARMOR_PENETRATION] =
|
||||
std::min(collector_->stats[STATS_TYPE_ARMOR_PENETRATION], (int)validPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -631,7 +639,7 @@ void StatsWeightCalculator::ApplyOverflowPenalty(Player* player)
|
||||
void StatsWeightCalculator::ApplyWeightFinetune(Player* player)
|
||||
{
|
||||
{
|
||||
if (type_ == CollectorType::MELEE || type_ == CollectorType::RANGED)
|
||||
if (type_ & (CollectorType::MELEE | CollectorType::RANGED))
|
||||
{
|
||||
float armor_penetration_current, armor_penetration_overflow;
|
||||
armor_penetration_current = player->GetRatingBonusValue(CR_ARMOR_PENETRATION);
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
void GenerateBasicWeights(Player* player);
|
||||
void GenerateAdditionalWeights(Player* player);
|
||||
|
||||
void CalculateItemSetBonus(Player* player, ItemTemplate const* proto);
|
||||
void CalculateItemSetMod(Player* player, ItemTemplate const* proto);
|
||||
void CalculateSocketBonus(Player* player, ItemTemplate const* proto);
|
||||
|
||||
void CalculateItemTypePenalty(ItemTemplate const* proto);
|
||||
|
||||
Reference in New Issue
Block a user