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 resources::{Secs, Time},
9 uid::Uid,
10};
11
12use core::cmp::Ordering;
13use enum_map::{Enum, EnumMap};
14use itertools::Either;
15use serde::{Deserialize, Serialize};
16use slotmap::{SlotMap, new_key_type};
17use specs::{Component, DerefFlaggedStorage, VecStorage};
18use strum::EnumIter;
19
20use super::Body;
21
22new_key_type! { pub struct BuffKey; }
23
24/// De/buff Kind.
25/// This is used to determine what effects a buff will have
26#[derive(
27 Clone, Copy, PartialEq, Eq, Hash, Debug, Serialize, Deserialize, PartialOrd, Ord, EnumIter, Enum,
28)]
29pub enum BuffKind {
30 // =================
31 // BUFFS
32 // =================
33 /// Restores health/time for some period.
34 /// Strength should be the healing per second.
35 Regeneration,
36 /// Restores health/time for some period for consumables.
37 /// Strength should be the healing per second.
38 Saturation,
39 /// Applied when drinking a potion.
40 /// Strength should be the healing per second.
41 Potion,
42 /// Increases movement speed and vulnerability to damage as well as
43 /// decreases the amount of damage dealt.
44 /// Movement speed increases linearly with strength 1.0 is an 100% increase
45 /// Damage vulnerability and damage reduction are both hard set to 100%
46 Agility,
47 /// Applied when resting (sitting at campfire or sleeping).
48 /// Strength is fraction of health restored per second.
49 RestingHeal,
50 /// Restores energy/time for some period.
51 /// Strength should be the energy regenerated per second.
52 EnergyRegen,
53 /// Generates combo over time for some period.
54 /// Strength should be the combo generated per second.
55 ComboGeneration,
56 /// Raises maximum energy.
57 /// Strength should be 10x the effect to max energy.
58 IncreaseMaxEnergy,
59 /// Raises maximum health.
60 /// Strength should be the effect to max health.
61 IncreaseMaxHealth,
62 /// Makes you immune to attacks.
63 /// Strength does not affect this buff.
64 Invulnerability,
65 /// Reduces incoming damage.
66 /// Strength scales the damage reduction non-linearly. 0.5 provides 50% DR,
67 /// 1.0 provides 67% DR.
68 ProtectingWard,
69 /// Increases movement speed and gives health regeneration.
70 /// Strength scales the movement speed linearly. 0.5 is 150% speed, 1.0 is
71 /// 200% speed. Provides regeneration at 10x the value of the strength.
72 Frenzied,
73 /// Increases movement and attack speed Strength scales strength of both
74 /// effects linearly. 0.5 is a 50% increase, 1.0 is a 100% increase.
75 Hastened,
76 /// Increases resistance to incoming poise, and poise damage dealt as health
77 /// is lost.
78 /// Strength scales the resistance non-linearly. 0.5 provides 50%, 1.0
79 /// provides 67%.
80 /// Strength scales the poise damage increase linearly, a strength of 1.0
81 /// and n health less from maximum health will cause poise damage to
82 /// increase by n%.
83 Fortitude,
84 /// Increases both attack damage and vulnerability to damage.
85 /// Damage increases linearly with strength, 1.0 is a 100% increase.
86 /// Damage reduction decreases linearly with strength, 1.0 is a 100%
87 /// decrease.
88 Reckless,
89 /// Provides immunity to burning and increases movement speed in lava.
90 /// Movement speed increases linearly with strength, 1.0 is a 100% increase.
91 // SalamanderAspect, TODO: Readd in second dwarven mine MR
92 /// Your attacks cause targets to receive the burning debuff
93 /// Strength of burning debuff is a fraction of the damage, fraction
94 /// increases linearly with strength
95 Flame,
96 /// Your attacks cause targets to receive the frozen debuff
97 /// Strength of frozen debuff is equal to the strength of this buff
98 Frigid,
99 /// Your attacks have lifesteal
100 /// Strength increases the fraction of damage restored as life
101 Lifesteal,
102 /// Your attacks against bleeding targets have lifesteal
103 /// Strength increases the fraction of damage restored as life
104 Bloodfeast,
105 /// Guarantees that the next attack is a precise hit. Does this kind of
106 /// hackily by adding 100% to the precision, will need to be adjusted if we
107 /// ever allow double precision hits instead of treating 100 as a
108 /// ceiling.
109 ImminentCritical,
110 /// Increases combo gain, every 1 strength increases combo per strike by 1,
111 /// rounds to nearest integer
112 Fury,
113 /// Allows attacks to ignore DR and increases energy reward
114 /// DR penetration is non-linear, 0.5 is 50% penetration and 1.0 is a 67%
115 /// penetration. Energy reward is increased linearly to strength, 1.0 is a
116 /// 150 % increase.
117 Sunderer,
118 /// Generates combo when damaged and decreases movement speed.
119 /// Movement speed is decreased to 50%. Combo generation is linear with
120 /// strength, 1.0 is 5 combo generated on being hit.
121 Defiance,
122 /// Increases both attack damage, vulnerability to damage, attack speed, and
123 /// movement speed Damage increases linearly with strength, 1.0 is a
124 /// 100% increase. Damage reduction decreases linearly with strength,
125 /// 1.0 is a 100% Attack speed increases non-linearly with strength, 0.5
126 /// is a 25% increase, 1.0 is a 33% increase Movement speed increases
127 /// non-linearly with strength, 0.5 is a 12.5% increase, 1.0 is a 16.7%
128 /// increase decrease.
129 Berserk,
130 /// Increases poise resistance and energy reward. However if killed, buffs
131 /// killer with Reckless buff. Poise resistance scales non-linearly with
132 /// strength, 0.5 is 50% and 1.0 is 67%. Energy reward scales linearly with
133 /// strength, 0.5 is +50% and 1.0 is +100% strength. Reckless buff reward
134 /// strength is equal to scornful taunt buff strength.
135 ScornfulTaunt,
136 /// Increases damage resistance, causes energy to be generated when damaged,
137 /// and decreases movement speed. Damage resistance increases non-linearly
138 /// with strength, 0.5 is 25% and 1.0 is 34%. Energy generation is linear
139 /// with strength, 1.0 is 10 energy per hit. Movement speed is decreased to
140 /// 70%.
141 Tenacity,
142 /// Applies to some debuffs that have strong CC effects. Automatically
143 /// gained upon receiving those debuffs, and causes future instances of
144 /// those debuffs to be applied with reduced duration.
145 /// Strength linearly decreases the duration of newly applied, affected
146 /// debuffs, 0.5 is a 50% reduction.
147 Resilience,
148 // =================
149 // DEBUFFS
150 // =================
151 /// Does damage to a creature over time.
152 /// Strength should be the DPS of the debuff.
153 /// Provides immunity against Frozen.
154 Burning,
155 /// Lowers health over time for some duration.
156 /// Strength should be the DPS of the debuff.
157 Bleeding,
158 /// Lower a creature's max health over time.
159 /// Strength only affects the target max health, 0.5 targets 50% of base
160 /// max, 1.0 targets 100% of base max.
161 Cursed,
162 /// Reduces movement speed and causes bleeding damage.
163 /// Strength scales the movement speed debuff non-linearly. 0.5 is 50%
164 /// speed, 1.0 is 33% speed. Bleeding is at 4x the value of the strength.
165 Crippled,
166 /// Slows movement and attack speed.
167 /// Strength scales the attack speed debuff non-linearly. 0.5 is ~50%
168 /// speed, 1.0 is 33% speed. Movement speed debuff is scaled to be slightly
169 /// smaller than attack speed debuff.
170 /// Provides immunity against Heatstroke.
171 Frozen,
172 /// Makes you wet and causes you to have reduced friction on the ground.
173 /// Strength scales the friction you ignore non-linearly. 0.5 is 50% ground
174 /// friction, 1.0 is 33% ground friction.
175 /// Provides immunity against Burning.
176 Wet,
177 /// Makes you move slower.
178 /// Strength scales the movement speed debuff non-linearly. 0.5 is 50%
179 /// speed, 1.0 is 33% speed.
180 Ensnared,
181 /// Drain stamina to a creature over time.
182 /// Strength should be the energy per second of the debuff.
183 Poisoned,
184 /// Results from having an attack parried.
185 /// Causes your attack speed to be slower to emulate the recover duration of
186 /// an ability being lengthened.
187 Parried,
188 /// Results from drinking a potion.
189 /// Decreases the health gained from subsequent potions.
190 PotionSickness,
191 /// Slows movement speed and reduces energy reward.
192 /// Both scales non-linearly to strength, 0.5 lead to movespeed reduction
193 /// by 25% and energy reward reduced by 150%, 1.0 lead to MS reduction by
194 /// 33.3% and energy reward reduced by 200%. Energy reward can't be
195 /// reduced by more than 200%, to a minimum value of -100%.
196 Heatstroke,
197 /// Reduces movement speed to 0.
198 /// Strength increases the relative mass of the creature that can be
199 /// targeted. A strength of 1.0 means that a creature of the same mass gets
200 /// rooted for the full duration. A strength of 2.0 means a creature of
201 /// twice the mass gets rooted for the full duration. If the target's mass
202 /// is higher than the strength allows for, duration gets reduced using a
203 /// mutiplier from the ratio of masses.
204 Rooted,
205 /// Slows movement speed and reduces energy reward
206 /// Both scale non-linearly with strength, 0.5 leads to 50% reduction of
207 /// energy reward and 33% reduction of move speed. 1.0 leads to 67%
208 /// reduction of energy reward and 50% reduction of move speed.
209 Winded,
210 /// Prevents use of auxiliary abilities.
211 /// Does not scale with strength
212 Amnesia,
213 /// Increases amount of poise damage received
214 /// Scales linearly with strength, 1.0 leads to 100% more poise damage
215 /// received
216 OffBalance,
217 // =================
218 // COMPLEX
219 // =================
220 /// Changed into another body.
221 Polymorphed,
222}
223
224/// Tells a little more about the buff kind than simple buff/debuff
225#[derive(Clone, Copy, Debug, PartialEq, Eq)]
226pub enum BuffDescriptor {
227 /// Simple positive buffs, like `BuffKind::Saturation`
228 SimplePositive,
229 /// Simple negative buffs, like `BuffKind::Bleeding`
230 SimpleNegative,
231 /// Buffs that require unusual data that can't be governed just by strength
232 /// and duration, like `BuffKind::Polymorhped`
233 Complex,
234 // For future additions, we may want to tell about non-obvious buffs,
235 // like Agility.
236 // Also maybe extend Complex to differentiate between Positive, Negative
237 // and Neutral buffs?
238 // For now, Complex is assumed to be neutral/non-obvious.
239}
240
241impl BuffKind {
242 /// Tells a little more about buff kind than simple buff/debuff
243 ///
244 /// Read more in [BuffDescriptor].
245 pub fn differentiate(self) -> BuffDescriptor {
246 match self {
247 BuffKind::Regeneration
248 | BuffKind::Saturation
249 | BuffKind::Potion
250 | BuffKind::Agility
251 | BuffKind::RestingHeal
252 | BuffKind::Frenzied
253 | BuffKind::EnergyRegen
254 | BuffKind::ComboGeneration
255 | BuffKind::IncreaseMaxEnergy
256 | BuffKind::IncreaseMaxHealth
257 | BuffKind::Invulnerability
258 | BuffKind::ProtectingWard
259 | BuffKind::Hastened
260 | BuffKind::Fortitude
261 | BuffKind::Reckless
262 | BuffKind::Flame
263 | BuffKind::Frigid
264 | BuffKind::Lifesteal
265 //| BuffKind::SalamanderAspect
266 | BuffKind::ImminentCritical
267 | BuffKind::Fury
268 | BuffKind::Sunderer
269 | BuffKind::Defiance
270 | BuffKind::Bloodfeast
271 | BuffKind::Berserk
272 | BuffKind::ScornfulTaunt
273 | BuffKind::Tenacity
274 | BuffKind::Resilience => BuffDescriptor::SimplePositive,
275 BuffKind::Bleeding
276 | BuffKind::Cursed
277 | BuffKind::Burning
278 | BuffKind::Crippled
279 | BuffKind::Frozen
280 | BuffKind::Wet
281 | BuffKind::Ensnared
282 | BuffKind::Poisoned
283 | BuffKind::Parried
284 | BuffKind::PotionSickness
285 | BuffKind::Heatstroke
286 | BuffKind::Rooted
287 | BuffKind::Winded
288 | BuffKind::Amnesia
289 | BuffKind::OffBalance => BuffDescriptor::SimpleNegative,
290 BuffKind::Polymorphed => BuffDescriptor::Complex,
291 }
292 }
293
294 /// Checks if buff is buff or debuff.
295 pub fn is_buff(self) -> bool {
296 match self.differentiate() {
297 BuffDescriptor::SimplePositive => true,
298 BuffDescriptor::SimpleNegative | BuffDescriptor::Complex => false,
299 }
300 }
301
302 pub fn is_simple(self) -> bool {
303 match self.differentiate() {
304 BuffDescriptor::SimplePositive | BuffDescriptor::SimpleNegative => true,
305 BuffDescriptor::Complex => false,
306 }
307 }
308
309 /// Checks if buff should queue.
310 pub fn queues(self) -> bool { matches!(self, BuffKind::Saturation) }
311
312 /// Checks if the buff can affect other buff effects applied in the same
313 /// tick.
314 pub fn affects_subsequent_buffs(self) -> bool {
315 matches!(
316 self,
317 BuffKind::PotionSickness /* | BuffKind::SalamanderAspect */
318 )
319 }
320
321 /// Checks if multiple instances of the buff should be processed, instead of
322 /// only the strongest.
323 pub fn stacks(self) -> bool { matches!(self, BuffKind::PotionSickness | BuffKind::Resilience) }
324
325 pub fn effects(&self, data: &BuffData) -> Vec<BuffEffect> {
326 // Normalized nonlinear scaling
327 // TODO: Do we want to make denominator term parameterized. Come back to if we
328 // add nn_scaling3.
329 let nn_scaling = |a: f32| a.abs() / (a.abs() + 0.5) * a.signum();
330 let nn_scaling2 = |a: f32| a.abs() / (a.abs() + 1.0) * a.signum();
331 let instance = rand::random();
332 match self {
333 BuffKind::Bleeding => vec![BuffEffect::HealthChangeOverTime {
334 rate: -data.strength,
335 kind: ModifierKind::Additive,
336 instance,
337 tick_dur: Secs(0.5),
338 }],
339 BuffKind::Regeneration => vec![BuffEffect::HealthChangeOverTime {
340 rate: data.strength,
341 kind: ModifierKind::Additive,
342 instance,
343 tick_dur: Secs(1.0),
344 }],
345 BuffKind::Saturation => vec![BuffEffect::HealthChangeOverTime {
346 rate: data.strength,
347 kind: ModifierKind::Additive,
348 instance,
349 tick_dur: Secs(3.0),
350 }],
351 BuffKind::Potion => {
352 vec![BuffEffect::HealthChangeOverTime {
353 rate: data.strength,
354 kind: ModifierKind::Additive,
355 instance,
356 tick_dur: Secs(0.1),
357 }]
358 },
359 BuffKind::Agility => vec![
360 BuffEffect::MovementSpeed(1.0 + data.strength),
361 BuffEffect::DamageReduction(-1.0),
362 BuffEffect::AttackDamage(0.0),
363 ],
364 BuffKind::RestingHeal => vec![BuffEffect::HealthChangeOverTime {
365 rate: data.strength,
366 kind: ModifierKind::Multiplicative,
367 instance,
368 tick_dur: Secs(2.0),
369 }],
370 BuffKind::Cursed => vec![
371 BuffEffect::MaxHealthChangeOverTime {
372 rate: -1.0,
373 kind: ModifierKind::Additive,
374 target_fraction: 1.0 - data.strength,
375 },
376 BuffEffect::HealthChangeOverTime {
377 rate: -1.0,
378 kind: ModifierKind::Additive,
379 instance,
380 tick_dur: Secs(0.5),
381 },
382 ],
383 BuffKind::EnergyRegen => vec![BuffEffect::EnergyChangeOverTime {
384 rate: data.strength,
385 kind: ModifierKind::Additive,
386 tick_dur: Secs(0.25),
387 reset_rate_on_tick: false,
388 }],
389 BuffKind::ComboGeneration => {
390 let target_tick_dur = 0.25;
391 // Combo per tick must be an integer
392 let nearest_valid_tick_dur =
393 (data.strength as f64 * target_tick_dur).round() / data.strength as f64;
394
395 vec![BuffEffect::ComboChangeOverTime {
396 rate: data.strength,
397 tick_dur: Secs(nearest_valid_tick_dur),
398 }]
399 },
400 BuffKind::IncreaseMaxEnergy => vec![BuffEffect::MaxEnergyModifier {
401 value: data.strength,
402 kind: ModifierKind::Additive,
403 }],
404 BuffKind::IncreaseMaxHealth => vec![BuffEffect::MaxHealthModifier {
405 value: data.strength,
406 kind: ModifierKind::Additive,
407 }],
408 BuffKind::Invulnerability => vec![BuffEffect::DamageReduction(1.0)],
409 BuffKind::ProtectingWard => vec![BuffEffect::DamageReduction(
410 // Causes non-linearity in effect strength, but necessary
411 // to allow for tool power and other things to affect the
412 // strength. 0.5 also still provides 50% damage reduction.
413 nn_scaling(data.strength),
414 )],
415 BuffKind::Burning => vec![
416 BuffEffect::HealthChangeOverTime {
417 rate: -data.strength,
418 kind: ModifierKind::Additive,
419 instance,
420 tick_dur: Secs(0.25),
421 },
422 BuffEffect::BuffImmunity(BuffKind::Frozen),
423 ],
424 BuffKind::Poisoned => vec![BuffEffect::EnergyChangeOverTime {
425 rate: -data.strength,
426 kind: ModifierKind::Additive,
427 tick_dur: Secs(0.5),
428 reset_rate_on_tick: true,
429 }],
430 BuffKind::Crippled => vec![
431 BuffEffect::MovementSpeed(1.0 - nn_scaling(data.strength)),
432 BuffEffect::HealthChangeOverTime {
433 rate: -data.strength * 4.0,
434 kind: ModifierKind::Additive,
435 instance,
436 tick_dur: Secs(0.5),
437 },
438 ],
439 BuffKind::Frenzied => vec![
440 BuffEffect::MovementSpeed(1.0 + data.strength),
441 BuffEffect::HealthChangeOverTime {
442 rate: data.strength * 10.0,
443 kind: ModifierKind::Additive,
444 instance,
445 tick_dur: Secs(1.0),
446 },
447 ],
448 BuffKind::Frozen => vec![
449 BuffEffect::MovementSpeed(f32::powf(1.0 - nn_scaling(data.strength), 1.1)),
450 BuffEffect::AttackSpeed(1.0 - nn_scaling(data.strength)),
451 BuffEffect::BuffImmunity(BuffKind::Heatstroke),
452 ],
453 BuffKind::Wet => vec![
454 BuffEffect::GroundFriction(1.0 - nn_scaling(data.strength)),
455 BuffEffect::BuffImmunity(BuffKind::Burning),
456 ],
457 BuffKind::Ensnared => vec![BuffEffect::MovementSpeed(1.0 - nn_scaling(data.strength))],
458 BuffKind::Hastened => vec![
459 BuffEffect::MovementSpeed(1.0 + data.strength),
460 BuffEffect::AttackSpeed(1.0 + data.strength),
461 ],
462 BuffKind::Fortitude => vec![
463 BuffEffect::PoiseReduction(nn_scaling(data.strength)),
464 BuffEffect::PoiseDamageFromLostHealth(data.strength),
465 ],
466 BuffKind::Parried => vec![BuffEffect::PrecisionVulnerabilityOverride(0.75)],
467 BuffKind::PotionSickness => vec![BuffEffect::ItemEffectReduction(data.strength)],
468 BuffKind::Reckless => vec![
469 BuffEffect::DamageReduction(-data.strength),
470 BuffEffect::AttackDamage(1.0 + data.strength),
471 ],
472 BuffKind::Polymorphed => {
473 let mut effects = Vec::new();
474 if let Some(MiscBuffData::Body(body)) = data.misc_data {
475 effects.push(BuffEffect::BodyChange(body));
476 }
477 effects
478 },
479 BuffKind::Flame => vec![BuffEffect::AttackEffect(AttackEffect::new(
480 None,
481 CombatEffect::Buff(CombatBuff {
482 kind: BuffKind::Burning,
483 dur_secs: data.secondary_duration.map_or(5.0, |dur| dur.0 as f32),
484 strength: CombatBuffStrength::DamageFraction(data.strength),
485 chance: 1.0,
486 }),
487 ))],
488 BuffKind::Frigid => vec![BuffEffect::AttackEffect(AttackEffect::new(
489 None,
490 CombatEffect::Buff(CombatBuff {
491 kind: BuffKind::Frozen,
492 dur_secs: data.secondary_duration.map_or(5.0, |dur| dur.0 as f32),
493 strength: CombatBuffStrength::Value(data.strength),
494 chance: 1.0,
495 }),
496 ))],
497 BuffKind::Lifesteal => vec![BuffEffect::AttackEffect(AttackEffect::new(
498 None,
499 CombatEffect::Lifesteal(data.strength),
500 ))],
501 /*BuffKind::SalamanderAspect => vec![
502 BuffEffect::BuffImmunity(BuffKind::Burning),
503 BuffEffect::SwimSpeed(1.0 + data.strength),
504 ],*/
505 BuffKind::Bloodfeast => vec![BuffEffect::AttackEffect(
506 AttackEffect::new(None, CombatEffect::Lifesteal(data.strength))
507 .with_requirement(CombatRequirement::TargetHasBuff(BuffKind::Bleeding)),
508 )],
509 BuffKind::ImminentCritical => vec![BuffEffect::PrecisionOverride(1.0)],
510 BuffKind::Fury => vec![BuffEffect::AttackEffect(
511 AttackEffect::new(None, CombatEffect::Combo(data.strength.round() as i32))
512 .with_requirement(CombatRequirement::AnyDamage),
513 )],
514 BuffKind::Sunderer => vec![
515 BuffEffect::MitigationsPenetration(nn_scaling(data.strength)),
516 BuffEffect::EnergyReward(1.0 + 1.5 * data.strength),
517 ],
518 BuffKind::Defiance => vec![
519 BuffEffect::MovementSpeed(0.5),
520 BuffEffect::DamagedEffect(DamagedEffect::Combo(
521 (data.strength * 5.0).round() as i32
522 )),
523 ],
524 BuffKind::Berserk => vec![
525 BuffEffect::DamageReduction(-data.strength),
526 BuffEffect::AttackDamage(1.0 + data.strength),
527 BuffEffect::AttackSpeed(1.0 + nn_scaling(data.strength) / 2.0),
528 BuffEffect::MovementSpeed(1.0 + nn_scaling(data.strength) / 4.0),
529 ],
530 BuffKind::Heatstroke => vec![
531 BuffEffect::MovementSpeed(1.0 - nn_scaling(data.strength) * 0.5),
532 BuffEffect::EnergyReward((1.0 - nn_scaling(data.strength) * 3.0).max(-1.0)),
533 ],
534 BuffKind::ScornfulTaunt => vec![
535 BuffEffect::PoiseReduction(nn_scaling(data.strength)),
536 BuffEffect::EnergyReward(1.0 + data.strength),
537 BuffEffect::DeathEffect(DeathEffect::AttackerBuff {
538 kind: BuffKind::Reckless,
539 strength: data.strength,
540 duration: data.duration,
541 }),
542 ],
543 BuffKind::Rooted => vec![BuffEffect::MovementSpeed(0.0)],
544 BuffKind::Winded => vec![
545 BuffEffect::MovementSpeed(1.0 - nn_scaling2(data.strength)),
546 BuffEffect::EnergyReward(1.0 - nn_scaling(data.strength)),
547 ],
548 BuffKind::Amnesia => vec![BuffEffect::DisableAuxiliaryAbilities],
549 BuffKind::OffBalance => vec![BuffEffect::PoiseReduction(-data.strength)],
550 BuffKind::Tenacity => vec![
551 BuffEffect::DamageReduction(nn_scaling(data.strength) / 2.0),
552 BuffEffect::MovementSpeed(0.7),
553 BuffEffect::DamagedEffect(DamagedEffect::Energy(data.strength * 10.0)),
554 ],
555 BuffKind::Resilience => vec![BuffEffect::CrowdControlResistance(data.strength)],
556 }
557 }
558
559 fn extend_cat_ids(&self, mut cat_ids: Vec<BuffCategory>) -> Vec<BuffCategory> {
560 match self {
561 BuffKind::ImminentCritical => {
562 cat_ids.push(BuffCategory::RemoveOnAttack);
563 },
564 BuffKind::PotionSickness => {
565 cat_ids.push(BuffCategory::PersistOnDowned);
566 },
567 _ => {},
568 }
569 cat_ids
570 }
571
572 fn modify_data(
573 &self,
574 mut data: BuffData,
575 source_mass: Option<&Mass>,
576 dest_info: DestInfo,
577 source: BuffSource,
578 ) -> BuffData {
579 // TODO: Remove clippy allow after another buff needs this
580 #[expect(clippy::single_match)]
581 match self {
582 BuffKind::Rooted => {
583 let source_mass = source_mass.map_or(50.0, |m| m.0 as f64);
584 let dest_mass = dest_info.mass.map_or(50.0, |m| m.0 as f64);
585 let ratio = (source_mass / dest_mass).min(1.0);
586 data.duration = data.duration.map(|dur| Secs(dur.0 * ratio));
587 },
588 _ => {},
589 }
590 if self.resilience_ccr_strength(data).is_some() {
591 let dur_mult = dest_info
592 .stats
593 .map_or(1.0, |s| (1.0 - s.crowd_control_resistance).max(0.0));
594 data.duration = data.duration.map(|dur| dur * dur_mult as f64);
595 }
596 self.apply_item_effect_reduction(&mut data, source, dest_info);
597 data
598 }
599
600 /// If a buff kind should also give resilience when applied, return the
601 /// strength that resilience should have, otherwise return None
602 pub fn resilience_ccr_strength(&self, data: BuffData) -> Option<f32> {
603 match self {
604 BuffKind::Amnesia => Some(0.3),
605 BuffKind::Frozen => Some(data.strength),
606 _ => None,
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}