17
17
/* ScriptData
18
18
SDName: Blades_Edge_Mountains
19
19
SD%Complete: 90
20
- SDComment: Quest support: 10503, 10504, 10512, 10545, 10556, 10609, 11058, 11080. (npc_daranelle needs bit more work before consider complete)
20
+ SDComment: Quest support: 10503, 10504, 10512, 10545, 10556, 10609, 10674, 10859, 11058, 11080. (npc_daranelle needs bit more work before consider complete)
21
21
SDCategory: Blade's Edge Mountains
22
22
EndScriptData */
23
23
@@ -26,6 +26,7 @@ mobs_nether_drake
26
26
npc_daranelle
27
27
npc_bloodmaul_stout_trigger
28
28
npc_simon_game_bunny
29
+ npc_light_orb_collector
29
30
EndContentData */
30
31
31
32
#include " precompiled.h"
@@ -794,6 +795,100 @@ bool EffectScriptEffectCreature_npc_simon_game_bunny(Unit* pCaster, uint32 uiSpe
794
795
return false ;
795
796
}
796
797
798
+ /* ######
799
+ ## npc_light_orb_collector
800
+ ######*/
801
+
802
+ enum
803
+ {
804
+ NPC_LIGHT_ORB_MINI = 20771 ,
805
+ NPC_KILL_CREDIT_TRIGGER = 21929 ,
806
+
807
+ MAX_PULL_DISTANCE = 20 ,
808
+ };
809
+
810
+ struct npc_light_orb_collectorAI : public ScriptedAI
811
+ {
812
+ npc_light_orb_collectorAI (Creature* pCreature) : ScriptedAI(pCreature) { Reset (); }
813
+
814
+ ObjectGuid m_selectedOrbGuid;
815
+ bool m_bOrbPulled;
816
+
817
+ uint32 m_uiStartTimer;
818
+
819
+ void Reset () override
820
+ {
821
+ m_bOrbPulled = false ;
822
+ m_uiStartTimer = 0 ;
823
+ }
824
+
825
+ void MoveInLineOfSight (Unit* pWho) override
826
+ {
827
+ if (pWho->GetTypeId () != TYPEID_UNIT || pWho->GetEntry () != NPC_LIGHT_ORB_MINI)
828
+ return ;
829
+
830
+ // Select an nearby orb to collect
831
+ if (!m_uiStartTimer && !m_bOrbPulled)
832
+ {
833
+ if (m_creature->GetDistance (pWho) <= MAX_PULL_DISTANCE)
834
+ {
835
+ m_selectedOrbGuid = pWho->GetObjectGuid ();
836
+ m_uiStartTimer = 2000 ;
837
+ }
838
+ }
839
+ else if (m_bOrbPulled && pWho->GetObjectGuid () == m_selectedOrbGuid && m_creature->IsWithinDistInMap (pWho, 3 .5f ))
840
+ {
841
+ // Despawn the collected orb if close enough
842
+ ((Creature*)pWho)->ForcedDespawn ();
843
+
844
+ // Give kill credit to the player
845
+ if (m_creature->IsTemporarySummon ())
846
+ {
847
+ TemporarySummon* pTemporary = (TemporarySummon*)m_creature;
848
+
849
+ if (Player* pSummoner = m_creature->GetMap ()->GetPlayer (pTemporary->GetSummonerGuid ()))
850
+ pSummoner->KilledMonsterCredit (NPC_KILL_CREDIT_TRIGGER, m_creature->GetObjectGuid ());
851
+ }
852
+
853
+ // Despawn collector
854
+ m_creature->ForcedDespawn ();
855
+ }
856
+ }
857
+
858
+ void UpdateAI (const uint32 uiDiff) override
859
+ {
860
+ if (m_uiStartTimer)
861
+ {
862
+ // Start collecting after some delay
863
+ if (m_uiStartTimer <= uiDiff)
864
+ {
865
+ Creature* pSelectedOrb = m_creature->GetMap ()->GetCreature (m_selectedOrbGuid);
866
+ if (!pSelectedOrb)
867
+ return ;
868
+
869
+ // Orb is pulled fast
870
+ pSelectedOrb->SetWalk (false );
871
+
872
+ // Move orb to the collector
873
+ float fX , fY , fZ ;;
874
+ pSelectedOrb->GetMotionMaster ()->MoveIdle ();
875
+ m_creature->GetContactPoint (pSelectedOrb, fX , fY , fZ );
876
+ pSelectedOrb->GetMotionMaster ()->MovePoint (0 , fX , fY , fZ );
877
+
878
+ m_bOrbPulled = true ;
879
+ m_uiStartTimer = 0 ;
880
+ }
881
+ else
882
+ m_uiStartTimer -= uiDiff;
883
+ }
884
+ }
885
+ };
886
+
887
+ CreatureAI* GetAI_npc_light_orb_collector (Creature* pCreature)
888
+ {
889
+ return new npc_light_orb_collectorAI (pCreature);
890
+ }
891
+
797
892
void AddSC_blades_edge_mountains ()
798
893
{
799
894
Script* pNewScript;
@@ -819,4 +914,9 @@ void AddSC_blades_edge_mountains()
819
914
pNewScript->pEffectDummyNPC = &EffectDummyCreature_npc_simon_game_bunny;
820
915
pNewScript->pEffectScriptEffectNPC = &EffectScriptEffectCreature_npc_simon_game_bunny;
821
916
pNewScript->RegisterSelf ();
917
+
918
+ pNewScript = new Script;
919
+ pNewScript->Name = " npc_light_orb_collector" ;
920
+ pNewScript->GetAI = &GetAI_npc_light_orb_collector;
921
+ pNewScript->RegisterSelf ();
822
922
}
0 commit comments