Core/Units: converted SMSG_SPELL_ENERGIZE_LOG to packet class and no longer send PowerUpdate packets when gaining power via energize spell effects
This commit is contained in:
1 parent
f8c35be20c
commit
a08ab06d36
6 files changed
+45
-20
No files matched your search
@@ -6559,13 +6559,14 @@ int32 Unit::HealBySpell(HealInfo& healInfo, bool critical /*= false*/)
|
||||
|
||||
void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, Powers powerType)
|
||||
{
|
||||
WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1));
|
||||
data << victim->GetPackGUID();
|
||||
data << GetPackGUID();
|
||||
data << uint32(spellId);
|
||||
data << uint32(powerType);
|
||||
data << int32(damage);
|
||||
SendMessageToSet(&data, true);
|
||||
WorldPackets::CombatLog::SpellEnergizeLog packet;
|
||||
packet.TargetGUID = victim->GetGUID();
|
||||
packet.CasterGUID = GetGUID();
|
||||
packet.SpellID = spellId;
|
||||
packet.Amount = damage;
|
||||
packet.Type = powerType;
|
||||
|
||||
SendMessageToSet(packet.Write(), true);
|
||||
}
|
||||
|
||||
void Unit::EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, Powers powerType)
|
||||
@@ -6576,10 +6577,9 @@ void Unit::EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, Powers po
|
||||
|
||||
void Unit::EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damage, Powers powerType)
|
||||
{
|
||||
SendEnergizeSpellLog(victim, spellInfo->Id, damage, powerType);
|
||||
// needs to be called after sending spell log
|
||||
victim->ModifyPower(powerType, damage);
|
||||
victim->ModifyPower(powerType, damage, false);
|
||||
victim->GetThreatManager().ForwardThreatForAssistingMe(this, float(damage) / 2, spellInfo, true);
|
||||
SendEnergizeSpellLog(victim, spellInfo->Id, damage, powerType);
|
||||
}
|
||||
|
||||
uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint8 effIndex, uint32 stack) const
|
||||
@@ -8706,7 +8706,7 @@ int32 Unit::GetHealthGain(int32 dVal)
|
||||
}
|
||||
|
||||
// returns negative amount on power reduction
|
||||
int32 Unit::ModifyPower(Powers power, int32 dVal)
|
||||
int32 Unit::ModifyPower(Powers power, int32 dVal, bool withPowerUpdate /*= true*/)
|
||||
{
|
||||
int32 gain = 0;
|
||||
|
||||
@@ -8718,7 +8718,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
|
||||
int32 val = dVal + curPower;
|
||||
if (val <= GetMinPower(power))
|
||||
{
|
||||
SetPower(power, GetMinPower(power));
|
||||
SetPower(power, GetMinPower(power), withPowerUpdate);
|
||||
return -curPower;
|
||||
}
|
||||
|
||||
@@ -8726,12 +8726,12 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
|
||||
|
||||
if (val < maxPower)
|
||||
{
|
||||
SetPower(power, val);
|
||||
SetPower(power, val, withPowerUpdate);
|
||||
gain = val - curPower;
|
||||
}
|
||||
else if (curPower != maxPower)
|
||||
{
|
||||
SetPower(power, maxPower);
|
||||
SetPower(power, maxPower, withPowerUpdate);
|
||||
gain = maxPower - curPower;
|
||||
}
|
||||
|
||||
@@ -9894,7 +9894,7 @@ int32 Unit::GetMaxPower(Powers power) const
|
||||
return GetInt32Value(UNIT_FIELD_MAXPOWER1 + powerIndex);
|
||||
}
|
||||
|
||||
void Unit::SetPower(Powers power, int32 val)
|
||||
void Unit::SetPower(Powers power, int32 val, bool withPowerUpdate /*= true*/)
|
||||
{
|
||||
uint32 powerIndex = GetPowerIndex(power);
|
||||
if (powerIndex == MAX_POWERS)
|
||||
@@ -9906,7 +9906,7 @@ void Unit::SetPower(Powers power, int32 val)
|
||||
|
||||
SetInt32Value(UNIT_FIELD_POWER1 + powerIndex, val);
|
||||
|
||||
if (IsInWorld())
|
||||
if (IsInWorld() && withPowerUpdate)
|
||||
{
|
||||
WorldPackets::Combat::PowerUpdate packet;
|
||||
packet.Guid = GetGUID();
|
||||
|
||||
@@ -1087,7 +1087,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
int32 GetMinPower(Powers power) const { return power == POWER_ECLIPSE ? -100 : 0; }
|
||||
int32 GetMaxPower(Powers power) const;
|
||||
int32 CountPctFromMaxPower(Powers power, int32 pct) const { return CalculatePct(GetMaxPower(power), pct); }
|
||||
void SetPower(Powers power, int32 val);
|
||||
void SetPower(Powers power, int32 val, bool withPowerUpdate = true);
|
||||
void SetMaxPower(Powers power, int32 val);
|
||||
void SetPowerBarID(uint32 id) { _powerBarId = id; }
|
||||
void Regenerate(Powers powerType, uint32 diff);
|
||||
@@ -1095,7 +1095,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
inline void SetFullPower(Powers power) { SetPower(power, GetMaxPower(power)); }
|
||||
|
||||
// returns the change in power
|
||||
int32 ModifyPower(Powers power, int32 val);
|
||||
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate = true);
|
||||
int32 ModifyPowerPct(Powers power, float pct, bool apply = true);
|
||||
float GetPowerRegen(Powers powerType, bool isInCombat) const;
|
||||
|
||||
|
||||
@@ -68,3 +68,14 @@ WorldPacket const* WorldPackets::CombatLog::AttackerStateUpdate::Write()
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::CombatLog::SpellEnergizeLog::Write()
|
||||
{
|
||||
_worldPacket << TargetGUID.WriteAsPacked();
|
||||
_worldPacket << CasterGUID.WriteAsPacked();
|
||||
_worldPacket << int32(SpellID);
|
||||
_worldPacket << int32(Type);
|
||||
_worldPacket << int32(Amount);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
@@ -73,6 +73,20 @@ namespace WorldPackets
|
||||
UnkAttackerState UnkState;
|
||||
float Unk = 0.0f;
|
||||
};
|
||||
|
||||
class SpellEnergizeLog final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
SpellEnergizeLog() : ServerPacket(SMSG_SPELL_ENERGIZE_LOG, 8 + 8 + 4 + 4 + 4) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid CasterGUID;
|
||||
ObjectGuid TargetGUID;
|
||||
int32 SpellID = 0;
|
||||
int32 Type = 0;
|
||||
int32 Amount = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1221,7 +1221,7 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELLBREAKLOG, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELLDAMAGESHIELD, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELLDISPELLOG, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELLENERGIZELOG, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_ENERGIZE_LOG, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELLHEALLOG, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELLINSTAKILLLOG, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELLINTERRUPTLOG, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
|
||||
@@ -1180,7 +1180,7 @@ enum OpcodeServer
|
||||
SMSG_SPELLBREAKLOG = 0x6B17,
|
||||
SMSG_SPELLDAMAGESHIELD = 0x2927,
|
||||
SMSG_SPELLDISPELLOG = 0x4516,
|
||||
SMSG_SPELLENERGIZELOG = 0x0414,
|
||||
SMSG_SPELL_ENERGIZE_LOG = 0x0414,
|
||||
SMSG_SPELLHEALLOG = 0x2816,
|
||||
SMSG_SPELLINSTAKILLLOG = 0x6216,
|
||||
SMSG_SPELLINTERRUPTLOG = 0x1DA7,
|
||||
|
||||
Reference in new issue
Block a user