Scripts/Icecrown Citadel: Added Rotting Frost Giant script

This commit is contained in:
Shauren
2011-02-15 22:07:40 +01:00
parent 21179288a2
commit 45095bdffb
9 changed files with 212 additions and 12 deletions

View File

@@ -22,16 +22,114 @@
#include "SpellAuraEffects.h"
#include "icecrown_citadel.h"
// Weekly quest support
//* Deprogramming
//* Securing the Ramparts (DONE)
//* Residue Rendezvous
//* Blood Quickening
//* Respite for a Tormented Soul
enum Texts
{
// Rotting Frost Giant
EMOTE_DEATH_PLAGUE_WARNING = 0,
};
enum Spells
{
// Rotting Frost Giant
SPELL_DEATH_PLAGUE = 72879,
SPELL_DEATH_PLAGUE_AURA = 72865,
SPELL_RECENTLY_INFECTED = 72884,
SPELL_DEATH_PLAGUE_KILL = 72867,
SPELL_STOMP = 64652,
SPELL_ARCTIC_BREATH = 72848,
// Frost Freeze Trap
SPELL_COLDFLAME_JETS = 70460,
};
enum Events
{
// Rotting Frost Giant
EVENT_DEATH_PLAGUE = 1,
EVENT_STOMP = 2,
EVENT_ARCTIC_BREATH = 3,
// Frost Freeze Trap
EVENT_ACTIVATE_TRAP = 1,
EVENT_ACTIVATE_TRAP = 4,
};
class npc_rotting_frost_giant : public CreatureScript
{
public:
npc_rotting_frost_giant() : CreatureScript("npc_rotting_frost_giant") { }
struct npc_rotting_frost_giantAI : public ScriptedAI
{
npc_rotting_frost_giantAI(Creature* creature) : ScriptedAI(creature)
{
}
void Reset()
{
events.Reset();
events.ScheduleEvent(EVENT_DEATH_PLAGUE, 15000);
events.ScheduleEvent(EVENT_STOMP, urand(5000, 8000));
events.ScheduleEvent(EVENT_ARCTIC_BREATH, urand(10000, 15000));
}
void JustDied(Unit* /*killer*/)
{
events.Reset();
}
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STAT_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_DEATH_PLAGUE:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true))
{
Talk(EMOTE_DEATH_PLAGUE_WARNING, target->GetGUID());
DoCast(target, SPELL_DEATH_PLAGUE);
}
events.ScheduleEvent(EVENT_DEATH_PLAGUE, 15000);
break;
case EVENT_STOMP:
DoCastVictim(SPELL_STOMP);
events.ScheduleEvent(EVENT_STOMP, urand(15000, 18000));
break;
case EVENT_ARCTIC_BREATH:
DoCastVictim(SPELL_ARCTIC_BREATH);
events.ScheduleEvent(EVENT_ARCTIC_BREATH, urand(26000, 33000));
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}
private:
EventMap events;
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_rotting_frost_giantAI(creature);
}
};
class npc_frost_freeze_trap : public CreatureScript
@@ -83,6 +181,92 @@ class npc_frost_freeze_trap : public CreatureScript
}
};
class DeathPlagueTargetSelector
{
public:
DeathPlagueTargetSelector(Unit* _caster) : caster(_caster) {}
bool operator()(Unit* unit)
{
if (unit == caster)
return true;
if (unit->GetTypeId() != TYPEID_PLAYER)
return true;
if (unit->HasAura(SPELL_RECENTLY_INFECTED) || unit->HasAura(SPELL_DEATH_PLAGUE_AURA))
return true;
return false;
}
Unit* caster;
};
class spell_frost_giant_death_plague : public SpellScriptLoader
{
public:
spell_frost_giant_death_plague() : SpellScriptLoader("spell_frost_giant_death_plague") { }
class spell_frost_giant_death_plague_SpellScript : public SpellScript
{
PrepareSpellScript(spell_frost_giant_death_plague_SpellScript);
bool Load()
{
failed = false;
return true;
}
// First effect
void CountTargets(std::list<Unit*>& unitList)
{
unitList.remove(GetCaster());
failed = unitList.empty();
}
// Second effect
void FilterTargets(std::list<Unit*>& unitList)
{
// Select valid targets for jump
unitList.remove_if(DeathPlagueTargetSelector(GetCaster()));
if (!unitList.empty())
{
std::list<Unit*>::iterator itr = unitList.begin();
std::advance(itr, urand(0, unitList.size()-1));
Unit* target = *itr;
unitList.clear();
unitList.push_back(target);
}
unitList.push_back(GetCaster());
}
void HandleScript(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (GetHitUnit() != GetCaster())
GetCaster()->CastSpell(GetHitUnit(), SPELL_DEATH_PLAGUE_AURA, true);
else if (failed)
GetCaster()->CastSpell(GetCaster(), SPELL_DEATH_PLAGUE_KILL, true);
}
void Register()
{
OnUnitTargetSelect += SpellUnitTargetFn(spell_frost_giant_death_plague_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_AREA_ALLY_SRC);
OnUnitTargetSelect += SpellUnitTargetFn(spell_frost_giant_death_plague_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_AREA_ALLY_SRC);
OnEffect += SpellEffectFn(spell_frost_giant_death_plague_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
bool failed;
};
SpellScript* GetSpellScript() const
{
return new spell_frost_giant_death_plague_SpellScript();
}
};
class at_icc_saurfang_portal : public AreaTriggerScript
{
public:
@@ -132,7 +316,9 @@ class at_icc_shutdown_traps : public AreaTriggerScript
void AddSC_icecrown_citadel()
{
new npc_rotting_frost_giant();
new npc_frost_freeze_trap();
new spell_frost_giant_death_plague();
new at_icc_saurfang_portal();
new at_icc_shutdown_traps();
}