[8449] Deprecate healing/damage item mods and merge internal data in to spell power.
[getmangos.git] / src / game / Vehicle.cpp
blob5c5fad43790e3e7d8a7274695b136d1ae6bf1a8a
1 /*
2 * Copyright (C) 2005-2009 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 "ObjectMgr.h"
22 #include "Vehicle.h"
23 #include "Unit.h"
24 #include "Util.h"
26 Vehicle::Vehicle() : Creature(), m_vehicleId(0)
28 m_isVehicle = true;
29 m_updateFlag = (UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_VEHICLE);
32 Vehicle::~Vehicle()
34 if(m_uint32Values) // only for fully created Object
35 ObjectAccessor::Instance().RemoveObject(this);
38 void Vehicle::AddToWorld()
40 ///- Register the vehicle for guid lookup
41 if(!IsInWorld()) ObjectAccessor::Instance().AddObject(this);
42 Unit::AddToWorld();
45 void Vehicle::RemoveFromWorld()
47 ///- Remove the vehicle from the accessor
48 if(IsInWorld()) ObjectAccessor::Instance().RemoveObject(this);
49 ///- Don't call the function for Creature, normal mobs + totems go in a different storage
50 Unit::RemoveFromWorld();
53 void Vehicle::setDeathState(DeathState s) // overwrite virtual Creature::setDeathState and Unit::setDeathState
55 Creature::setDeathState(s);
58 void Vehicle::Update(uint32 diff)
60 Creature::Update(diff);
63 bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team)
65 SetMap(map);
67 Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE);
69 if(!InitEntry(Entry, team))
70 return false;
72 m_defaultMovementType = IDLE_MOTION_TYPE;
74 AIM_Initialize();
76 SetVehicleId(vehicleId);
78 SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
79 SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
81 CreatureInfo const *ci = GetCreatureInfo();
82 setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H);
83 SetMaxHealth(ci->maxhealth);
84 SelectLevel(ci);
85 SetHealth(GetMaxHealth());
87 return true;
90 void Vehicle::Dismiss()
92 SendObjectDeSpawnAnim(GetGUID());
93 CombatStop();
94 AddObjectToRemoveList();