aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-03-08 13:31:57 +0100
committerShauren <shauren.trinity@gmail.com>2015-03-08 13:31:57 +0100
commit0ba2e0d5ee416a2daf89d53877984fb0cf27ca9b (patch)
tree0cb086bb038bf7d3164b9c25dab9ecd1bf93cad6 /src/server/game/Entities
parent9ffeb58d094ddba9bffb33a79b33ade9af9f5c00 (diff)
Core/Spells: Implemented multiple spell power costs
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp15
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.h2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp39
3 files changed, 44 insertions, 12 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 096b4b749be..f5c7b42292e 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -1721,8 +1721,12 @@ SpellInfo const* Creature::reachWithSpellAttack(Unit* victim)
if (bcontinue)
continue;
- if (spellInfo->ManaCost > (uint32)GetPower(POWER_MANA))
- continue;
+ std::vector<SpellInfo::CostData> costs = spellInfo->CalcPowerCost(this, SpellSchoolMask(spellInfo->SchoolMask));
+ auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; });
+ if (m != costs.end())
+ if (m->Amount > (uint32)GetPower(POWER_MANA))
+ continue;
+
float range = spellInfo->GetMaxRange(false);
float minrange = spellInfo->GetMinRange(false);
float dist = GetDistance(victim);
@@ -1765,8 +1769,11 @@ SpellInfo const* Creature::reachWithSpellCure(Unit* victim)
if (bcontinue)
continue;
- if (spellInfo->ManaCost > (uint32)GetPower(POWER_MANA))
- continue;
+ std::vector<SpellInfo::CostData> costs = spellInfo->CalcPowerCost(this, SpellSchoolMask(spellInfo->SchoolMask));
+ auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; });
+ if (m != costs.end())
+ if (m->Amount > (uint32)GetPower(POWER_MANA))
+ continue;
float range = spellInfo->GetMaxRange(true);
float minrange = spellInfo->GetMinRange(true);
diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h
index a73d570d0e7..b4b08d7ace2 100644
--- a/src/server/game/Entities/Object/ObjectGuid.h
+++ b/src/server/game/Entities/Object/ObjectGuid.h
@@ -162,7 +162,7 @@ class ObjectGuid
return UI64LIT(0xFFFFFFFFFF);
}
- uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); }
+ LowType GetMaxCounter() const { return GetMaxCounter(GetHigh()); }
uint8& operator[](uint32 index)
{
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 88de4a88bfc..caeac1c73ea 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -5491,7 +5491,12 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
case 28719:
{
// mana back
- basepoints0 = int32(CalculatePct(procSpell->ManaCost, 30));
+ std::vector<SpellInfo::CostData> costs = procSpell->CalcPowerCost(this, procSpell->GetSchoolMask());
+ auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; });
+ if (m == costs.end())
+ return false;
+
+ basepoints0 = int32(CalculatePct(m->Amount, 30));
target = this;
triggered_spell_id = 28742;
break;
@@ -6712,7 +6717,12 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
// Enlightenment (trigger only from mana cost spells)
case 35095:
{
- if (!procSpell || procSpell->PowerType != POWER_MANA || (procSpell->ManaCost == 0 && procSpell->ManaCostPercentage == 0 && procSpell->ManaCostPerlevel == 0))
+ if (!procSpell)
+ return false;
+
+ std::vector<SpellInfo::CostData> costs = procSpell->CalcPowerCost(this, procSpell->GetSchoolMask());
+ auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA && cost.Amount > 0; });
+ if (m == costs.end())
return false;
break;
}
@@ -11510,16 +11520,28 @@ int32 Unit::GetCreatePowers(Powers power) const
return (GetTypeId() == TYPEID_PLAYER || !((Creature const*)this)->IsPet() || ((Pet const*)this)->getPetType() != HUNTER_PET ? 0 : 100);
case POWER_ENERGY:
return 100;
+ case POWER_COMBO_POINTS:
+ return 5;
case POWER_RUNIC_POWER:
return 1000;
case POWER_RUNES:
return 0;
case POWER_SOUL_SHARDS:
- return 3;
+ return 400;
case POWER_ECLIPSE:
return 100;
case POWER_HOLY_POWER:
return 3;
+ case POWER_CHI:
+ return 4;
+ case POWER_SHADOW_ORBS:
+ return 3;
+ case POWER_BURNING_EMBERS:
+ return 40;
+ case POWER_DEMONIC_FURY:
+ return 1000;
+ case POWER_ARCANE_CHARGES:
+ return 4;
case POWER_HEALTH:
return 0;
default:
@@ -12322,10 +12344,13 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
case SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT:
case SPELL_AURA_MOD_POWER_COST_SCHOOL:
// Skip melee hits and spells ws wrong school or zero cost
- if (procSpell &&
- (procSpell->ManaCost != 0 || procSpell->ManaCostPercentage != 0) && // Cost check
- (triggeredByAura->GetMiscValue() & procSpell->SchoolMask)) // School check
- takeCharges = true;
+ if (procSpell && (triggeredByAura->GetMiscValue() & procSpell->SchoolMask)) // School check
+ {
+ std::vector<SpellInfo::CostData> costs = procSpell->CalcPowerCost(this, procSpell->GetSchoolMask());
+ auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Amount > 0; });
+ if (m != costs.end())
+ takeCharges = true;
+ }
break;
case SPELL_AURA_MECHANIC_IMMUNITY:
// Compare mechanic