aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjoschiwald <joschiwald@online.de>2014-01-26 01:02:20 +0100
committerjoschiwald <joschiwald@online.de>2014-01-26 01:02:20 +0100
commit96060bf0078441e779c4cfcaa80f66ac5e97a3ff (patch)
tree534c908bea32b02ac918eab1264e750851da4708 /src
parent3c0b906a864911ca1ce41e13ce0fc776952f478c (diff)
Core/Spells: move some spells so spellscripts
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp38
-rw-r--r--src/server/game/Entities/Unit/Unit.h24
-rw-r--r--src/server/game/Spells/Spell.cpp81
-rw-r--r--src/server/scripts/Spells/spell_druid.cpp60
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp57
-rw-r--r--src/server/scripts/Spells/spell_rogue.cpp5
-rw-r--r--src/server/scripts/Spells/spell_warrior.cpp98
7 files changed, 260 insertions, 103 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index e7e29fe2588..cc0b338de3f 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -5668,17 +5668,6 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
break;
}
}
-
- // Retaliation
- if (dummySpell->SpellFamilyFlags[1] & 0x8)
- {
- // check attack comes not from behind
- if (!HasInArc(M_PI, victim) || HasUnitState(UNIT_STATE_STUNNED))
- return false;
-
- triggered_spell_id = 22858;
- break;
- }
// Second Wind
if (dummySpell->SpellIconID == 1697)
{
@@ -5708,19 +5697,6 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
triggered_spell_id = 58374;
break;
}
- // Glyph of Sunder Armor
- if (dummySpell->Id == 58387)
- {
- if (!victim || !victim->IsAlive() || !procSpell)
- return false;
-
- target = SelectNearbyTarget(victim);
- if (!target)
- return false;
-
- triggered_spell_id = 58567;
- break;
- }
break;
}
case SPELLFAMILY_WARLOCK:
@@ -9365,9 +9341,7 @@ void Unit::SetMinion(Minion *minion, bool apply)
}
if (minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
- {
SetCritterGUID(minion->GetGUID());
- }
// PvP, FFAPvP
minion->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1));
@@ -13274,12 +13248,14 @@ void Unit::SetLevel(uint8 lvl)
{
SetUInt32Value(UNIT_FIELD_LEVEL, lvl);
- // group update
- if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetGroup())
- ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL);
+ if (Player* player = ToPlayer())
+ {
+ // group update
+ if (player->GetGroup())
+ player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL);
- if (GetTypeId() == TYPEID_PLAYER)
- sWorld->UpdateCharacterNameDataLevel(ToPlayer()->GetGUIDLow(), lvl);
+ sWorld->UpdateCharacterNameDataLevel(GetGUIDLow(), lvl);
+ }
}
void Unit::SetHealth(uint32 val)
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index bae10abe85b..41b181e54f8 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -2261,12 +2261,23 @@ namespace Trinity
{
public:
PowerPctOrderPred(Powers power, bool ascending = true) : _power(power), _ascending(ascending) { }
- bool operator() (Unit const* a, Unit const* b) const
+
+ bool operator()(WorldObject const* objA, WorldObject const* objB) const
+ {
+ Unit const* a = objA->ToUnit();
+ Unit const* b = objB->ToUnit();
+ float rA = (a && a->GetMaxPower(_power)) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
+ float rB = (b && b->GetMaxPower(_power)) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
+ return _ascending ? rA < rB : rA > rB;
+ }
+
+ bool operator()(Unit const* a, Unit const* b) const
{
float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
return _ascending ? rA < rB : rA > rB;
}
+
private:
Powers const _power;
bool const _ascending;
@@ -2277,12 +2288,23 @@ namespace Trinity
{
public:
HealthPctOrderPred(bool ascending = true) : _ascending(ascending) { }
+
+ bool operator()(WorldObject const* objA, WorldObject const* objB) const
+ {
+ Unit const* a = objA->ToUnit();
+ Unit const* b = objB->ToUnit();
+ float rA = (a && a->GetMaxHealth()) ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
+ float rB = (b && b->GetMaxHealth()) ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
+ return _ascending ? rA < rB : rA > rB;
+ }
+
bool operator() (Unit const* a, Unit const* b) const
{
float rA = a->GetMaxHealth() ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
float rB = b->GetMaxHealth() ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
return _ascending ? rA < rB : rA > rB;
}
+
private:
bool const _ascending;
};
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 08e0323b491..3c2e06bb631 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -1276,17 +1276,6 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
maxSize = m_spellInfo->MaxAffectedTargets;
power = POWER_HEALTH;
break;
- case 57669: // Replenishment
- // In arenas Replenishment may only affect the caster
- if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->ToPlayer()->InArena())
- {
- unitTargets.clear();
- unitTargets.push_back(m_caster);
- break;
- }
- maxSize = 10;
- power = POWER_MANA;
- break;
default:
break;
}
@@ -1319,22 +1308,6 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
++itr;
}
break;
- case SPELLFAMILY_DRUID:
- if (m_spellInfo->SpellFamilyFlags[1] == 0x04000000) // Wild Growth
- {
- maxSize = m_caster->HasAura(62970) ? 6 : 5; // Glyph of Wild Growth
- power = POWER_HEALTH;
- }
- else
- break;
-
- // Remove targets outside caster's raid
- for (std::list<Unit*>::iterator itr = unitTargets.begin(); itr != unitTargets.end();)
- if (!(*itr)->IsInRaidWith(m_caster))
- itr = unitTargets.erase(itr);
- else
- ++itr;
- break;
default:
break;
}
@@ -1427,33 +1400,33 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
break;
case TARGET_DEST_CASTER_FISHING:
{
- float min_dis = m_spellInfo->GetMinRange(true);
- float max_dis = m_spellInfo->GetMaxRange(true);
- float dis = (float)rand_norm() * (max_dis - min_dis) + min_dis;
- float x, y, z, angle;
- angle = (float)rand_norm() * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
- m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE, dis, angle);
-
- float ground = z;
- float liquidLevel = m_caster->GetMap()->GetWaterOrGroundLevel(x, y, z, &ground);
- if (liquidLevel <= ground) // When there is no liquid Map::GetWaterOrGroundLevel returns ground level
- {
- SendCastResult(SPELL_FAILED_NOT_HERE);
- SendChannelUpdate(0);
- finish(false);
- return;
- }
-
- if (ground + 0.75 > liquidLevel)
- {
- SendCastResult(SPELL_FAILED_TOO_SHALLOW);
- SendChannelUpdate(0);
- finish(false);
- return;
- }
-
- dest = SpellDestination(x, y, liquidLevel, m_caster->GetOrientation());
- break;
+ float minDist = m_spellInfo->GetMinRange(true);
+ float maxDist = m_spellInfo->GetMaxRange(true);
+ float dist = frand(minDist, maxDist);
+ float x, y, z, angle;
+ float angle = float(rand_norm()) * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
+ m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE, dis, angle);
+
+ float ground = z;
+ float liquidLevel = m_caster->GetMap()->GetWaterOrGroundLevel(x, y, z, &ground);
+ if (liquidLevel <= ground) // When there is no liquid Map::GetWaterOrGroundLevel returns ground level
+ {
+ SendCastResult(SPELL_FAILED_NOT_HERE);
+ SendChannelUpdate(0);
+ finish(false);
+ return;
+ }
+
+ if (ground + 0.75 > liquidLevel)
+ {
+ SendCastResult(SPELL_FAILED_TOO_SHALLOW);
+ SendChannelUpdate(0);
+ finish(false);
+ return;
+ }
+
+ dest = SpellDestination(x, y, liquidLevel, m_caster->GetOrientation());
+ break;
}
default:
{
diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp
index 9fd43807fd5..79aa334d432 100644
--- a/src/server/scripts/Spells/spell_druid.cpp
+++ b/src/server/scripts/Spells/spell_druid.cpp
@@ -993,6 +993,65 @@ class spell_dru_t10_restoration_4p_bonus : public SpellScriptLoader
}
};
+class RaidCheck
+{
+ public:
+ explicit RaidCheck(Unit const* caster) : _caster(caster) { }
+
+ bool operator()(WorldObject* obj) const
+ {
+ if (Unit* target = obj->ToUnit())
+ return !_caster->IsInRaidWith(target);
+
+ return true;
+ }
+
+ private:
+ Unit const* _caster;
+};
+
+// -48438 - Wild Growth
+class spell_dru_wild_growth : public SpellScriptLoader
+{
+ public:
+ spell_dru_wild_growth() : SpellScriptLoader("spell_dru_wild_growth") { }
+
+ class spell_dru_wild_growth_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_dru_wild_growth_SpellScript);
+
+ bool Validate(SpellInfo const* spellInfo) OVERRIDE
+ {
+ if (spellInfo->Effects[EFFECT_2].IsEffect() || !spellInfo->Effects[EFFECT_2].CalcValue())
+ return false;
+ return true;
+ }
+
+ void FilterTargets(std::list<WorldObject*>& targets)
+ {
+ targets.remove_if(RaidCheck(GetCaster()));
+
+ int32 const maxTargets = GetSpellInfo()->Effects[EFFECT_2].CalcValue(GetCaster());
+
+ if (targets.size() > maxTargets)
+ {
+ targets.sort(Trinity::HealthPctOrderPred());
+ targets.resize(maxTargets);
+ }
+ }
+
+ void Register() OVERRIDE
+ {
+ OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dru_wild_growth_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const OVERRIDE
+ {
+ return new spell_dru_wild_growth_SpellScript();
+ }
+};
+
void AddSC_druid_spell_scripts()
{
new spell_dru_dash();
@@ -1018,4 +1077,5 @@ void AddSC_druid_spell_scripts()
new spell_dru_tiger_s_fury();
new spell_dru_typhoon();
new spell_dru_t10_restoration_4p_bonus();
+ new spell_dru_wild_growth();
}
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 3feb9821177..1e9a8713019 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -2963,22 +2963,65 @@ enum Replenishment
SPELL_INFINITE_REPLENISHMENT = 61782
};
+class ReplenishmentCheck
+{
+public:
+ bool operator()(WorldObject* obj) const
+ {
+ if (Unit* target = obj->ToUnit())
+ return target->getPowerType() != POWER_MANA;
+
+ return true;
+ }
+};
+
class spell_gen_replenishment : public SpellScriptLoader
{
public:
spell_gen_replenishment() : SpellScriptLoader("spell_gen_replenishment") { }
- class spell_gen_replenishment_AuraScript : public AuraScript
+ class spell_gen_replenishment_SpellScript : public SpellScript
{
- PrepareAuraScript(spell_gen_replenishment_AuraScript);
+ PrepareSpellScript(spell_gen_replenishment_SpellScript);
- bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
+ void RemoveInvalidTargets(std::list<WorldObject*>& targets)
{
- if (!sSpellMgr->GetSpellInfo(SPELL_REPLENISHMENT) ||
- !sSpellMgr->GetSpellInfo(SPELL_INFINITE_REPLENISHMENT))
- return false;
- return true;
+ // In arenas Replenishment may only affect the caster
+ if (Player* caster = GetCaster()->ToPlayer())
+ {
+ if (caster->InArena())
+ {
+ targets.clear();
+ targets.push_back(caster);
+ return;
+ }
+ }
+
+ targets.remove_if(ReplenishmentCheck());
+
+ uint8 const maxTargets = 10;
+
+ if (targets.size() > maxTargets)
+ {
+ targets.sort(Trinity::PowerPctOrderPred(POWER_MANA));
+ targets.resize(maxTargets);
+ }
+ }
+
+ void Register() OVERRIDE
+ {
+ OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_gen_replenishment_SpellScript::RemoveInvalidTargets, EFFECT_ALL, TARGET_UNIT_CASTER_AREA_RAID);
}
+ };
+
+ SpellScript* GetSpellScript() const OVERRIDE
+ {
+ return new spell_gen_replenishment_SpellScript();
+ }
+
+ class spell_gen_replenishment_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_gen_replenishment_AuraScript);
bool Load() OVERRIDE
{
diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp
index b8b652eb314..d1d43684f3e 100644
--- a/src/server/scripts/Spells/spell_rogue.cpp
+++ b/src/server/scripts/Spells/spell_rogue.cpp
@@ -255,10 +255,11 @@ class spell_rog_deadly_poison : public SpellScriptLoader
};
// 51690 - Killing Spree
+#define KillingSpreeScriptName "spell_rog_killing_spree"
class spell_rog_killing_spree : public SpellScriptLoader
{
public:
- spell_rog_killing_spree() : SpellScriptLoader("spell_rog_killing_spree") { }
+ spell_rog_killing_spree() : SpellScriptLoader(KillingSpreeScriptName) { }
class spell_rog_killing_spree_SpellScript : public SpellScript
{
@@ -274,7 +275,7 @@ class spell_rog_killing_spree : public SpellScriptLoader
{
if (Aura* aura = GetCaster()->GetAura(SPELL_ROGUE_KILLING_SPREE))
{
- if (spell_rog_killing_spree_AuraScript* script = dynamic_cast<spell_rog_killing_spree_AuraScript*>(aura->GetScriptByName("spell_rog_killing_spree")))
+ if (spell_rog_killing_spree_AuraScript* script = dynamic_cast<spell_rog_killing_spree_AuraScript*>(aura->GetScriptByName(KillingSpreeScriptName)))
script->AddTarget(GetHitUnit());
}
}
diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp
index cafe510cc4f..5a655a92996 100644
--- a/src/server/scripts/Spells/spell_warrior.cpp
+++ b/src/server/scripts/Spells/spell_warrior.cpp
@@ -42,7 +42,9 @@ enum WarriorSpells
SPELL_WARRIOR_JUGGERNAUT_CRIT_BONUS_BUFF = 65156,
SPELL_WARRIOR_JUGGERNAUT_CRIT_BONUS_TALENT = 64976,
SPELL_WARRIOR_LAST_STAND_TRIGGERED = 12976,
+ SPELL_WARRIOR_RETALIATION_DAMAGE = 22858,
SPELL_WARRIOR_SLAM = 50783,
+ SPELL_WARRIOR_SUNDER_ARMOR = 58567,
SPELL_WARRIOR_SWEEPING_STRIKES_EXTRA_ATTACK = 26654,
SPELL_WARRIOR_TAUNT = 355,
SPELL_WARRIOR_UNRELENTING_ASSAULT_RANK_1 = 46859,
@@ -53,6 +55,11 @@ enum WarriorSpells
SPELL_WARRIOR_VIGILANCE_REDIRECT_THREAT = 59665
};
+enum WarriorSpellIcons
+{
+ WARRIOR_ICON_ID_SUDDEN_DEATH = 1989
+};
+
enum MiscSpells
{
SPELL_PALADIN_BLESSING_OF_SANCTUARY = 20911,
@@ -61,11 +68,6 @@ enum MiscSpells
SPELL_GEN_DAMAGE_REDUCTION_AURA = 68066,
};
-enum WarriorSpellIcons
-{
- WARRIOR_ICON_ID_SUDDEN_DEATH = 1989
-};
-
// 23881 - Bloodthirst
class spell_warr_bloodthirst : public SpellScriptLoader
{
@@ -313,7 +315,7 @@ class spell_warr_execute : public SpellScriptLoader
return true;
}
- void HandleDummy(SpellEffIndex effIndex)
+ void HandleEffect(SpellEffIndex effIndex)
{
Unit* caster = GetCaster();
if (Unit* target = GetHitUnit())
@@ -342,7 +344,7 @@ class spell_warr_execute : public SpellScriptLoader
void Register() OVERRIDE
{
- OnEffectHitTarget += SpellEffectFn(spell_warr_execute_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
+ OnEffectHitTarget += SpellEffectFn(spell_warr_execute_SpellScript::HandleEffect, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
@@ -352,6 +354,42 @@ class spell_warr_execute : public SpellScriptLoader
}
};
+// 58387 - Glyph of Sunder Armor
+class spell_warr_glyph_of_sunder_armor : public SpellScriptLoader
+{
+ public:
+ spell_warr_glyph_of_sunder_armor() : SpellScriptLoader("spell_warr_glyph_of_sunder_armor") { }
+
+ class spell_warr_glyph_of_sunder_armor_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_warr_glyph_of_sunder_armor_AuraScript);
+
+ void HandleEffectCalcSpellMod(AuraEffect const* aurEff, SpellModifier*& spellMod)
+ {
+ if (!spellMod)
+ {
+ spellMod = new SpellModifier(aurEff->GetBase());
+ spellMod->op = SpellModOp(aurEff->GetMiscValue());
+ spellMod->type = SPELLMOD_FLAT;
+ spellMod->spellId = GetId();
+ spellMod->mask = GetSpellInfo()->Effects[aurEff->GetEffIndex()].SpellClassMask;
+ }
+
+ spellMod->value = aurEff->GetAmount();
+ }
+
+ void Register() OVERRIDE
+ {
+ DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_warr_glyph_of_sunder_armor_AuraScript::HandleEffectCalcSpellMod, EFFECT_0, SPELL_AURA_DUMMY);
+ }
+ };
+
+ AuraScript* GetAuraScript() const OVERRIDE
+ {
+ return new spell_warr_glyph_of_sunder_armor_AuraScript();
+ }
+};
+
// 59725 - Improved Spell Reflection
class spell_warr_improved_spell_reflection : public SpellScriptLoader
{
@@ -528,6 +566,48 @@ class spell_warr_rend : public SpellScriptLoader
}
};
+// 20230 - Retaliation
+class spell_warr_retaliation : public SpellScriptLoader
+{
+ public:
+ spell_warr_retaliation() : SpellScriptLoader("spell_warr_retaliation") { }
+
+ class spell_warr_retaliation_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_warr_retaliation_AuraScript);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_WARRIOR_RETALIATION_DAMAGE))
+ return false;
+ return true;
+ }
+
+ bool CheckProc(ProcEventInfo& eventInfo)
+ {
+ // check attack comes not from behind and warrior is not stunned
+ return GetTarget()->isInFront(eventInfo.GetActor(), M_PI) && !GetTarget()->HasUnitState(UNIT_STATE_STUNNED);
+ }
+
+ void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
+ {
+ PreventDefaultAction();
+ GetTarget()->CastSpell(eventInfo.GetProcTarget(), SPELL_WARRIOR_RETALIATION_DAMAGE, true, NULL, aurEff);
+ }
+
+ void Register() OVERRIDE
+ {
+ DoCheckProc += AuraCheckProcFn(spell_warr_retaliation_AuraScript::CheckProc);
+ OnEffectProc += AuraEffectProcFn(spell_warr_retaliation_AuraScript::HandleEffectProc, EFFECT_0, SPELL_AURA_DUMMY);
+ }
+ };
+
+ AuraScript* GetAuraScript() const OVERRIDE
+ {
+ return new spell_warr_retaliation_AuraScript();
+ }
+};
+
// 64380, 65941 - Shattering Throw
class spell_warr_shattering_throw : public SpellScriptLoader
{
@@ -739,7 +819,7 @@ class spell_warr_vigilance : public SpellScriptLoader
}
};
-// 50725 Vigilance
+// 50725 - Vigilance
class spell_warr_vigilance_trigger : public SpellScriptLoader
{
public:
@@ -779,11 +859,13 @@ void AddSC_warrior_spell_scripts()
new spell_warr_damage_shield();
new spell_warr_deep_wounds();
new spell_warr_execute();
+ new spell_warr_glyph_of_sunder_armor();
new spell_warr_improved_spell_reflection();
new spell_warr_intimidating_shout();
new spell_warr_last_stand();
new spell_warr_overpower();
new spell_warr_rend();
+ new spell_warr_retaliation();
new spell_warr_shattering_throw();
new spell_warr_slam();
new spell_warr_sweeping_strikes();