diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index e9dbaea0fc..89322111c0 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -956,7 +956,7 @@ pub enum CharacterAbility { buff_duration: Option, energy_cost: f32, #[serde(default = "default_true")] - remove_previous: bool, + enforced_limit: bool, #[serde(default)] combo_cost: u32, combo_scaling: Option, @@ -1606,7 +1606,7 @@ impl CharacterAbility { ref mut buff_strength, buff_duration: _, ref mut energy_cost, - remove_previous: _, + enforced_limit: _, combo_cost: _, combo_scaling: _, meta: _, @@ -2837,7 +2837,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { energy_cost: _, combo_cost, combo_scaling, - remove_previous, + enforced_limit, meta: _, } => CharacterState::SelfBuff(self_buff::Data { static_data: self_buff::StaticData { @@ -2850,7 +2850,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { combo_cost: *combo_cost, combo_scaling: *combo_scaling, combo_on_use: data.combo.map_or(0, |c| c.counter()), - remove_previous: *remove_previous, + enforced_limit: *enforced_limit, ability_info, }, timer: Duration::default(), diff --git a/common/src/states/self_buff.rs b/common/src/states/self_buff.rs index 6442be1df4..2dfd58d9ea 100644 --- a/common/src/states/self_buff.rs +++ b/common/src/states/self_buff.rs @@ -38,7 +38,7 @@ pub struct StaticData { pub combo_on_use: u32, /// Controls whether `SelfBuff`s that were previously applied should be /// removed - pub remove_previous: bool, + pub enforced_limit: bool, /// What key is used to press ability pub ability_info: AbilityInfo, } @@ -81,8 +81,28 @@ impl CharacterBehavior for Data { change: -(combo_consumption as i32), }); + let scaling_factor = self.static_data.combo_scaling.map_or(1.0, |cs| { + cs.factor( + self.static_data.combo_on_use as f32, + self.static_data.combo_cost as f32, + ) + }); + + let mut buff_cat_ids = if self + .static_data + .ability_info + .ability + .map_or(false, |a| a.ability.is_from_tool()) + { + vec![BuffCategory::RemoveOnLoadoutChange] + } else { + Vec::new() + }; + // Remove previous selfbuffs if we should - if self.static_data.remove_previous { + if self.static_data.enforced_limit { + buff_cat_ids.push(BuffCategory::SelfBuff); + output_events.emit_server(ServerEvent::Buff { entity: data.entity, buff_change: BuffChange::RemoveByCategory { @@ -93,22 +113,6 @@ impl CharacterBehavior for Data { }); } - let scaling_factor = self.static_data.combo_scaling.map_or(1.0, |cs| { - cs.factor( - self.static_data.combo_on_use as f32, - self.static_data.combo_cost as f32, - ) - }); - let buff_cat_ids = if self - .static_data - .ability_info - .ability - .map_or(false, |a| a.ability.is_from_tool()) - { - vec![BuffCategory::RemoveOnLoadoutChange, BuffCategory::SelfBuff] - } else { - vec![BuffCategory::SelfBuff] - }; // Creates buff let buff = Buff::new( self.static_data.buff_kind,