veloren_common/comp/buff.rs
1use crate::{
2 combat::{
3 AttackEffect, CombatBuff, CombatBuffStrength, CombatEffect, CombatRequirement,
4 DamagedEffect, DeathEffect,
5 },
6 comp::{Mass, Stats, aura::AuraKey},
7 link::DynWeakLinkHandle,
8 match_some,
9 resources::{Secs, Time},
10 uid::Uid,
11};
12
13use core::cmp::Ordering;
14use enum_map::{Enum, EnumMap};
15use itertools::Either;
16use serde::{Deserialize, Serialize};
17use slotmap::{SlotMap, new_key_type};
18use specs::{Component, DerefFlaggedStorage, VecStorage};
19use strum::EnumIter;
20
21use super::Body;
22
23new_key_type! { pub struct BuffKey; }
24
25/// De/buff Kind.
26/// This is used to determine what effects a buff will have
27#[derive(
28 Clone, Copy, PartialEq, Eq, Hash, Debug, Serialize, Deserialize, PartialOrd, Ord, EnumIter, Enum,
29)]
30pub enum BuffKind {
31 // =================
32 // BUFFS
33 // =================
34 /// Restores health/time for some period.
35 /// Strength should be the healing per second.
36 Regeneration,
37 /// Restores health/time for some period for consumables.
38 /// Strength should be the healing per second.
39 Saturation,
40 /// Applied when drinking a potion.
41 /// Strength should be the healing per second.
42 Potion,
43 /// Increases movement speed and vulnerability to damage as well as
44 /// decreases the amount of damage dealt.
45 /// Movement speed increases linearly with strength 1.0 is an 100% increase
46 /// Damage vulnerability and damage reduction are both hard set to 100%
47 Agility,
48 /// Applied when resting (sitting at campfire or sleeping).
49 /// Strength is fraction of health restored per second.
50 RestingHeal,
51 /// Restores energy/time for some period.
52 /// Strength should be the energy regenerated per second.
53 EnergyRegen,
54 /// Generates combo over time for some period.
55 /// Strength should be the combo generated per second.
56 ComboGeneration,
57 /// Raises maximum energy.
58 /// Strength should be 10x the effect to max energy.
59 IncreaseMaxEnergy,
60 /// Raises maximum health.
61 /// Strength should be the effect to max health.
62 IncreaseMaxHealth,
63 /// Makes you immune to attacks.
64 /// Strength does not affect this buff.
65 Invulnerability,
66 /// Reduces incoming damage.
67 /// Strength scales the damage reduction non-linearly. 0.5 provides 50% DR,
68 /// 1.0 provides 67% DR.
69 ProtectingWard,
70 /// Increases movement speed and gives health regeneration.
71 /// Strength scales the movement speed linearly. 0.5 is 150% speed, 1.0 is
72 /// 200% speed. Provides regeneration at 10x the value of the strength.
73 Frenzied,
74 /// Increases movement and attack speed Strength scales strength of both
75 /// effects linearly. 0.5 is a 50% increase, 1.0 is a 100% increase.
76 Hastened,
77 /// Increases resistance to incoming poise, and poise damage dealt as health
78 /// is lost.
79 /// Strength scales the resistance non-linearly. 0.5 provides 50%, 1.0
80 /// provides 67%.
81 /// Strength scales the poise damage increase linearly, a strength of 1.0
82 /// and n health less from maximum health will cause poise damage to
83 /// increase by n%.
84 Fortitude,
85 /// Increases both attack damage and vulnerability to damage.
86 /// Damage increases linearly with strength, 1.0 is a 100% increase.
87 /// Damage reduction decreases linearly with strength, 1.0 is a 100%
88 /// decrease.
89 Reckless,
90 /// Provides immunity to burning and increases movement speed in lava.
91 /// Movement speed increases linearly with strength, 1.0 is a 100% increase.
92 // SalamanderAspect, TODO: Readd in second dwarven mine MR
93 /// Your attacks cause targets to receive the burning debuff
94 /// Strength of burning debuff is a fraction of the damage, fraction
95 /// increases linearly with strength
96 Flame,
97 /// Your attacks cause targets to receive the frozen debuff
98 /// Strength of frozen debuff is equal to the strength of this buff
99 Frigid,
100 /// Your attacks have lifesteal
101 /// Strength increases the fraction of damage restored as life
102 Lifesteal,
103 /// Your attacks against bleeding targets have lifesteal
104 /// Strength increases the fraction of damage restored as life
105 Bloodfeast,
106 /// Guarantees that the next attack is a precise hit. Does this kind of
107 /// hackily by adding 100% to the precision, will need to be adjusted if we
108 /// ever allow double precision hits instead of treating 100 as a
109 /// ceiling.
110 ImminentCritical,
111 /// Increases combo gain, every 1 strength increases combo per strike by 1,
112 /// rounds to nearest integer
113 Fury,
114 /// Allows attacks to ignore DR and increases energy reward
115 /// DR penetration is non-linear, 0.5 is 50% penetration and 1.0 is a 67%
116 /// penetration. Energy reward is increased linearly to strength, 1.0 is a
117 /// 150 % increase.
118 Sunderer,
119 /// Generates combo when damaged and decreases movement speed.
120 /// Movement speed is decreased to 50%. Combo generation is linear with
121 /// strength, 1.0 is 5 combo generated on being hit.
122 Defiance,
123 /// Increases both attack damage, vulnerability to damage, attack speed, and
124 /// movement speed Damage increases linearly with strength, 1.0 is a
125 /// 100% increase. Damage reduction decreases linearly with strength,
126 /// 1.0 is a 100% Attack speed increases non-linearly with strength, 0.5
127 /// is a 25% increase, 1.0 is a 33% increase Movement speed increases
128 /// non-linearly with strength, 0.5 is a 12.5% increase, 1.0 is a 16.7%
129 /// increase decrease.
130 Berserk,
131 /// Increases poise resistance and energy reward. However if killed, buffs
132 /// killer with Reckless buff. Poise resistance scales non-linearly with
133 /// strength, 0.5 is 50% and 1.0 is 67%. Energy reward scales linearly with
134 /// strength, 0.5 is +50% and 1.0 is +100% strength. Reckless buff reward
135 /// strength is equal to scornful taunt buff strength.
136 ScornfulTaunt,
137 /// Increases damage resistance, causes energy to be generated when damaged,
138 /// and decreases movement speed. Damage resistance increases non-linearly
139 /// with strength, 0.5 is 25% and 1.0 is 34%. Energy generation is linear
140 /// with strength, 1.0 is 10 energy per hit. Movement speed is decreased to
141 /// 70%.
142 Tenacity,
143 /// Applies to some debuffs that have strong CC effects. Automatically
144 /// gained upon receiving those debuffs, and causes future instances of
145 /// those debuffs to be applied with reduced duration.
146 /// Strength linearly decreases the duration of newly applied, affected
147 /// debuffs, 0.5 is a 50% reduction.
148 Resilience,
149 // =================
150 // DEBUFFS
151 // =================
152 /// Does damage to a creature over time.
153 /// Strength should be the DPS of the debuff.
154 /// Provides immunity against Frozen.
155 Burning,
156 /// Lowers health over time for some duration.
157 /// Strength should be the DPS of the debuff.
158 Bleeding,
159 /// Lower a creature's max health over time.
160 /// Strength only affects the target max health, 0.5 targets 50% of base
161 /// max, 1.0 targets 100% of base max.
162 Cursed,
163 /// Reduces movement speed and causes bleeding damage.
164 /// Strength scales the movement speed debuff non-linearly. 0.5 is 50%
165 /// speed, 1.0 is 33% speed. Bleeding is at 4x the value of the strength.
166 Crippled,
167 /// Slows movement and attack speed.
168 /// Strength scales the attack speed debuff non-linearly. 0.5 is ~50%
169 /// speed, 1.0 is 33% speed. Movement speed debuff is scaled to be slightly
170 /// smaller than attack speed debuff.
171 /// Provides immunity against Heatstroke.
172 Frozen,
173 /// Makes you wet and causes you to have reduced friction on the ground.
174 /// Strength scales the friction you ignore non-linearly. 0.5 is 50% ground
175 /// friction, 1.0 is 33% ground friction.
176 /// Provides immunity against Burning.
177 Wet,
178 /// Makes you move slower.
179 /// Strength scales the movement speed debuff non-linearly. 0.5 is 50%
180 /// speed, 1.0 is 33% speed.
181 Ensnared,
182 /// Drain stamina to a creature over time.
183 /// Strength should be the energy per second of the debuff.
184 Poisoned,
185 /// Results from having an attack parried.
186 /// Causes your attack speed to be slower to emulate the recover duration of
187 /// an ability being lengthened.
188 Parried,
189 /// Results from drinking a potion.
190 /// Decreases the health gained from subsequent potions.
191 PotionSickness,
192 /// Slows movement speed and reduces energy reward.
193 /// Both scales non-linearly to strength, 0.5 lead to movespeed reduction
194 /// by 25% and energy reward reduced by 150%, 1.0 lead to MS reduction by
195 /// 33.3% and energy reward reduced by 200%. Energy reward can't be
196 /// reduced by more than 200%, to a minimum value of -100%.
197 Heatstroke,
198 /// Reduces movement speed to 0.
199 /// Strength increases the relative mass of the creature that can be
200 /// targeted. A strength of 1.0 means that a creature of the same mass gets
201 /// rooted for the full duration. A strength of 2.0 means a creature of
202 /// twice the mass gets rooted for the full duration. If the target's mass
203 /// is higher than the strength allows for, duration gets reduced using a
204 /// mutiplier from the ratio of masses.
205 Rooted,
206 /// Slows movement speed and reduces energy reward
207 /// Both scale non-linearly with strength, 0.5 leads to 50% reduction of
208 /// energy reward and 33% reduction of move speed. 1.0 leads to 67%
209 /// reduction of energy reward and 50% reduction of move speed.
210 Winded,
211 /// Prevents use of auxiliary abilities.
212 /// Does not scale with strength
213 Amnesia,
214 /// Increases amount of poise damage received
215 /// Scales linearly with strength, 1.0 leads to 100% more poise damage
216 /// received
217 OffBalance,
218 // =================
219 // COMPLEX
220 // =================
221 /// Changed into another body.
222 Polymorphed,
223}
224
225/// Tells a little more about the buff kind than simple buff/debuff
226#[derive(Clone, Copy, Debug, PartialEq, Eq)]
227pub enum BuffDescriptor {
228 /// Simple positive buffs, like `BuffKind::Saturation`
229 SimplePositive,
230 /// Simple negative buffs, like `BuffKind::Bleeding`
231 SimpleNegative,
232 /// Buffs that require unusual data that can't be governed just by strength
233 /// and duration, like `BuffKind::Polymorhped`
234 Complex,
235 // For future additions, we may want to tell about non-obvious buffs,
236 // like Agility.
237 // Also maybe extend Complex to differentiate between Positive, Negative
238 // and Neutral buffs?
239 // For now, Complex is assumed to be neutral/non-obvious.
240}
241
242impl BuffKind {
243 /// Tells a little more about buff kind than simple buff/debuff
244 ///
245 /// Read more in [BuffDescriptor].
246 pub fn differentiate(self) -> BuffDescriptor {
247 match self {
248 BuffKind::Regeneration
249 | BuffKind::Saturation
250 | BuffKind::Potion
251 | BuffKind::Agility
252 | BuffKind::RestingHeal
253 | BuffKind::Frenzied
254 | BuffKind::EnergyRegen
255 | BuffKind::ComboGeneration
256 | BuffKind::IncreaseMaxEnergy
257 | BuffKind::IncreaseMaxHealth
258 | BuffKind::Invulnerability
259 | BuffKind::ProtectingWard
260 | BuffKind::Hastened
261 | BuffKind::Fortitude
262 | BuffKind::Reckless
263 | BuffKind::Flame
264 | BuffKind::Frigid
265 | BuffKind::Lifesteal
266 //| BuffKind::SalamanderAspect
267 | BuffKind::ImminentCritical
268 | BuffKind::Fury
269 | BuffKind::Sunderer
270 | BuffKind::Defiance
271 | BuffKind::Bloodfeast
272 | BuffKind::Berserk
273 | BuffKind::ScornfulTaunt
274 | BuffKind::Tenacity
275 | BuffKind::Resilience => BuffDescriptor::SimplePositive,
276 BuffKind::Bleeding
277 | BuffKind::Cursed
278 | BuffKind::Burning
279 | BuffKind::Crippled
280 | BuffKind::Frozen
281 | BuffKind::Wet
282 | BuffKind::Ensnared
283 | BuffKind::Poisoned
284 | BuffKind::Parried
285 | BuffKind::PotionSickness
286 | BuffKind::Heatstroke
287 | BuffKind::Rooted
288 | BuffKind::Winded
289 | BuffKind::Amnesia
290 | BuffKind::OffBalance => BuffDescriptor::SimpleNegative,
291 BuffKind::Polymorphed => BuffDescriptor::Complex,
292 }
293 }
294
295 /// Checks if buff is buff or debuff.
296 pub fn is_buff(self) -> bool {
297 match self.differentiate() {
298 BuffDescriptor::SimplePositive => true,
299 BuffDescriptor::SimpleNegative | BuffDescriptor::Complex => false,
300 }
301 }
302
303 pub fn is_simple(self) -> bool {
304 match self.differentiate() {
305 BuffDescriptor::SimplePositive | BuffDescriptor::SimpleNegative => true,
306 BuffDescriptor::Complex => false,
307 }
308 }
309
310 /// Checks if buff should queue.
311 pub fn queues(self) -> bool { matches!(self, BuffKind::Saturation) }
312
313 /// Checks if the buff can affect other buff effects applied in the same
314 /// tick.
315 pub fn affects_subsequent_buffs(self) -> bool {
316 matches!(
317 self,
318 BuffKind::PotionSickness /* | BuffKind::SalamanderAspect */
319 )
320 }
321
322 /// Checks if multiple instances of the buff should be processed, instead of
323 /// only the strongest.
324 pub fn stacks(self) -> bool { matches!(self, BuffKind::PotionSickness | BuffKind::Resilience) }
325
326 pub fn effects(&self, data: &BuffData) -> Vec<BuffEffect> {
327 // Normalized nonlinear scaling
328 // TODO: Do we want to make denominator term parameterized. Come back to if we
329 // add nn_scaling3.
330 let nn_scaling = |a: f32| a.abs() / (a.abs() + 0.5) * a.signum();
331 let nn_scaling2 = |a: f32| a.abs() / (a.abs() + 1.0) * a.signum();
332 let instance = rand::random();
333 match self {
334 BuffKind::Bleeding => vec![BuffEffect::HealthChangeOverTime {
335 rate: -data.strength,
336 kind: ModifierKind::Additive,
337 instance,
338 tick_dur: Secs(0.5),
339 }],
340 BuffKind::Regeneration => vec![BuffEffect::HealthChangeOverTime {
341 rate: data.strength,
342 kind: ModifierKind::Additive,
343 instance,
344 tick_dur: Secs(1.0),
345 }],
346 BuffKind::Saturation => vec![BuffEffect::HealthChangeOverTime {
347 rate: data.strength,
348 kind: ModifierKind::Additive,
349 instance,
350 tick_dur: Secs(3.0),
351 }],
352 BuffKind::Potion => {
353 vec![BuffEffect::HealthChangeOverTime {
354 rate: data.strength,
355 kind: ModifierKind::Additive,
356 instance,
357 tick_dur: Secs(0.1),
358 }]
359 },
360 BuffKind::Agility => vec![
361 BuffEffect::MovementSpeed(1.0 + data.strength),
362 BuffEffect::DamageReduction(-1.0),
363 BuffEffect::AttackDamage(0.0),
364 ],
365 BuffKind::RestingHeal => vec![BuffEffect::HealthChangeOverTime {
366 rate: data.strength,
367 kind: ModifierKind::Multiplicative,
368 instance,
369 tick_dur: Secs(2.0),
370 }],
371 BuffKind::Cursed => vec![
372 BuffEffect::MaxHealthChangeOverTime {
373 rate: -1.0,
374 kind: ModifierKind::Additive,
375 target_fraction: 1.0 - data.strength,
376 },
377 BuffEffect::HealthChangeOverTime {
378 rate: -1.0,
379 kind: ModifierKind::Additive,
380 instance,
381 tick_dur: Secs(0.5),
382 },
383 ],
384 BuffKind::EnergyRegen => vec![BuffEffect::EnergyChangeOverTime {
385 rate: data.strength,
386 kind: ModifierKind::Additive,
387 tick_dur: Secs(0.25),
388 reset_rate_on_tick: false,
389 }],
390 BuffKind::ComboGeneration => {
391 let target_tick_dur = 0.25;
392 // Combo per tick must be an integer
393 let nearest_valid_tick_dur =
394 (data.strength as f64 * target_tick_dur).round() / data.strength as f64;
395
396 vec![BuffEffect::ComboChangeOverTime {
397 rate: data.strength,
398 tick_dur: Secs(nearest_valid_tick_dur),
399 }]
400 },
401 BuffKind::IncreaseMaxEnergy => vec![BuffEffect::MaxEnergyModifier {
402 value: data.strength,
403 kind: ModifierKind::Additive,
404 }],
405 BuffKind::IncreaseMaxHealth => vec![BuffEffect::MaxHealthModifier {
406 value: data.strength,
407 kind: ModifierKind::Additive,
408 }],
409 BuffKind::Invulnerability => vec![BuffEffect::DamageReduction(1.0)],
410 BuffKind::ProtectingWard => vec![BuffEffect::DamageReduction(
411 // Causes non-linearity in effect strength, but necessary
412 // to allow for tool power and other things to affect the
413 // strength. 0.5 also still provides 50% damage reduction.
414 nn_scaling(data.strength),
415 )],
416 BuffKind::Burning => vec![
417 BuffEffect::HealthChangeOverTime {
418 rate: -data.strength,
419 kind: ModifierKind::Additive,
420 instance,
421 tick_dur: Secs(0.25),
422 },
423 BuffEffect::BuffImmunity(BuffKind::Frozen),
424 ],
425 BuffKind::Poisoned => vec![BuffEffect::EnergyChangeOverTime {
426 rate: -data.strength,
427 kind: ModifierKind::Additive,
428 tick_dur: Secs(0.5),
429 reset_rate_on_tick: true,
430 }],
431 BuffKind::Crippled => vec![
432 BuffEffect::MovementSpeed(1.0 - nn_scaling(data.strength)),
433 BuffEffect::HealthChangeOverTime {
434 rate: -data.strength * 4.0,
435 kind: ModifierKind::Additive,
436 instance,
437 tick_dur: Secs(0.5),
438 },
439 ],
440 BuffKind::Frenzied => vec![
441 BuffEffect::MovementSpeed(1.0 + data.strength),
442 BuffEffect::HealthChangeOverTime {
443 rate: data.strength * 10.0,
444 kind: ModifierKind::Additive,
445 instance,
446 tick_dur: Secs(1.0),
447 },
448 ],
449 BuffKind::Frozen => vec![
450 BuffEffect::MovementSpeed(f32::powf(1.0 - nn_scaling(data.strength), 1.1)),
451 BuffEffect::AttackSpeed(1.0 - nn_scaling(data.strength)),
452 BuffEffect::BuffImmunity(BuffKind::Heatstroke),
453 ],
454 BuffKind::Wet => vec![
455 BuffEffect::GroundFriction(1.0 - nn_scaling(data.strength)),
456 BuffEffect::BuffImmunity(BuffKind::Burning),
457 ],
458 BuffKind::Ensnared => vec![BuffEffect::MovementSpeed(1.0 - nn_scaling(data.strength))],
459 BuffKind::Hastened => vec![
460 BuffEffect::MovementSpeed(1.0 + data.strength),
461 BuffEffect::AttackSpeed(1.0 + data.strength),
462 ],
463 BuffKind::Fortitude => vec![
464 BuffEffect::PoiseReduction(nn_scaling(data.strength)),
465 BuffEffect::PoiseDamageFromLostHealth(data.strength),
466 ],
467 BuffKind::Parried => vec![BuffEffect::PrecisionVulnerabilityOverride(0.75)],
468 BuffKind::PotionSickness => vec![BuffEffect::ItemEffectReduction(data.strength)],
469 BuffKind::Reckless => vec![
470 BuffEffect::DamageReduction(-data.strength),
471 BuffEffect::AttackDamage(1.0 + data.strength),
472 ],
473 BuffKind::Polymorphed => {
474 let mut effects = Vec::new();
475 if let Some(MiscBuffData::Body(body)) = data.misc_data {
476 effects.push(BuffEffect::BodyChange(body));
477 }
478 effects
479 },
480 BuffKind::Flame => vec![BuffEffect::AttackEffect(AttackEffect::new(
481 None,
482 CombatEffect::Buff(CombatBuff {
483 kind: BuffKind::Burning,
484 dur_secs: data.secondary_duration.map_or(5.0, |dur| dur.0 as f32),
485 strength: CombatBuffStrength::DamageFraction(data.strength),
486 chance: 1.0,
487 }),
488 ))],
489 BuffKind::Frigid => vec![BuffEffect::AttackEffect(AttackEffect::new(
490 None,
491 CombatEffect::Buff(CombatBuff {
492 kind: BuffKind::Frozen,
493 dur_secs: data.secondary_duration.map_or(5.0, |dur| dur.0 as f32),
494 strength: CombatBuffStrength::Value(data.strength),
495 chance: 1.0,
496 }),
497 ))],
498 BuffKind::Lifesteal => vec![BuffEffect::AttackEffect(AttackEffect::new(
499 None,
500 CombatEffect::Lifesteal(data.strength),
501 ))],
502 /*BuffKind::SalamanderAspect => vec![
503 BuffEffect::BuffImmunity(BuffKind::Burning),
504 BuffEffect::SwimSpeed(1.0 + data.strength),
505 ],*/
506 BuffKind::Bloodfeast => vec![BuffEffect::AttackEffect(
507 AttackEffect::new(None, CombatEffect::Lifesteal(data.strength))
508 .with_requirement(CombatRequirement::TargetHasBuff(BuffKind::Bleeding)),
509 )],
510 BuffKind::ImminentCritical => vec![BuffEffect::PrecisionOverride(1.0)],
511 BuffKind::Fury => vec![BuffEffect::AttackEffect(
512 AttackEffect::new(None, CombatEffect::Combo(data.strength.round() as i32))
513 .with_requirement(CombatRequirement::AnyDamage),
514 )],
515 BuffKind::Sunderer => vec![
516 BuffEffect::MitigationsPenetration(nn_scaling(data.strength)),
517 BuffEffect::EnergyReward(1.0 + 1.5 * data.strength),
518 ],
519 BuffKind::Defiance => vec![
520 BuffEffect::MovementSpeed(0.5),
521 BuffEffect::DamagedEffect(DamagedEffect::Combo(
522 (data.strength * 5.0).round() as i32
523 )),
524 ],
525 BuffKind::Berserk => vec![
526 BuffEffect::DamageReduction(-data.strength),
527 BuffEffect::AttackDamage(1.0 + data.strength),
528 BuffEffect::AttackSpeed(1.0 + nn_scaling(data.strength) / 2.0),
529 BuffEffect::MovementSpeed(1.0 + nn_scaling(data.strength) / 4.0),
530 ],
531 BuffKind::Heatstroke => vec![
532 BuffEffect::MovementSpeed(1.0 - nn_scaling(data.strength) * 0.5),
533 BuffEffect::EnergyReward((1.0 - nn_scaling(data.strength) * 3.0).max(-1.0)),
534 ],
535 BuffKind::ScornfulTaunt => vec![
536 BuffEffect::PoiseReduction(nn_scaling(data.strength)),
537 BuffEffect::EnergyReward(1.0 + data.strength),
538 BuffEffect::DeathEffect(DeathEffect::AttackerBuff {
539 kind: BuffKind::Reckless,
540 strength: data.strength,
541 duration: data.duration,
542 }),
543 ],
544 BuffKind::Rooted => vec![BuffEffect::MovementSpeed(0.0)],
545 BuffKind::Winded => vec![
546 BuffEffect::MovementSpeed(1.0 - nn_scaling2(data.strength)),
547 BuffEffect::EnergyReward(1.0 - nn_scaling(data.strength)),
548 ],
549 BuffKind::Amnesia => vec![BuffEffect::DisableAuxiliaryAbilities],
550 BuffKind::OffBalance => vec![BuffEffect::PoiseReduction(-data.strength)],
551 BuffKind::Tenacity => vec![
552 BuffEffect::DamageReduction(nn_scaling(data.strength) / 2.0),
553 BuffEffect::MovementSpeed(0.7),
554 BuffEffect::DamagedEffect(DamagedEffect::Energy(data.strength * 10.0)),
555 ],
556 BuffKind::Resilience => vec![BuffEffect::CrowdControlResistance(data.strength)],
557 }
558 }
559
560 fn extend_cat_ids(&self, mut cat_ids: Vec<BuffCategory>) -> Vec<BuffCategory> {
561 match self {
562 BuffKind::ImminentCritical => {
563 cat_ids.push(BuffCategory::RemoveOnAttack);
564 },
565 BuffKind::PotionSickness => {
566 cat_ids.push(BuffCategory::PersistOnDowned);
567 },
568 _ => {},
569 }
570 cat_ids
571 }
572
573 fn modify_data(
574 &self,
575 mut data: BuffData,
576 source_mass: Option<&Mass>,
577 dest_info: DestInfo,
578 source: BuffSource,
579 ) -> BuffData {
580 // TODO: Remove clippy allow after another buff needs this
581 #[expect(clippy::single_match)]
582 match self {
583 BuffKind::Rooted => {
584 let source_mass = source_mass.map_or(50.0, |m| m.0 as f64);
585 let dest_mass = dest_info.mass.map_or(50.0, |m| m.0 as f64);
586 let ratio = (source_mass / dest_mass).min(1.0);
587 data.duration = data.duration.map(|dur| Secs(dur.0 * ratio));
588 },
589 _ => {},
590 }
591 if self.resilience_ccr_strength(data).is_some() {
592 let dur_mult = dest_info
593 .stats
594 .map_or(1.0, |s| (1.0 - s.crowd_control_resistance).max(0.0));
595 data.duration = data.duration.map(|dur| dur * dur_mult as f64);
596 }
597 self.apply_item_effect_reduction(&mut data, source, dest_info);
598 data
599 }
600
601 /// If a buff kind should also give resilience when applied, return the
602 /// strength that resilience should have, otherwise return None
603 pub fn resilience_ccr_strength(&self, data: BuffData) -> Option<f32> {
604 match_some!(self,
605 BuffKind::Amnesia => 0.3,
606 BuffKind::Frozen => data.strength,
607 )
608 }
609
610 pub fn apply_item_effect_reduction(
611 &self,
612 data: &mut BuffData,
613 source: BuffSource,
614 dest_info: DestInfo,
615 ) {
616 if !matches!(source, BuffSource::Item) {
617 return;
618 }
619 let item_effect_reduction = dest_info.stats.map_or(1.0, |s| s.item_effect_reduction);
620 match self {
621 BuffKind::Potion | BuffKind::Agility => {
622 data.strength *= item_effect_reduction;
623 },
624 BuffKind::Burning | BuffKind::Frozen | BuffKind::Resilience => {
625 data.duration = data.duration.map(|dur| dur * item_effect_reduction as f64);
626 },
627 _ => {},
628 };
629 }
630}
631
632// Struct used to store data relevant to a buff
633#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
634#[serde(deny_unknown_fields, default)]
635pub struct BuffData {
636 pub strength: f32,
637 #[serde(default)]
638 pub duration: Option<Secs>,
639 #[serde(default)]
640 pub delay: Option<Secs>,
641 /// Used for buffs that have rider buffs (e.g. Flame, Frigid)
642 #[serde(default)]
643 pub secondary_duration: Option<Secs>,
644 /// Used to add random data to buffs if needed (e.g. polymorphed)
645 #[serde(default)]
646 pub misc_data: Option<MiscBuffData>,
647}
648
649impl Default for BuffData {
650 fn default() -> Self { Self::new(0.0, Some(Secs(0.0))) }
651}
652
653#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
654pub enum MiscBuffData {
655 Body(Body),
656}
657
658impl BuffData {
659 pub fn new(strength: f32, duration: Option<Secs>) -> Self {
660 Self {
661 strength,
662 duration,
663 delay: None,
664 secondary_duration: None,
665 misc_data: None,
666 }
667 }
668
669 pub fn with_delay(mut self, delay: Secs) -> Self {
670 self.delay = Some(delay);
671 self
672 }
673
674 pub fn with_secondary_duration(mut self, sec_dur: Secs) -> Self {
675 self.secondary_duration = Some(sec_dur);
676 self
677 }
678
679 pub fn with_misc_data(mut self, misc_data: MiscBuffData) -> Self {
680 self.misc_data = Some(misc_data);
681 self
682 }
683}
684
685/// De/buff category ID.
686/// Similar to `BuffKind`, but to mark a category (for more generic usage, like
687/// positive/negative buffs).
688#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
689pub enum BuffCategory {
690 Natural,
691 Physical,
692 Magical,
693 Divine,
694 PersistOnDowned,
695 PersistOnDeath,
696 FromActiveAura(Uid, AuraKey),
697 FromLink(DynWeakLinkHandle),
698 RemoveOnAttack,
699 RemoveOnLoadoutChange,
700 SelfBuff,
701}
702
703#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
704pub enum ModifierKind {
705 Additive,
706 Multiplicative,
707}
708
709/// Data indicating and configuring behaviour of a de/buff.
710#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
711pub enum BuffEffect {
712 /// Periodically damages or heals entity
713 HealthChangeOverTime {
714 rate: f32,
715 kind: ModifierKind,
716 instance: u64,
717 tick_dur: Secs,
718 },
719 /// Periodically consume entity energy
720 EnergyChangeOverTime {
721 rate: f32,
722 kind: ModifierKind,
723 tick_dur: Secs,
724 reset_rate_on_tick: bool,
725 },
726 /// Periodically change entity combo
727 ComboChangeOverTime {
728 rate: f32,
729 tick_dur: Secs,
730 },
731 /// Changes maximum health by a certain amount
732 MaxHealthModifier {
733 value: f32,
734 kind: ModifierKind,
735 },
736 /// Changes maximum energy by a certain amount
737 MaxEnergyModifier {
738 value: f32,
739 kind: ModifierKind,
740 },
741 /// Reduces damage after armor is accounted for by this fraction
742 DamageReduction(f32),
743 /// Gradually changes an entities max health over time
744 MaxHealthChangeOverTime {
745 rate: f32,
746 kind: ModifierKind,
747 target_fraction: f32,
748 },
749 /// Modifies move speed of target
750 MovementSpeed(f32),
751 /// Modifies attack speed of target
752 AttackSpeed(f32),
753 /// Modifies recovery speed of target
754 RecoverySpeed(f32),
755 /// Modifies ground friction of target
756 GroundFriction(f32),
757 /// Reduces poise damage taken after armor is accounted for by this fraction
758 PoiseReduction(f32),
759 /// Increases poise damage dealt when health is lost
760 PoiseDamageFromLostHealth(f32),
761 /// Modifier to the amount of damage dealt with attacks
762 AttackDamage(f32),
763 /// Overrides the precision multiplier applied to an attack
764 PrecisionOverride(f32),
765 /// Overrides the precision multiplier applied to an incoming attack
766 PrecisionVulnerabilityOverride(f32),
767 /// Changes body.
768 BodyChange(Body),
769 BuffImmunity(BuffKind),
770 SwimSpeed(f32),
771 /// Add an attack effect to attacks made while buff is active
772 AttackEffect(AttackEffect),
773 /// Increases poise damage dealt by attacks
774 AttackPoise(f32),
775 /// Ignores some damage reduction on target
776 MitigationsPenetration(f32),
777 /// Modifies energy rewarded on successful strikes
778 EnergyReward(f32),
779 /// Add an effect to the entity when damaged by an attack
780 DamagedEffect(DamagedEffect),
781 /// Add an effect to the entity when killed
782 DeathEffect(DeathEffect),
783 /// Prevents use of auxiliary abilities
784 DisableAuxiliaryAbilities,
785 /// Reduces duration of crowd control debuffs
786 CrowdControlResistance(f32),
787 /// Reduces the strength or duration of item buff
788 ItemEffectReduction(f32),
789}
790
791/// Actual de/buff.
792/// Buff can timeout after some time if `time` is Some. If `time` is None,
793/// Buff will last indefinitely, until removed manually (by some action, like
794/// uncursing).
795///
796/// Buff has a kind, which is used to determine the effects in a builder
797/// function.
798///
799/// To provide more classification info when needed,
800/// buff can be in one or more buff category.
801#[derive(Clone, Debug, Serialize, Deserialize)]
802pub struct Buff {
803 pub kind: BuffKind,
804 pub data: BuffData,
805 pub cat_ids: Vec<BuffCategory>,
806 pub end_time: Option<Time>,
807 pub start_time: Time,
808 pub effects: Vec<BuffEffect>,
809 pub source: BuffSource,
810}
811
812/// Information about whether buff addition or removal was requested.
813/// This to implement "on_add" and "on_remove" hooks for constant buffs.
814#[derive(Clone, Debug)]
815pub enum BuffChange {
816 /// Adds this buff.
817 Add(Buff),
818 /// Removes all buffs with this ID.
819 RemoveByKind(BuffKind),
820 /// Removes all buffs with this ID, but not debuffs.
821 RemoveFromController(BuffKind),
822 /// Removes buffs of these indices, should only be called when buffs expire
823 RemoveByKey(Vec<BuffKey>),
824 /// Removes buffs of these categories (first vec is of categories of which
825 /// all are required, second vec is of categories of which at least one is
826 /// required, third vec is of categories that will not be removed)
827 RemoveByCategory {
828 all_required: Vec<BuffCategory>,
829 any_required: Vec<BuffCategory>,
830 none_required: Vec<BuffCategory>,
831 },
832 /// Refreshes durations of all buffs with this kind.
833 Refresh(BuffKind),
834}
835
836impl Buff {
837 /// Builder function for buffs
838 pub fn new(
839 kind: BuffKind,
840 data: BuffData,
841 cat_ids: Vec<BuffCategory>,
842 source: BuffSource,
843 time: Time,
844 dest_info: DestInfo,
845 // Create source_info if we need more parameters from source
846 source_mass: Option<&Mass>,
847 ) -> Self {
848 let data = kind.modify_data(data, source_mass, dest_info, source);
849 let effects = kind.effects(&data);
850 let cat_ids = kind.extend_cat_ids(cat_ids);
851 let start_time = Time(time.0 + data.delay.map_or(0.0, |delay| delay.0));
852 let end_time = if cat_ids.iter().any(|cat_id| {
853 matches!(
854 cat_id,
855 BuffCategory::FromActiveAura(..) | BuffCategory::FromLink(_)
856 )
857 }) {
858 None
859 } else {
860 data.duration.map(|dur| Time(start_time.0 + dur.0))
861 };
862 Buff {
863 kind,
864 data,
865 cat_ids,
866 start_time,
867 end_time,
868 effects,
869 source,
870 }
871 }
872
873 /// Calculate how much time has elapsed since the buff was applied
874 pub fn elapsed(&self, time: Time) -> Secs { Secs(time.0 - self.start_time.0) }
875}
876
877impl PartialOrd for Buff {
878 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
879 if self == other {
880 Some(Ordering::Equal)
881 } else if self.data.strength > other.data.strength {
882 Some(Ordering::Greater)
883 } else if self.data.strength < other.data.strength {
884 Some(Ordering::Less)
885 } else if self.data.delay.is_none() && other.data.delay.is_some() {
886 Some(Ordering::Greater)
887 } else if self.data.delay.is_some() && other.data.delay.is_none() {
888 Some(Ordering::Less)
889 } else if compare_end_time(self.end_time, other.end_time) {
890 Some(Ordering::Greater)
891 } else if compare_end_time(other.end_time, self.end_time) {
892 Some(Ordering::Less)
893 } else {
894 None
895 }
896 }
897}
898
899fn compare_end_time(a: Option<Time>, b: Option<Time>) -> bool {
900 a.is_none_or(|time_a| b.is_some_and(|time_b| time_a.0 > time_b.0))
901}
902
903impl PartialEq for Buff {
904 fn eq(&self, other: &Self) -> bool {
905 self.data.strength == other.data.strength
906 && self.end_time == other.end_time
907 && self.start_time == other.start_time
908 }
909}
910
911/// Source of the de/buff
912#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
913pub enum BuffSource {
914 /// Applied by a character
915 Character { by: Uid },
916 /// Applied by world, like a poisonous fumes from a swamp
917 World,
918 /// Applied by command
919 Command,
920 /// Applied by an item
921 Item,
922 /// Applied by another buff (like an after-effect)
923 Buff,
924 /// Applied by a block
925 Block,
926 /// Some other source
927 Unknown,
928}
929
930/// Component holding all de/buffs that gets resolved each tick.
931/// On each tick, remaining time of buffs get lowered and
932/// buff effect of each buff is applied or not, depending on the `BuffEffect`
933/// (specs system will decide based on `BuffEffect`, to simplify
934/// implementation). TODO: Something like `once` flag for `Buff` to remove the
935/// dependence on `BuffEffect` enum?
936///
937/// In case of one-time buffs, buff effects will be applied on addition
938/// and undone on removal of the buff (by the specs system).
939/// Example could be decreasing max health, which, if repeated each tick,
940/// would be probably an undesired effect).
941#[derive(Clone, Debug, Serialize, Deserialize, Default)]
942pub struct Buffs {
943 /// Maps kinds of buff to currently applied buffs of that kind and
944 /// the time that the first buff was added (time gets reset if entity no
945 /// longer has buffs of that kind)
946 pub kinds: EnumMap<BuffKind, Option<(Vec<BuffKey>, Time)>>,
947 // All buffs currently present on an entity
948 pub buffs: SlotMap<BuffKey, Buff>,
949}
950
951impl Buffs {
952 fn sort_kind(&mut self, kind: BuffKind) {
953 if let Some(buff_order) = self.kinds[kind].as_mut() {
954 if buff_order.0.is_empty() {
955 self.kinds[kind] = None;
956 } else {
957 let buffs = &self.buffs;
958 // Intentionally sorted in reverse so that the strongest buffs are earlier in
959 // the vector
960 buff_order
961 .0
962 .sort_by(|a, b| buffs[*b].partial_cmp(&buffs[*a]).unwrap_or(Ordering::Equal));
963 }
964 }
965 }
966
967 pub fn remove_kind(&mut self, kind: BuffKind) {
968 if let Some((buff_keys, _)) = self.kinds[kind].as_ref() {
969 for key in buff_keys {
970 self.buffs.remove(*key);
971 }
972 self.kinds[kind] = None;
973 }
974 }
975
976 pub fn insert(&mut self, buff: Buff, current_time: Time) -> BuffKey {
977 let kind = buff.kind;
978 // Try to find another overlaping non-queueable buff with same data, cat_ids and
979 // source.
980 let other_key = if kind.queues() {
981 None
982 } else {
983 self.kinds[kind].as_ref().and_then(|(keys, _)| {
984 keys.iter()
985 .find(|key| {
986 self.buffs.get(**key).is_some_and(|other_buff| {
987 other_buff.data == buff.data
988 && other_buff.cat_ids == buff.cat_ids
989 && other_buff.source == buff.source
990 && other_buff
991 .end_time
992 .is_none_or(|end_time| end_time.0 >= buff.start_time.0)
993 })
994 })
995 .copied()
996 })
997 };
998
999 // If another buff with the same fields is found, update end_time and effects
1000 let key = if !kind.stacks()
1001 && let Some((other_buff, key)) =
1002 other_key.and_then(|key| Some((self.buffs.get_mut(key)?, key)))
1003 {
1004 other_buff.end_time = buff.end_time;
1005 other_buff.effects = buff.effects;
1006 key
1007 // Otherwise, insert a new buff
1008 } else {
1009 let key = self.buffs.insert(buff);
1010 self.kinds[kind]
1011 .get_or_insert_with(|| (Vec::new(), current_time))
1012 .0
1013 .push(key);
1014 key
1015 };
1016
1017 self.sort_kind(kind);
1018 if kind.queues() {
1019 self.delay_queueable_buffs(kind, current_time);
1020 }
1021 key
1022 }
1023
1024 pub fn contains(&self, kind: BuffKind) -> bool { self.kinds[kind].is_some() }
1025
1026 pub fn contains_any(&self, kinds: &[BuffKind]) -> bool {
1027 kinds.iter().any(|kind| self.contains(*kind))
1028 }
1029
1030 // Iterate through buffs of a given kind in effect order (most powerful first)
1031 pub fn iter_kind(&self, kind: BuffKind) -> impl Iterator<Item = (BuffKey, &Buff)> + '_ {
1032 self.kinds[kind]
1033 .as_ref()
1034 .map(|keys| keys.0.iter())
1035 .unwrap_or_else(|| [].iter())
1036 .map(move |&key| (key, &self.buffs[key]))
1037 }
1038
1039 // Iterates through all active buffs (the most powerful buff of each
1040 // non-stacking kind, and all of the stacking ones)
1041 pub fn iter_active(&self) -> impl Iterator<Item = impl Iterator<Item = &Buff>> + '_ {
1042 self.kinds
1043 .iter()
1044 .filter_map(|(kind, keys)| keys.as_ref().map(|keys| (kind, keys)))
1045 .map(move |(kind, keys)| {
1046 if kind.stacks() {
1047 // Iterate stackable buffs in reverse order to show the timer of the soonest one
1048 // to expire
1049 Either::Left(keys.0.iter().filter_map(|key| self.buffs.get(*key)).rev())
1050 } else {
1051 Either::Right(self.buffs.get(keys.0[0]).into_iter())
1052 }
1053 })
1054 }
1055
1056 // Gets most powerful buff of a given kind
1057 pub fn remove(&mut self, buff_key: BuffKey) {
1058 if let Some(buff) = self.buffs.remove(buff_key) {
1059 let kind = buff.kind;
1060 self.kinds[kind]
1061 .as_mut()
1062 .map(|keys| keys.0.retain(|key| *key != buff_key));
1063 self.sort_kind(kind);
1064 }
1065 }
1066
1067 fn delay_queueable_buffs(&mut self, kind: BuffKind, current_time: Time) {
1068 let mut next_start_time: Option<Time> = None;
1069 debug_assert!(kind.queues());
1070 if let Some(buffs) = self.kinds[kind].as_mut() {
1071 buffs.0.iter().for_each(|key| {
1072 if let Some(buff) = self.buffs.get_mut(*key) {
1073 // End time only being updated when there is some next_start_time will
1074 // technically cause buffs to "end early" if they have a weaker strength than a
1075 // buff with an infinite duration, but this is fine since those buffs wouldn't
1076 // matter anyways
1077 if let Some(next_start_time) = next_start_time {
1078 // Delays buff so that it has the same progress it has now at the time the
1079 // previous buff would end.
1080 //
1081 // Shift should be relative to current time, unless the buff is delayed and
1082 // hasn't started yet
1083 let reference_time = current_time.0.max(buff.start_time.0);
1084 // If buff has a delay, ensure that queueables shuffling queue does not
1085 // potentially allow skipping delay
1086 buff.start_time = Time(next_start_time.0.max(buff.start_time.0));
1087 buff.end_time = buff.end_time.map(|end| {
1088 Time(end.0 + next_start_time.0.max(reference_time) - reference_time)
1089 });
1090 }
1091 next_start_time = buff.end_time;
1092 }
1093 })
1094 }
1095 }
1096}
1097
1098impl Component for Buffs {
1099 type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
1100}
1101
1102#[derive(Default, Copy, Clone)]
1103pub struct DestInfo<'a> {
1104 pub stats: Option<&'a Stats>,
1105 pub mass: Option<&'a Mass>,
1106}
1107
1108#[cfg(test)]
1109pub mod tests {
1110 use crate::comp::buff::*;
1111
1112 #[cfg(test)]
1113 fn create_test_queueable_buff(buff_data: BuffData, time: Time) -> Buff {
1114 // Change to another buff that queues if we ever add one and remove saturation,
1115 // otherwise maybe add a test buff kind?
1116 debug_assert!(BuffKind::Saturation.queues());
1117 Buff::new(
1118 BuffKind::Saturation,
1119 buff_data,
1120 Vec::new(),
1121 BuffSource::Unknown,
1122 time,
1123 DestInfo::default(),
1124 None,
1125 )
1126 }
1127
1128 #[test]
1129 /// Tests a number of buffs with various progresses that queue to ensure
1130 /// queue has correct total duration
1131 fn test_queueable_buffs_three() {
1132 let mut buff_comp: Buffs = Default::default();
1133 let buff_data = BuffData::new(1.0, Some(Secs(10.0)));
1134 let time_a = Time(0.0);
1135 buff_comp.insert(create_test_queueable_buff(buff_data, time_a), time_a);
1136 let time_b = Time(6.0);
1137 buff_comp.insert(create_test_queueable_buff(buff_data, time_b), time_b);
1138 let time_c = Time(11.0);
1139 buff_comp.insert(create_test_queueable_buff(buff_data, time_c), time_c);
1140 // Check that all buffs have an end_time less than or equal to 30, and that at
1141 // least one has an end_time greater than or equal to 30.
1142 //
1143 // This should be true because 3 buffs that each lasted for 10 seconds were
1144 // inserted at various times, so the total duration should be 30 seconds.
1145 assert!(
1146 buff_comp
1147 .buffs
1148 .values()
1149 .all(|b| b.end_time.unwrap().0 < 30.01)
1150 );
1151 assert!(
1152 buff_comp
1153 .buffs
1154 .values()
1155 .any(|b| b.end_time.unwrap().0 > 29.99)
1156 );
1157 }
1158
1159 #[test]
1160 /// Tests that if a buff had a delay but will start soon, and an immediate
1161 /// queueable buff is added, delayed buff has correct start time
1162 fn test_queueable_buff_delay_start() {
1163 let mut buff_comp: Buffs = Default::default();
1164 let queued_buff_data = BuffData::new(1.0, Some(Secs(10.0))).with_delay(Secs(10.0));
1165 let buff_data = BuffData::new(1.0, Some(Secs(10.0)));
1166 let time_a = Time(0.0);
1167 buff_comp.insert(create_test_queueable_buff(queued_buff_data, time_a), time_a);
1168 let time_b = Time(6.0);
1169 buff_comp.insert(create_test_queueable_buff(buff_data, time_b), time_b);
1170 // Check that all buffs have an end_time less than or equal to 26, and that at
1171 // least one has an end_time greater than or equal to 26.
1172 //
1173 // This should be true because the first buff added had a delay of 10 seconds
1174 // and a duration of 10 seconds, the second buff added at 6 seconds had no
1175 // delay, and a duration of 10 seconds. When it finishes at 16 seconds the first
1176 // buff is past the delay time so should finish at 26 seconds.
1177 assert!(
1178 buff_comp
1179 .buffs
1180 .values()
1181 .all(|b| b.end_time.unwrap().0 < 26.01)
1182 );
1183 assert!(
1184 buff_comp
1185 .buffs
1186 .values()
1187 .any(|b| b.end_time.unwrap().0 > 25.99)
1188 );
1189 }
1190
1191 #[test]
1192 /// Tests that if a buff had a long delay, a short immediate queueable buff
1193 /// does not move delayed buff start or end times
1194 fn test_queueable_buff_long_delay() {
1195 let mut buff_comp: Buffs = Default::default();
1196 let queued_buff_data = BuffData::new(1.0, Some(Secs(10.0))).with_delay(Secs(50.0));
1197 let buff_data = BuffData::new(1.0, Some(Secs(10.0)));
1198 let time_a = Time(0.0);
1199 buff_comp.insert(create_test_queueable_buff(queued_buff_data, time_a), time_a);
1200 let time_b = Time(10.0);
1201 buff_comp.insert(create_test_queueable_buff(buff_data, time_b), time_b);
1202 // Check that all buffs have either an end time less than or equal to 20 seconds
1203 // XOR a start time greater than or equal to 50 seconds, that all buffs have a
1204 // start time less than or equal to 50 seconds, that all buffs have an end time
1205 // less than or equal to 60 seconds, and that at least one buff has an end time
1206 // greater than or equal to 60 seconds
1207 //
1208 // This should be true because the first buff has a delay of 50 seconds, the
1209 // second buff added has no delay at 10 seconds and lasts 10 seconds, so should
1210 // end at 20 seconds and not affect the start time of the delayed buff, and
1211 // since the delayed buff was not affected the end time should be 10 seconds
1212 // after the start time: 60 seconds != used here to emulate xor
1213 assert!(
1214 buff_comp
1215 .buffs
1216 .values()
1217 .all(|b| (b.end_time.unwrap().0 < 20.01) != (b.start_time.0 > 49.99))
1218 );
1219 assert!(buff_comp.buffs.values().all(|b| b.start_time.0 < 50.01));
1220 assert!(
1221 buff_comp
1222 .buffs
1223 .values()
1224 .all(|b| b.end_time.unwrap().0 < 60.01)
1225 );
1226 assert!(
1227 buff_comp
1228 .buffs
1229 .values()
1230 .any(|b| b.end_time.unwrap().0 > 59.99)
1231 );
1232 }
1233}