mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-08 17:19:10 -10:00
critical_hit: gate before the smash bonus, vanilla's default multiplier, correct sweep doc
Review fixes from #7036: the damage gate is read before the mace's smash bonus is added, damage_multiplier starts at 1.0 when vanilla's hit is not critical, and the docs say a forced crit prevents the sweep. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
3d1a782d69
commit
ea3611dc04
4 files changed
+14
-10
No files matched your search
@@ -11522,13 +11522,15 @@ impl Game<'_> {
|
||||
// attack strength scales the base damage.
|
||||
let enchant_bonus = self.enchanted_damage(target_kind, damage) - damage;
|
||||
let mut amount = damage * (0.2 + scale * scale * 0.8);
|
||||
// Player.attack decides the critical hit only for a hit with base or
|
||||
// enchantment damage: checked before the mace's smash bonus is added.
|
||||
let damaging = amount > 0.0 || enchant_bonus * scale > 0.0;
|
||||
// Item.getAttackDamageBonus (a mace's smash), before the critical hit.
|
||||
amount += self.smash_damage_bonus(target_kind);
|
||||
let vanilla_crit = living && self.critical_attack(scale);
|
||||
let mut crit = vanilla_crit;
|
||||
let mut multiplier = 1.5;
|
||||
// Player.attack decides the critical hit only for a hit that does damage.
|
||||
if living && (amount > 0.0 || enchant_bonus * scale > 0.0) {
|
||||
let mut multiplier = if vanilla_crit { 1.5 } else { 1.0 };
|
||||
if living && damaging {
|
||||
self.native_critical_hit(target_kind, vanilla_crit, &mut crit, &mut multiplier);
|
||||
}
|
||||
if crit {
|
||||
|
||||
@@ -5069,9 +5069,10 @@ impl Game<'_> {
|
||||
/// `target_kind` (`minecraft:zombie`, `minecraft:armor_stand`) that deals
|
||||
/// damage, where `Player.attack` decides whether it is critical.
|
||||
/// `vanilla_critical` is vanilla's answer; `critical` starts as it and may
|
||||
/// be forced or denied (a denied crit also drops the sweep it would allow,
|
||||
/// the crit sound and the particles); `damage_multiplier` starts at 1.5 and
|
||||
/// scales the damage only while `critical` ends true. Not fired for a
|
||||
/// be forced or denied (as in vanilla a critical hit prevents the sweep, so
|
||||
/// a forced crit loses it; a denied crit loses the crit sound and
|
||||
/// particles); `damage_multiplier` starts at 1.5 for vanilla's critical and
|
||||
/// 1.0 otherwise, and scales the damage only while `critical` ends true. Not fired for a
|
||||
/// target that is no living entity (a dragon part) or when the hit does
|
||||
/// no damage. Fires on the Game that runs the attack. @API:critical_hit@.
|
||||
pub(super) fn native_critical_hit(
|
||||
|
||||
+4
-3
@@ -2673,9 +2673,10 @@ pub trait Hooks: Send + Sync {
|
||||
/// `target_kind` (`minecraft:zombie`, `minecraft:armor_stand`) that deals
|
||||
/// damage, where `Player.attack` decides whether it is critical.
|
||||
/// `vanilla_critical` is vanilla's answer; `critical` starts as it and may
|
||||
/// be forced or denied (a denied crit also drops the sweep it would allow,
|
||||
/// the crit sound and the particles); `damage_multiplier` starts at 1.5 and
|
||||
/// scales the damage only while `critical` ends true. Not fired for a
|
||||
/// be forced or denied (as in vanilla a critical hit prevents the sweep, so
|
||||
/// a forced crit loses it; a denied crit loses the crit sound and
|
||||
/// particles); `damage_multiplier` starts at 1.5 for vanilla's critical and
|
||||
/// 1.0 otherwise, and scales the damage only while `critical` ends true. Not fired for a
|
||||
/// target that is no living entity (a dragon part) or when the hit does
|
||||
/// no damage. Fires on the Game that runs the attack. @API:critical_hit@.
|
||||
fn critical_hit(&self, host: &mut dyn Host, event: &mut CriticalHitEvent<'_>) {
|
||||
|
||||
@@ -12,5 +12,5 @@
|
||||
}
|
||||
],
|
||||
"rust_summary": "A player's melee hit on a living target decides whether it is critical (`native_critical_hit`).",
|
||||
"doc_summary": "A player's damaging melee hit on a living target: `native_critical_hit(target_kind, vanilla_critical, critical, damage_multiplier)` may force or deny the critical hit and change its 1.5 multiplier; the sweep, sound and particles follow the decided result. Not fired for a dragon part or a hit that does no damage. Bundles need \"hooks\": @API:critical_hit@."
|
||||
"doc_summary": "A player's damaging melee hit on a living target: `native_critical_hit(target_kind, vanilla_critical, critical, damage_multiplier)` may force or deny the critical hit and change its multiplier (1.5 for a vanilla crit, else 1.0); the sweep, sound and particles follow the decided result. Not fired for a dragon part or a hit that does no damage. Bundles need \"hooks\": @API:critical_hit@."
|
||||
}
|
||||
Reference in new issue
Block a user