Skip to content

Commit 686252d

Browse files
horstchexfurry
authored andcommitted
[s2838] Implement script support for quests 10674 and 10859
Signed-off-by: Xfurry <xfurry@scriptdev2.com> (based on commit SD2-TBC[3122] - 16f1ae1) Signed-off-by: xfurry <xfurry@scriptdev2.com>
1 parent 28fb90c commit 686252d

File tree

5 files changed

+106
-4
lines changed

5 files changed

+106
-4
lines changed

scripts/outland/blades_edge_mountains.cpp

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/* ScriptData
1818
SDName: Blades_Edge_Mountains
1919
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)
2121
SDCategory: Blade's Edge Mountains
2222
EndScriptData */
2323

@@ -26,6 +26,7 @@ mobs_nether_drake
2626
npc_daranelle
2727
npc_bloodmaul_stout_trigger
2828
npc_simon_game_bunny
29+
npc_light_orb_collector
2930
EndContentData */
3031

3132
#include "precompiled.h"
@@ -794,6 +795,100 @@ bool EffectScriptEffectCreature_npc_simon_game_bunny(Unit* pCaster, uint32 uiSpe
794795
return false;
795796
}
796797

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+
797892
void AddSC_blades_edge_mountains()
798893
{
799894
Script* pNewScript;
@@ -819,4 +914,9 @@ void AddSC_blades_edge_mountains()
819914
pNewScript->pEffectDummyNPC = &EffectDummyCreature_npc_simon_game_bunny;
820915
pNewScript->pEffectScriptEffectNPC = &EffectScriptEffectCreature_npc_simon_game_bunny;
821916
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();
822922
}

sd2_revision_nr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#ifndef __SD2_REVISION_NR_H__
22
#define __SD2_REVISION_NR_H__
3-
#define SD2_REVISION_NR "s2837"
3+
#define SD2_REVISION_NR "s2838"
44
#endif // __SD2_REVISION_NR_H__

sd2_revision_sql.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef __SD2_REVISION_SQL_H__
22
#define __SD2_REVISION_SQL_H__
3-
#define REVISION_DB_SCRIPTDEV2 "required__scriptdev2"
4-
#define REVISION_DB_SD2_MANGOS "required__mangos"
3+
#define REVISION_DB_SCRIPTDEV2 "required__scriptdev2"
4+
#define REVISION_DB_SD2_MANGOS "required__mangos"
55
#endif // __SD2_REVISION_SQL_H__

sql/mangos_scriptname_full.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ UPDATE creature_template SET ScriptName='mobs_nether_drake' WHERE entry IN (2002
308308
UPDATE creature_template SET ScriptName='npc_daranelle' WHERE entry=21469;
309309
UPDATE creature_template SET ScriptName='npc_bloodmaul_stout_trigger' WHERE entry=21241;
310310
UPDATE creature_template SET ScriptName='npc_simon_game_bunny' WHERE entry=22923;
311+
UPDATE creature_template SET ScriptName='npc_light_orb_collector' WHERE entry IN (21926,22333);
311312

312313
/* BLASTED LANDS */
313314
UPDATE creature_template SET ScriptName='npc_fallen_hero_of_horde' WHERE entry=7572;

sql/updates/r2838_mangos.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UPDATE creature_template SET ScriptName='npc_light_orb_collector' WHERE entry IN (21926,22333);

0 commit comments

Comments
 (0)