Skip to content

Commit 08edc7d

Browse files
committed
Core/Vehicles: Fixed power issues
* Regenerate powers only if vehicle has UNIT_FLAG2_REGENERATE_POWER * Removed old pyrite power hack * Apply creature_template.ManaMod to all power types Closes #12141
1 parent e9c9e36 commit 08edc7d

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

src/server/game/Entities/Creature/Creature.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,13 @@ void Creature::Update(uint32 diff)
567567
if (!IsInEvadeMode() && (!bInCombat || IsPolymorphed())) // regenerate health if not in combat or if polymorphed
568568
RegenerateHealth();
569569

570-
if (getPowerType() == POWER_ENERGY)
570+
if (HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER))
571571
{
572-
if (!IsVehicle() || GetVehicleKit()->GetVehicleInfo()->m_powerDisplayId != POWER_PYRITE)
572+
if (getPowerType() == POWER_ENERGY)
573573
Regenerate(POWER_ENERGY);
574+
else
575+
RegenerateMana();
574576
}
575-
else
576-
RegenerateMana();
577577

578578
/*if (!bIsPolymorphed) // only increase the timer if not polymorphed
579579
m_regenTimer += CREATURE_REGEN_INTERVAL - diff;

src/server/game/Entities/Unit/Unit.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8645,25 +8645,30 @@ void Unit::setPowerType(Powers new_powertype)
86458645
}
86468646
}
86478647

8648+
float powerMultiplier = 1.0f;
8649+
if (!IsPet())
8650+
if (Creature* creature = ToCreature())
8651+
powerMultiplier = creature->GetCreatureTemplate()->ModMana;
8652+
86488653
switch (new_powertype)
86498654
{
86508655
default:
86518656
case POWER_MANA:
86528657
break;
86538658
case POWER_RAGE:
8654-
SetMaxPower(POWER_RAGE, GetCreatePowers(POWER_RAGE));
8659+
SetMaxPower(POWER_RAGE, uint32(std::ceilf(GetCreatePowers(POWER_RAGE) * powerMultiplier)));
86558660
SetPower(POWER_RAGE, 0);
86568661
break;
86578662
case POWER_FOCUS:
8658-
SetMaxPower(POWER_FOCUS, GetCreatePowers(POWER_FOCUS));
8659-
SetPower(POWER_FOCUS, GetCreatePowers(POWER_FOCUS));
8663+
SetMaxPower(POWER_FOCUS, uint32(std::ceilf(GetCreatePowers(POWER_FOCUS) * powerMultiplier)));
8664+
SetPower(POWER_FOCUS, uint32(std::ceilf(GetCreatePowers(POWER_FOCUS) * powerMultiplier)));
86608665
break;
86618666
case POWER_ENERGY:
8662-
SetMaxPower(POWER_ENERGY, GetCreatePowers(POWER_ENERGY));
8667+
SetMaxPower(POWER_ENERGY, uint32(std::ceilf(GetCreatePowers(POWER_ENERGY) * powerMultiplier)));
86638668
break;
86648669
case POWER_HAPPINESS:
8665-
SetMaxPower(POWER_HAPPINESS, GetCreatePowers(POWER_HAPPINESS));
8666-
SetPower(POWER_HAPPINESS, GetCreatePowers(POWER_HAPPINESS));
8670+
SetMaxPower(POWER_HAPPINESS, uint32(std::ceilf(GetCreatePowers(POWER_HAPPINESS) * powerMultiplier)));
8671+
SetPower(POWER_HAPPINESS, uint32(std::ceilf(GetCreatePowers(POWER_HAPPINESS) * powerMultiplier)));
86678672
break;
86688673
}
86698674
}

src/server/game/Entities/Vehicle/Vehicle.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ Vehicle::~Vehicle()
7777
void Vehicle::Install()
7878
{
7979
if (_me->GetTypeId() == TYPEID_UNIT)
80+
{
8081
if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(_vehicleInfo->m_powerDisplayId))
8182
_me->setPowerType(Powers(powerDisplay->PowerType));
83+
else if (_me->getClass() == CLASS_ROGUE)
84+
_me->setPowerType(POWER_ENERGY);
85+
}
8286

8387
_status = STATUS_INSTALLED;
8488
if (GetBase()->GetTypeId() == TYPEID_UNIT)

0 commit comments

Comments
 (0)