Skip to content

Commit

Permalink
Scripts/Icecrown Citadel: Lock Deathbringer Saurfang and Valithria Dr…
Browse files Browse the repository at this point in the history
…eamwalker chests to players who fought them
  • Loading branch information
Shauren committed Mar 12, 2012
1 parent 671fd41 commit c0165ec
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 16 deletions.
3 changes: 3 additions & 0 deletions sql/updates/world/2012_03_12_01_world_conditions.sql
@@ -0,0 +1,3 @@
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceEntry`=72257;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
(13,1,72257,0,0,32,0,144,0,0,0,0,'','Remove Marks of the Fallen Champion - target player');
4 changes: 4 additions & 0 deletions sql/updates/world/2012_03_12_01_world_gameobject.sql
@@ -0,0 +1,4 @@
UPDATE `gameobject_template` SET `flags`=0x32 WHERE `entry` IN (202239,202240,202238,202241,201959,202339,202338,202340);

-- Set Deathbringer's Cache spawned by default
UPDATE `gameobject` SET `spawntimesecs`=604800 WHERE `id` IN (202239,202240,202238,202241);
3 changes: 3 additions & 0 deletions sql/updates/world/2012_03_12_01_world_spell_script_names.sql
@@ -0,0 +1,3 @@
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_deathbringer_remove_marks';
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
(72257,'spell_deathbringer_remove_marks');
Expand Up @@ -111,6 +111,8 @@ enum Spells

SPELL_RIDE_VEHICLE = 70640, // Outro
SPELL_ACHIEVEMENT = 72928,
SPELL_REMOVE_MARKS_OF_THE_FALLEN_CHAMPION = 72257,
SPELL_PERMANENT_FEIGN_DEATH = 70628,
};

// Helper to get id of the aura on different modes (HasAura(baseId) wont work)
Expand Down Expand Up @@ -254,6 +256,7 @@ class boss_deathbringer_saurfang : public CreatureScript
me->SetReactState(REACT_DEFENSIVE);
events.SetPhase(PHASE_COMBAT);
_frenzied = false;
_dead = false;
me->SetPower(POWER_ENERGY, 0);
DoCast(me, SPELL_ZERO_POWER, true);
DoCast(me, SPELL_BLOOD_LINK, true);
Expand Down Expand Up @@ -303,13 +306,6 @@ class boss_deathbringer_saurfang : public CreatureScript

void JustDied(Unit* /*killer*/)
{
_JustDied();
DoCast(me, SPELL_ACHIEVEMENT, true);
Talk(SAY_DEATH);

instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_MARK_OF_THE_FALLEN_CHAMPION);
if (Creature* creature = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SAURFANG_EVENT_NPC)))
creature->AI()->DoAction(ACTION_START_OUTRO);
}

void AttackStart(Unit* victim)
Expand Down Expand Up @@ -348,6 +344,22 @@ class boss_deathbringer_saurfang : public CreatureScript
DoCast(me, SPELL_FRENZY);
Talk(SAY_FRENZY);
}

if (!_dead && me->GetHealth() < FightWonValue)
{
_dead = true;
_JustDied();
_EnterEvadeMode();

DoCastAOE(SPELL_REMOVE_MARKS_OF_THE_FALLEN_CHAMPION);
DoCast(me, SPELL_ACHIEVEMENT, true);
Talk(SAY_DEATH);

//instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_MARK_OF_THE_FALLEN_CHAMPION);
DoCast(me, SPELL_PERMANENT_FEIGN_DEATH);
if (Creature* creature = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SAURFANG_EVENT_NPC)))
creature->AI()->DoAction(ACTION_START_OUTRO);
}
}

void JustSummoned(Creature* summon)
Expand Down Expand Up @@ -542,10 +554,13 @@ class boss_deathbringer_saurfang : public CreatureScript
}
}

static uint32 const FightWonValue;

private:
uint32 _fallenChampionCastCount;
bool _introDone;
bool _frenzied; // faster than iterating all auras to find Frenzy
bool _dead;
};

CreatureAI* GetAI(Creature* creature) const
Expand All @@ -554,6 +569,8 @@ class boss_deathbringer_saurfang : public CreatureScript
}
};

uint32 const boss_deathbringer_saurfang::boss_deathbringer_saurfangAI::FightWonValue = 100000;

class npc_high_overlord_saurfang_icc : public CreatureScript
{
public:
Expand Down Expand Up @@ -655,7 +672,7 @@ class npc_high_overlord_saurfang_icc : public CreatureScript
{
deathbringer->CastSpell(me, SPELL_RIDE_VEHICLE, true); // for the packet logs.
deathbringer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
deathbringer->setDeathState(ALIVE);
deathbringer->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_DROWNED);
}
_events.ScheduleEvent(EVENT_OUTRO_HORDE_5, 1000); // move
_events.ScheduleEvent(EVENT_OUTRO_HORDE_6, 4000); // say
Expand Down Expand Up @@ -818,6 +835,10 @@ class npc_muradin_bronzebeard_icc : public CreatureScript
me->MonsterMoveWithSpeed(me->GetPositionX(), me->GetPositionY(), 539.2917f, 0.0f);
for (std::list<Creature*>::iterator itr = _guardList.begin(); itr != _guardList.end(); ++itr)
(*itr)->AI()->DoAction(ACTION_DESPAWN);

// temp until outro fully done - to put deathbringer on respawn timer (until next reset)
if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_DEATHBRINGER_SAURFANG)))
deathbringer->DespawnOrUnsummon(5000);
break;
}
case ACTION_INTERRUPT_INTRO:
Expand Down Expand Up @@ -1175,6 +1196,9 @@ class spell_deathbringer_blood_nova_targeting : public SpellScriptLoader

void FilterTargetsInitial(std::list<Unit*>& unitList)
{
if (unitList.empty())
return;

// select one random target, with preference of ranged targets
uint32 targetsAtRange = 0;
uint32 const minTargets = uint32(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 10 : 4);
Expand All @@ -1189,7 +1213,9 @@ class spell_deathbringer_blood_nova_targeting : public SpellScriptLoader
if (targetsAtRange < minTargets)
targetsAtRange = std::min<uint32>(unitList.size() - 1, minTargets);

target = SelectRandomContainerElement(unitList);
std::list<Unit*>::const_iterator itr = unitList.begin();
std::advance(itr, urand(0, targetsAtRange));
target = *itr;
unitList.clear();
unitList.push_back(target);
}
Expand Down Expand Up @@ -1256,6 +1282,33 @@ class spell_deathbringer_boiling_blood : public SpellScriptLoader
}
};

class spell_deathbringer_remove_marks : public SpellScriptLoader
{
public:
spell_deathbringer_remove_marks() : SpellScriptLoader("spell_deathbringer_remove_marks") { }

class spell_deathbringer_remove_marks_SpellScript : public SpellScript
{
PrepareSpellScript(spell_deathbringer_remove_marks_SpellScript);

void HandleScript(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue()));
}

void Register()
{
OnEffectHitTarget += SpellEffectFn(spell_deathbringer_remove_marks_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};

SpellScript* GetSpellScript() const
{
return new spell_deathbringer_remove_marks_SpellScript();
}
};

class achievement_ive_gone_and_made_a_mess : public AchievementCriteriaScript
{
public:
Expand Down Expand Up @@ -1285,5 +1338,6 @@ void AddSC_boss_deathbringer_saurfang()
new spell_deathbringer_blood_nova();
new spell_deathbringer_blood_nova_targeting();
new spell_deathbringer_boiling_blood();
new spell_deathbringer_remove_marks();
new achievement_ive_gone_and_made_a_mess();
}
Expand Up @@ -585,8 +585,8 @@ class boss_the_lich_king : public CreatureScript
SendLightOverride(0, 5000);
break;
case ACTION_BREAK_FROSTMOURNE:
DoCastAOE(SPELL_SUMMON_BROKEN_FROSTMOURNE);
DoCastAOE(SPELL_SUMMON_BROKEN_FROSTMOURNE_2);
me->CastSpell((Unit*)NULL, SPELL_SUMMON_BROKEN_FROSTMOURNE, TRIGGERED_IGNORE_CAST_IN_PROGRESS);
me->CastSpell((Unit*)NULL, SPELL_SUMMON_BROKEN_FROSTMOURNE_2, TRIGGERED_IGNORE_CAST_IN_PROGRESS);
SetEquipmentSlots(false, EQUIP_BROKEN_FROSTMOURNE);
events.ScheduleEvent(EVENT_OUTRO_TALK_6, 2500, 0, PHASE_OUTRO);
break;
Expand Down Expand Up @@ -1065,12 +1065,11 @@ class boss_the_lich_king : public CreatureScript
Talk(SAY_LK_OUTRO_6);
if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HIGHLORD_TIRION_FORDRING)))
tirion->SetFacingToObject(me);
me->ClearUnitState(UNIT_STATE_CASTING);
DoCastAOE(SPELL_SUMMON_BROKEN_FROSTMOURNE_3);
me->CastSpell((Unit*)NULL, SPELL_SUMMON_BROKEN_FROSTMOURNE_3, TRIGGERED_IGNORE_CAST_IN_PROGRESS);
SetEquipmentSlots(false, EQUIP_UNEQUIP);
break;
case EVENT_OUTRO_SOUL_BARRAGE:
DoCastAOE(SPELL_SOUL_BARRAGE);
me->CastSpell((Unit*)NULL, SPELL_SOUL_BARRAGE, TRIGGERED_IGNORE_CAST_IN_PROGRESS);
sCreatureTextMgr->SendSound(me, SOUND_PAIN, CHAT_MSG_MONSTER_YELL, 0, TEXT_RANGE_NORMAL, TEAM_OTHER, false);
// set flight
me->SetDisableGravity(true);
Expand Down
Expand Up @@ -329,8 +329,13 @@ class boss_valithria_dreamwalker : public CreatureScript
_events.ScheduleEvent(EVENT_BERSERK, 420000);
}

void HealReceived(Unit* /*healer*/, uint32& heal)
void HealReceived(Unit* healer, uint32& heal)
{
if (!me->hasLootRecipient())
me->SetLootRecipient(healer);

me->LowerPlayerDamageReq(heal);

// encounter complete
if (me->HealthAbovePctHealed(100, heal) && !_done)
{
Expand Down
Expand Up @@ -331,6 +331,10 @@ enum GameObjectsIds
GO_DOODAD_ICECROWN_ROOSTPORTCULLIS_02 = 201381,
GO_DOODAD_ICECROWN_ROOSTPORTCULLIS_03 = 201382,
GO_DOODAD_ICECROWN_ROOSTPORTCULLIS_04 = 201383,
GO_CACHE_OF_THE_DREAMWALKER_10N = 201959,
GO_CACHE_OF_THE_DREAMWALKER_25N = 202339,
GO_CACHE_OF_THE_DREAMWALKER_10H = 202338,
GO_CACHE_OF_THE_DREAMWALKER_25H = 202340,

// Sindragosa
GO_SINDRAGOSA_ENTRANCE_DOOR = 201373,
Expand Down
Expand Up @@ -452,6 +452,14 @@ class instance_icecrown_citadel : public InstanceMapScript
case GO_DRINK_ME:
PutricideTableGUID = go->GetGUID();
break;
case GO_CACHE_OF_THE_DREAMWALKER_10N:
case GO_CACHE_OF_THE_DREAMWALKER_25N:
case GO_CACHE_OF_THE_DREAMWALKER_10H:
case GO_CACHE_OF_THE_DREAMWALKER_25H:
if (Creature* valithria = instance->GetCreature(ValithriaDreamwalkerGUID))
go->SetLootRecipient(valithria->GetLootRecipient());
go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE | GO_FLAG_NODESPAWN);
break;
case GO_ARTHAS_PLATFORM:
// this enables movement at The Frozen Throne, when printed this value is 0.000000f
// however, when represented as integer client will accept only this value
Expand Down Expand Up @@ -638,7 +646,13 @@ class instance_icecrown_citadel : public InstanceMapScript
switch (state)
{
case DONE:
DoRespawnGameObject(DeathbringersCacheGUID, 7*DAY);
if (GameObject* loot = instance->GetGameObject(DeathbringersCacheGUID))
{
if (Creature* deathbringer = instance->GetCreature(DeathbringerSaurfangGUID))
loot->SetLootRecipient(deathbringer->GetLootRecipient());
loot->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE | GO_FLAG_NODESPAWN);
}
// no break
case NOT_STARTED:
if (GameObject* teleporter = instance->GetGameObject(SaurfangTeleportGUID))
{
Expand Down

0 comments on commit c0165ec

Please sign in to comment.