From 4a5ef6dce31792d8a77cfc69114eb97698e51021 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 17 Jun 2022 21:13:45 -0400 Subject: [PATCH] Poise damage dealt to a target in a stunned state is now no longer universally applied to the target as health damage. Instead poise damage is only converted to health damage when its source is mitigated crushing damage. Fixed 'Long Pole' -> 'Longpole' --- .../modular/weapon/primary/staff/longpole.ron | 2 +- common/src/combat.rs | 25 ++++++++++++++++--- server/src/events/entity_manipulation.rs | 23 ++++------------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/assets/common/items/modular/weapon/primary/staff/longpole.ron b/assets/common/items/modular/weapon/primary/staff/longpole.ron index 23c4a470bc..6cc9c8fc42 100644 --- a/assets/common/items/modular/weapon/primary/staff/longpole.ron +++ b/assets/common/items/modular/weapon/primary/staff/longpole.ron @@ -15,7 +15,7 @@ ItemDef( buff_strength: 0.8, ), hand_restriction: Some(Two), - weapon_name: Universal("Long Pole"), + weapon_name: Universal("Longpole"), ) ), quality: Low, diff --git a/common/src/combat.rs b/common/src/combat.rs index 6a4ecf9aec..d2330c9c64 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -286,10 +286,27 @@ impl Attack { time, }; if change.abs() > Poise::POISE_EPSILON { - emit(ServerEvent::PoiseChange { - entity: target.entity, - change: poise_change, - }); + // If target is in a stunned state, apply extra poise damage as health + // damage instead + if let Some(CharacterState::Stunned(data)) = target.char_state { + let health_change = + change * data.static_data.poise_state.damage_multiplier(); + let health_change = HealthChange { + amount: health_change, + by: attacker.map(|x| x.into()), + cause: Some(damage.damage.source), + time, + }; + emit(ServerEvent::HealthChange { + entity: target.entity, + change: health_change, + }); + } else { + emit(ServerEvent::PoiseChange { + entity: target.entity, + change: poise_change, + }); + } } }, // Piercing damage ignores some penetration, and is handled when damage diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 985c7f10ed..7ff49a5e79 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -55,24 +55,11 @@ enum DamageContrib { pub fn handle_poise(server: &Server, entity: EcsEntity, change: comp::PoiseChange) { let ecs = &server.state.ecs(); if let Some(character_state) = ecs.read_storage::().get(entity) { - // Entity is invincible to poise change during stunned/staggered character - // state, but the mitigated poise damage is converted to health damage instead - if let CharacterState::Stunned(data) = character_state { - let health_change = change.amount * data.static_data.poise_state.damage_multiplier(); - let time = ecs.read_resource::