mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Script/Spells: Solve problems with argent tournament spells
- Including cleanup in spell_generic
This commit is contained in:
@@ -342,11 +342,8 @@ class spell_gen_remove_flight_auras : public SpellScriptLoader
|
||||
PrepareSpellScript(spell_gen_remove_flight_auras_SpellScript);
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
Unit* target = GetHitUnit();
|
||||
if (!target)
|
||||
return;
|
||||
target->RemoveAurasByType(SPELL_AURA_FLY);
|
||||
target->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED);
|
||||
GetHitUnit()->RemoveAurasByType(SPELL_AURA_FLY);
|
||||
GetHitUnit()->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED);
|
||||
}
|
||||
|
||||
void Register()
|
||||
@@ -448,25 +445,22 @@ class spell_gen_elune_candle : public SpellScriptLoader
|
||||
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Unit* target = GetHitUnit())
|
||||
uint32 spellId = 0;
|
||||
|
||||
if (GetHitUnit()->GetEntry() == NPC_OMEN)
|
||||
{
|
||||
uint32 spellId = 0;
|
||||
|
||||
if (target->GetEntry() == NPC_OMEN)
|
||||
switch (urand(0, 3))
|
||||
{
|
||||
switch (urand(0, 3))
|
||||
{
|
||||
case 0: spellId = SPELL_ELUNE_CANDLE_OMEN_HEAD; break;
|
||||
case 1: spellId = SPELL_ELUNE_CANDLE_OMEN_CHEST; break;
|
||||
case 2: spellId = SPELL_ELUNE_CANDLE_OMEN_HAND_R; break;
|
||||
case 3: spellId = SPELL_ELUNE_CANDLE_OMEN_HAND_L; break;
|
||||
}
|
||||
case 0: spellId = SPELL_ELUNE_CANDLE_OMEN_HEAD; break;
|
||||
case 1: spellId = SPELL_ELUNE_CANDLE_OMEN_CHEST; break;
|
||||
case 2: spellId = SPELL_ELUNE_CANDLE_OMEN_HAND_R; break;
|
||||
case 3: spellId = SPELL_ELUNE_CANDLE_OMEN_HAND_L; break;
|
||||
}
|
||||
else
|
||||
spellId = SPELL_ELUNE_CANDLE_NORMAL;
|
||||
|
||||
GetCaster()->CastSpell(target, spellId, true, NULL);
|
||||
}
|
||||
else
|
||||
spellId = SPELL_ELUNE_CANDLE_NORMAL;
|
||||
|
||||
GetCaster()->CastSpell(GetHitUnit(), spellId, true, NULL);
|
||||
}
|
||||
|
||||
void Register()
|
||||
@@ -947,11 +941,8 @@ class spell_generic_clone : public SpellScriptLoader
|
||||
void HandleScriptEffect(SpellEffIndex effIndex)
|
||||
{
|
||||
PreventHitDefaultEffect(effIndex);
|
||||
Unit* caster = GetCaster();
|
||||
uint32 spellId = uint32(GetSpellInfo()->Effects[effIndex].CalcValue());
|
||||
|
||||
if (Unit* target = GetHitUnit())
|
||||
target->CastSpell(caster, spellId, true);
|
||||
GetHitUnit()->CastSpell(GetCaster(), spellId, true);
|
||||
}
|
||||
|
||||
void Register()
|
||||
@@ -1591,7 +1582,6 @@ class spell_gen_dalaran_disguise : public SpellScriptLoader
|
||||
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
|
||||
if (Player* player = GetHitPlayer())
|
||||
{
|
||||
uint8 gender = player->getGender();
|
||||
@@ -1661,66 +1651,74 @@ enum BreakShieldSpells
|
||||
|
||||
class spell_gen_break_shield: public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_gen_break_shield() : SpellScriptLoader("spell_gen_break_shield") { }
|
||||
public:
|
||||
spell_gen_break_shield() : SpellScriptLoader("spell_gen_break_shield") { }
|
||||
|
||||
class spell_gen_break_shield_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_gen_break_shield_SpellScript)
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex effIndex)
|
||||
class spell_gen_break_shield_SpellScript : public SpellScript
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
Unit* target = GetTargetUnit();
|
||||
PrepareSpellScript(spell_gen_break_shield_SpellScript)
|
||||
|
||||
if (!caster || !target)
|
||||
return;
|
||||
|
||||
switch (effIndex)
|
||||
void HandleScriptEffect(SpellEffIndex effIndex)
|
||||
{
|
||||
case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual)
|
||||
uint32 spellId;
|
||||
switch (GetSpellInfo()->Id)
|
||||
{
|
||||
case SPELL_BREAK_SHIELD_TRIGGER_UNK:
|
||||
case SPELL_BREAK_SHIELD_TRIGGER_CAMPAING_WARHORSE:
|
||||
spellId = SPELL_BREAK_SHIELD_DAMAGE_10K;
|
||||
break;
|
||||
case SPELL_BREAK_SHIELD_TRIGGER_FACTION_MOUNTS:
|
||||
spellId = SPELL_BREAK_SHIELD_DAMAGE_2K;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
Unit* target = GetHitUnit();
|
||||
|
||||
if (Unit* rider = caster->GetCharmer())
|
||||
rider->CastSpell(target, spellId, false);
|
||||
else
|
||||
caster->CastSpell(target, spellId, false);
|
||||
break;
|
||||
case EFFECT_1: // On damaging spells, for removing the a defend layer
|
||||
Unit::AuraApplicationMap const& auras = target->GetAppliedAuras();
|
||||
for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
|
||||
switch (effIndex)
|
||||
{
|
||||
case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual)
|
||||
{
|
||||
Aura* aura = itr->second->GetBase();
|
||||
SpellInfo const* auraInfo = aura->GetSpellInfo();
|
||||
if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN))
|
||||
aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
uint32 spellId;
|
||||
|
||||
switch (GetSpellInfo()->Id)
|
||||
{
|
||||
case SPELL_BREAK_SHIELD_TRIGGER_UNK:
|
||||
case SPELL_BREAK_SHIELD_TRIGGER_CAMPAING_WARHORSE:
|
||||
spellId = SPELL_BREAK_SHIELD_DAMAGE_10K;
|
||||
break;
|
||||
case SPELL_BREAK_SHIELD_TRIGGER_FACTION_MOUNTS:
|
||||
spellId = SPELL_BREAK_SHIELD_DAMAGE_2K;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (Unit* rider = GetCaster()->GetCharmer())
|
||||
rider->CastSpell(target, spellId, false);
|
||||
else
|
||||
GetCaster()->CastSpell(target, spellId, false);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EFFECT_1: // On damaging spells, for removing a defend layer
|
||||
{
|
||||
Unit::AuraApplicationMap const& auras = target->GetAppliedAuras();
|
||||
for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
|
||||
{
|
||||
Aura* aura = itr->second->GetBase();
|
||||
SpellInfo const* auraInfo = aura->GetSpellInfo();
|
||||
if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN))
|
||||
{
|
||||
aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
// Remove dummys from rider (Necessary for updating visual shields)
|
||||
if (Unit* rider = target->GetCharmer())
|
||||
if (Aura* defend = rider->GetAura(aura->GetId()))
|
||||
defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
void Register()
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_gen_break_shield_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
OnEffectHit += SpellEffectFn(spell_gen_break_shield_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
return new spell_gen_break_shield_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_gen_break_shield_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
/* DOCUMENTATION: Charge spells
|
||||
@@ -1775,109 +1773,110 @@ enum ChargeSpells
|
||||
|
||||
class spell_gen_mounted_charge: public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_gen_mounted_charge() : SpellScriptLoader("spell_gen_mounted_charge") { }
|
||||
public:
|
||||
spell_gen_mounted_charge() : SpellScriptLoader("spell_gen_mounted_charge") { }
|
||||
|
||||
class spell_gen_mounted_charge_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_gen_mounted_charge_SpellScript)
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex effIndex)
|
||||
class spell_gen_mounted_charge_SpellScript : public SpellScript
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
Unit* target = GetTargetUnit();
|
||||
PrepareSpellScript(spell_gen_mounted_charge_SpellScript)
|
||||
|
||||
if (!caster || !target)
|
||||
return;
|
||||
|
||||
switch (effIndex)
|
||||
void HandleScriptEffect(SpellEffIndex effIndex)
|
||||
{
|
||||
case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual)
|
||||
uint32 spellId;
|
||||
Unit* target = GetHitUnit();
|
||||
|
||||
switch (GetSpellInfo()->Id)
|
||||
switch (effIndex)
|
||||
{
|
||||
case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual)
|
||||
{
|
||||
case SPELL_CHARGE_TRIGGER_TRIAL_CHAMPION:
|
||||
spellId = SPELL_CHARGE_CHARGING_EFFECT_20K_1;
|
||||
case SPELL_CHARGE_TRIGGER_FACTION_MOUNTS:
|
||||
spellId = SPELL_CHARGE_CHARGING_EFFECT_8K5;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
uint32 spellId;
|
||||
|
||||
if (Unit* vehicle = caster->GetVehicleBase())
|
||||
vehicle->CastSpell(target, spellId, false);
|
||||
else
|
||||
caster->CastSpell(target, spellId, false);
|
||||
break;
|
||||
case EFFECT_1: // On damaging spells, for removing the a defend layer
|
||||
case EFFECT_2:
|
||||
Unit::AuraApplicationMap const& auras = target->GetAppliedAuras();
|
||||
for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
|
||||
switch (GetSpellInfo()->Id)
|
||||
{
|
||||
case SPELL_CHARGE_TRIGGER_TRIAL_CHAMPION:
|
||||
spellId = SPELL_CHARGE_CHARGING_EFFECT_20K_1;
|
||||
case SPELL_CHARGE_TRIGGER_FACTION_MOUNTS:
|
||||
spellId = SPELL_CHARGE_CHARGING_EFFECT_8K5;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// If target isn't a training dummy there's a chance of failing the charge
|
||||
if (!target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE) && roll_chance_f(12.5f))
|
||||
spellId = SPELL_CHARGE_MISS_EFFECT;
|
||||
|
||||
if (Unit* vehicle = GetCaster()->GetVehicleBase())
|
||||
vehicle->CastSpell(target, spellId, false);
|
||||
else
|
||||
GetCaster()->CastSpell(target, spellId, false);
|
||||
break;
|
||||
}
|
||||
case EFFECT_1: // On damaging spells, for removing a defend layer
|
||||
case EFFECT_2:
|
||||
{
|
||||
Aura* aura = itr->second->GetBase();
|
||||
SpellInfo const* auraInfo = aura->GetSpellInfo();
|
||||
if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN))
|
||||
aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
Unit::AuraApplicationMap const& auras = target->GetAppliedAuras();
|
||||
for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
|
||||
{
|
||||
Aura* aura = itr->second->GetBase();
|
||||
SpellInfo const* auraInfo = aura->GetSpellInfo();
|
||||
if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN))
|
||||
{
|
||||
aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
// Remove dummys from rider (Necessary for updating visual shields)
|
||||
if (Unit* rider = target->GetCharmer())
|
||||
if (Aura* defend = rider->GetAura(aura->GetId()))
|
||||
defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void HandleChargeEffect(SpellEffIndex effIndex)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
Unit* target = GetTargetUnit();
|
||||
|
||||
if (!caster || !target)
|
||||
return;
|
||||
|
||||
uint32 spellId;
|
||||
|
||||
switch (GetSpellInfo()->Id)
|
||||
{
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_8K5:
|
||||
spellId = SPELL_CHARGE_DAMAGE_8K5;
|
||||
break;
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_20K_1:
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_20K_2:
|
||||
spellId = SPELL_CHARGE_DAMAGE_20K;
|
||||
break;
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_45K_1:
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_45K_2:
|
||||
spellId = SPELL_CHARGE_DAMAGE_45K;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If target isn't a training dummy there's a chance of failing the charge
|
||||
if (!target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE) && urand(0,7) == 0)
|
||||
spellId = SPELL_CHARGE_MISS_EFFECT;
|
||||
void HandleChargeEffect(SpellEffIndex effIndex)
|
||||
{
|
||||
uint32 spellId;
|
||||
|
||||
if (Unit* rider = caster->GetCharmer())
|
||||
rider->CastSpell(target, spellId, false);
|
||||
else
|
||||
caster->CastSpell(target, spellId, false);
|
||||
}
|
||||
switch (GetSpellInfo()->Id)
|
||||
{
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_8K5:
|
||||
spellId = SPELL_CHARGE_DAMAGE_8K5;
|
||||
break;
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_20K_1:
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_20K_2:
|
||||
spellId = SPELL_CHARGE_DAMAGE_20K;
|
||||
break;
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_45K_1:
|
||||
case SPELL_CHARGE_CHARGING_EFFECT_45K_2:
|
||||
spellId = SPELL_CHARGE_DAMAGE_45K;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
void Register()
|
||||
if (Unit* rider = GetCaster()->GetCharmer())
|
||||
rider->CastSpell(GetHitUnit(), spellId, false);
|
||||
else
|
||||
GetCaster()->CastSpell(GetHitUnit(), spellId, false);
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
SpellInfo const* spell = sSpellMgr->GetSpellInfo(m_scriptSpellId);
|
||||
|
||||
if (spell->HasEffect(SPELL_EFFECT_SCRIPT_EFFECT))
|
||||
OnEffectHitTarget += SpellEffectFn(spell_gen_mounted_charge_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
|
||||
if (spell->Effects[EFFECT_0].Effect == SPELL_EFFECT_CHARGE)
|
||||
OnEffectHitTarget += SpellEffectFn(spell_gen_mounted_charge_SpellScript::HandleChargeEffect, EFFECT_0, SPELL_EFFECT_CHARGE);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
SpellInfo const* spell = sSpellMgr->GetSpellInfo(m_scriptSpellId);
|
||||
|
||||
if (spell->HasEffect(SPELL_EFFECT_SCRIPT_EFFECT))
|
||||
OnEffectHit += SpellEffectFn(spell_gen_mounted_charge_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
|
||||
if (spell->Effects[EFFECT_0].Effect == SPELL_EFFECT_CHARGE)
|
||||
OnEffectHit += SpellEffectFn(spell_gen_mounted_charge_SpellScript::HandleChargeEffect, EFFECT_0, SPELL_EFFECT_CHARGE);
|
||||
return new spell_gen_mounted_charge_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_gen_mounted_charge_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
enum DefendVisuals
|
||||
@@ -1907,44 +1906,33 @@ class spell_gen_defend : public SpellScriptLoader
|
||||
return true;
|
||||
}
|
||||
|
||||
void RefreshVisualShields(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
void RefreshVisualShields(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
Unit* target = GetTarget();
|
||||
|
||||
if(!target)
|
||||
return;
|
||||
|
||||
if (!caster)
|
||||
if (Unit* caster = GetCaster())
|
||||
{
|
||||
target->RemoveAurasDueToSpell(GetId());
|
||||
return;
|
||||
Unit* target = GetTarget();
|
||||
|
||||
for (uint8 i = 0; i < GetSpellInfo()->StackAmount; ++i)
|
||||
target->RemoveAurasDueToSpell(SPELL_VISUAL_SHIELD_1 + i);
|
||||
|
||||
target->CastSpell(target, SPELL_VISUAL_SHIELD_1 + GetAura()->GetStackAmount() - 1, true, NULL, aurEff);
|
||||
}
|
||||
|
||||
for (uint8 i = 0; i < GetSpellInfo()->StackAmount; ++i)
|
||||
target->RemoveAurasDueToSpell(SPELL_VISUAL_SHIELD_1 + i);
|
||||
|
||||
target->CastSpell(target, SPELL_VISUAL_SHIELD_1 + GetAura()->GetStackAmount() - 1);
|
||||
else
|
||||
GetTarget()->RemoveAurasDueToSpell(GetId());
|
||||
}
|
||||
|
||||
void RemoveVisualShields(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
|
||||
if(!target)
|
||||
return;
|
||||
|
||||
for (uint8 i = 0; i < GetSpellInfo()->StackAmount; ++i)
|
||||
target->RemoveAurasDueToSpell(SPELL_VISUAL_SHIELD_1 + i);
|
||||
GetTarget()->RemoveAurasDueToSpell(SPELL_VISUAL_SHIELD_1 + i);
|
||||
}
|
||||
|
||||
void RemoveDummyFromDriver(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
|
||||
if (caster && caster->ToTempSummon())
|
||||
if (Unit* rider = caster->ToTempSummon()->GetSummoner())
|
||||
rider->RemoveAurasDueToSpell(GetId());
|
||||
if (Unit* caster = GetCaster())
|
||||
if (TempSummon* vehicle = caster->ToTempSummon())
|
||||
if (Unit* rider = vehicle->GetSummoner())
|
||||
rider->RemoveAurasDueToSpell(GetId());
|
||||
}
|
||||
|
||||
void Register()
|
||||
@@ -1955,7 +1943,7 @@ class spell_gen_defend : public SpellScriptLoader
|
||||
if (spell->Effects[EFFECT_0].ApplyAuraName == SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)
|
||||
{
|
||||
AfterEffectApply += AuraEffectApplyFn(spell_gen_defendAuraScript::RefreshVisualShields, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
|
||||
OnEffectRemove += AuraEffectRemoveFn(spell_gen_defendAuraScript::RemoveVisualShields, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL);
|
||||
OnEffectRemove += AuraEffectRemoveFn(spell_gen_defendAuraScript::RemoveVisualShields, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
|
||||
}
|
||||
|
||||
// Remove Defend spell from player when he dismounts
|
||||
@@ -1966,7 +1954,7 @@ class spell_gen_defend : public SpellScriptLoader
|
||||
if (spell->Effects[EFFECT_1].ApplyAuraName == SPELL_AURA_DUMMY)
|
||||
{
|
||||
AfterEffectApply += AuraEffectApplyFn(spell_gen_defendAuraScript::RefreshVisualShields, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
|
||||
OnEffectRemove += AuraEffectRemoveFn(spell_gen_defendAuraScript::RemoveVisualShields, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
||||
OnEffectRemove += AuraEffectRemoveFn(spell_gen_defendAuraScript::RemoveVisualShields, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -2003,33 +1991,24 @@ class spell_gen_tournament_duel : public SpellScriptLoader
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex effIndex)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
Unit* target = GetTargetUnit();
|
||||
Unit* player = GetCaster()->GetCharmer();
|
||||
|
||||
if (!caster || !target || !player)
|
||||
return;
|
||||
|
||||
if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
if (Unit* rider = GetCaster()->GetCharmer())
|
||||
{
|
||||
|
||||
if (!target->HasAura(SPELL_ON_TOURNAMENT_MOUNT) || !target->GetVehicleBase())
|
||||
return;
|
||||
|
||||
player->CastSpell(target, SPELL_MOUNTED_DUEL, true);
|
||||
}
|
||||
else if (target->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
if (!target->GetCharmer() || target->GetCharmer()->GetTypeId() != TYPEID_PLAYER || !target->GetCharmer()->HasAura(SPELL_ON_TOURNAMENT_MOUNT))
|
||||
return;
|
||||
|
||||
player->CastSpell(target->GetCharmer(), SPELL_MOUNTED_DUEL, true);
|
||||
if (Player* plrTarget = GetHitPlayer())
|
||||
{
|
||||
if (plrTarget->HasAura(SPELL_ON_TOURNAMENT_MOUNT) && plrTarget->GetVehicleBase())
|
||||
rider->CastSpell(plrTarget, SPELL_MOUNTED_DUEL, true);
|
||||
}
|
||||
else if (Unit* unitTarget = GetHitUnit())
|
||||
{
|
||||
if (unitTarget->GetCharmer() && unitTarget->GetCharmer()->GetTypeId() == TYPEID_PLAYER && unitTarget->GetCharmer()->HasAura(SPELL_ON_TOURNAMENT_MOUNT))
|
||||
rider->CastSpell(unitTarget->GetCharmer(), SPELL_MOUNTED_DUEL, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnEffectHit += SpellEffectFn(spell_gen_tournament_duel_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
OnEffectHitTarget += SpellEffectFn(spell_gen_tournament_duel_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2062,9 +2041,13 @@ class spell_gen_summon_tournament_mount : public SpellScriptLoader
|
||||
|
||||
SpellCastResult CheckIfLanceEquiped()
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (GetCaster()->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
|
||||
{
|
||||
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_CANT_MOUNT_WITH_SHAPESHIFT);
|
||||
return SPELL_FAILED_CUSTOM_ERROR;
|
||||
}
|
||||
|
||||
if (!caster->HasAura(SPELL_LANCE_EQUIPPED))
|
||||
if (!GetCaster()->HasAura(SPELL_LANCE_EQUIPPED))
|
||||
{
|
||||
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_MUST_HAVE_LANCE_EQUIPPED);
|
||||
return SPELL_FAILED_CUSTOM_ERROR;
|
||||
@@ -2194,25 +2177,24 @@ class spell_gen_on_tournament_mount : public SpellScriptLoader
|
||||
bool Load()
|
||||
{
|
||||
_pennantSpellId = 0;
|
||||
return (GetCaster()->GetTypeId() == TYPEID_PLAYER);
|
||||
return GetCaster() && GetCaster()->GetTypeId() == TYPEID_PLAYER;
|
||||
}
|
||||
|
||||
void HandleApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
|
||||
if (caster && caster->GetVehicleBase())
|
||||
if (Unit* caster = GetCaster())
|
||||
{
|
||||
_pennantSpellId = GetPennatSpellId(caster->ToPlayer(), caster->GetVehicleBase());
|
||||
caster->CastSpell(caster, _pennantSpellId,true);
|
||||
if (Unit* vehicle = caster->GetVehicleBase())
|
||||
{
|
||||
_pennantSpellId = GetPennatSpellId(caster->ToPlayer(), vehicle);
|
||||
caster->CastSpell(caster, _pennantSpellId, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandleRemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
|
||||
if (caster)
|
||||
if (Unit* caster = GetCaster())
|
||||
caster->RemoveAurasDueToSpell(_pennantSpellId);
|
||||
}
|
||||
|
||||
@@ -2348,12 +2330,16 @@ class spell_gen_tournament_pennant : public SpellScriptLoader
|
||||
{
|
||||
PrepareAuraScript(spell_gen_tournament_pennantAuraScript);
|
||||
|
||||
bool Load()
|
||||
{
|
||||
return GetCaster() && GetCaster()->GetTypeId() == TYPEID_PLAYER;
|
||||
}
|
||||
|
||||
void HandleApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
|
||||
if (caster && caster->GetTypeId() == TYPEID_PLAYER && !caster->GetVehicleBase())
|
||||
caster->RemoveAurasDueToSpell(GetId());
|
||||
if (Unit* caster = GetCaster())
|
||||
if (!caster->GetVehicleBase())
|
||||
caster->RemoveAurasDueToSpell(GetId());
|
||||
}
|
||||
|
||||
void Register()
|
||||
|
||||
@@ -285,6 +285,16 @@ class achievement_bg_sa_defense_of_ancients : public AchievementCriteriaScript
|
||||
}
|
||||
};
|
||||
|
||||
enum ArgentTournamentAreas
|
||||
{
|
||||
AREA_ARGENT_TOURNAMENT_FIELDS = 4658,
|
||||
AREA_RING_OF_ASPIRANTS = 4670,
|
||||
AREA_RING_OF_ARGENT_VALIANTS = 4671,
|
||||
AREA_RING_OF_ALLIANCE_VALIANTS = 4672,
|
||||
AREA_RING_OF_HORDE_VALIANTS = 4673,
|
||||
AREA_RING_OF_CHAMPIONS = 4669,
|
||||
};
|
||||
|
||||
class achievement_tilted : public AchievementCriteriaScript
|
||||
{
|
||||
public:
|
||||
@@ -292,7 +302,14 @@ class achievement_tilted : public AchievementCriteriaScript
|
||||
|
||||
bool OnCheck(Player* player, Unit* /*target*/)
|
||||
{
|
||||
return player && player->duel && player->duel->isMounted;
|
||||
bool checkArea = player->GetAreaId() == AREA_ARGENT_TOURNAMENT_FIELDS ||
|
||||
player->GetAreaId() == AREA_RING_OF_ASPIRANTS ||
|
||||
player->GetAreaId() == AREA_RING_OF_ARGENT_VALIANTS ||
|
||||
player->GetAreaId() == AREA_RING_OF_ALLIANCE_VALIANTS ||
|
||||
player->GetAreaId() == AREA_RING_OF_HORDE_VALIANTS ||
|
||||
player->GetAreaId() == AREA_RING_OF_CHAMPIONS;
|
||||
|
||||
return player && checkArea && player->duel && player->duel->isMounted;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user