Add support for vehicle scaling based on item level.
Requires database data. Fixes issue #2754 --HG-- branch : trunk
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#include "CreatureAI.h"
|
||||
#include "ZoneScript.h"
|
||||
|
||||
Vehicle::Vehicle(Unit *unit, VehicleEntry const *vehInfo) : me(unit), m_vehicleInfo(vehInfo), m_usableSeatNum(0)
|
||||
Vehicle::Vehicle(Unit *unit, VehicleEntry const *vehInfo) : me(unit), m_vehicleInfo(vehInfo), m_usableSeatNum(0), m_bonusHP(0)
|
||||
{
|
||||
for (uint32 i = 0; i < 8; ++i)
|
||||
{
|
||||
@@ -306,8 +306,6 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
|
||||
if (seat->second.seatInfo->m_flags && !(seat->second.seatInfo->m_flags & 0x400))
|
||||
unit->addUnitState(UNIT_STAT_ONVEHICLE);
|
||||
|
||||
//SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
|
||||
unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
|
||||
VehicleSeatEntry const *veSeat = seat->second.seatInfo;
|
||||
unit->m_movementInfo.t_pos.m_positionX = veSeat->m_attachmentOffsetX;
|
||||
@@ -320,9 +318,24 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
|
||||
if (me->GetTypeId() == TYPEID_UNIT
|
||||
&& unit->GetTypeId() == TYPEID_PLAYER
|
||||
&& seat->first == 0 && seat->second.seatInfo->m_flags & 0x800) // not right
|
||||
{
|
||||
if (!me->SetCharmedBy(unit, CHARM_TYPE_VEHICLE))
|
||||
ASSERT(false);
|
||||
|
||||
if (VehicleScalingInfo const *scalingInfo = sObjectMgr.GetVehicleScalingInfo(m_vehicleInfo->m_ID))
|
||||
{
|
||||
Player *plr = unit->ToPlayer();
|
||||
float averageItemLevel = plr->GetAverageItemLevel();
|
||||
if (averageItemLevel < scalingInfo->baseItemLevel)
|
||||
averageItemLevel = scalingInfo->baseItemLevel;
|
||||
averageItemLevel -= scalingInfo->baseItemLevel;
|
||||
|
||||
m_bonusHP = uint32(me->GetMaxHealth() * (averageItemLevel * scalingInfo->scalingFactor));
|
||||
me->SetMaxHealth(me->GetMaxHealth() + m_bonusHP);
|
||||
me->SetHealth(me->GetHealth() + m_bonusHP);
|
||||
}
|
||||
}
|
||||
|
||||
if (me->IsInWorld())
|
||||
{
|
||||
unit->SendMonsterMoveTransport(me);
|
||||
@@ -377,8 +390,17 @@ void Vehicle::RemovePassenger(Unit *unit)
|
||||
if (me->GetTypeId() == TYPEID_UNIT
|
||||
&& unit->GetTypeId() == TYPEID_PLAYER
|
||||
&& seat->first == 0 && seat->second.seatInfo->m_flags & 0x800)
|
||||
{
|
||||
me->RemoveCharmedBy(unit);
|
||||
|
||||
if (m_bonusHP)
|
||||
{
|
||||
me->SetHealth(me->GetHealth() - m_bonusHP);
|
||||
me->SetMaxHealth(me->GetMaxHealth() - m_bonusHP);
|
||||
m_bonusHP = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (me->GetTypeId() == TYPEID_UNIT && me->ToCreature()->IsAIEnabled)
|
||||
me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, false);
|
||||
|
||||
|
||||
@@ -46,8 +46,16 @@ struct VehicleAccessory
|
||||
uint32 bMinion;
|
||||
};
|
||||
|
||||
struct VehicleScalingInfo
|
||||
{
|
||||
uint32 ID;
|
||||
float baseItemLevel;
|
||||
float scalingFactor;
|
||||
};
|
||||
|
||||
typedef std::vector<VehicleAccessory> VehicleAccessoryList;
|
||||
typedef std::map<uint32, VehicleAccessoryList> VehicleAccessoryMap;
|
||||
typedef std::map<uint32, VehicleScalingInfo> VehicleScalingMap;
|
||||
|
||||
typedef std::map<int8, VehicleSeat> SeatMap;
|
||||
|
||||
@@ -82,6 +90,7 @@ class Vehicle
|
||||
Unit *me;
|
||||
VehicleEntry const *m_vehicleInfo;
|
||||
uint32 m_usableSeatNum;
|
||||
uint32 m_bonusHP;
|
||||
|
||||
void InstallAccessory(uint32 entry, int8 seatId, bool minion = true);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user