Disable selfbuff stacking

This commit is contained in:
maxicarlos08 2023-11-01 21:48:22 +01:00
parent 3332401ac4
commit d3f4b854fc
No known key found for this signature in database
3 changed files with 27 additions and 0 deletions

View File

@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved running, wielding, and riding animations - Improved running, wielding, and riding animations
- Fixed offset of items carried on backs when wearing cloaks and backpacks - 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 - Linearize light colors on the CPU rather than in shaders on the GPU
- You can no longer stack self buffs
### Removed ### Removed
- Medium and large potions from all loot tables - Medium and large potions from all loot tables

View File

@ -955,6 +955,8 @@ pub enum CharacterAbility {
buff_strength: f32, buff_strength: f32,
buff_duration: Option<Secs>, buff_duration: Option<Secs>,
energy_cost: f32, energy_cost: f32,
#[serde(default = "default_true")]
remove_previous: bool,
#[serde(default)] #[serde(default)]
combo_cost: u32, combo_cost: u32,
combo_scaling: Option<ScalingKind>, combo_scaling: Option<ScalingKind>,
@ -1604,6 +1606,7 @@ impl CharacterAbility {
ref mut buff_strength, ref mut buff_strength,
buff_duration: _, buff_duration: _,
ref mut energy_cost, ref mut energy_cost,
remove_previous: _,
combo_cost: _, combo_cost: _,
combo_scaling: _, combo_scaling: _,
meta: _, 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 { impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
fn from((ability, ability_info, data): (&CharacterAbility, AbilityInfo, &JoinData)) -> Self { fn from((ability, ability_info, data): (&CharacterAbility, AbilityInfo, &JoinData)) -> Self {
match ability { match ability {
@ -2831,6 +2837,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
energy_cost: _, energy_cost: _,
combo_cost, combo_cost,
combo_scaling, combo_scaling,
remove_previous,
meta: _, meta: _,
} => CharacterState::SelfBuff(self_buff::Data { } => CharacterState::SelfBuff(self_buff::Data {
static_data: self_buff::StaticData { static_data: self_buff::StaticData {
@ -2843,6 +2850,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
combo_cost: *combo_cost, combo_cost: *combo_cost,
combo_scaling: *combo_scaling, combo_scaling: *combo_scaling,
combo_on_use: data.combo.map_or(0, |c| c.counter()), combo_on_use: data.combo.map_or(0, |c| c.counter()),
remove_previous: *remove_previous,
ability_info, ability_info,
}, },
timer: Duration::default(), timer: Duration::default(),

View File

@ -36,6 +36,9 @@ pub struct StaticData {
/// This is the amount of combo held by the entity when this character state /// This is the amount of combo held by the entity when this character state
/// was entered /// was entered
pub combo_on_use: u32, 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 /// What key is used to press ability
pub ability_info: AbilityInfo, pub ability_info: AbilityInfo,
} }
@ -77,6 +80,21 @@ impl CharacterBehavior for Data {
entity: data.entity, entity: data.entity,
change: -(combo_consumption as i32), 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| { let scaling_factor = self.static_data.combo_scaling.map_or(1.0, |cs| {
cs.factor( cs.factor(
self.static_data.combo_on_use as f32, self.static_data.combo_on_use as f32,