Skip to content

Instantly share code, notes, and snippets.

@Demonid
Created June 21, 2016 13:21
Show Gist options
  • Save Demonid/27cedc44249cee4f143401829e49ec74 to your computer and use it in GitHub Desktop.
Save Demonid/27cedc44249cee4f143401829e49ec74 to your computer and use it in GitHub Desktop.
diff --git a/sql/updates/world/DontLookUp.sql b/sql/updates/world/DontLookUp.sql
new file mode 100644
index 0000000..824655e
--- /dev/null
+++ b/sql/updates/world/DontLookUp.sql
@@ -0,0 +1,10 @@
+DELETE FROM `achievement_criteria_data` WHERE `criteria_id`=12994 AND `type`=18;
+UPDATE `creature_template` SET `ScriptName`='npc_pit_of_saron_icicle' WHERE `entry`=32780;
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_pos_ice_shards';
+INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
+(70827, 'spell_pos_ice_shards');
+
+DELETE FROM `areatrigger_scripts` WHERE `entry` IN (5580,5581);
+INSERT INTO `areatrigger_scripts` (`entry`, `ScriptName`) VALUES
+(5580, 'at_pit_cavern_entrance'),
+(5581, 'at_pit_cavern_end');
diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp
index 12845d6..d7fbf4d 100644
--- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp
@@ -45,6 +45,8 @@ class instance_pit_of_saron : public InstanceMapScript
SetBossNumber(EncounterCount);
LoadDoorData(Doors);
_teamInInstance = 0;
+ _cavernActive = 0;
+ _shardsHit = 0;
}
void OnPlayerEnter(Player* player) override
@@ -224,6 +226,10 @@ class instance_pit_of_saron : public InstanceMapScript
{
case DATA_TEAM_IN_INSTANCE:
return _teamInInstance;
+ case DATA_ICE_SHARDS_HIT:
+ return _shardsHit;
+ case DATA_CAVERN_ACTIVE:
+ return _cavernActive;
default:
break;
}
@@ -231,6 +237,19 @@ class instance_pit_of_saron : public InstanceMapScript
return 0;
}
+ void SetData(uint32 type, uint32 data) override
+ {
+ switch (type)
+ {
+ case DATA_ICE_SHARDS_HIT:
+ _shardsHit = data;
+ break;
+ case DATA_CAVERN_ACTIVE:
+ _cavernActive = data;
+ break;
+ }
+ }
+
ObjectGuid GetGuidData(uint32 type) const override
{
switch (type)
@@ -270,6 +289,8 @@ class instance_pit_of_saron : public InstanceMapScript
ObjectGuid _jainaOrSylvanas2GUID;
uint32 _teamInInstance;
+ uint8 _shardsHit;
+ uint8 _cavernActive;
};
InstanceScript* GetInstanceScript(InstanceMap* map) const override
diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp
index a39c451..a2a8afb 100644
--- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp
@@ -21,6 +21,7 @@
#include "SpellAuraEffects.h"
#include "pit_of_saron.h"
#include "Vehicle.h"
+#include "Player.h"
enum Spells
{
@@ -246,10 +247,179 @@ class spell_trash_npc_glacial_strike : public SpellScriptLoader
}
};
+enum SpellsIcicle
+{
+ // Collapsing Icicle
+ SPELL_ICICLE_SUMMON = 69424,
+ SPELL_ICICLE_FALL_TRIGGER = 69426,
+ SPELL_ICICLE_FALL_VISUAL = 69428,
+ SPELL_DONT_LOOK_UP_ACHIEV_CREDIT = 72845
+};
+
+class DelayedIcicleFallEvent : public BasicEvent
+{
+ public:
+ DelayedIcicleFallEvent(Creature* trigger, ObjectGuid casterGUID) : _trigger(trigger), _casterGUID(casterGUID) { }
+
+ bool Execute(uint64 /*time*/, uint32 /*diff*/) override
+ {
+ _trigger->CastSpell(_trigger, SPELL_ICICLE_FALL_TRIGGER, true);
+ _trigger->CastSpell(_trigger, SPELL_ICICLE_FALL_VISUAL, false);
+
+ if (Unit* caster = ObjectAccessor::GetUnit(*_trigger, _casterGUID))
+ caster->RemoveDynObject(SPELL_ICICLE_SUMMON);
+
+ /// @todo: fix snowfall visual after collapse
+
+ return true;
+ }
+
+ private:
+ Creature* _trigger;
+ ObjectGuid _casterGUID;
+};
+
+/// @todo: delete duplicate spawns in db
+class npc_pit_of_saron_icicle : public CreatureScript
+{
+ public:
+ npc_pit_of_saron_icicle() : CreatureScript("npc_pit_of_saron_icicle") { }
+
+ struct npc_pit_of_saron_icicleAI : public ScriptedAI
+ {
+ npc_pit_of_saron_icicleAI(Creature* creature) : ScriptedAI(creature)
+ {
+ instance = me->GetInstanceScript();
+ }
+
+ uint32 timer;
+ InstanceScript* instance;
+
+ void Reset() override
+ {
+ timer = urand(1000, 30000);
+ }
+
+ void JustSummoned(Creature* summon) override
+ {
+ summon->SetReactState(REACT_PASSIVE);
+ summon->m_Events.AddEvent(new DelayedIcicleFallEvent(summon, me->GetGUID()), summon->m_Events.CalculateTime(3000));
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ if (!me->GetMap()->GetPlayersCountExceptGMs())
+ return;
+
+ if (instance->GetData(DATA_CAVERN_ACTIVE) != 1)
+ return;
+
+ if (timer <= diff)
+ {
+ if (urand(1, 8) == 1)
+ {
+ me->CastSpell(me, SPELL_ICICLE_SUMMON, true);
+ timer = urand(20000, 35000);
+ }
+ else
+ timer = urand(1000, 20000);
+ }
+ else
+ timer -= diff;
+ }
+ };
+
+ CreatureAI* GetAI(Creature* creature) const override
+ {
+ return GetPitOfSaronAI<npc_pit_of_saron_icicleAI>(creature);
+ }
+};
+
+class spell_pos_ice_shards : public SpellScriptLoader
+{
+ public:
+ spell_pos_ice_shards() : SpellScriptLoader("spell_pos_ice_shards") { }
+
+ class spell_pos_ice_shards_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_pos_ice_shards_SpellScript);
+
+ bool Load() override
+ {
+ // This script should execute only in Pit of Saron
+ if (InstanceMap* instance = GetCaster()->GetMap()->ToInstanceMap())
+ if (instance->GetInstanceScript())
+ if (instance->GetScriptId() == sObjectMgr->GetScriptId(PoSScriptName))
+ return true;
+
+ return false;
+ }
+
+ void HandleScriptEffect(SpellEffIndex /*effIndex*/)
+ {
+ if (GetHitPlayer())
+ GetCaster()->GetInstanceScript()->SetData(DATA_ICE_SHARDS_HIT, 1);
+ }
+
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_pos_ice_shards_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_pos_ice_shards_SpellScript();
+ }
+};
+
+class at_pit_cavern_entrance : public AreaTriggerScript
+{
+ public:
+ at_pit_cavern_entrance() : AreaTriggerScript("at_pit_cavern_entrance") { }
+
+ bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
+ {
+ if (InstanceScript* instance = player->GetInstanceScript())
+ if (Creature* tyrannus = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_TYRANNUS)))
+ {
+ instance->SetData(DATA_CAVERN_ACTIVE, 1);
+ tyrannus->AI()->Talk(1);
+ }
+
+
+ return true;
+ }
+};
+
+class at_pit_cavern_end : public AreaTriggerScript
+{
+public:
+ at_pit_cavern_end() : AreaTriggerScript("at_pit_cavern_end") { }
+
+ bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
+ {
+ if (InstanceScript* instance = player->GetInstanceScript())
+ {
+ instance->SetData(DATA_CAVERN_ACTIVE, 0);
+
+ if (instance->GetData(DATA_ICE_SHARDS_HIT) == 0)
+ instance->DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_DONT_LOOK_UP_ACHIEV_CREDIT, 0, player);
+ }
+
+ return true;
+ }
+};
+
void AddSC_pit_of_saron()
{
new npc_ymirjar_flamebearer();
new npc_iceborn_protodrake();
new npc_geist_ambusher();
new spell_trash_npc_glacial_strike();
+
+ new npc_pit_of_saron_icicle();
+ new spell_pos_ice_shards();
+ new at_pit_cavern_entrance();
+ new at_pit_cavern_end();
}
diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.h b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.h
index 8e2b46c..d7a6727 100644
--- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.h
+++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.h
@@ -36,7 +36,9 @@ enum DataTypes
DATA_JAINA_SYLVANAS_1 = 5, // GUID of either Jaina or Sylvanas part 1, depending on team, as it's the same spawn.
DATA_JAINA_SYLVANAS_2 = 6, // GUID of either Jaina or Sylvanas part 2, depending on team, as it's the same spawn.
DATA_TYRANNUS_EVENT = 7,
- DATA_TEAM_IN_INSTANCE = 8
+ DATA_TEAM_IN_INSTANCE = 8,
+ DATA_ICE_SHARDS_HIT = 9,
+ DATA_CAVERN_ACTIVE = 10
};
enum CreatureIds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment