*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
This commit is contained in:
megamage
2009-05-30 22:15:05 -05:00
parent b5778357d9
commit 8d1f4f9ea0
25 changed files with 224 additions and 263 deletions
+1 -10
View File
@@ -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);
+1 -2
View File
@@ -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})
+22 -21
View File
@@ -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);
+1 -1
View File
@@ -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);
+4 -14
View File
@@ -782,25 +782,15 @@ 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()))
float x, y, z, o = m_session->GetPlayer()->GetOrientation();
m_session->GetPlayer()->GetClosePoint(x, y, z, m_session->GetPlayer()->GetObjectSize());
if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, m_session->GetPlayer()->GetPhaseMask(), entry, id, m_session->GetPlayer()->GetTeam(), x, y, z, o))
{
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());
if(!v->IsPositionValid())
{
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;
}
map->Add((Creature*)v);
return true;
+6 -20
View File
@@ -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;
}
+5 -14
View File
@@ -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
+5 -52
View File
@@ -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);
+17 -32
View File
@@ -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,22 +1856,12 @@ 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))
if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, GetPhaseMask(), entry, id, team, x, y, z, ang))
{
delete v;
return NULL;
}
v->Relocate(x, y, z, ang);
if(!v->IsPositionValid())
{
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;
}
map->Add((Creature*)v);
//ObjectAccessor::UpdateObjectVisibility(v);
+4
View File
@@ -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
+8 -9
View File
@@ -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);
+11 -10
View File
@@ -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;
}
+5 -5
View File
@@ -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);
+6 -8
View File
@@ -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)
+2 -1
View File
@@ -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);
-17
View File
@@ -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
*/
-17
View File
@@ -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
*/
+3 -10
View File
@@ -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);
+1 -1
View File
@@ -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
+58 -2
View File
@@ -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)
+7
View File
@@ -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);
+47
View File
@@ -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