Added exhaustion check to BasicAura to try to prevent repeated casts

This commit is contained in:
Knightress Paladin 2021-07-19 17:50:42 -07:00
parent 68725a0131
commit ce31ac9fd1
2 changed files with 22 additions and 9 deletions

View File

@ -1927,6 +1927,8 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState {
}, },
timer: Duration::default(), timer: Duration::default(),
stage_section: StageSection::Buildup, stage_section: StageSection::Buildup,
exhausted: false,
combo_at_cast: 0.0,
}), }),
CharacterAbility::Blink { CharacterAbility::Blink {
buildup_duration, buildup_duration,

View File

@ -47,6 +47,10 @@ pub struct Data {
pub timer: Duration, pub timer: Duration,
/// What section the character stage is in /// What section the character stage is in
pub stage_section: StageSection, pub stage_section: StageSection,
/// Whether the aura has been cast already or not
pub exhausted: bool,
/// Combo which is updated only on the first tick behavior is called
pub combo_at_cast: f32,
} }
impl CharacterBehavior for Data { impl CharacterBehavior for Data {
@ -60,13 +64,25 @@ impl CharacterBehavior for Data {
match self.stage_section { match self.stage_section {
StageSection::Buildup => { StageSection::Buildup => {
if self.timer < self.static_data.buildup_duration { if self.timer < self.static_data.buildup_duration {
let combo = if self.combo_at_cast > 0.0 {
self.combo_at_cast
} else {
if self.static_data.scales_with_combo {
update.server_events.push_front(ServerEvent::ComboChange {
entity: data.entity,
change: -(data.combo.counter() as i32),
});
}
data.combo.counter() as f32
};
// Build up // Build up
update.character = CharacterState::BasicAura(Data { update.character = CharacterState::BasicAura(Data {
timer: tick_attack_or_default(data, self.timer, None), timer: tick_attack_or_default(data, self.timer, None),
combo_at_cast: combo,
..*self ..*self
}); });
} else { } else if !self.exhausted {
// Creates aura // Creates aura if it hasn't been created already
let targets = let targets =
AuraTarget::from((Some(self.static_data.targets), Some(data.uid))); AuraTarget::from((Some(self.static_data.targets), Some(data.uid)));
let mut aura = self.static_data.aura.to_aura( let mut aura = self.static_data.aura.to_aura(
@ -76,7 +92,6 @@ impl CharacterBehavior for Data {
targets, targets,
); );
if self.static_data.scales_with_combo { if self.static_data.scales_with_combo {
let combo = data.combo.counter();
match aura.aura_kind { match aura.aura_kind {
AuraKind::Buff { AuraKind::Buff {
kind: _, kind: _,
@ -84,14 +99,9 @@ impl CharacterBehavior for Data {
category: _, category: _,
source: _, source: _,
} => { } => {
data.strength *= data.strength *= 1.0 + (self.combo_at_cast).log(2.0_f32);
1.0 + (if combo > 0 { combo } else { 1 } as f32).log(2.0_f32);
}, },
} }
update.server_events.push_front(ServerEvent::ComboChange {
entity: data.entity,
change: -(combo as i32),
});
} }
update.server_events.push_front(ServerEvent::Aura { update.server_events.push_front(ServerEvent::Aura {
entity: data.entity, entity: data.entity,
@ -101,6 +111,7 @@ impl CharacterBehavior for Data {
update.character = CharacterState::BasicAura(Data { update.character = CharacterState::BasicAura(Data {
timer: Duration::default(), timer: Duration::default(),
stage_section: StageSection::Cast, stage_section: StageSection::Cast,
exhausted: true,
..*self ..*self
}); });
} }