From b4ec4335096785ae757df2f5c7d27a73f9c4dd37 Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Sat, 10 Jul 2021 00:10:31 -0700 Subject: [PATCH] Add healing aura for sceptre M2 --- .../common/abilities/ability_set_manifest.ron | 2 +- .../common/abilities/sceptre/healingaura.ron | 17 ++++++ .../common/abilities/sceptre/wardingaura.ron | 4 +- common/src/comp/ability.rs | 59 +++++++++++++++---- common/src/comp/aura.rs | 6 ++ common/src/states/basic_aura.rs | 23 +++++++- 6 files changed, 95 insertions(+), 16 deletions(-) create mode 100644 assets/common/abilities/sceptre/healingaura.ron diff --git a/assets/common/abilities/ability_set_manifest.ron b/assets/common/abilities/ability_set_manifest.ron index 41b0c565d9..ddb17ff4a7 100644 --- a/assets/common/abilities/ability_set_manifest.ron +++ b/assets/common/abilities/ability_set_manifest.ron @@ -79,7 +79,7 @@ ), Tool(Sceptre): ( primary: "common.abilities.sceptre.lifestealbeam", - secondary: "common.abilities.sceptre.healingbeam", + secondary: "common.abilities.sceptre.healingaura", abilities: [ (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), ], diff --git a/assets/common/abilities/sceptre/healingaura.ron b/assets/common/abilities/sceptre/healingaura.ron new file mode 100644 index 0000000000..16c74e8e60 --- /dev/null +++ b/assets/common/abilities/sceptre/healingaura.ron @@ -0,0 +1,17 @@ +BasicAura( + buildup_duration: 0.25, + cast_duration: 0.5, + recover_duration: 0.25, + targets: InGroup, + aura: ( + kind: Regeneration, + strength: 4.0, + duration: Some(10.0), + category: Magical, + ), + aura_duration: 1.0, + range: 25.0, + energy_cost: 200, + scales_with_combo: true, + specifier: HealingAura, +) diff --git a/assets/common/abilities/sceptre/wardingaura.ron b/assets/common/abilities/sceptre/wardingaura.ron index 566cf6ec31..1785bbd971 100644 --- a/assets/common/abilities/sceptre/wardingaura.ron +++ b/assets/common/abilities/sceptre/wardingaura.ron @@ -12,4 +12,6 @@ BasicAura( aura_duration: 1.0, range: 25.0, energy_cost: 400, -) \ No newline at end of file + scales_with_combo: false, + specifier: WardingAura, +) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 1e7fcc7286..22ef67f214 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -260,6 +260,8 @@ pub enum CharacterAbility { aura_duration: f32, range: f32, energy_cost: f32, + scales_with_combo: bool, + specifier: aura::FrontendSpecifier, }, HealingBeam { buildup_duration: f32, @@ -352,7 +354,6 @@ impl CharacterAbility { | CharacterAbility::ChargedRanged { energy_cost, .. } | CharacterAbility::ChargedMelee { energy_cost, .. } | CharacterAbility::Shockwave { energy_cost, .. } - | CharacterAbility::BasicAura { energy_cost, .. } | CharacterAbility::BasicBlock { energy_cost, .. } | CharacterAbility::SelfBuff { energy_cost, .. } => update .energy @@ -369,6 +370,17 @@ impl CharacterAbility { .try_change_by(-(*energy_cost as i32), EnergySource::Ability) .is_ok() }, + CharacterAbility::BasicAura { + energy_cost, + scales_with_combo, + .. + } => { + ((*scales_with_combo && data.combo.counter() > 0) | !*scales_with_combo) + && update + .energy + .try_change_by(-(*energy_cost as i32), EnergySource::Ability) + .is_ok() + }, CharacterAbility::HealingBeam { .. } => data.combo.counter() > 0, CharacterAbility::ComboMelee { .. } | CharacterAbility::Boost { .. } @@ -711,6 +723,8 @@ impl CharacterAbility { aura_duration: _, ref mut range, ref mut energy_cost, + scales_with_combo: _, + specifier: _, } => { *buildup_duration /= stats.speed; *cast_duration /= stats.speed; @@ -1330,21 +1344,36 @@ impl CharacterAbility { ref mut aura, ref mut range, ref mut energy_cost, + ref specifier, .. } => { - if let Ok(Some(level)) = skillset.skill_level(Sceptre(AStrength)) { - aura.strength *= 1.15_f32.powi(level.into()); - } - if let Ok(Some(level)) = skillset.skill_level(Sceptre(ADuration)) { - if let Some(ref mut duration) = aura.duration { - *duration *= 1.2_f32.powi(level.into()); + if matches!(*specifier, aura::FrontendSpecifier::WardingAura) { + if let Ok(Some(level)) = skillset.skill_level(Sceptre(AStrength)) { + aura.strength *= 1.15_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(ADuration)) { + aura.duration.map(|dur| dur * 1.2_f32.powi(level.into())); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(ARange)) { + *range *= 1.25_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(ACost)) { + *energy_cost *= 0.85_f32.powi(level.into()); + } + } else if matches!(*specifier, aura::FrontendSpecifier::HealingAura) { + if let Ok(Some(level)) = skillset.skill_level(Sceptre(HHeal)) { + aura.strength *= 1.15_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(ADuration)) { + //TODO: make a proper healing duration ability + aura.duration.map(|dur| dur * 1.2_f32.powi(level.into())); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(HRange)) { + *range *= 1.25_f32.powi(level.into()); + } + if let Ok(Some(level)) = skillset.skill_level(Sceptre(HCost)) { + *energy_cost *= 0.85_f32.powi(level.into()); } - } - if let Ok(Some(level)) = skillset.skill_level(Sceptre(ARange)) { - *range *= 1.25_f32.powi(level.into()); - } - if let Ok(Some(level)) = skillset.skill_level(Sceptre(ACost)) { - *energy_cost *= 0.85_f32.powi(level.into()); } }, _ => {}, @@ -1852,6 +1881,8 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { aura_duration, range, energy_cost: _, + scales_with_combo, + specifier, } => CharacterState::BasicAura(basic_aura::Data { static_data: basic_aura::StaticData { buildup_duration: Duration::from_secs_f32(*buildup_duration), @@ -1862,6 +1893,8 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { aura_duration: Duration::from_secs_f32(*aura_duration), range: *range, ability_info, + scales_with_combo: *scales_with_combo, + specifier: *specifier, }, timer: Duration::default(), stage_section: StageSection::Buildup, diff --git a/common/src/comp/aura.rs b/common/src/comp/aura.rs index e172878d4c..902ea23de5 100644 --- a/common/src/comp/aura.rs +++ b/common/src/comp/aura.rs @@ -71,6 +71,12 @@ pub enum AuraTarget { All, } +#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] +pub enum FrontendSpecifier { + WardingAura, + HealingAura, +} + impl From<(Option, Option<&Uid>)> for AuraTarget { fn from((target, uid): (Option, Option<&Uid>)) -> Self { match (target, uid) { diff --git a/common/src/states/basic_aura.rs b/common/src/states/basic_aura.rs index 1e82d062f8..128645b6b9 100644 --- a/common/src/states/basic_aura.rs +++ b/common/src/states/basic_aura.rs @@ -1,7 +1,7 @@ use crate::{ combat::GroupTarget, comp::{ - aura::{AuraBuffConstructor, AuraChange, AuraTarget}, + aura::{AuraBuffConstructor, AuraChange, AuraKind, AuraTarget, FrontendSpecifier}, CharacterState, StateUpdate, }, event::ServerEvent, @@ -32,6 +32,10 @@ pub struct StaticData { pub range: f32, /// What key is used to press ability pub ability_info: AbilityInfo, + /// Whether the aura's effect scales with the user's current combo + pub scales_with_combo: bool, + /// Used to specify aura to the frontend + pub specifier: FrontendSpecifier, } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -71,6 +75,23 @@ impl CharacterBehavior for Data { Some(self.static_data.aura_duration), targets, ); + if self.static_data.scales_with_combo { + let combo = data.combo.counter(); + match aura.aura_kind { + AuraKind::Buff { + kind: _, + mut data, + category: _, + source: _, + } => { + data.strength *= 1.1_f32; + }, + } + update.server_events.push_front(ServerEvent::ComboChange { + entity: data.entity, + change: -(combo as i32), + }); + } update.server_events.push_front(ServerEvent::Aura { entity: data.entity, aura_change: AuraChange::Add(aura),