aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Northrend
diff options
context:
space:
mode:
authorKandera <KanderaDev@gmail.com>2012-02-18 12:12:49 +0100
committerQAston <qaston@gmail.com>2012-02-18 12:12:49 +0100
commitc517806a23751dd92d6a064b7f721507f182bc75 (patch)
treee74b5c99a83b78eae49d8c085de37c0c077d5e74 /src/server/scripts/Northrend
parentd55c8c7cc422fb75a669c2e337c02690266ca7af (diff)
Scripts/Spells: Convert code from Spell::EffectDummy to spell scripts.
Diffstat (limited to 'src/server/scripts/Northrend')
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp41
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp63
2 files changed, 102 insertions, 2 deletions
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
index 7977fa4df8a..e308cc59708 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
@@ -15,7 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ScriptPCH.h"
#include "naxxramas.h"
//Stalagg
@@ -87,7 +86,9 @@ enum ThaddiusSpells
SPELL_POSITIVE_CHARGE = 28062,
SPELL_POSITIVE_CHARGE_STACK = 29659,
SPELL_NEGATIVE_CHARGE = 28085,
- SPELL_NEGATIVE_CHARGE_STACK = 29660
+ SPELL_NEGATIVE_CHARGE_STACK = 29660,
+ SPELL_POSITIVE_POLARITY = 28059,
+ SPELL_NEGATIVE_POLARITY = 28084,
};
enum Events
@@ -503,6 +504,41 @@ class spell_thaddius_pos_neg_charge : public SpellScriptLoader
}
};
+class spell_thaddius_polarity_shift : public SpellScriptLoader
+{
+ public:
+ spell_thaddius_polarity_shift() : SpellScriptLoader("spell_thaddius_polarity_shift") { }
+
+ class spell_thaddius_polarity_shift_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_thaddius_polarity_shift_SpellScript);
+
+ bool Validate(SpellInfo const* /*spell*/)
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_POLARITY) || !sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_POLARITY))
+ return false;
+ return true;
+ }
+
+ void HandleDummy(SpellEffIndex /* effIndex */)
+ {
+ Unit* caster = GetCaster();
+ if (Unit* target = GetHitUnit())
+ target->CastSpell(target, roll_chance_i(50) ? SPELL_POSITIVE_POLARITY : SPELL_NEGATIVE_POLARITY, true, NULL, NULL, caster->GetGUID());
+ }
+
+ void Register()
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_thaddius_polarity_shift_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_thaddius_polarity_shift_SpellScript();
+ }
+};
+
class achievement_polarity_switch : public AchievementCriteriaScript
{
public:
@@ -520,5 +556,6 @@ void AddSC_boss_thaddius()
new mob_stalagg();
new mob_feugen();
new spell_thaddius_pos_neg_charge();
+ new spell_thaddius_polarity_shift();
new achievement_polarity_switch();
}
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
index 2bc2284a246..8c637bc4e90 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
@@ -34,6 +34,7 @@
#include "Vehicle.h"
#include "VehicleDefines.h"
#include "ulduar.h"
+#include "Spell.h"
enum Spells
{
@@ -1718,6 +1719,67 @@ class spell_pursue : public SpellScriptLoader
}
};
+class spell_vehicle_throw_passenger : public SpellScriptLoader
+{
+ public:
+ spell_vehicle_throw_passenger() : SpellScriptLoader("spell_vehicle_throw_passenger") {}
+
+ class spell_vehicle_throw_passenger_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_vehicle_throw_passenger_SpellScript);
+ void HandleScript(SpellEffIndex effIndex)
+ {
+ Spell* baseSpell = GetSpell();
+ SpellCastTargets targets = baseSpell->m_targets;
+ int32 damage = GetEffectValue();
+ if (targets.HasTraj())
+ if (Vehicle* vehicle = GetCaster()->GetVehicleKit())
+ if (Unit* passenger = vehicle->GetPassenger(damage - 1))
+ {
+ std::list<Unit*> unitList;
+ // use 99 because it is 3d search
+ SearchAreaTarget(unitList, 99, PUSH_DST_CENTER, SPELL_TARGETS_ENTRY, NPC_SEAT);
+ float minDist = 99 * 99;
+ Unit* target = NULL;
+ for (std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
+ {
+ if (Vehicle* seat = (*itr)->GetVehicleKit())
+ if (!seat->GetPassenger(0))
+ if (Unit* device = seat->GetPassenger(2))
+ if (!device->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
+ {
+ float dist = (*itr)->GetExactDistSq(targets.GetDst());
+ if (dist < minDist)
+ {
+ minDist = dist;
+ target = (*itr);
+ }
+ }
+ }
+ if (target && target->IsWithinDist2d(targets.GetDst(), GetSpellInfo()->Effects[effIndex].CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct
+ passenger->EnterVehicle(target, 0);
+ else
+ {
+ passenger->ExitVehicle();
+ float x, y, z;
+ targets.GetDst()->GetPosition(x, y, z);
+ passenger->GetMotionMaster()->MoveJump(x, y, z, targets.GetSpeedXY(), targets.GetSpeedZ());
+ }
+ }
+ }
+
+ void Register()
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_vehicle_throw_passenger_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_vehicle_throw_passenger_SpellScript();
+ }
+};
+
void AddSC_boss_flame_leviathan()
{
new boss_flame_leviathan();
@@ -1752,4 +1814,5 @@ void AddSC_boss_flame_leviathan()
new spell_auto_repair();
new spell_systems_shutdown();
new spell_pursue();
+ new spell_vehicle_throw_passenger();
}