aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-05-30 22:15:05 -0500
committermegamage <none@none>2009-05-30 22:15:05 -0500
commit8d1f4f9ea0beb503e2a3014abb95263e501ef1c5 (patch)
tree41d48951c315129dee817befa40d4dab90d3fd14 /src
parentb5778357d9d8c5fb10da5d99c46b48250578cb49 (diff)
*Provide another way to implement dynamic spawns. Now a creature will call its zonescript before spawn to determine the spawned entry. This can be used to implement zones such as wintergrasp with less data requirement (only need to know the entry of counterpart creatures, not require spawn points)
*Use zonescript as basic class of opvp script and dugeon script (can also be used for bg) *Store zonescript in worldobject. *Add door for sapphiron. --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp3
-rw-r--r--src/game/BattleGround.cpp11
-rw-r--r--src/game/CMakeLists.txt3
-rw-r--r--src/game/Creature.cpp43
-rw-r--r--src/game/Creature.h2
-rw-r--r--src/game/Debugcmds.cpp16
-rw-r--r--src/game/GameObject.cpp26
-rw-r--r--src/game/InstanceData.h19
-rw-r--r--src/game/Level2.cpp57
-rw-r--r--src/game/Object.cpp49
-rw-r--r--src/game/Object.h4
-rw-r--r--src/game/ObjectMgr.cpp17
-rw-r--r--src/game/OutdoorPvP.cpp21
-rw-r--r--src/game/OutdoorPvP.h10
-rw-r--r--src/game/OutdoorPvPMgr.cpp14
-rw-r--r--src/game/OutdoorPvPMgr.h3
-rw-r--r--src/game/OutdoorPvPObjectiveAI.cpp17
-rw-r--r--src/game/OutdoorPvPObjectiveAI.h17
-rw-r--r--src/game/Vehicle.cpp13
-rw-r--r--src/game/Vehicle.h2
-rw-r--r--src/game/Wintergrasp.cpp60
-rw-r--r--src/game/Wintergrasp.h7
-rw-r--r--src/game/ZoneScript.h47
23 files changed, 215 insertions, 246 deletions
diff --git a/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp b/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp
index f2ba97d2858..95783562e65 100644
--- a/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp
+++ b/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp
@@ -41,6 +41,7 @@ const DoorData doorData[] =
{181125, BOSS_GOTHIK, DOOR_TYPE_PASSAGE, BOUNDARY_S},
{181119, BOSS_GOTHIK, DOOR_TYPE_PASSAGE, 0},
{181119, BOSS_HORSEMEN, DOOR_TYPE_ROOM, BOUNDARY_NE},
+ {181225, BOSS_SAPPHIRON, DOOR_TYPE_PASSAGE, BOUNDARY_W},
{0, 0, DOOR_TYPE_ROOM, 0}, // EOF
};
@@ -115,7 +116,7 @@ struct TRINITY_DLL_DECL instance_naxxramas : public InstanceData
AddMinion(creature, add);
}
- void OnObjectCreate(GameObject* go, bool add)
+ void OnGameObjectCreate(GameObject* go, bool add)
{
if(go->GetGOInfo()->displayId == 6785 || go->GetGOInfo()->displayId == 1287)
{
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index acb3f25ae31..a995157786f 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -1490,22 +1490,13 @@ Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, f
return NULL;
Creature* pCreature = new Creature;
- if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, teamval))
+ if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, teamval, x, y, z, o))
{
sLog.outError("Can't create creature entry: %u",entry);
delete pCreature;
return NULL;
}
- pCreature->Relocate(x, y, z, o);
-
- if (!pCreature->IsPositionValid())
- {
- sLog.outError("Creature (guidlow %d, entry %d) not added to battleground. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
- delete pCreature;
- return NULL;
- }
-
pCreature->SetHomePosition(x, y, z, o);
//pCreature->SetDungeonDifficulty(0);
diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt
index 44e692b71ba..09e9918cdbb 100644
--- a/src/game/CMakeLists.txt
+++ b/src/game/CMakeLists.txt
@@ -186,8 +186,6 @@ SET(game_STAT_SRCS
OutdoorPvPMgr.h
OutdoorPvPNA.cpp
OutdoorPvPNA.h
- OutdoorPvPObjectiveAI.cpp
- OutdoorPvPObjectiveAI.h
OutdoorPvPSI.cpp
OutdoorPvPSI.h
OutdoorPvPTF.cpp
@@ -296,6 +294,7 @@ SET(game_STAT_SRCS
OutdoorPvPImpl.h
Wintergrasp.h
Wintergrasp.cpp
+ ZoneScript.h
)
add_library(game STATIC ${game_STAT_SRCS})
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index fc5b0436867..01a3b057ce9 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -174,6 +174,8 @@ void Creature::AddToWorld()
///- Register the creature for guid lookup
if(!IsInWorld())
{
+ if(m_zoneScript)
+ m_zoneScript->OnCreatureCreate(this, true);
ObjectAccessor::Instance().AddObject(this);
Unit::AddToWorld();
SearchFormationAndPath();
@@ -185,9 +187,8 @@ void Creature::RemoveFromWorld()
{
if(IsInWorld())
{
- if(Map *map = FindMap())
- if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData())
- ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this, false);
+ if(m_zoneScript)
+ m_zoneScript->OnCreatureCreate(this, false);
if(m_formation)
formation_mgr.RemoveCreatureFromGroup(m_formation, this);
Unit::RemoveFromWorld();
@@ -694,8 +695,15 @@ void Creature::Motion_Initialize()
i_motionMaster.Initialize();
}
-bool Creature::Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data)
+bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, float x, float y, float z, float ang, const CreatureData *data)
{
+ Relocate(x, y, z, ang);
+ if(!IsPositionValid())
+ {
+ sLog.outError("Creature (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",guidlow,Entry,x,y);
+ return false;
+ }
+
SetMapId(map->GetId());
SetInstanceId(map->GetInstanceId());
SetPhaseMask(phaseMask,false);
@@ -1440,12 +1448,21 @@ float Creature::GetSpellDamageMod(int32 Rank)
bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const CreatureData *data)
{
+ SetZoneScript();
+ if(m_zoneScript)
+ {
+ Entry = m_zoneScript->GetCreatureEntry(guidlow, Entry);
+ if(!Entry)
+ return false;
+ }
+
CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry);
if(!cinfo)
{
sLog.outErrorDb("Creature entry %u does not exist.", Entry);
return false;
}
+
m_originalEntry = Entry;
if(isVehicle())
@@ -1456,15 +1473,6 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const
if(!UpdateEntry(Entry, team, data))
return false;
- //Notify the map's instance data.
- //Only works if you create the object in it, not if it is moves to that map.
- //Normally non-players do not teleport to other maps.
- Map *map = FindMap();
- if(map && map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData())
- {
- ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this, true);
- }
-
return true;
}
@@ -1486,16 +1494,9 @@ bool Creature::LoadFromDB(uint32 guid, Map *map)
if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT);
uint16 team = 0;
- if(!Create(guid,map,data->phaseMask,data->id,team,data))
+ if(!Create(guid,map,data->phaseMask,data->id,team,data->posX,data->posY,data->posZ,data->orientation,data))
return false;
- Relocate(data->posX,data->posY,data->posZ,data->orientation);
-
- if(!IsPositionValid())
- {
- sLog.outError("Creature (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",GetGUIDLow(),GetEntry(),GetPositionX(),GetPositionY());
- return false;
- }
//We should set first home position, because then AI calls home movement
SetHomePosition(data->posX,data->posY,data->posZ,data->orientation);
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 017b617cb94..31c127f983f 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -478,7 +478,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
void AddToWorld();
void RemoveFromWorld();
- bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data = NULL);
+ bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, float x, float y, float z, float ang, const CreatureData *data = NULL);
bool LoadCreaturesAddon(bool reload = false);
void SelectLevel(const CreatureInfo *cinfo);
void LoadEquipment(uint32 equip_entry, bool force=false);
diff --git a/src/game/Debugcmds.cpp b/src/game/Debugcmds.cpp
index fda50f8b9a6..196816fff02 100644
--- a/src/game/Debugcmds.cpp
+++ b/src/game/Debugcmds.cpp
@@ -782,21 +782,11 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args)
Vehicle *v = new Vehicle;
Map *map = m_session->GetPlayer()->GetMap();
- if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, m_session->GetPlayer()->GetPhaseMask(), entry, id, m_session->GetPlayer()->GetTeam()))
- {
- delete v;
- return false;
- }
-
- float px, py, pz;
- m_session->GetPlayer()->GetClosePoint(px, py, pz, m_session->GetPlayer()->GetObjectSize());
-
- v->Relocate(px, py, pz, m_session->GetPlayer()->GetOrientation());
+ float x, y, z, o = m_session->GetPlayer()->GetOrientation();
+ m_session->GetPlayer()->GetClosePoint(x, y, z, m_session->GetPlayer()->GetObjectSize());
- if(!v->IsPositionValid())
+ if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, m_session->GetPlayer()->GetPhaseMask(), entry, id, m_session->GetPlayer()->GetTeam(), x, y, z, o))
{
- sLog.outError("Vehicle (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
- v->GetGUIDLow(), v->GetEntry(), v->GetPositionX(), v->GetPositionY());
delete v;
return false;
}
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index bb1103e2262..0cc32ce4f2d 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -83,6 +83,9 @@ void GameObject::AddToWorld()
///- Register the gameobject for guid lookup
if(!IsInWorld())
{
+ if(m_zoneScript)
+ m_zoneScript->OnGameObjectCreate(this, true);
+
ObjectAccessor::Instance().AddObject(this);
WorldObject::AddToWorld();
}
@@ -93,16 +96,8 @@ void GameObject::RemoveFromWorld()
///- Remove the gameobject from the accessor
if(IsInWorld())
{
- if(Map *map = FindMap())
- if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData())
- ((InstanceMap*)map)->GetInstanceData()->OnObjectCreate(this, false);
-
- switch(m_goInfo->type)
- {
- case GAMEOBJECT_TYPE_CAPTURE_POINT:
- sOutdoorPvPMgr.OnGameObjectCreate(this, false);
- break;
- }
+ if(m_zoneScript)
+ m_zoneScript->OnGameObjectCreate(this, false);
// Possible crash at access to deleted GO in Unit::m_gameobj
if(uint64 owner_guid = GetOwnerGUID())
@@ -181,18 +176,9 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
m_goValue->destructibleBuilding.health = goinfo->destructibleBuilding.damagedHealth;
break;
- case GAMEOBJECT_TYPE_CAPTURE_POINT:
- sOutdoorPvPMgr.OnGameObjectCreate(this, true);
- break;
}
- //Notify the map's instance data.
- //Only works if you create the object in it, not if it is moves to that map.
- //Normally non-players do not teleport to other maps.
- if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData())
- {
- ((InstanceMap*)map)->GetInstanceData()->OnObjectCreate(this, true);
- }
+ SetZoneScript();
return true;
}
diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h
index 133f92ecc60..f3d45cc0cf6 100644
--- a/src/game/InstanceData.h
+++ b/src/game/InstanceData.h
@@ -21,7 +21,7 @@
#ifndef TRINITY_INSTANCE_DATA_H
#define TRINITY_INSTANCE_DATA_H
-#include "Common.h"
+#include "ZoneScript.h"
//#include "GameObject.h"
//#include "Map.h"
@@ -109,7 +109,7 @@ struct MinionInfo
typedef std::multimap<uint32 /*entry*/, DoorInfo> DoorInfoMap;
typedef std::map<uint32 /*entry*/, MinionInfo> MinionInfoMap;
-class TRINITY_DLL_SPEC InstanceData
+class TRINITY_DLL_SPEC InstanceData : public ZoneScript
{
public:
@@ -129,8 +129,7 @@ class TRINITY_DLL_SPEC InstanceData
void SaveToDB();
- //Called every map update
- virtual void Update(uint32 /*diff*/) {}
+ virtual void Update(uint32 diff) {}
//Used by the map's CanEnter function.
//This is to prevent players from entering during boss encounters.
@@ -140,18 +139,10 @@ class TRINITY_DLL_SPEC InstanceData
virtual void OnPlayerEnter(Player *) {}
//Called when a gameobject is created
- virtual void OnObjectCreate(GameObject *go, bool add) { OnObjectCreate(go); }
+ void OnGameObjectCreate(GameObject *go, bool add) { OnObjectCreate(go); }
//called on creature creation
- virtual void OnCreatureCreate(Creature *, bool add);
-
- //All-purpose data storage 64 bit
- virtual uint64 GetData64(uint32 /*Data*/) { return 0; }
- virtual void SetData64(uint32 /*Data*/, uint64 /*Value*/) { }
-
- //All-purpose data storage 32 bit
- virtual uint32 GetData(uint32) { return 0; }
- virtual void SetData(uint32, uint32 data) {}
+ void OnCreatureCreate(Creature *, bool add);
//Handle open / close objects
//use HandleGameObject(NULL,boolen,GO); in OnObjectCreate in instance scripts
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index d9516835201..e7eeda7966d 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -1117,21 +1117,12 @@ bool ChatHandler::HandleNpcAddCommand(const char* args)
Map *map = chr->GetMap();
Creature* pCreature = new Creature;
- if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, (uint32)teamval))
+ if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, (uint32)teamval, x, y, z, o))
{
delete pCreature;
return false;
}
- pCreature->Relocate(x,y,z,o);
-
- if(!pCreature->IsPositionValid())
- {
- sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
- delete pCreature;
- return false;
- }
-
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
uint32 db_guid = pCreature->GetDBTableGUIDLow();
@@ -3100,20 +3091,12 @@ bool ChatHandler::HandleWpModifyCommand(const char* args)
wpCreature->AddObjectToRemoveList();
// re-create
Creature* wpCreature2 = new Creature;
- if (!wpCreature2->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0))
+ if (!wpCreature2->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
{
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
return false;
}
- wpCreature2->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation());
-
- if(!wpCreature2->IsPositionValid())
- {
- sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature2->GetGUIDLow(),wpCreature2->GetEntry(),wpCreature2->GetPositionX(),wpCreature2->GetPositionY());
- delete wpCreature2;
- return false;
- }
wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
@@ -3327,7 +3310,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
float o = chr->GetOrientation();
Creature* wpCreature = new Creature;
- if (!wpCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0))
+ if (!wpCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
{
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature;
@@ -3335,16 +3318,6 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
return false;
}
- wpCreature->Relocate(x, y, z, o);
-
- if(!wpCreature->IsPositionValid())
- {
- sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature->GetGUIDLow(),wpCreature->GetEntry(),wpCreature->GetPositionX(),wpCreature->GetPositionY());
- delete wpCreature;
- delete result;
- return false;
- }
-
sLog.outDebug("DEBUG: UPDATE waypoint_data SET wpguid = '%u");
// set "wpguid" column to the visual waypoint
WorldDatabase.PExecuteLog("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point);
@@ -3391,7 +3364,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
Map *map = chr->GetMap();
Creature* pCreature = new Creature;
- if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id, 0))
+ if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
{
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete pCreature;
@@ -3399,16 +3372,6 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
return false;
}
- pCreature->Relocate(x, y, z, o);
-
- if(!pCreature->IsPositionValid())
- {
- sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
- delete pCreature;
- delete result;
- return false;
- }
-
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map);
map->Add(pCreature);
@@ -3456,7 +3419,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
Map *map = chr->GetMap();
Creature* pCreature = new Creature;
- if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0))
+ if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
{
PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
delete pCreature;
@@ -3464,16 +3427,6 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
return false;
}
- pCreature->Relocate(x, y, z, o);
-
- if(!pCreature->IsPositionValid())
- {
- sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
- delete pCreature;
- delete result;
- return false;
- }
-
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map);
map->Add(pCreature);
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 99f2c0d8417..a4850615d07 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -45,6 +45,7 @@
#include "TemporarySummon.h"
#include "Totem.h"
+#include "OutdoorPvPMgr.h"
uint32 GuidHigh2TypeId(uint32 guid_hi)
{
@@ -1074,20 +1075,10 @@ bool Object::PrintIndexError(uint32 index, bool set) const
WorldObject::WorldObject()
: m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL),
m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f)
+ , m_map(NULL), m_zoneScript(NULL)
+ , m_isActive(false), IsTempWorldObject(false)
+ , m_name("")
{
- m_positionX = 0.0f;
- m_positionY = 0.0f;
- m_positionZ = 0.0f;
- m_orientation = 0.0f;
-
- m_mapId = 0;
- m_InstanceId = 0;
- m_map = NULL;
-
- m_name = "";
-
- m_isActive = false;
- IsTempWorldObject = false;
}
void WorldObject::SetWorldObject(bool on)
@@ -1801,16 +1792,9 @@ TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float a
case SUMMON_MASK_MINION: summon = new Minion (properties, summoner); break;
default: return NULL;
}
- if(!summon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, team))
- {
- delete summon;
- return NULL;
- }
- summon->Relocate(x, y, z, angle);
- if(!summon->IsPositionValid())
+ if(!summon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, team, x, y, z, angle))
{
- sLog.outError("Creature (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",summon->GetGUIDLow(),summon->GetEntry(),summon->GetPositionX(),summon->GetPositionY());
delete summon;
return NULL;
}
@@ -1826,6 +1810,17 @@ TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float a
return summon;
}
+void WorldObject::SetZoneScript()
+{
+ if(Map *map = FindMap())
+ {
+ if(map->IsDungeon())
+ m_zoneScript = (ZoneScript*)((InstanceMap*)map)->GetInstanceData();
+ else if(!map->IsBattleGroundOrArena())
+ m_zoneScript = sOutdoorPvPMgr.GetZoneScript(GetZoneId());
+ }
+}
+
TempSummon* WorldObject::SummonCreature(uint32 entry, float x, float y, float z, float ang, TempSummonType spwtype, uint32 duration)
{
Map *map = FindMap();
@@ -1861,18 +1856,8 @@ Vehicle* WorldObject::SummonVehicle(uint32 entry, float x, float y, float z, flo
uint32 team = 0;
if (GetTypeId()==TYPEID_PLAYER)
team = ((Player*)this)->GetTeam();
- if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, GetPhaseMask(), entry, id, team))
- {
- delete v;
- return NULL;
- }
-
- v->Relocate(x, y, z, ang);
-
- if(!v->IsPositionValid())
+ if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, GetPhaseMask(), entry, id, team, x, y, z, ang))
{
- sLog.outError("ERROR: Vehicle (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
- v->GetGUIDLow(), v->GetEntry(), v->GetPositionX(), v->GetPositionY());
delete v;
return NULL;
}
diff --git a/src/game/Object.h b/src/game/Object.h
index e6731db1712..1667d266016 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -107,6 +107,7 @@ class GameObject;
class TempSummon;
class Vehicle;
class CreatureAI;
+class ZoneScript;
typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
@@ -537,6 +538,8 @@ class TRINITY_DLL_SPEC WorldObject : public Object
Map * FindMap() const { return m_map ? m_map : const_cast<WorldObject*>(this)->_findMap(); }
Map const* GetBaseMap() const;
+ void SetZoneScript();
+
TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0,TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN,uint32 despwtime = 0);
Vehicle* SummonVehicle(uint32 entry, float x, float y, float z, float ang = 0);
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime);
@@ -565,6 +568,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object
explicit WorldObject();
std::string m_name;
bool m_isActive;
+ ZoneScript *m_zoneScript;
private:
uint32 m_mapId; // object at map with map_id
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 7232da67103..e23d114f0f2 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -894,13 +894,7 @@ uint32 ObjectMgr::ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const
display_id = cinfo->GetRandomValidModelId();
}
else
- {
display_id = data->displayid; // overwritten from creature data
- // I do not know why but in db most display id are not zero
- if(display_id == cinfo->Modelid_A1 || display_id == cinfo->Modelid_A2
- || display_id == cinfo->Modelid_H1 || display_id == cinfo->Modelid_H2)
- display_id = cinfo->GetRandomValidModelId();
- }
return display_id;
}
@@ -1068,7 +1062,7 @@ void ObjectMgr::LoadCreatures()
heroicCreatures.insert(cInfo->HeroicEntry);
//TODO: remove this
- gameeventmgr.mGameEventCreatureGuids.resize(52*2-1);
+ //gameeventmgr.mGameEventCreatureGuids.resize(52*2-1);
barGoLink bar(result->GetRowCount());
@@ -1115,6 +1109,11 @@ void ObjectMgr::LoadCreatures()
continue;
}
+ // I do not know why but in db most display id are not zero
+ if(data.displayid == cInfo->Modelid_A1 || data.displayid == cInfo->Modelid_A2
+ || data.displayid == cInfo->Modelid_H1 || data.displayid == cInfo->Modelid_H2)
+ data.displayid = 0;
+
if(data.equipmentId > 0) // -1 no equipment, 0 use default
{
if(!GetEquipmentInfo(data.equipmentId))
@@ -1172,7 +1171,7 @@ void ObjectMgr::LoadCreatures()
}
//if(entry == 32307 || entry == 32308)
- if(entry == 30739 || entry == 30740)
+ /*if(entry == 30739 || entry == 30740)
{
gameEvent = 51;
uint32 guid2 = objmgr.GenerateLowGuid(HIGHGUID_UNIT);
@@ -1183,7 +1182,7 @@ void ObjectMgr::LoadCreatures()
data2.displayid = 0;
gameeventmgr.mGameEventCreatureGuids[51+51].push_back(guid);
gameeventmgr.mGameEventCreatureGuids[51+50].push_back(guid2);
- }
+ }*/
if (gameEvent==0 && PoolId==0) // if not this is to be managed by GameEvent System or Pool system
AddCreatureToGrid(guid, &data);
diff --git a/src/game/OutdoorPvP.cpp b/src/game/OutdoorPvP.cpp
index 97626c8c4e6..483574c45f7 100644
--- a/src/game/OutdoorPvP.cpp
+++ b/src/game/OutdoorPvP.cpp
@@ -146,22 +146,13 @@ bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 teamval, ui
if(!pMap)
return true;
Creature* pCreature = new Creature;
- if (!pCreature->Create(guid, pMap, PHASEMASK_NORMAL, entry, teamval))
+ if (!pCreature->Create(guid, pMap, PHASEMASK_NORMAL, entry, teamval, x, y, z, o))
{
sLog.outError("Can't create creature entry: %u",entry);
delete pCreature;
return false;
}
- pCreature->Relocate(x, y, z, o);
-
- if(!pCreature->IsPositionValid())
- {
- sLog.outError("ERROR: Creature (guidlow %d, entry %d) not added to opvp. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
- delete pCreature;
- return false;
- }
-
if(spawntimedelay)
pCreature->SetRespawnDelay(spawntimedelay);
@@ -638,3 +629,13 @@ void OutdoorPvP::TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2)
TeamCastSpell(team, spellId);
TeamCastSpell(OTHER_TEAM(team), spellId2 ? -(int32)spellId2 : -(int32)spellId);
}
+
+void OutdoorPvP::OnGameObjectCreate(GameObject *go, bool add)
+{
+ if(go->GetGoType() != GAMEOBJECT_TYPE_CAPTURE_POINT)
+ return;
+
+ for(OutdoorPvP::OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
+ if((*itr)->m_CapturePointGUID == go->GetDBTableGUIDLow())
+ (*itr)->m_capturePoint = add ? go : NULL;
+}
diff --git a/src/game/OutdoorPvP.h b/src/game/OutdoorPvP.h
index e72461bd234..36073b78b37 100644
--- a/src/game/OutdoorPvP.h
+++ b/src/game/OutdoorPvP.h
@@ -21,10 +21,7 @@
#include "Util.h"
#include "SharedDefines.h"
-#include "GameObject.h"
-
-#include <map>
-#include <set>
+#include "ZoneScript.h"
class GameObject;
@@ -151,7 +148,7 @@ protected:
};
// base class for specific outdoor pvp handlers
-class OutdoorPvP
+class OutdoorPvP : public ZoneScript
{
friend class OutdoorPvPMgr;
public:
@@ -175,6 +172,9 @@ public:
// setup stuff
virtual bool SetupOutdoorPvP() {return true;}
+ void OnGameObjectCreate(GameObject *go, bool add);
+ void OnCreatureCreate(Creature *, bool add) {}
+
// send world state update to all players present
virtual void SendUpdateWorldState(uint32 field, uint32 value);
diff --git a/src/game/OutdoorPvPMgr.cpp b/src/game/OutdoorPvPMgr.cpp
index 7d367392764..446f7e2ce95 100644
--- a/src/game/OutdoorPvPMgr.cpp
+++ b/src/game/OutdoorPvPMgr.cpp
@@ -207,15 +207,13 @@ bool OutdoorPvPMgr::HandleCustomSpell(Player *plr, uint32 spellId, GameObject *
return false;
}
-void OutdoorPvPMgr::OnGameObjectCreate(GameObject *go, bool add)
+ZoneScript * OutdoorPvPMgr::GetZoneScript(uint32 zoneId)
{
- if(go->GetGoType() != GAMEOBJECT_TYPE_CAPTURE_POINT)
- return;
-
- for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
- for(OutdoorPvP::OPvPCapturePointMap::iterator itr2 = (*itr)->m_capturePoints.begin(); itr2 != (*itr)->m_capturePoints.end(); ++itr2)
- if((*itr2)->m_CapturePointGUID == go->GetDBTableGUIDLow())
- (*itr2)->m_capturePoint = add ? go : NULL;
+ OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneId);
+ if(itr != m_OutdoorPvPMap.end())
+ return itr->second;
+ else
+ return NULL;
}
bool OutdoorPvPMgr::HandleOpenGo(Player *plr, uint64 guid)
diff --git a/src/game/OutdoorPvPMgr.h b/src/game/OutdoorPvPMgr.h
index 22083ecd5ee..9490ac87d4b 100644
--- a/src/game/OutdoorPvPMgr.h
+++ b/src/game/OutdoorPvPMgr.h
@@ -27,6 +27,7 @@
class Player;
class GameObject;
class Creature;
+class ZoneScript;
struct GossipOption;
// class to handle player enter / leave / areatrigger / GO use events
@@ -51,7 +52,7 @@ public:
// handle custom go if registered
bool HandleOpenGo(Player * plr, uint64 guid);
- void OnGameObjectCreate(GameObject *go, bool add);
+ ZoneScript * GetZoneScript(uint32 zoneId);
void AddZone(uint32 zoneid, OutdoorPvP * handle);
diff --git a/src/game/OutdoorPvPObjectiveAI.cpp b/src/game/OutdoorPvPObjectiveAI.cpp
deleted file mode 100644
index 0fe57fcaa87..00000000000
--- a/src/game/OutdoorPvPObjectiveAI.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
diff --git a/src/game/OutdoorPvPObjectiveAI.h b/src/game/OutdoorPvPObjectiveAI.h
deleted file mode 100644
index 0fe57fcaa87..00000000000
--- a/src/game/OutdoorPvPObjectiveAI.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
index 0bcdf088bc2..aaf97b3e413 100644
--- a/src/game/Vehicle.cpp
+++ b/src/game/Vehicle.cpp
@@ -90,9 +90,9 @@ void Vehicle::Update(uint32 diff)
// ModifyPower(POWER_ENERGY, 1);
}
-bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData * data)
+bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, float x, float y, float z, float o, const CreatureData * data)
{
- if(!Creature::Create(guidlow, map, phaseMask, Entry, team, data))
+ if(!Creature::Create(guidlow, map, phaseMask, Entry, team, x, y, z, o, data))
return false;
SetVehicleId(vehicleId);
@@ -338,16 +338,9 @@ bool Vehicle::LoadFromDB(uint32 guid, Map *map)
if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_VEHICLE);
uint16 team = 0;
- if(!Create(guid,map,data->phaseMask,data->id,id,team,data))
+ if(!Create(guid,map,data->phaseMask,data->id,id,team,data->posX,data->posY,data->posZ,data->orientation,data))
return false;
- Relocate(data->posX,data->posY,data->posZ,data->orientation);
-
- if(!IsPositionValid())
- {
- sLog.outError("Creature (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",GetGUIDLow(),GetEntry(),GetPositionX(),GetPositionY());
- return false;
- }
//We should set first home position, because then AI calls home movement
SetHomePosition(data->posX,data->posY,data->posZ,data->orientation);
diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h
index 083033c7574..d1e606caf4a 100644
--- a/src/game/Vehicle.h
+++ b/src/game/Vehicle.h
@@ -44,7 +44,7 @@ class Vehicle : public Creature
void AddToWorld();
void RemoveFromWorld();
- bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData * data = NULL);
+ bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, float x, float y, float z, float o, const CreatureData * data = NULL);
void setDeathState(DeathState s); // overwrite virtual Creature::setDeathState and Unit::setDeathState
void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update
diff --git a/src/game/Wintergrasp.cpp b/src/game/Wintergrasp.cpp
index a6f84c83b2e..06ef39bd599 100644
--- a/src/game/Wintergrasp.cpp
+++ b/src/game/Wintergrasp.cpp
@@ -19,7 +19,8 @@
#include "Wintergrasp.h"
#include "SpellAuras.h"
#include "Vehicle.h"
-#include "GameEventMgr.h"
+//#include "GameEventMgr.h"
+#include "ObjectMgr.h"
bool OPvPWintergrasp::SetupOutdoorPvP()
{
@@ -33,11 +34,66 @@ bool OPvPWintergrasp::SetupOutdoorPvP()
}
m_defender = TeamId(rand()%2);
- gameeventmgr.StartInternalEvent(GameEventWintergraspDefender[m_defender]);
+ //m_defender = TEAM_ALLIANCE;
+ //gameeventmgr.StartInternalEvent(GameEventWintergraspDefender[m_defender]);
return true;
}
+uint32 OPvPWintergrasp::GetCreatureEntry(uint32 guidlow, uint32 entry)
+{
+ if(m_defender == TEAM_ALLIANCE)
+ {
+ switch(entry)
+ {
+ case 30739: return 30740;
+ case 30740: return 30739;
+ }
+ }
+ return entry;
+}
+
+/*
+uint32 OPvPWintergrasp::GetGameObjectEntry(uint32 guidlow, uint32 entry)
+{
+ if(m_defender == TEAM_ALLIANCE)
+ {
+ GameObjectInfo const* goInfo = objmgr.GetGameObjectInfo(entry);
+ if(!goInfo)
+ return 0;
+ switch(goInfo->displayId)
+ {
+ case 5651: return 192289;
+ case 5652: return 192288;
+ case 8256: return 192502;
+ case 8257: return 192501;
+ }
+ }
+ return entry;
+}
+*/
+
+void OPvPWintergrasp::OnGameObjectCreate(GameObject *go, bool add)
+{
+ OutdoorPvP::OnGameObjectCreate(go, add);
+ if(m_defender == TEAM_ALLIANCE)
+ {
+ switch(go->GetEntry())
+ {
+ case 190763: go->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[m_defender]); break;
+ }
+
+ // Note: this is only for test, still need db support
+ switch(go->GetGOInfo()->displayId)
+ {
+ case 5651: go->SetUInt32Value(GAMEOBJECT_DISPLAYID, 5652); break;
+ case 5652: go->SetUInt32Value(GAMEOBJECT_DISPLAYID, 5651); break;
+ case 8256: go->SetUInt32Value(GAMEOBJECT_DISPLAYID, 8257); break;
+ case 8257: go->SetUInt32Value(GAMEOBJECT_DISPLAYID, 8256); break;
+ }
+ }
+}
+
void OPvPWintergrasp::HandlePlayerEnterZone(Player * plr, uint32 zone)
{
if(!plr->HasAura(SPELL_RECRUIT) && !plr->HasAura(SPELL_CORPORAL)
diff --git a/src/game/Wintergrasp.h b/src/game/Wintergrasp.h
index 76838068d48..cce9eb55d7e 100644
--- a/src/game/Wintergrasp.h
+++ b/src/game/Wintergrasp.h
@@ -24,6 +24,7 @@
#define ZONE_WINTERGRASP 4197
const uint16 GameEventWintergraspDefender[2] = {50, 51};
+const uint32 WintergraspFaction[2] = {1732, 1735};
#define POS_X_CENTER 4700
@@ -62,6 +63,12 @@ class OPvPWintergrasp : public OutdoorPvP
public:
explicit OPvPWintergrasp() : m_tenacityStack(0) {}
bool SetupOutdoorPvP();
+
+ uint32 GetCreatureEntry(uint32 guidlow, uint32 entry);
+ //uint32 GetGameObjectEntry(uint32 guidlow, uint32 entry);
+
+ void OnGameObjectCreate(GameObject *go, bool add);
+
void HandlePlayerEnterZone(Player *plr, uint32 zone);
void HandlePlayerLeaveZone(Player *plr, uint32 zone);
void HandleKill(Player *killer, Unit *victim);
diff --git a/src/game/ZoneScript.h b/src/game/ZoneScript.h
new file mode 100644
index 00000000000..2725e44c16c
--- /dev/null
+++ b/src/game/ZoneScript.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef ZONE_SCRIPT_H_
+#define ZONE_SCRIPT_H_
+
+#include "Common.h"
+
+class Creature;
+class GameObject;
+
+class TRINITY_DLL_SPEC ZoneScript
+{
+ public:
+ explicit ZoneScript() {}
+
+ virtual uint32 GetCreatureEntry(uint32 guidlow, uint32 entry) { return entry; }
+ virtual uint32 GetGameObjectEntry(uint32 guidlow, uint32 entry) { return entry; }
+
+ virtual void OnCreatureCreate(Creature *, bool add) {}
+ virtual void OnGameObjectCreate(GameObject *go, bool add) {}
+
+ //All-purpose data storage 64 bit
+ virtual uint64 GetData64(uint32 /*Data*/) { return 0; }
+ virtual void SetData64(uint32 /*Data*/, uint64 /*Value*/) {}
+
+ //All-purpose data storage 32 bit
+ virtual uint32 GetData(uint32) { return 0; }
+ virtual void SetData(uint32, uint32 data) {}
+};
+
+#endif \ No newline at end of file