diff --git a/CHANGELOG.md b/CHANGELOG.md index be6d4a43b9..78613d380a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved running, wielding, and riding animations - Fixed offset of items carried on backs when wearing cloaks and backpacks - Linearize light colors on the CPU rather than in shaders on the GPU +- You can no longer stack self buffs ### Removed - Medium and large potions from all loot tables diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 06ae998cc4..e9dbaea0fc 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -955,6 +955,8 @@ pub enum CharacterAbility { buff_strength: f32, buff_duration: Option, energy_cost: f32, + #[serde(default = "default_true")] + remove_previous: bool, #[serde(default)] combo_cost: u32, combo_scaling: Option, @@ -1604,6 +1606,7 @@ impl CharacterAbility { ref mut buff_strength, buff_duration: _, ref mut energy_cost, + remove_previous: _, combo_cost: _, combo_scaling: _, meta: _, @@ -2255,6 +2258,9 @@ impl CharacterAbility { } } +/// Small helper for #[serde(default)] booleans +fn default_true() -> bool { true } + impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { fn from((ability, ability_info, data): (&CharacterAbility, AbilityInfo, &JoinData)) -> Self { match ability { @@ -2831,6 +2837,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { energy_cost: _, combo_cost, combo_scaling, + remove_previous, meta: _, } => CharacterState::SelfBuff(self_buff::Data { static_data: self_buff::StaticData { @@ -2843,6 +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, ability_info, }, timer: Duration::default(), diff --git a/common/src/states/self_buff.rs b/common/src/states/self_buff.rs index 4c341f3817..29d2d07caf 100644 --- a/common/src/states/self_buff.rs +++ b/common/src/states/self_buff.rs @@ -36,6 +36,9 @@ pub struct StaticData { /// This is the amount of combo held by the entity when this character state /// was entered pub combo_on_use: u32, + /// Controls whether `SelfBuff`s that were previously applied should be + /// removed + pub remove_previous: bool, /// What key is used to press ability pub ability_info: AbilityInfo, } @@ -77,6 +80,21 @@ impl CharacterBehavior for Data { entity: data.entity, change: -(combo_consumption as i32), }); + + // Remove previous selfbuffs if we should + if self.static_data.remove_previous { + output_events.emit_server(ServerEvent::Buff { + entity: data.entity, + buff_change: BuffChange::RemoveByCategory { + // TODO: Consider renaming [BuffCategory::RemoveOnLoadoutChange] to + // something more generic? + all_required: vec![BuffCategory::RemoveOnLoadoutChange], + any_required: vec![], + none_required: vec![], + }, + }); + } + let scaling_factor = self.static_data.combo_scaling.map_or(1.0, |cs| { cs.factor( self.static_data.combo_on_use as f32,