From 8d1f4f9ea0beb503e2a3014abb95263e501ef1c5 Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 30 May 2009 22:15:05 -0500 Subject: *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 --- src/game/Object.cpp | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) (limited to 'src/game/Object.cpp') 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; } -- cgit v1.2.3