Updated vmap extractor bin's
[getmangos.git] / src / game / Vehicle.cpp
blob12acd640e0b20bc2b74e5c3ec6b0dd8a9b0a0c60
1 /*
2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "Common.h"
20 #include "Log.h"
21 #include "WorldSession.h"
22 #include "WorldPacket.h"
23 #include "ObjectMgr.h"
24 #include "SpellMgr.h"
25 #include "Vehicle.h"
26 #include "MapManager.h"
27 #include "SpellAuras.h"
28 #include "Unit.h"
29 #include "Util.h"
31 Vehicle::Vehicle() : Creature(), m_vehicleId(0)
33 m_isVehicle = true;
34 m_updateFlag = (UPDATEFLAG_LOWGUID | UPDATEFLAG_HIGHGUID | UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_VEHICLE);
37 Vehicle::~Vehicle()
39 if(m_uint32Values) // only for fully created Object
40 ObjectAccessor::Instance().RemoveObject(this);
43 void Vehicle::AddToWorld()
45 ///- Register the vehicle for guid lookup
46 if(!IsInWorld()) ObjectAccessor::Instance().AddObject(this);
47 Unit::AddToWorld();
50 void Vehicle::RemoveFromWorld()
52 ///- Remove the vehicle from the accessor
53 if(IsInWorld()) ObjectAccessor::Instance().RemoveObject(this);
54 ///- Don't call the function for Creature, normal mobs + totems go in a different storage
55 Unit::RemoveFromWorld();
58 void Vehicle::setDeathState(DeathState s) // overwrite virtual Creature::setDeathState and Unit::setDeathState
60 Creature::setDeathState(s);
63 void Vehicle::Update(uint32 diff)
65 Creature::Update(diff);
68 bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team)
70 SetMapId(map->GetId());
71 SetInstanceId(map->GetInstanceId());
73 Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE);
75 if(!InitEntry(Entry, team))
76 return false;
78 m_defaultMovementType = IDLE_MOTION_TYPE;
80 AIM_Initialize();
82 SetVehicleId(vehicleId);
84 SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
85 //SetUInt32Value(UNIT_FIELD_BYTES_1, 0x02000001);
86 //SetUInt32Value(UNIT_FIELD_BYTES_2, 0x00000001);
87 SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
89 CreatureInfo const *ci = GetCreatureInfo();
90 setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H);
91 SetMaxHealth(ci->maxhealth);
92 SelectLevel(ci);
93 SetHealth(GetMaxHealth());
95 return true;