void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime) { /// @Prevent adding accessories when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.) if (_status == STATUS_UNINSTALLING) { TC_LOG_ERROR(LOG_FILTER_VEHICLES, "Vehicle (GuidLow: %u, DB GUID: %u, Entry: %u) attempts to install accessory (Entry: %u) on seat %d with STATUS_UNINSTALLING! " "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), (_me->GetTypeId() == TYPEID_UNIT ? _me->ToCreature()->GetDBTableGUIDLow() : _me->GetGUIDLow()), GetCreatureEntry(), entry, (int32)seatId); return; } TC_LOG_DEBUG(LOG_FILTER_VEHICLES, "Vehicle (GuidLow: %u, DB Guid: %u, Entry %u): installing accessory (Entry: %u) on seat: %d", _me->GetGUIDLow(), (_me->GetTypeId() == TYPEID_UNIT ? _me->ToCreature()->GetDBTableGUIDLow() : _me->GetGUIDLow()), GetCreatureEntry(), entry, (int32)seatId); TempSummon* accessory = _me->SummonCreature(entry, *_me, TempSummonType(type), summonTime); ASSERT(accessory); if (minion) accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); (void)_me->HandleSpellClick(accessory, seatId); /// If for some reason adding accessory to vehicle fails it will unsummon in /// @VehicleJoinEvent::Abort }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime) { sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle: Installing accessory entry %u on vehicle entry %u (seat:%i)", entry, GetCreatureEntry(), seatId); if (Unit* passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) { ASSERT(passenger->GetTypeId() == TYPEID_UNIT); if (_me->GetTypeId() == TYPEID_UNIT) { if (_me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) passenger->ToCreature()->AI()->EnterEvadeMode(); return; } } else passenger->ExitVehicle(); // this should not happen } if (TempSummon* accessory = _me->SummonCreature(entry, *_me, TempSummonType(type), summonTime)) { accessory->setFaction(_me->getFaction()); if (minion) accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); if (!_me->HandleSpellClick(accessory, seatId)) { accessory->UnSummon(); return; } // this cannot be checked instantly like this // spellsystem is delaying everything to next update tick //if (!accessory->IsOnVehicle(me)) //{ // accessory->UnSummon(); // return; // Something went wrong in the spellsystem //} // This is not good, we have to send update twice accessory->SendMovementFlagUpdate(); if (GetBase()->GetTypeId() == TYPEID_UNIT) sScriptMgr->OnInstallAccessory(this, accessory); } }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime) { /// @Prevent adding accessories when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.) if (_status == STATUS_UNINSTALLING) { sLog->outError("Vehicle GuidLow: %u, Entry: %u attempts to install accessory Entry: %u on seat %d with STATUS_UNINSTALLING! " "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry(), entry, (int32)seatId); return; } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle: Installing accessory entry %u on vehicle entry %u (seat:%i)", entry, GetCreatureEntry(), seatId); #endif if (Unit* passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) { ASSERT(passenger->GetTypeId() == TYPEID_UNIT); if (_me->GetTypeId() == TYPEID_UNIT) { if (_me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) passenger->ToCreature()->AI()->EnterEvadeMode(); return; } } else passenger->ExitVehicle(); // this should not happen } if (TempSummon* accessory = _me->SummonCreature(entry, *_me, TempSummonType(type), summonTime)) { if (minion) accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); if (!_me->HandleSpellClick(accessory, seatId)) { accessory->UnSummon(); return; } if (GetBase()->GetTypeId() == TYPEID_UNIT) sScriptMgr->OnInstallAccessory(this, accessory); } }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime) { if (Unit *passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) { ASSERT(passenger->GetTypeId() == TYPEID_UNIT); if (me->GetTypeId() == TYPEID_UNIT) { if (me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) passenger->ToCreature()->AI()->EnterEvadeMode(); return; } } else passenger->ExitVehicle(); // this should not happen } if (Creature *accessory = me->SummonCreature(entry, *me, TempSummonType(type), summonTime)) { if (minion) accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); if (!me->HandleSpellClick(accessory, seatId)) { accessory->AddObjectToRemoveList(); return; } if (!accessory->IsOnVehicle(me)) { accessory->AddObjectToRemoveList(); return; // Something went wrong in the spellsystem } // This is not good, we have to send update twice accessory->SendMovementFlagUpdate(); if (GetBase()->GetTypeId() == TYPEID_UNIT) sScriptMgr->OnInstallAccessory(this, accessory); } }
Creature* ScriptedAI::DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime) { return me->SummonCreature(entry, me->GetPositionX() + offsetX, me->GetPositionY() + offsetY, me->GetPositionZ() + offsetZ, angle, TempSummonType(type), despawntime); }