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
21 #include "ObjectMgr.h"
26 Vehicle::Vehicle() : Creature(), m_vehicleId(0)
29 m_updateFlag
= (UPDATEFLAG_LOWGUID
| UPDATEFLAG_HIGHGUID
| UPDATEFLAG_LIVING
| UPDATEFLAG_HAS_POSITION
| UPDATEFLAG_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);
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 SetMapId(map
->GetId());
66 SetInstanceId(map
->GetInstanceId());
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 CleanupsBeforeDelete();
96 AddObjectToRemoveList();