Permalink
Browse files

Merge branch 'master' of https://github.com/scriptdev2/scriptdev2

Conflicts:
	include/precompiled.h
	include/sc_grid_searchers.cpp
	scripts/northrend/nexus/oculus/instance_oculus.cpp
  • Loading branch information...
2 parents 0bf84e1 + 5bc7e0e commit 28529bea3e7d1b69fd04a3f89b58736df82cd89c @rsa rsa committed Apr 15, 2012
View
@@ -6,11 +6,17 @@
#define SC_PRECOMPILED_H
#include "../ScriptMgr.h"
+#include "Object.h"
+#include "Unit.h"
+#include "Creature.h"
+#include "CreatureAI.h"
+#include "GameObject.h"
#include "sc_creature.h"
#include "sc_gossip.h"
#include "sc_grid_searchers.h"
#include "sc_instance.h"
#include "sc_utility.h"
+#include "SpellAuras.h"
#ifdef WIN32
# include <windows.h>
View
@@ -7,6 +7,10 @@
#include "Spell.h"
#include "WorldPacket.h"
#include "ObjectMgr.h"
+#include "Cell.h"
+#include "CellImpl.h"
+#include "GridNotifiers.h"
+#include "GridNotifiersImpl.h"
// Spell summary for ScriptedAI::SelectSpell
struct TSpellSummary
View
@@ -5,8 +5,6 @@
#ifndef SC_CREATURE_H
#define SC_CREATURE_H
-#include "CreatureAI.h"
-#include "Creature.h"
#include "Chat.h"
class EventManager;
@@ -3,7 +3,10 @@
* Please see the included DOCS/LICENSE.TXT for more information */
#include "precompiled.h"
-
+#include "Cell.h"
+#include "CellImpl.h"
+#include "GridNotifiers.h"
+#include "GridNotifiersImpl.h"
//return closest attackable Unit in grid, with range from pSource
Unit* GetClosestAttackableUnit(Unit* pSource, float fMaxSearchRange)
@@ -43,16 +46,16 @@ Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 uiEntry, floa
void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList , WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
{
- AllGameObjectsWithEntryInRangeCheck check(pSource, uiEntry, fMaxSearchRange);
- MaNGOS::GameObjectListSearcher<AllGameObjectsWithEntryInRangeCheck> searcher(lList, check);
+ MaNGOS::GameObjectEntryInPosRangeCheck check(*pSource, uiEntry, pSource->GetPositionX(), pSource->GetPositionY(), pSource->GetPositionZ(), fMaxSearchRange);
+ MaNGOS::GameObjectListSearcher<MaNGOS::GameObjectEntryInPosRangeCheck> searcher(lList, check);
Cell::VisitGridObjects(pSource, searcher, fMaxSearchRange);
}
void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
{
- AllCreaturesOfEntryInRangeCheck check(pSource, uiEntry, fMaxSearchRange);
- MaNGOS::CreatureListSearcher<AllCreaturesOfEntryInRangeCheck> searcher(lList, check);
+ MaNGOS::AllCreaturesOfEntryInRangeCheck check(pSource, uiEntry, fMaxSearchRange);
+ MaNGOS::CreatureListSearcher<MaNGOS::AllCreaturesOfEntryInRangeCheck> searcher(lList, check);
Cell::VisitGridObjects(pSource, searcher, fMaxSearchRange);
}
@@ -5,13 +5,9 @@
#ifndef SC_GRIDSEARCH_H
#define SC_GRIDSEARCH_H
-#include "Unit.h"
-#include "GameObject.h"
-
-#include "Cell.h"
-#include "CellImpl.h"
-#include "GridNotifiers.h"
-#include "GridNotifiersImpl.h"
+#include "Object.h"
+class GameObject;
+class Creature;
struct ObjectDistanceOrder : public std::binary_function<const WorldObject, const WorldObject, bool>
{
@@ -44,44 +40,6 @@ Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 uiEntry, floa
void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList , WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange);
void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange);
-class AllGameObjectsWithEntryInRangeCheck
-{
- public:
- AllGameObjectsWithEntryInRangeCheck(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {}
- WorldObject const& GetFocusObject() const { return *m_pObject; }
- bool operator() (GameObject* pGo)
- {
- if (pGo->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pGo,m_fRange,false))
- return true;
-
- return false;
- }
-
- private:
- const WorldObject* m_pObject;
- uint32 m_uiEntry;
- float m_fRange;
-};
-
-class AllCreaturesOfEntryInRangeCheck
-{
- public:
- AllCreaturesOfEntryInRangeCheck(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {}
- WorldObject const& GetFocusObject() const { return *m_pObject; }
- bool operator() (Unit* pUnit)
- {
- if (pUnit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pUnit,m_fRange,false))
- return true;
-
- return false;
- }
-
- private:
- const WorldObject* m_pObject;
- uint32 m_uiEntry;
- float m_fRange;
-};
-
//Used in: hyjalAI.cpp
/*
class AllFriendlyCreaturesInGrid
View
@@ -67,6 +67,39 @@ void ScriptedInstance::DoRespawnGameObject(ObjectGuid guid, uint32 uiTimeToDespa
}
}
+/// Function that uses a door or button that is stored in m_mGoEntryGuidStore
+void ScriptedInstance::DoToggleGameObjectFlags(uint32 uiEntry, uint32 uiGOflags, bool bApply)
+{
+ EntryGuidMap::iterator find = m_mGoEntryGuidStore.find(uiEntry);
+ if (find != m_mGoEntryGuidStore.end())
+ DoToggleGameObjectFlags(find->second, uiGOflags, bApply);
+ else
+ // Output log, possible reason is not added GO to storage, or not yet loaded
+ debug_log("SD2: Script call ToogleTameObjectFlags (by Entry), but no gameobject of entry %u was created yet, or it was not stored by script for map %u.", uiEntry, instance->GetId());
+}
+
+/**
+ Function that toggles the GO-flags of a GameObject
+
+ @param guid The ObjectGuid of the GO that will be respawned
+ @param uiGOflags Which GO-flags to toggle
+ @param bApply should the GO-flags be applied or removed?
+ */
+void ScriptedInstance::DoToggleGameObjectFlags(ObjectGuid guid, uint32 uiGOflags, bool bApply)
+{
+ if (!guid)
+ return;
+
+ if (GameObject* pGo = instance->GetGameObject(guid))
+ {
+ if (bApply)
+ pGo->SetFlag(GAMEOBJECT_FLAGS, uiGOflags);
+ else
+ pGo->RemoveFlag(GAMEOBJECT_FLAGS, uiGOflags);
+ }
+}
+
+
/// Function that respawns a despawned GO that is stored in m_mGoEntryGuidStore
void ScriptedInstance::DoRespawnGameObject(uint32 uiEntry, uint32 uiTimeToDespawn)
{
View
@@ -41,6 +41,10 @@ class MANGOS_DLL_DECL ScriptedInstance : public InstanceData
void DoRespawnGameObject(ObjectGuid guid, uint32 uiTimeToDespawn = MINUTE);
void DoRespawnGameObject(uint32 uiEntry, uint32 uiTimeToDespawn = MINUTE);
+ // Toggle the flags of a GO
+ void DoToggleGameObjectFlags(ObjectGuid guid, uint32 uiGOflags, bool bApply);
+ void DoToggleGameObjectFlags(uint32 uiEntry, uint32 uiGOflags, bool bApply);
+
// Sends world state update to all players in instance
void DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData);
@@ -109,8 +109,7 @@ void instance_blackwing_lair::SetData(uint32 uiType, uint32 uiData)
else if (uiData == FAIL)
{
// Reset the Orb of Domination and the eggs
- if (GameObject* pOrb = GetSingleGameObjectFromStorage(GO_ORB_OF_DOMINATION))
- pOrb->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
+ DoToggleGameObjectFlags(GO_ORB_OF_DOMINATION, GO_FLAG_NO_INTERACT, true);
// ToDo: reset the Dragon Eggs
}
@@ -195,8 +194,7 @@ void instance_blackwing_lair::OnCreatureDeath(Creature* pCreature)
{
if (pCreature->GetEntry() == NPC_GRETHOK_CONTROLLER)
{
- if (GameObject* pOrb = GetSingleGameObjectFromStorage(GO_ORB_OF_DOMINATION))
- pOrb->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
+ DoToggleGameObjectFlags(GO_ORB_OF_DOMINATION, GO_FLAG_NO_INTERACT, false);
if (Creature* pOrbTrigger = GetSingleCreatureFromStorage(NPC_BLACKWING_ORB_TRIGGER))
pOrbTrigger->InterruptNonMeleeSpells(false);
@@ -146,8 +146,7 @@ void instance_karazhan::SetData(uint32 uiType, uint32 uiData)
{
DoUseDoorOrButton(GO_STAGE_DOOR_LEFT);
DoUseDoorOrButton(GO_STAGE_DOOR_RIGHT);
- if (GameObject* pSideEntrance = GetSingleGameObjectFromStorage(GO_SIDE_ENTRANCE_DOOR))
- pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
+ DoToggleGameObjectFlags(GO_SIDE_ENTRANCE_DOOR, GO_FLAG_LOCKED, false);
}
break;
case TYPE_CURATOR:
@@ -304,16 +304,7 @@ bool instance_sunken_temple::ProcessStatueEvent(uint32 uiEventId)
void instance_sunken_temple::DoUpdateFlamesFlags(bool bRestore)
{
for (GUIDList::const_iterator itr = m_luiFlameGUIDs.begin(); itr != m_luiFlameGUIDs.end(); ++itr)
- {
- if (GameObject* pFlame = instance->GetGameObject(*itr))
- {
- // Remove the flags of the flames for Hakkar event
- if (!bRestore)
- pFlame->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
- else
- pFlame->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
- }
- }
+ DoToggleGameObjectFlags(*itr, GO_FLAG_NO_INTERACT, bRestore);
}
void instance_sunken_temple::Load(const char* chrIn)
@@ -143,8 +143,7 @@ struct MANGOS_DLL_DECL npc_harrison_jones_zaAI : public npc_escortAI
case 1:
DoScriptText(SAY_AT_GONG, m_creature);
- if (GameObject* pStrangeGong = m_pInstance->GetSingleGameObjectFromStorage(GO_STRANGE_GONG))
- pStrangeGong->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
+ m_pInstance->DoToggleGameObjectFlags(GO_STRANGE_GONG, GO_FLAG_NO_INTERACT, false);
//Start bang gong for 2min
m_creature->CastSpell(m_creature, SPELL_BANGING_THE_GONG, false);
@@ -78,6 +78,10 @@ struct MANGOS_DLL_DECL boss_arlokkAI : public ScriptedAI
m_uiSummonTimer = 5000;
m_bIsPhaseTwo = false;
+
+ // Restore visibility
+ if (m_creature->GetVisibility() != VISIBILITY_ON)
+ m_creature->SetVisibility(VISIBILITY_ON);
}
void Aggro(Unit* pWho)
@@ -98,7 +102,8 @@ struct MANGOS_DLL_DECL boss_arlokkAI : public ScriptedAI
{
DoScriptText(SAY_DEATH, m_creature);
// Restore visibility in case of killed by dots
- m_creature->SetVisibility(VISIBILITY_ON);
+ if (m_creature->GetVisibility() != VISIBILITY_ON)
+ m_creature->SetVisibility(VISIBILITY_ON);
if (m_pInstance)
m_pInstance->SetData(TYPE_ARLOKK, DONE);
@@ -65,7 +65,7 @@ void instance_zulgurub::OnCreatureCreate(Creature* pCreature)
if (pCreature->GetPositionY() < -1626)
m_lLeftPantherTriggerGUIDList.push_back(pCreature->GetObjectGuid());
else
- m_lRightPantherTirggerGUIDList.push_back(pCreature->GetObjectGuid());
+ m_lRightPantherTriggerGUIDList.push_back(pCreature->GetObjectGuid());
break;
}
}
@@ -170,7 +170,7 @@ uint32 instance_zulgurub::GetData(uint32 uiType)
Creature* instance_zulgurub::SelectRandomPantherTrigger(bool bIsLeft)
{
- GUIDList* plTempList = bIsLeft ? &m_lLeftPantherTriggerGUIDList : &m_lRightPantherTirggerGUIDList;
+ GUIDList* plTempList = bIsLeft ? &m_lLeftPantherTriggerGUIDList : &m_lRightPantherTriggerGUIDList;
std::vector<Creature*> vTriggers;
vTriggers.reserve(plTempList->size());
@@ -66,7 +66,7 @@ class MANGOS_DLL_DECL instance_zulgurub : public ScriptedInstance
uint32 m_auiEncounter[MAX_ENCOUNTER];
std::string m_strInstData;
- GUIDList m_lRightPantherTirggerGUIDList;
+ GUIDList m_lRightPantherTriggerGUIDList;
GUIDList m_lLeftPantherTriggerGUIDList;
bool m_bHasIntroYelled;
@@ -104,28 +104,19 @@ void instance_nexus::SetData(uint32 uiType, uint32 uiData)
if (uiData == IN_PROGRESS)
SetSpecialAchievementCriteria(TYPE_ACHIEV_SPLIT_PERSONALITY, true);
if (uiData == DONE)
- {
- if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_CONTAINMENT_SPHERE_TELESTRA))
- pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
- }
+ DoToggleGameObjectFlags(GO_CONTAINMENT_SPHERE_TELESTRA, GO_FLAG_NO_INTERACT, false);
break;
case TYPE_ANOMALUS:
m_auiEncounter[uiType] = uiData;
if (uiData == IN_PROGRESS)
SetSpecialAchievementCriteria(TYPE_ACHIEV_CHAOS_THEORY, true);
if (uiData == DONE)
- {
- if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_CONTAINMENT_SPHERE_ANOMALUS))
- pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
- }
+ DoToggleGameObjectFlags(GO_CONTAINMENT_SPHERE_ANOMALUS, GO_FLAG_NO_INTERACT, false);
break;
case TYPE_ORMOROK:
m_auiEncounter[uiType] = uiData;
if (uiData == DONE)
- {
- if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_CONTAINMENT_SPHERE_ORMOROK))
- pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
- }
+ DoToggleGameObjectFlags(GO_CONTAINMENT_SPHERE_ORMOROK, GO_FLAG_NO_INTERACT, false);
break;
case TYPE_KERISTRASZA:
m_auiEncounter[uiType] = uiData;
@@ -225,4 +225,4 @@ void AddSC_instance_oculus()
newscript->Name = "go_oculus_portal";
newscript->pGOUse = GOUse_go_oculus_portal;
newscript->RegisterSelf();
-}
+}
@@ -113,8 +113,7 @@ void instance_halls_of_stone::SetData(uint32 uiType, uint32 uiData)
SortFaces();
break;
case DONE:
- if (GameObject* pChest = GetSingleGameObjectFromStorage(instance->IsRegularDifficulty() ? GO_TRIBUNAL_CHEST : GO_TRIBUNAL_CHEST_H))
- pChest->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
+ DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_TRIBUNAL_CHEST : GO_TRIBUNAL_CHEST_H, GO_FLAG_NO_INTERACT, false);
// Door workaround because of the missing Bran event
DoUseDoorOrButton(GO_DOOR_SJONNIR);
break;
@@ -65,9 +65,7 @@ void instance_sethekk_halls::SetData(uint32 uiType, uint32 uiData)
if (uiData == DONE)
{
DoUseDoorOrButton(GO_IKISS_DOOR, DAY);
-
- if(GameObject* pChest = GetSingleGameObjectFromStorage(GO_IKISS_CHEST))
- pChest->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT | GO_FLAG_INTERACT_COND);
+ DoToggleGameObjectFlags(GO_IKISS_CHEST, GO_FLAG_NO_INTERACT | GO_FLAG_INTERACT_COND, false);
}
m_auiEncounter[uiType] = uiData;
break;
@@ -84,7 +84,10 @@ void instance_ramparts::SetData(uint32 uiType, uint32 uiData)
return;
}
if (uiData == DONE && m_auiEncounter[0] == DONE)
+ {
DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_FEL_IRON_CHEST : GO_FEL_IRON_CHEST_H, HOUR);
+ DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_FEL_IRON_CHEST : GO_FEL_IRON_CHEST_H, GO_FLAG_NO_INTERACT, false);
+ }
if (uiData == FAIL && m_auiEncounter[1] != FAIL)
DoFailVazruden();
View
@@ -1,4 +1,4 @@
#ifndef __SD2_REVISION_NR_H__
#define __SD2_REVISION_NR_H__
- #define SD2_REVISION_NR "2518"
+ #define SD2_REVISION_NR "2524"
#endif // __SD2_REVISION_NR_H__
@@ -3,7 +3,7 @@
--
DELETE FROM sd2_db_version;
-INSERT INTO sd2_db_version (version) VALUES ('ScriptDev2 (for MaNGOS 11942+) ');
+INSERT INTO sd2_db_version (version) VALUES ('ScriptDev2 (for MaNGOS 11962+) ');
--
-- Below contains data for table `script_texts` mainly used in C++ parts.
@@ -0,0 +1 @@
+UPDATE sd2_db_version SET version='ScriptDev2 (for MaNGOS 11962+) ';

0 comments on commit 28529be

Please sign in to comment.