Skip to content

Commit

Permalink
Ghost-O-Plasm event implementation
Browse files Browse the repository at this point in the history
(based on cmangos/mangos-wotlk@70c8c8320)

Signed-off-by: Xfurry <xfurry.cmangos@outlook.com>
  • Loading branch information
killerwife authored and xfurry committed Jan 2, 2018
1 parent e86f4ed commit 37e0559
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/game/SpellEffects.cpp
Expand Up @@ -10879,6 +10879,9 @@ void Spell::EffectSummonObject(SpellEffectEntry const* effect)

pGameObj->SummonLinkedTrapIfAny();

if (gameobject_id == 177746)
pGameObj->Use(m_caster);

// Notify Summoner
if (m_originalCaster && (m_originalCaster != m_caster) && (m_originalCaster->AI()))
m_originalCaster->AI()->JustSummoned(pGameObj);
Expand Down
73 changes: 73 additions & 0 deletions src/scriptdev2/scripts/kalimdor/desolace.cpp
Expand Up @@ -678,6 +678,74 @@ bool QuestAccept_npc_rigger_gizelton(Player* pPlayer, Creature* pCreature, const
return true;
}

enum
{
SPELL_CURSE_OF_MAGRAMI = 18159,
SPELL_GHOST_SPAWN_IN = 17321,
SPELL_BLUE_AURA = 17327,
SPELL_GREEN_AURA = 18951,

FACTION_HOSTILE = 16,
};

struct npc_magrami_spectre : public ScriptedAI
{
npc_magrami_spectre(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); }

uint32 m_uiCurseTimer;

void Reset() override
{
m_uiCurseTimer = 4000;
}

void JustAIInit() override
{
m_creature->CastSpell(m_creature, SPELL_GHOST_SPAWN_IN, TRIGGERED_NONE);
m_creature->CastSpell(m_creature, SPELL_BLUE_AURA,TRIGGERED_NONE);
}

void MovementInform(uint32 uiMovementType, uint32 uiData) override
{
if (uiMovementType == POINT_MOTION_TYPE)
{
if (uiData == 1)
{
float x, y, z;
m_creature->GetPosition(x, y, z);
m_creature->GetMotionMaster()->MoveRandomAroundPoint(x, y, z, 3.f);
m_creature->RemoveAurasDueToSpell(SPELL_BLUE_AURA);
m_creature->CastSpell(m_creature, SPELL_GREEN_AURA, TRIGGERED_NONE);
m_creature->SetFactionTemporary(FACTION_HOSTILE, TEMPFACTION_NONE);
}
}
}

void UpdateAI(const uint32 uiDiff) override
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;

if (m_uiCurseTimer)
{
if (m_uiCurseTimer <= uiDiff)
{
m_uiCurseTimer = 0;
DoCastSpellIfCan(m_creature->getVictim(), SPELL_CURSE_OF_MAGRAMI);
}
else
m_uiCurseTimer -= uiDiff;
}

DoMeleeAttackIfReady();
}
};

CreatureAI* GetAI_npc_magrami_spectre(Creature* pCreature)
{
return new npc_magrami_spectre(pCreature);
}

void AddSC_desolace()
{
Script* pNewScript;
Expand Down Expand Up @@ -712,4 +780,9 @@ void AddSC_desolace()
pNewScript->GetAI = &GetAI_npc_rigger_gizelton;
pNewScript->pQuestAcceptNPC = &QuestAccept_npc_rigger_gizelton;
pNewScript->RegisterSelf();

pNewScript = new Script;
pNewScript->Name = "npc_magrami_spectre";
pNewScript->GetAI = &GetAI_npc_magrami_spectre;
pNewScript->RegisterSelf();
}
72 changes: 72 additions & 0 deletions src/scriptdev2/scripts/world/world_map_scripts.cpp
Expand Up @@ -52,6 +52,14 @@ InstanceData* GetInstanceData_world_map_eastern_kingdoms(Map* pMap)
return new world_map_eastern_kingdoms(pMap);
}

