Skip to content

Commit

Permalink
Core/PacketIO: updated SMSG_DURABILITY_DAMAGE_DEATH (#24442)
Browse files Browse the repository at this point in the history
- use RATE_DURABILITY_LOSS_ON_DEATH for death from falling
- add note, that RATE_DURABILITY_LOSS_ON_DEATH doesn't change log message

(cherry picked from commit a1831e0)

# Conflicts:
#	src/server/game/Entities/GameObject/GameObject.cpp
#	src/server/game/Entities/Player/Player.cpp
#	src/server/game/Entities/Unit/Unit.cpp
#	src/server/game/Server/Packets/GameObjectPackets.h
#	src/server/game/Server/Protocol/Opcodes.cpp

Co-authored-by: MitchesD <majklprofik@seznam.cz>
  • Loading branch information
ForesterDev and MitchesD committed Apr 14, 2020
1 parent 37ff154 commit e1a8ebc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/server/game/Entities/Player/Player.cpp
Expand Up @@ -789,12 +789,11 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
{
if (type == DAMAGE_FALL) // DealDamage does not apply item durability loss from self-induced damage.
{
TC_LOG_DEBUG("entities.player", "Player::EnvironmentalDamage: Player '%s' (%s) fall to death, losing 10%% durability",
GetName().c_str(), GetGUID().ToString().c_str());
DurabilityLossAll(0.10f, false);
TC_LOG_DEBUG("entities.player", "Player::EnvironmentalDamage: Player '%s' (%s) fall to death, losing %f durability",
GetName().c_str(), GetGUID().ToString().c_str(), sWorld->getRate(RATE_DURABILITY_LOSS_ON_DEATH));
DurabilityLossAll(sWorld->getRate(RATE_DURABILITY_LOSS_ON_DEATH), false);
// durability lost message
WorldPacket data2(SMSG_DURABILITY_DAMAGE_DEATH, 0);
SendDirectMessage(&data2);
SendDurabilityLoss();
}

UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, 1, type);
Expand Down Expand Up @@ -4770,6 +4769,11 @@ Corpse* Player::GetCorpse() const
return GetMap()->GetCorpseByPlayer(GetGUID());
}

void Player::SendDurabilityLoss()
{
SendDirectMessage(WorldPackets::Misc::DurabilityDamageDeath().Write());
}

void Player::DurabilityLossAll(double percent, bool inventory)
{
for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++)
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Entities/Player/Player.h
Expand Up @@ -1696,6 +1696,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>

void RemoveGhoul();

void SendDurabilityLoss();
void DurabilityLossAll(double percent, bool inventory);
void DurabilityLoss(Item* item, double percent);
void DurabilityPointsLossAll(int32 points, bool inventory);
Expand Down
3 changes: 1 addition & 2 deletions src/server/game/Entities/Unit/Unit.cpp
Expand Up @@ -10949,8 +10949,7 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
TC_LOG_DEBUG("entities.unit", "We are dead, losing %f percent durability", sWorld->getRate(RATE_DURABILITY_LOSS_ON_DEATH));
plrVictim->DurabilityLossAll(sWorld->getRate(RATE_DURABILITY_LOSS_ON_DEATH), false);
// durability lost message
WorldPacket data(SMSG_DURABILITY_DAMAGE_DEATH, 0);
plrVictim->SendDirectMessage(&data);
plrVictim->SendDurabilityLoss();
}
// Call KilledUnit for creatures
if (attacker && attacker->GetTypeId() == TYPEID_UNIT && attacker->IsAIEnabled())
Expand Down
8 changes: 8 additions & 0 deletions src/server/game/Server/Packets/MiscPackets.h
Expand Up @@ -87,6 +87,14 @@ namespace WorldPackets
int32 GameTimeHolidayOffset = 0;
};

class DurabilityDamageDeath final : public ServerPacket
{
public:
DurabilityDamageDeath() : ServerPacket(SMSG_DURABILITY_DAMAGE_DEATH, 0) { }

WorldPacket const* Write() override { return &_worldPacket; }
};

class TriggerCinematic final : public ServerPacket
{
public:
Expand Down
1 change: 1 addition & 0 deletions src/server/worldserver/worldserver.conf.dist
Expand Up @@ -2453,6 +2453,7 @@ DurabilityLoss.InPvP = 0
#
# DurabilityLoss.OnDeath
# Description: Durability loss percentage on death.
# Note: On 3.3.5 client always shows log message "Your items have lost 10% durability"
# Default: 10

DurabilityLoss.OnDeath = 10
Expand Down

0 comments on commit e1a8ebc

Please sign in to comment.