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'
This commit is contained in:
Sam 2022-06-17 21:13:45 -04:00
parent 33014225be
commit 4a5ef6dce3
3 changed files with 27 additions and 23 deletions

View File

@ -15,7 +15,7 @@ ItemDef(
buff_strength: 0.8,
),
hand_restriction: Some(Two),
weapon_name: Universal("Long Pole"),
weapon_name: Universal("Longpole"),
)
),
quality: Low,

View File

@ -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

View File

@ -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::<CharacterState>().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::<Time>();
let health_change = HealthChange {
amount: health_change,
by: None,
cause: None,
time: *time,
};
let server_eventbus = ecs.read_resource::<EventBus<ServerEvent>>();
server_eventbus.emit_now(ServerEvent::HealthChange {
entity,
change: health_change,
});
} else if let Some(mut poise) = ecs.write_storage::<Poise>().get_mut(entity) {
poise.change(change);
// Entity is invincible to poise change during stunned character state
if !matches!(character_state, CharacterState::Stunned(_)) {
if let Some(mut poise) = ecs.write_storage::<Poise>().get_mut(entity) {
poise.change(change);
}
}
}
}