From 8fd083c073ab52655a56e8ccc09da8c9e783b138 Mon Sep 17 00:00:00 2001 From: Souler Date: Wed, 9 Nov 2011 16:47:51 +0100 Subject: Scripts/Gundrak: Add support for achievement "Snakes. Why'd It Have To Be Snakes?" --- .../scripts/Northrend/Gundrak/boss_slad_ran.cpp | 64 +++++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp index 7e417a840f2..b3801c5cfa9 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp @@ -52,6 +52,7 @@ enum Creatures enum ConstrictorSpells { SPELL_GRIP_OF_SLAD_RAN = 55093, + SPELL_SNAKE_WRAP = 55126, SPELL_VENOMOUS_BITE = 54987, H_SPELL_VENOMOUS_BITE = 58996 }; @@ -65,6 +66,8 @@ static Position SpawnLoc[]= {1716.76f, 635.159f, 129.282f, 0.191986f} }; +#define DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES 1 + class boss_slad_ran : public CreatureScript { public: @@ -89,6 +92,8 @@ public: uint8 uiPhase; + bool snakesAchievement; + SummonList lSummons; InstanceScript* instance; @@ -100,6 +105,7 @@ public: uiVenomBoltTimer = 15*IN_MILLISECONDS; uiSpawnTimer = 5*IN_MILLISECONDS; uiPhase = 0; + snakesAchievement = true; lSummons.DespawnAll(); @@ -171,6 +177,7 @@ public: void JustDied(Unit* /*killer*/) { DoScriptText(SAY_DEATH, me); + lSummons.DespawnAll(); if (instance) instance->SetData(DATA_SLAD_RAN_EVENT, DONE); @@ -186,6 +193,20 @@ public: summoned->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); lSummons.Summon(summoned); } + + void SetData(uint32 type, uint32 /*data*/) + { + if (type == DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES) + snakesAchievement = false; + } + + uint32 GetData(uint32 type) + { + if (type == DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES) + return snakesAchievement ? 1 : 0; + + return 0; + } }; }; @@ -215,10 +236,26 @@ public: { if (!UpdateVictim()) return; + if (uiGripOfSladRanTimer <= diff) { - DoCast(me->getVictim(), SPELL_GRIP_OF_SLAD_RAN); - uiGripOfSladRanTimer = 5*IN_MILLISECONDS; + Unit* target = me->getVictim(); + + DoCast(target, SPELL_GRIP_OF_SLAD_RAN); + uiGripOfSladRanTimer = urand(3, 6)*IN_MILLISECONDS; + + Aura* grip = target->GetAura(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID()); + if (grip && grip->GetStackAmount() == 5) + { + target->RemoveAurasDueToSpell(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID()); + target->CastSpell(target, SPELL_SNAKE_WRAP, true); + + if (TempSummon* _me = me->ToTempSummon()) + if (Creature* sladran = _me->GetSummoner()->ToCreature()) + sladran->AI()->SetData(DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES, 0); + + me->DespawnOrUnsummon(); + } } else uiGripOfSladRanTimer -= diff; } @@ -265,9 +302,30 @@ public: }; +class achievement_snakes_whyd_it_have_to_be_snakes : public AchievementCriteriaScript +{ + public: + achievement_snakes_whyd_it_have_to_be_snakes() : AchievementCriteriaScript("achievement_snakes_whyd_it_have_to_be_snakes") + { + } + + bool OnCheck(Player* /*player*/, Unit* target) + { + if (!target) + return false; + + if (Creature* sladran = target->ToCreature()) + if (sladran->AI()->GetData(DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES)) + return true; + + return false; + } +}; + void AddSC_boss_slad_ran() { new boss_slad_ran(); new mob_slad_ran_constrictor(); new mob_slad_ran_viper(); -} + new achievement_snakes_whyd_it_have_to_be_snakes(); +} \ No newline at end of file -- cgit v1.2.3 From 9343645625eb8d4a5493c1f9d3db41deb542ff1d Mon Sep 17 00:00:00 2001 From: Souler Date: Wed, 9 Nov 2011 18:45:39 +0100 Subject: Scripts/Gundrak: Achievement "Snakes. Why'd It Have To Be Snakes?" should be individual for each player. Thanks to @Lopin for pointing it. --- .../scripts/Northrend/Gundrak/boss_slad_ran.cpp | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp index b3801c5cfa9..f2b9fb704d5 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp @@ -92,8 +92,7 @@ public: uint8 uiPhase; - bool snakesAchievement; - + std::set lWrappedPlayers; SummonList lSummons; InstanceScript* instance; @@ -105,7 +104,7 @@ public: uiVenomBoltTimer = 15*IN_MILLISECONDS; uiSpawnTimer = 5*IN_MILLISECONDS; uiPhase = 0; - snakesAchievement = true; + lWrappedPlayers.clear(); lSummons.DespawnAll(); @@ -194,18 +193,15 @@ public: lSummons.Summon(summoned); } - void SetData(uint32 type, uint32 /*data*/) + void SetGUID(uint64 guid, int32 type) { if (type == DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES) - snakesAchievement = false; + lWrappedPlayers.insert(guid); } - uint32 GetData(uint32 type) + bool WasWrapped(uint64 guid) { - if (type == DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES) - return snakesAchievement ? 1 : 0; - - return 0; + return lWrappedPlayers.count(guid); } }; @@ -252,7 +248,7 @@ public: if (TempSummon* _me = me->ToTempSummon()) if (Creature* sladran = _me->GetSummoner()->ToCreature()) - sladran->AI()->SetData(DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES, 0); + sladran->AI()->SetGUID(target->GetGUID() ,DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES); me->DespawnOrUnsummon(); } @@ -309,15 +305,13 @@ class achievement_snakes_whyd_it_have_to_be_snakes : public AchievementCriteriaS { } - bool OnCheck(Player* /*player*/, Unit* target) + bool OnCheck(Player* player, Unit* target) { if (!target) return false; - if (Creature* sladran = target->ToCreature()) - if (sladran->AI()->GetData(DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES)) - return true; - + if (boss_slad_ran::boss_slad_ranAI* sladRanAI = CAST_AI(boss_slad_ran::boss_slad_ranAI, target->GetAI())) + return !sladRanAI->WasWrapped(player->GetGUID()); return false; } }; -- cgit v1.2.3