2 * Copyright (C) 2005-2010 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
21 #include "ObjectMgr.h"
26 Vehicle::Vehicle() : Creature(CREATURE_SUBTYPE_VEHICLE
), m_vehicleId(0)
28 m_updateFlag
= (UPDATEFLAG_LIVING
| UPDATEFLAG_HAS_POSITION
| UPDATEFLAG_VEHICLE
);
35 void Vehicle::AddToWorld()
37 ///- Register the vehicle for guid lookup
39 GetMap()->GetObjectsStore().insert
<Vehicle
>(GetGUID(), (Vehicle
*)this);
44 void Vehicle::RemoveFromWorld()
46 ///- Remove the vehicle from the accessor
48 GetMap()->GetObjectsStore().erase
<Vehicle
>(GetGUID(), (Vehicle
*)NULL
);
50 ///- Don't call the function for Creature, normal mobs + totems go in a different storage
51 Unit::RemoveFromWorld();
54 void Vehicle::setDeathState(DeathState s
) // overwrite virtual Creature::setDeathState and Unit::setDeathState
56 Creature::setDeathState(s
);
59 void Vehicle::Update(uint32 diff
)
61 Creature::Update(diff
);
64 bool Vehicle::Create(uint32 guidlow
, Map
*map
, uint32 Entry
, uint32 vehicleId
, uint32 team
)
68 Object::_Create(guidlow
, Entry
, HIGHGUID_VEHICLE
);
70 if(!InitEntry(Entry
, team
))
73 m_defaultMovementType
= IDLE_MOTION_TYPE
;
77 SetVehicleId(vehicleId
);
79 SetUInt32Value(UNIT_NPC_FLAGS
, UNIT_NPC_FLAG_SPELLCLICK
);
80 SetFloatValue(UNIT_FIELD_HOVERHEIGHT
, 1.0f
);
82 CreatureInfo
const *ci
= GetCreatureInfo();
83 setFaction(team
== ALLIANCE
? ci
->faction_A
: ci
->faction_H
);
84 SetMaxHealth(ci
->maxhealth
);
86 SetHealth(GetMaxHealth());
91 void Vehicle::Dismiss()
93 SendObjectDeSpawnAnim(GetGUID());
95 AddObjectToRemoveList();