Skip to content

Commit

Permalink
feat(Core/Packet): SMSG_DURABILITY_DAMAGE_DEATH (#10894)
Browse files Browse the repository at this point in the history
  • Loading branch information
IntelligentQuantum committed Mar 23, 2022
1 parent ccb6d3e commit 6a6d0e5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,11 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
{
if (type == DAMAGE_FALL) // DealDamage not apply item durability loss at self damage
{
LOG_DEBUG("entities.player", "We are fall to death, loosing 10 percents durability");
DurabilityLossAll(0.10f, false);
LOG_DEBUG("entities.player", "Player::EnvironmentalDamage: Player '{}' ({}) fall to death, losing {} durability",
GetName(), GetGUID().ToString(), 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);
GetSession()->SendPacket(&data2);
SendDurabilityLoss();
}

UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, 1, type);
Expand Down Expand Up @@ -4590,6 +4590,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
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,7 @@ class Player : public Unit, public GridObject<Player>
void BuildPlayerRepop();
void RepopAtGraveyard();

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
Original file line number Diff line number Diff line change
Expand Up @@ -17325,8 +17325,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
LOG_DEBUG("entities.unit", "We are dead, losing {} 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->GetSession()->SendPacket(&data);
plrVictim->SendDurabilityLoss();
}
// Call KilledUnit for creatures
if (killer && killer->GetTypeId() == TYPEID_UNIT && killer->IsAIEnabled)
Expand Down
9 changes: 9 additions & 0 deletions src/server/game/Server/Packets/MiscPackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ namespace WorldPackets
ObjectGuid Roller;
};

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

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

class CrossedInebriationThreshold final : public ServerPacket
{
public:
Expand All @@ -124,6 +132,7 @@ namespace WorldPackets
ObjectGuid Guid;
uint32 Threshold = 0;
uint32 ItemID = 0;

};
}
}
Expand Down
1 change: 1 addition & 0 deletions src/server/worldserver/worldserver.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2471,6 +2471,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 6a6d0e5

Please sign in to comment.