From 646c57501f6cc8b06830c558c80a03710ee38768 Mon Sep 17 00:00:00 2001 From: do-no-van Date: Sun, 21 Jan 2024 20:15:24 +0000 Subject: [PATCH] make fortitude scale of difference from maximum health --- common/src/combat.rs | 4 ---- common/src/comp/buff.rs | 29 +++++++----------------- common/src/states/self_buff.rs | 1 - common/systems/src/aura.rs | 1 - common/systems/src/buff.rs | 17 ++------------ server/agent/src/action_nodes.rs | 2 +- server/src/cmd.rs | 2 -- server/src/events/entity_manipulation.rs | 2 -- server/src/state_ext.rs | 2 -- 9 files changed, 11 insertions(+), 49 deletions(-) diff --git a/common/src/combat.rs b/common/src/combat.rs index 2d68aee5ff..371ec66297 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -391,7 +391,6 @@ impl Attack { time, attacker.map(|a| a.uid), target.stats, - target.health, applied_damage, strength_modifier, )), @@ -611,7 +610,6 @@ impl Attack { time, attacker.map(|a| a.uid), target.stats, - target.health, accumulated_damage, strength_modifier, )), @@ -1179,7 +1177,6 @@ impl CombatBuff { time: Time, uid: Option, tgt_stats: Option<&Stats>, - tgt_health: Option<&Health>, damage: f32, strength_modifier: f32, ) -> Buff { @@ -1199,7 +1196,6 @@ impl CombatBuff { source, time, tgt_stats, - tgt_health, ) } } diff --git a/common/src/comp/buff.rs b/common/src/comp/buff.rs index e4c883188e..327281f7fc 100644 --- a/common/src/comp/buff.rs +++ b/common/src/comp/buff.rs @@ -4,7 +4,7 @@ use crate::{ AttackEffect, CombatBuff, CombatBuffStrength, CombatEffect, CombatRequirement, DamagedEffect, }, - comp::{aura::AuraKey, Health, Stats}, + comp::{aura::AuraKey, Stats}, resources::{Secs, Time}, uid::Uid, }; @@ -70,12 +70,12 @@ pub enum BuffKind { /// 50% increase, 1.0 is a 100% increase. Hastened, /// Increases resistance to incoming poise, and poise damage dealt as health - /// is lost from the time the buff activated. + /// is lost. /// Strength scales the resistance non-linearly. 0.5 provides 50%, 1.0 /// provides 67%. /// Strength scales the poise damage increase linearly, a strength of 1.0 - /// and n health less from activation will cause poise damage to increase by - /// n%. + /// and n health less from maximum health will cause poise damage to + /// increase by n%. Fortitude, /// Increases both attack damage and vulnerability to damage. /// Damage increases linearly with strength, 1.0 is a 100% increase. @@ -268,12 +268,7 @@ impl BuffKind { /// only the strongest. pub fn stacks(self) -> bool { matches!(self, BuffKind::PotionSickness) } - pub fn effects( - &self, - data: &BuffData, - stats: Option<&Stats>, - health: Option<&Health>, - ) -> Vec { + pub fn effects(&self, data: &BuffData, stats: Option<&Stats>) -> Vec { // Normalized nonlinear scaling let nn_scaling = |a| a / (a + 0.5); let instance = rand::random(); @@ -392,10 +387,7 @@ impl BuffKind { ], BuffKind::Fortitude => vec![ BuffEffect::PoiseReduction(nn_scaling(data.strength)), - BuffEffect::PoiseDamageFromLostHealth { - initial_health: health.map_or(0.0, |h| h.current()), - strength: data.strength, - }, + BuffEffect::PoiseDamageFromLostHealth(data.strength), ], BuffKind::Parried => vec![BuffEffect::AttackSpeed(0.5)], //TODO: Handle potion sickness in a more general way. @@ -601,10 +593,7 @@ pub enum BuffEffect { /// Reduces amount of speed increase by consumables MoveSpeedReduction(f32), /// Increases poise damage dealt when health is lost - PoiseDamageFromLostHealth { - initial_health: f32, - strength: f32, - }, + PoiseDamageFromLostHealth(f32), /// Modifier to the amount of damage dealt with attacks AttackDamage(f32), /// Overrides the precision multiplier applied to an attack @@ -679,9 +668,8 @@ impl Buff { source: BuffSource, time: Time, stats: Option<&Stats>, - health: Option<&Health>, ) -> Self { - let effects = kind.effects(&data, stats, health); + let effects = kind.effects(&data, stats); let cat_ids = kind.extend_cat_ids(cat_ids); let start_time = Time(time.0 + data.delay.map_or(0.0, |delay| delay.0)); let end_time = if cat_ids @@ -941,7 +929,6 @@ pub mod tests { BuffSource::Unknown, time, None, - None, ) } diff --git a/common/src/states/self_buff.rs b/common/src/states/self_buff.rs index 196d22cb26..9975866130 100644 --- a/common/src/states/self_buff.rs +++ b/common/src/states/self_buff.rs @@ -127,7 +127,6 @@ impl CharacterBehavior for Data { BuffSource::Character { by: *data.uid }, *data.time, Some(data.stats), - data.health, ); output_events.emit_server(ServerEvent::Buff { entity: data.entity, diff --git a/common/systems/src/aura.rs b/common/systems/src/aura.rs index 037b42d84c..0738d4926a 100644 --- a/common/systems/src/aura.rs +++ b/common/systems/src/aura.rs @@ -232,7 +232,6 @@ fn activate_aura( source, *read_data.time, stats, - Some(health), )), }); } diff --git a/common/systems/src/buff.rs b/common/systems/src/buff.rs index 7840a1a667..c1bb6e0080 100644 --- a/common/systems/src/buff.rs +++ b/common/systems/src/buff.rs @@ -153,7 +153,6 @@ impl<'a> System<'a> for Sys { BuffSource::World, *read_data.time, Some(&stat), - Some(health), )), }); } @@ -171,7 +170,6 @@ impl<'a> System<'a> for Sys { BuffSource::World, *read_data.time, Some(&stat), - Some(health), )), }); } @@ -202,7 +200,6 @@ impl<'a> System<'a> for Sys { BuffSource::World, *read_data.time, Some(&stat), - Some(health), )), }); } @@ -221,7 +218,6 @@ impl<'a> System<'a> for Sys { BuffSource::World, *read_data.time, Some(&stat), - Some(health), )), }); } @@ -239,7 +235,6 @@ impl<'a> System<'a> for Sys { BuffSource::World, *read_data.time, Some(&stat), - Some(health), )), }); } @@ -257,7 +252,6 @@ impl<'a> System<'a> for Sys { BuffSource::World, *read_data.time, Some(&stat), - Some(health), )), }); // When standing on IceSpike also apply Frozen @@ -270,7 +264,6 @@ impl<'a> System<'a> for Sys { BuffSource::World, *read_data.time, Some(&stat), - Some(health), )), }); } @@ -288,7 +281,6 @@ impl<'a> System<'a> for Sys { BuffSource::World, *read_data.time, Some(&stat), - Some(health), )), }); } @@ -310,7 +302,6 @@ impl<'a> System<'a> for Sys { BuffSource::World, *read_data.time, Some(&stat), - Some(health), )), }); } else if matches!( @@ -387,7 +378,6 @@ impl<'a> System<'a> for Sys { buff.source, *read_data.time, Some(&stat), - Some(health), )), }); } @@ -701,11 +691,8 @@ fn execute_effect( BuffEffect::MoveSpeedReduction(red) => { stat.move_speed_multiplier *= 1.0 - *red; }, - BuffEffect::PoiseDamageFromLostHealth { - initial_health, - strength, - } => { - let lost_health = (*initial_health - health.current()).max(0.0); + BuffEffect::PoiseDamageFromLostHealth(strength) => { + let lost_health = health.maximum() - health.current(); stat.poise_damage_modifier *= lost_health / 100.0 * *strength; }, BuffEffect::AttackDamage(dam) => { diff --git a/server/agent/src/action_nodes.rs b/server/agent/src/action_nodes.rs index 8100c20a3e..29c38d93bb 100644 --- a/server/agent/src/action_nodes.rs +++ b/server/agent/src/action_nodes.rs @@ -713,7 +713,7 @@ impl<'a> AgentData<'a> { }, Effect::Buff(BuffEffect { kind, data, .. }) => { if let Some(duration) = data.duration { - for effect in kind.effects(data, self.stats, self.health) { + for effect in kind.effects(data, self.stats) { match effect { comp::BuffEffect::HealthChangeOverTime { rate, kind, .. } => { let amount = match kind { diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 747487942f..fbe69ac378 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -4287,7 +4287,6 @@ fn cast_buff(buffkind: BuffKind, data: BuffData, server: &mut Server, target: Ec let ecs = &server.state.ecs(); let mut buffs_all = ecs.write_storage::(); let stats = ecs.read_storage::(); - let healths = ecs.read_storage::(); let time = ecs.read_resource::