*Add some vehicle ai functions.
--HG-- branch : trunk
This commit is contained in:
@@ -159,6 +159,9 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
|
|||||||
|
|
||||||
void SetGazeOn(Unit *target);
|
void SetGazeOn(Unit *target);
|
||||||
|
|
||||||
|
virtual void PassengerBoarded(Unit *who, int8 seatId) {}
|
||||||
|
virtual void PassengerLeft(Unit *who, int8 seatId) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _EnterEvadeMode();
|
bool _EnterEvadeMode();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14555,12 +14555,18 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
|
|||||||
if(m_Vehicle == vehicle)
|
if(m_Vehicle == vehicle)
|
||||||
{
|
{
|
||||||
if(seatId >= 0)
|
if(seatId >= 0)
|
||||||
|
{
|
||||||
|
sLog.outDebug("EnterVehicle: %u leave vehicle %u seat %d and enter %d.", GetEntry(), m_Vehicle->GetEntry(), GetTransSeat(), seatId);
|
||||||
ChangeSeat(seatId);
|
ChangeSeat(seatId);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
sLog.outDebug("EnterVehicle: %u exit %u and enter %u.", GetEntry(), m_Vehicle->GetEntry(), vehicle->GetEntry());
|
||||||
ExitVehicle();
|
ExitVehicle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(GetTypeId() == TYPEID_PLAYER)
|
if(GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
|
|||||||
assert(!seat->second.passenger);
|
assert(!seat->second.passenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
sLog.outDebug("Unit %s enter vehicle entry %u id %u dbguid %u", unit->GetName(), GetEntry(), m_vehicleInfo->m_ID, GetDBTableGUIDLow());
|
sLog.outDebug("Unit %s enter vehicle entry %u id %u dbguid %u seat %d", unit->GetName(), GetEntry(), m_vehicleInfo->m_ID, GetDBTableGUIDLow(), (int32)seat->first);
|
||||||
|
|
||||||
seat->second.passenger = unit;
|
seat->second.passenger = unit;
|
||||||
if(seat->second.seatInfo->IsUsable())
|
if(seat->second.seatInfo->IsUsable())
|
||||||
@@ -335,6 +335,9 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
|
|||||||
GetMap()->CreatureRelocation(this, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
GetMap()->CreatureRelocation(this, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(AI())
|
||||||
|
AI()->PassengerBoarded(unit, seat->first);
|
||||||
|
|
||||||
//if(unit->GetTypeId() == TYPEID_PLAYER)
|
//if(unit->GetTypeId() == TYPEID_PLAYER)
|
||||||
// ((Player*)unit)->SendTeleportAckMsg();
|
// ((Player*)unit)->SendTeleportAckMsg();
|
||||||
//unit->SendMovementFlagUpdate();
|
//unit->SendMovementFlagUpdate();
|
||||||
@@ -372,6 +375,9 @@ void Vehicle::RemovePassenger(Unit *unit)
|
|||||||
if(unit->GetTypeId() == TYPEID_PLAYER && seat->first == 0 && seat->second.seatInfo->m_flags & 0x800)
|
if(unit->GetTypeId() == TYPEID_PLAYER && seat->first == 0 && seat->second.seatInfo->m_flags & 0x800)
|
||||||
RemoveCharmedBy(unit);
|
RemoveCharmedBy(unit);
|
||||||
|
|
||||||
|
if(AI())
|
||||||
|
AI()->PassengerLeft(unit, seat->first);
|
||||||
|
|
||||||
// only for flyable vehicles?
|
// only for flyable vehicles?
|
||||||
//CastSpell(this, 45472, true); // Parachute
|
//CastSpell(this, 45472, true); // Parachute
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -57,6 +57,7 @@ class TRINITY_DLL_SPEC Vehicle : public Creature
|
|||||||
int8 GetNextEmptySeat(int8 seatId, bool next) const;
|
int8 GetNextEmptySeat(int8 seatId, bool next) const;
|
||||||
bool AddPassenger(Unit *passenger, int8 seatId = -1);
|
bool AddPassenger(Unit *passenger, int8 seatId = -1);
|
||||||
void RemovePassenger(Unit *passenger);
|
void RemovePassenger(Unit *passenger);
|
||||||
|
void RemoveAllPassengers();
|
||||||
void InstallAllAccessories();
|
void InstallAllAccessories();
|
||||||
void Dismiss();
|
void Dismiss();
|
||||||
|
|
||||||
@@ -67,7 +68,6 @@ class TRINITY_DLL_SPEC Vehicle : public Creature
|
|||||||
VehicleEntry const *m_vehicleInfo;
|
VehicleEntry const *m_vehicleInfo;
|
||||||
uint32 m_usableSeatNum;
|
uint32 m_usableSeatNum;
|
||||||
|
|
||||||
void RemoveAllPassengers();
|
|
||||||
void InstallAccessory(uint32 entry, int8 seatId);
|
void InstallAccessory(uint32 entry, int8 seatId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user