aboutsummaryrefslogtreecommitdiff
path: root/src/game/Object.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-03-18 21:39:09 -0600
committermegamage <none@none>2009-03-18 21:39:09 -0600
commit281d20be0d1c342f01798b1254fccb3b5a202bcd (patch)
treef2edf7a2f81a625d72f4beacb4523747ee004aad /src/game/Object.cpp
parent886b2a51e9f3fdbb8f6353e47701be825f8cf4b3 (diff)
*Allow spells to summon vehicles.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Object.cpp')
-rw-r--r--src/game/Object.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 08615ba3679..a8dff0b73ab 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1621,6 +1621,43 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
return pCreature;
}
+Vehicle* WorldObject::SummonVehicle(uint32 entry, float x, float y, float z, float ang)
+{
+ CreatureInfo const *ci = objmgr.GetCreatureTemplate(entry);
+ if(!ci)
+ return false;
+
+ uint32 id = ci->spells[7]; //temp store id here
+ VehicleEntry const *ve = sVehicleStore.LookupEntry(id);
+ if(!ve)
+ return false;
+
+ Vehicle *v = new Vehicle;
+ Map *map = GetMap();
+ uint32 team = 0;
+ if (GetTypeId()==TYPEID_PLAYER)
+ team = ((Player*)this)->GetTeam();
+ if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, entry, id, team))
+ {
+ 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);
+
+ return v;
+}
+
Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration)
{
Pet* pet = new Pet(petType);