[PR #2142] [MERGED] Scale mob damage to players with the difficulty #4043

Closed
opened 2026-11-03 04:14:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2142
Author: @kacpherek
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/mob-damage-difficulty-scaling


📝 Commits (1)

  • aec3b7e Scale mob damage to players with the difficulty

📊 Changes

4 files changed (+33 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+5 -1)
📝 crates/horizon-client/src/game/explosion.rs (+3 -1)
📝 crates/horizon-client/src/health.rs (+24 -2)
📝 crates/horizon-client/src/hunger.rs (+1 -0)

📄 Description

What and why

A mob's hit on the player ignored the difficulty. The player's hurt code already scales damage (easy min(d/2+1, d), hard d*1.5, peaceful 0), but the client only treated damage types marked always as scaling. The ones marked when_caused_by_living_non_player (mob_attack, arrow, fireball, mob_projectile, spit, wither_skull, wind_charge, ...) never scaled, so a zombie hit 3 on every difficulty.

The hurt now carries whether a living non-player caused it:

  • PlayerMotion::hurt_caused_by is hurt_blocking plus that flag (hurt_blocking keeps its signature and passes false).
  • mob_hits_player passes true when a mob made the hit, either the attacking mob or the owner of the projectile. Player hits and ownerless projectiles pass false. LAN guests go through the same function.
  • An explosion caused by a mob (creeper) passes true too.

With this, a zombie's 3 becomes 4.5 on hard and 2.5 on easy.

Not changed: the splash of a witch's harming potion still goes through hurt_player_by, which has no causing entity.

Vanilla reference

  • DamageSource.scalesWithDifficulty (NEVER, ALWAYS, WHEN_CAUSED_BY_LIVING_NON_PLAYER with a living non-player causing entity)
  • Player.hurtServer (difficulty scaling before the hurt)

Self-check

cargo check -p horizon-client passes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2142 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mob-damage-difficulty-scaling` --- ### 📝 Commits (1) - [`aec3b7e`](https://github.com/horizon-rust/horizon/commit/aec3b7e2624ea88f8d5ccd2019a9b13e03700e04) Scale mob damage to players with the difficulty ### 📊 Changes **4 files changed** (+33 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+5 -1) 📝 `crates/horizon-client/src/game/explosion.rs` (+3 -1) 📝 `crates/horizon-client/src/health.rs` (+24 -2) 📝 `crates/horizon-client/src/hunger.rs` (+1 -0) </details> ### 📄 Description ## What and why A mob's hit on the player ignored the difficulty. The player's hurt code already scales damage (easy `min(d/2+1, d)`, hard `d*1.5`, peaceful 0), but the client only treated damage types marked `always` as scaling. The ones marked `when_caused_by_living_non_player` (`mob_attack`, `arrow`, `fireball`, `mob_projectile`, `spit`, `wither_skull`, `wind_charge`, ...) never scaled, so a zombie hit 3 on every difficulty. The hurt now carries whether a living non-player caused it: - `PlayerMotion::hurt_caused_by` is `hurt_blocking` plus that flag (`hurt_blocking` keeps its signature and passes `false`). - `mob_hits_player` passes true when a mob made the hit, either the attacking mob or the owner of the projectile. Player hits and ownerless projectiles pass false. LAN guests go through the same function. - An explosion caused by a mob (creeper) passes true too. With this, a zombie's 3 becomes 4.5 on hard and 2.5 on easy. Not changed: the splash of a witch's harming potion still goes through `hurt_player_by`, which has no causing entity. ## Vanilla reference - `DamageSource.scalesWithDifficulty` (`NEVER`, `ALWAYS`, `WHEN_CAUSED_BY_LIVING_NON_PLAYER` with a living non-player causing entity) - `Player.hurtServer` (difficulty scaling before the hurt) ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:14 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4043
No description provided.