void Vehicle::InstallAllAccessories() { if(!GetMap()) return; CreatureDataAddon const *cainfo = GetCreatureAddon(); if(!cainfo || !cainfo->passengers) return; for (CreatureDataAddonPassengers const* cPassanger = cainfo->passengers; cPassanger->seat_idx != -1; ++cPassanger) { // Continue if seat already taken if(GetPassenger(cPassanger->seat_idx)) continue; uint32 guid = 0; bool isVehicle = false; // Set guid and check whatever it is if(cPassanger->guid != 0) guid = cPassanger->guid; else { CreatureDataAddon const* passAddon; passAddon = ObjectMgr::GetCreatureTemplateAddon(cPassanger->entry); if(passAddon && passAddon->vehicle_id != 0) isVehicle = true; else guid = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT); } // Create it Creature *pPassenger = new Creature; if(!isVehicle) { uint32 entry = cPassanger->entry; if(entry == 0) { CreatureData const* data = sObjectMgr.GetCreatureData(guid); if(!data) continue; entry = data->id; } if(!pPassenger->Create(guid, GetMap(), GetPhaseMask(), entry, 0)) continue; pPassenger->LoadFromDB(guid, GetMap()); pPassenger->Relocate(GetPositionX(), GetPositionY(), GetPositionZ()); GetMap()->Add(pPassenger); pPassenger->AIM_Initialize(); } else pPassenger = (Creature*)SummonVehicle(cPassanger->entry, GetPositionX(), GetPositionY(), GetPositionZ(), 0); // Enter vehicle... pPassenger->EnterVehicle(this, cPassanger->seat_idx, true); // ...and send update. Without this, client wont show this new creature/vehicle... WorldPacket data; pPassenger->BuildHeartBeatMsg(&data); pPassenger->SendMessageToSet(&data, false); } }
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData *data) { SetMapId(map->GetId()); SetInstanceId(map->GetInstanceId()); SetPhaseMask(phaseMask,false); CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry); if(!cinfo) { sLog.outErrorDb("Creature entry %u does not exist.", Entry); return false; } Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE); if(!UpdateEntry(Entry, team, data)) return false; if(!vehicleId) { CreatureDataAddon const *cainfo = GetCreatureAddon(); if(!cainfo) return false; vehicleId = cainfo->vehicle_id; } if(!SetVehicleId(vehicleId)) return false; LoadCreaturesAddon(); m_regenHealth = false; m_creation_time = getMSTime(); SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); //RemoveMonsterMoveFlag(MONSTER_MOVE_WALK); //Notify the map's instance data. //Only works if you create the object in it, not if it is moves to that map. //Normally non-players do not teleport to other maps. if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) { ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this); } return true; }
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData *data) { SetMap(map); SetPhaseMask(phaseMask,false); CreatureInfo const *cinfo = sObjectMgr.GetCreatureTemplate(Entry); if(!cinfo) { sLog.outErrorDb("Creature entry %u does not exist.", Entry); return false; } Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE); if(!UpdateEntry(Entry, team, data)) return false; if(!vehicleId) { CreatureDataAddon const *cainfo = GetCreatureAddon(); if(!cainfo) return false; vehicleId = cainfo->vehicle_id; } if(!SetVehicleId(vehicleId)) return false; LoadCreaturesAddon(); m_regenHealth = false; m_creation_time = getMSTime(); SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); //RemoveMonsterMoveFlag(MONSTER_MOVE_WALK); //Notify the map's instance data. //Only works if you create the object in it, not if it is moves to that map. //Normally non-players do not teleport to other maps. if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) { ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this); } if(m_vehicleInfo->m_powerType == POWER_TYPE_STEAM) { setPowerType(POWER_ENERGY); SetMaxPower(POWER_ENERGY, 100); SetPower(POWER_ENERGY, 100); } else if(m_vehicleInfo->m_powerType == POWER_TYPE_PYRITE) { setPowerType(POWER_ENERGY); SetMaxPower(POWER_ENERGY, 50); SetPower(POWER_ENERGY, 50); } else { for (uint32 i = 0; i < MAX_VEHICLE_SPELLS; ++i) { if(!GetVehicleData()->v_spells[i]) continue; SpellEntry const *spellInfo = sSpellStore.LookupEntry(GetVehicleData()->v_spells[i]); if(!spellInfo) continue; if(spellInfo->powerType == POWER_MANA) break; if(spellInfo->powerType == POWER_ENERGY) { setPowerType(POWER_ENERGY); SetMaxPower(POWER_ENERGY, 100); SetPower(POWER_ENERGY, 100); break; } } } SetHealth(GetMaxHealth()); InstallAllAccessories(); return true; }