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

View File

@ -955,6 +955,8 @@ pub enum CharacterAbility {
buff_strength: f32,
buff_duration: Option<Secs>,
energy_cost: f32,
#[serde(default = "default_true")]
remove_previous: bool,
#[serde(default)]
combo_cost: u32,
combo_scaling: Option<ScalingKind>,
@ -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(),

View File

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