Skip to content

Commit

Permalink
Core/Unit: Round damage instead of truncating it
Browse files Browse the repository at this point in the history
Round damage instead of truncating it when calculating armor-reduced damage. This fixes some level 1 creatures doing 0 damage (displayed as "Miss" ingame)
  • Loading branch information
jackpoz committed Apr 9, 2020
1 parent 81a09eb commit a0d5088
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ void Unit::HandleEmoteCommand(uint32 emoteId)
damageReduction /= (1.0f + damageReduction);

RoundToInterval(damageReduction, 0.f, 0.75f);
return uint32(std::max(damage * (1.0f - damageReduction), 0.0f));
return uint32(std::lroundf(std::max(damage * (1.0f - damageReduction), 0.0f)));
}

/*static*/ uint32 Unit::CalcSpellResistedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellSchoolMask schoolMask, SpellInfo const* spellInfo)
Expand Down

9 comments on commit a0d5088

@jackpoz
Copy link
Member Author

@jackpoz jackpoz commented on a0d5088 Apr 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be other places where this might make sense, for now only this one has been updated

@Killyana
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a character that have 25k armor I still don't get any damage.
Tested with SpawnID: 79960

@jackpoz
Copy link
Member Author

@jackpoz jackpoz commented on a0d5088 Apr 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you supposed to always get damage ? Because some years ago this code forced to always do 1 damage at least, then it got changed to 0

Here's the commit that changed it from 1 to 0: f1986c6#diff-4522eeffcbc961602e86620011a2d579R1646

@Killyana
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Idea, maybe someone in retail can check that

@jackpoz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shauren
Copy link
Member

@Shauren Shauren commented on a0d5088 Jan 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late test but I got retail result now - 0 damage (and miss) is actually blizzlike

@jackpoz
Copy link
Member Author

@jackpoz jackpoz commented on a0d5088 Jan 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change ceil back to round then ?

@Shauren
Copy link
Member

@Shauren Shauren commented on a0d5088 Jan 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@Shauren
Copy link
Member

@Shauren Shauren commented on a0d5088 Jan 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a sniff sample

ServerToClient: SMSG_ATTACKER_STATE_UPDATE (0x294C) Length: 97 ConnIdx: 1 Time: 01/01/2022 13:13:35.094 Number: 2935
HasLogData: False
Size: 92
(AttackRoundInfo) HitInfo: 8389122 (HITINFO_AFFECTS_VICTIM, HITINFO_CRITICALHIT, HITINFO_RAGE_GAIN)
(AttackRoundInfo) AttackerGUID: Full: 0x2016E4002029DAC000001B00004FD642 Creature/0 R1465/S27 Map: 1 (Kalimdor) Entry: 42859 (Wild Mature Swine) Low: 5232194
(AttackRoundInfo) TargetGUID: Full: 0xREDACTED Player/0 R1305/S0 Map: 0 (Eastern Kingdoms) Low: REDACTED
(AttackRoundInfo) Damage: 0
(AttackRoundInfo) OriginalDamage: 0
(AttackRoundInfo) OverDamage: -1
(AttackRoundInfo) HasSubDmg: true
(AttackRoundInfo) SchoolMask: 1
(AttackRoundInfo) FloatDamage: 0
(AttackRoundInfo) IntDamage: 0
(AttackRoundInfo) VictimState: 1 (VICTIMSTATE_NORMAL)
(AttackRoundInfo) AttackerState: 0
(AttackRoundInfo) MeleeSpellID: 0 (0)
(AttackRoundInfo) RageGained: 35
(AttackRoundInfo) (ContentTuning) Type: 1
(AttackRoundInfo) (ContentTuning) TargetLevel: 52
(AttackRoundInfo) (ContentTuning) Expansion: 0
(AttackRoundInfo) (ContentTuning) PlayerLevelDelta: 0
(AttackRoundInfo) (ContentTuning) TargetScalingLevelDelta: -1
(AttackRoundInfo) (ContentTuning) PlayerItemLevel: 80.5
(AttackRoundInfo) (ContentTuning) TargetItemLevel: 91.13182830810546875
(AttackRoundInfo) (ContentTuning) ScalingHealthItemLevelCurveID: 0
(AttackRoundInfo) (ContentTuning) Flags: 0
(AttackRoundInfo) (ContentTuning) PlayerContentTuningID: 70
(AttackRoundInfo) (ContentTuning) TargetContentTuningID: 70

Please sign in to comment.