struct GhostOPlasmEvent
{
ObjectGuid guid;
uint32 despawnTimer;
uint8 phaseCounter;
std::vector<ObjectGuid> summonedMagrami;
};

/* *********************************************************
* KALIMDOR
*/
Expand All @@ -60,10 +68,12 @@ struct world_map_kalimdor : public ScriptedMap
world_map_kalimdor(Map* pMap) : ScriptedMap(pMap) { Initialize(); }

uint8 m_uiMurkdeepAdds_KilledAddCount;
std::vector<GhostOPlasmEvent> m_vGOEvents;

void Initialize()
{
m_uiMurkdeepAdds_KilledAddCount = 0;
m_vGOEvents.clear();
}

void OnCreatureCreate(Creature* pCreature)
Expand Down Expand Up @@ -129,6 +139,68 @@ struct world_map_kalimdor : public ScriptedMap
}
}

void OnObjectCreate(GameObject* pGo) override
{
switch (pGo->GetEntry())
{
case GO_GHOST_MAGNET:
m_vGOEvents.push_back({ pGo->GetObjectGuid(),0,0 }); // insert new event with 0 timer
pGo->SetActiveObjectState(true);
break;
}
}

bool GhostOPlasmEventStep(GhostOPlasmEvent& eventData)
{
if (eventData.despawnTimer > 180000)
{
for (auto guid : eventData.summonedMagrami)
if (Creature* magrami = instance->GetCreature(guid))
magrami->ForcedDespawn();

if (GameObject* go = instance->GetGameObject(eventData.guid))
go->AddObjectToRemoveList(); // TODO: Establish rules for despawning temporary GOs that were used in their lifetime (buttons for example)

return false;
}


if (GameObject* go = instance->GetGameObject(eventData.guid))
{
if (eventData.despawnTimer / 15000 >= eventData.phaseCounter)
{
float x, y, z;
go->GetPosition(x, y, z); // do some urand radius shenanigans to spawn it further and make it walk to go using doing X and Y yourself and using function in MAP to get proper Z
uint32 random = urand(0, 35);
float xR = x + random, yR = y + (35 - random), zR = z;
instance->GetHeightInRange(xR, yR, zR);
Creature* creature = go->SummonCreature(NPC_MAGRAMI_SPECTRE, xR, yR, zR, 0, TEMPSUMMON_TIMED_OOC_OR_CORPSE_DESPAWN, 180000); // add more timed logic here
instance->GetReachableRandomPointOnGround(x, y, z, 5.0f); // get position to which spectre will walk
eventData.phaseCounter++;
eventData.summonedMagrami.push_back(creature->GetObjectGuid());
creature->GetMotionMaster()->MovePoint(1, x, y, z);
}
return true;
}
else
return false;
}

void Update(uint32 diff)
{
if (!m_vGOEvents.empty())
{
for (auto iter = m_vGOEvents.begin(); iter != m_vGOEvents.end();)
{
iter->despawnTimer += diff;
if (!GhostOPlasmEventStep((*iter)))
iter = m_vGOEvents.erase(iter);
else
++iter;
}
}
}

void SetData(uint32 /*uiType*/, uint32 /*uiData*/) {}
};

Expand Down
4 changes: 4 additions & 0 deletions src/scriptdev2/scripts/world/world_map_scripts.h
Expand Up @@ -14,6 +14,10 @@ enum
NPC_MURKDEEP = 10323,
QUEST_WANTED_MURKDEEP = 4740,

// Quest 6134
GO_GHOST_MAGNET = 177746,
NPC_MAGRAMI_SPECTRE = 11560,

// Quest 6403
NPC_JONATHAN = 466,
NPC_WRYNN = 1747,
Expand Down

0 comments on commit 37e0559

Please sign in to comment.