mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-16 08:46:09 +00:00
fix(Core/Vehicles): feat vehicle seat addon, vehicle enter/exit positions (#20082)
* implement initial vehicle_seat_addon Co-authored-by: Ovah <dreadkiller@gmx.de> * add more vehicle_seat_addon data * make exiting passenger visible fixes "immediate despawn" of travelers mammoth * style, update comments * remove hacked pos relocate * remove sending MSG_MOVE_ROOT/UNROOT on Ack * set and unset UNIT_NPC_FLAG_PLAYER_VEHICLE on init/entry * ulduar demolisher: remove flag correction and no longer needed usableseat * fixup! implement initial vehicle_seat_addon * fixup! fixup! implement initial vehicle_seat_addon * re-add AddPassenger Flame Leviathan hack was commented by mistake * Update rev_1725993194571320983.sql add missing ticks --------- Co-authored-by: Ovah <dreadkiller@gmx.de>
This commit is contained in:
@@ -34,15 +34,18 @@ Vehicle::Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry)
|
||||
if (uint32 seatId = _vehicleInfo->m_seatID[i])
|
||||
if (VehicleSeatEntry const* veSeat = sVehicleSeatStore.LookupEntry(seatId))
|
||||
{
|
||||
Seats.insert(std::make_pair(i, VehicleSeat(veSeat)));
|
||||
VehicleSeatAddon const* addon = sObjectMgr->GetVehicleSeatAddon(seatId);
|
||||
Seats.insert(std::make_pair(i, VehicleSeat(veSeat, addon)));
|
||||
if (veSeat->CanEnterOrExit())
|
||||
++_usableSeatNum;
|
||||
}
|
||||
}
|
||||
|
||||
// Ulduar demolisher
|
||||
if (vehInfo->m_ID == 338)
|
||||
++_usableSeatNum;
|
||||
// Set or remove correct flags based on available seats. Will overwrite db data (if wrong).
|
||||
if (_usableSeatNum)
|
||||
_me->SetNpcFlag((_me->IsPlayer() ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
|
||||
else
|
||||
_me->RemoveNpcFlag((_me->IsPlayer() ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
|
||||
|
||||
InitMovementInfoForBase();
|
||||
}
|
||||
@@ -230,6 +233,15 @@ Unit* Vehicle::GetPassenger(int8 seatId) const
|
||||
return ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger.Guid);
|
||||
}
|
||||
|
||||
VehicleSeatAddon const* Vehicle::GetSeatAddonForSeatOfPassenger(Unit const* passenger) const
|
||||
{
|
||||
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); itr++)
|
||||
if (!itr->second.IsEmpty() && itr->second.Passenger.Guid == passenger->GetGUID())
|
||||
return itr->second.SeatAddon;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int8 Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
|
||||
{
|
||||
SeatMap::const_iterator seat = Seats.find(seatId);
|
||||
@@ -356,12 +368,9 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
|
||||
ASSERT(_usableSeatNum);
|
||||
--_usableSeatNum;
|
||||
if (!_usableSeatNum)
|
||||
{
|
||||
if (_me->IsPlayer())
|
||||
_me->RemoveNpcFlag(UNIT_NPC_FLAG_PLAYER_VEHICLE);
|
||||
else
|
||||
_me->RemoveNpcFlag(UNIT_NPC_FLAG_SPELLCLICK);
|
||||
}
|
||||
_me->RemoveNpcFlag(_me->IsPlayer() ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK);
|
||||
else
|
||||
_me->SetNpcFlag(_me->IsPlayer() ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK);
|
||||
}
|
||||
|
||||
if (!_me || !_me->IsInWorld() || _me->IsDuringRemoveFromWorld())
|
||||
@@ -376,7 +385,14 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
|
||||
|
||||
unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
|
||||
VehicleSeatEntry const* veSeat = seat->second.SeatInfo;
|
||||
unit->m_movementInfo.transport.pos.Relocate(veSeat->m_attachmentOffsetX, veSeat->m_attachmentOffsetY, veSeat->m_attachmentOffsetZ);
|
||||
VehicleSeatAddon const* veSeatAddon = seat->second.SeatAddon;
|
||||
|
||||
float o = veSeatAddon ? veSeatAddon->SeatOrientationOffset : 0.f;
|
||||
float x = veSeat->m_attachmentOffsetX;
|
||||
float y = veSeat->m_attachmentOffsetY;
|
||||
float z = veSeat->m_attachmentOffsetZ;
|
||||
|
||||
unit->m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||
unit->m_movementInfo.transport.time = 0;
|
||||
unit->m_movementInfo.transport.seat = seat->first;
|
||||
unit->m_movementInfo.transport.guid = _me->GetGUID();
|
||||
@@ -410,16 +426,17 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
|
||||
// also adds MOVEMENTFLAG_ROOT
|
||||
Movement::MoveSplineInit init(unit);
|
||||
init.DisableTransportPathTransformations();
|
||||
init.MoveTo(veSeat->m_attachmentOffsetX, veSeat->m_attachmentOffsetY, veSeat->m_attachmentOffsetZ);
|
||||
init.MoveTo(x, y, z, false, true);
|
||||
// Xinef: did not found anything unique in dbc, maybe missed something
|
||||
if (veSeat->m_ID == 3566 || veSeat->m_ID == 3567 || veSeat->m_ID == 3568 || veSeat->m_ID == 3570)
|
||||
{
|
||||
float x = veSeat->m_attachmentOffsetX, y = veSeat->m_attachmentOffsetY, z = veSeat->m_attachmentOffsetZ, o;
|
||||
CalculatePassengerPosition(x, y, z, &o);
|
||||
init.SetFacing(_me->GetAngle(x, y));
|
||||
}
|
||||
else
|
||||
init.SetFacing(0.0f);
|
||||
{
|
||||
init.SetFacing(o);
|
||||
}
|
||||
|
||||
init.SetTransportEnter();
|
||||
init.Launch();
|
||||
|
||||
Reference in New Issue
Block a user