From 68725a01317a31fb99428f712c784c0ee4e258e8 Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Sun, 18 Jul 2021 22:23:04 -0700 Subject: [PATCH 1/6] Added check for 0 combo in healing aura strength equation --- common/src/states/basic_aura.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/states/basic_aura.rs b/common/src/states/basic_aura.rs index c9835e6d2e..a4c029a2fd 100644 --- a/common/src/states/basic_aura.rs +++ b/common/src/states/basic_aura.rs @@ -84,7 +84,8 @@ impl CharacterBehavior for Data { category: _, source: _, } => { - data.strength *= 1.0 + (combo as f32).log(2.0_f32); + data.strength *= + 1.0 + (if combo > 0 { combo } else { 1 } as f32).log(2.0_f32); }, } update.server_events.push_front(ServerEvent::ComboChange { From ce31ac9fd1884dec4d27479e443829549f3be268 Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Mon, 19 Jul 2021 17:50:42 -0700 Subject: [PATCH 2/6] Added exhaustion check to BasicAura to try to prevent repeated casts --- common/src/comp/ability.rs | 2 ++ common/src/states/basic_aura.rs | 29 ++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index c3cb0be16a..0095cb51b3 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1927,6 +1927,8 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { }, timer: Duration::default(), stage_section: StageSection::Buildup, + exhausted: false, + combo_at_cast: 0.0, }), CharacterAbility::Blink { buildup_duration, diff --git a/common/src/states/basic_aura.rs b/common/src/states/basic_aura.rs index a4c029a2fd..f5fc0ba926 100644 --- a/common/src/states/basic_aura.rs +++ b/common/src/states/basic_aura.rs @@ -47,6 +47,10 @@ pub struct Data { pub timer: Duration, /// What section the character stage is in 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 { @@ -60,13 +64,25 @@ impl CharacterBehavior for Data { match self.stage_section { StageSection::Buildup => { 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 update.character = CharacterState::BasicAura(Data { timer: tick_attack_or_default(data, self.timer, None), + combo_at_cast: combo, ..*self }); - } else { - // Creates aura + } else if !self.exhausted { + // Creates aura if it hasn't been created already let targets = AuraTarget::from((Some(self.static_data.targets), Some(data.uid))); let mut aura = self.static_data.aura.to_aura( @@ -76,7 +92,6 @@ impl CharacterBehavior for Data { targets, ); if self.static_data.scales_with_combo { - let combo = data.combo.counter(); match aura.aura_kind { AuraKind::Buff { kind: _, @@ -84,14 +99,9 @@ impl CharacterBehavior for Data { category: _, source: _, } => { - data.strength *= - 1.0 + (if combo > 0 { combo } else { 1 } as f32).log(2.0_f32); + data.strength *= 1.0 + (self.combo_at_cast).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 { entity: data.entity, @@ -101,6 +111,7 @@ impl CharacterBehavior for Data { update.character = CharacterState::BasicAura(Data { timer: Duration::default(), stage_section: StageSection::Cast, + exhausted: true, ..*self }); } From 9be690770af999c3cd69fe4046209e48e353616c Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Tue, 20 Jul 2021 17:48:35 -0700 Subject: [PATCH 3/6] Added check to prevent heal aura from being negative --- common/src/states/basic_aura.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/states/basic_aura.rs b/common/src/states/basic_aura.rs index f5fc0ba926..5f3c8834e2 100644 --- a/common/src/states/basic_aura.rs +++ b/common/src/states/basic_aura.rs @@ -99,7 +99,7 @@ impl CharacterBehavior for Data { category: _, source: _, } => { - data.strength *= 1.0 + (self.combo_at_cast).log(2.0_f32); + data.strength *= 1.0 + self.combo_at_cast.max(1.0_f32).log(2.0_f32); }, } } From 578cacc194d30326fc852eb77833e93eaa1af3ba Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Tue, 20 Jul 2021 20:15:38 -0700 Subject: [PATCH 4/6] Relocated BasicAura's combo reading to its static data --- common/src/comp/ability.rs | 6 +-- common/src/states/basic_aura.rs | 25 ++++------ common/src/states/utils.rs | 82 ++++++++++++++++++++------------- 3 files changed, 61 insertions(+), 52 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 0095cb51b3..495e2f671e 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1443,8 +1443,8 @@ impl CharacterAbility { } } -impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { - fn from((ability, ability_info): (&CharacterAbility, AbilityInfo)) -> Self { +impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { + fn from((ability, ability_info, data): (&CharacterAbility, AbilityInfo, &JoinData)) -> Self { match ability { CharacterAbility::BasicMelee { buildup_duration, @@ -1923,12 +1923,12 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { range: *range, ability_info, scales_with_combo: *scales_with_combo, + combo_at_cast: data.combo.counter() as f32, specifier: *specifier, }, timer: Duration::default(), stage_section: StageSection::Buildup, exhausted: false, - combo_at_cast: 0.0, }), CharacterAbility::Blink { buildup_duration, diff --git a/common/src/states/basic_aura.rs b/common/src/states/basic_aura.rs index 5f3c8834e2..76ad142c18 100644 --- a/common/src/states/basic_aura.rs +++ b/common/src/states/basic_aura.rs @@ -34,6 +34,8 @@ pub struct StaticData { pub ability_info: AbilityInfo, /// Whether the aura's effect scales with the user's current combo pub scales_with_combo: bool, + /// Combo at the time the aura is first cast + pub combo_at_cast: f32, /// Used to specify aura to the frontend pub specifier: Specifier, } @@ -49,8 +51,6 @@ pub struct Data { 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 { @@ -64,24 +64,12 @@ impl CharacterBehavior for Data { match self.stage_section { StageSection::Buildup => { 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 update.character = CharacterState::BasicAura(Data { timer: tick_attack_or_default(data, self.timer, None), - combo_at_cast: combo, ..*self }); - } else if !self.exhausted { + } else if true { // Creates aura if it hasn't been created already let targets = AuraTarget::from((Some(self.static_data.targets), Some(data.uid))); @@ -99,9 +87,14 @@ impl CharacterBehavior for Data { category: _, source: _, } => { - data.strength *= 1.0 + self.combo_at_cast.max(1.0_f32).log(2.0_f32); + data.strength *= + 1.0 + self.static_data.combo_at_cast.max(1.0_f32).log(2.0_f32); }, } + update.server_events.push_front(ServerEvent::ComboChange { + entity: data.entity, + change: -(self.static_data.combo_at_cast as i32), + }); } update.server_events.push_front(ServerEvent::Aura { entity: data.entity, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 75ca0b324e..a6020bd393 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -237,7 +237,7 @@ impl Body { } /// Handles updating `Components` to move player based on state of `JoinData` -pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { +pub fn handle_move(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32) { let submersion = data .physics .in_liquid() @@ -262,7 +262,7 @@ pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { /// Updates components to move player as if theyre on ground or in air #[allow(clippy::assign_op_pattern)] // TODO: Pending review in #587 -fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { +fn basic_move(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32) { let efficiency = efficiency * data.stats.move_speed_modifier * data.stats.friction_modifier; let accel = if data.physics.on_ground.is_some() { @@ -303,7 +303,11 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { } /// Handles forced movement -pub fn handle_forced_movement(data: &JoinData, update: &mut StateUpdate, movement: ForcedMovement) { +pub fn handle_forced_movement( + data: &JoinData<'_>, + update: &mut StateUpdate, + movement: ForcedMovement, +) { match movement { ForcedMovement::Forward { strength } => { let strength = strength * data.stats.move_speed_modifier * data.stats.friction_modifier; @@ -345,7 +349,7 @@ pub fn handle_forced_movement(data: &JoinData, update: &mut StateUpdate, movemen } } -pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { +pub fn handle_orientation(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32) { if let Some(dir) = (is_strafing(data, update) || update.character.is_attack()) .then(|| data.inputs.look_dir.to_horizontal().unwrap_or_default()) .or_else(|| Dir::from_unnormalized(data.inputs.move_dir.into())) @@ -361,7 +365,12 @@ pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, efficiency: } /// Updates components to move player as if theyre swimming -fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32, submersion: f32) -> bool { +fn swim_move( + data: &JoinData<'_>, + update: &mut StateUpdate, + efficiency: f32, + submersion: f32, +) -> bool { let efficiency = efficiency * data.stats.move_speed_modifier * data.stats.friction_modifier; if let Some(force) = data.body.swim_thrust() { let force = efficiency * force; @@ -399,7 +408,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32, submers } /// Updates components to move entity as if it's flying -pub fn fly_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) -> bool { +pub fn fly_move(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32) -> bool { let efficiency = efficiency * data.stats.move_speed_modifier * data.stats.friction_modifier; let glider = match data.character { @@ -466,14 +475,14 @@ pub fn fly_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) -> b /// Checks if an input related to an attack is held. If one is, moves entity /// into wielding state -pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) { +pub fn handle_wield(data: &JoinData<'_>, update: &mut StateUpdate) { if data.controller.queued_inputs.keys().any(|i| i.is_ability()) { attempt_wield(data, update); } } /// If a tool is equipped, goes into Equipping state, otherwise goes to Idle -pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { +pub fn attempt_wield(data: &JoinData<'_>, update: &mut StateUpdate) { // Closure to get equip time provided an equip slot if a tool is equipped in // equip slot let equip_time = |equip_slot| { @@ -511,32 +520,32 @@ pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { } /// Checks that player can `Sit` and updates `CharacterState` if so -pub fn attempt_sit(data: &JoinData, update: &mut StateUpdate) { +pub fn attempt_sit(data: &JoinData<'_>, update: &mut StateUpdate) { if data.physics.on_ground.is_some() { update.character = CharacterState::Sit; } } -pub fn attempt_dance(data: &JoinData, update: &mut StateUpdate) { +pub fn attempt_dance(data: &JoinData<'_>, update: &mut StateUpdate) { if data.physics.on_ground.is_some() && data.body.is_humanoid() { update.character = CharacterState::Dance; } } -pub fn attempt_talk(data: &JoinData, update: &mut StateUpdate) { +pub fn attempt_talk(data: &JoinData<'_>, update: &mut StateUpdate) { if data.physics.on_ground.is_some() { update.character = CharacterState::Talk; } } -pub fn attempt_sneak(data: &JoinData, update: &mut StateUpdate) { +pub fn attempt_sneak(data: &JoinData<'_>, update: &mut StateUpdate) { if data.physics.on_ground.is_some() && data.body.is_humanoid() { update.character = CharacterState::Sneak; } } /// Checks that player can `Climb` and updates `CharacterState` if so -pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) -> bool { +pub fn handle_climb(data: &JoinData<'_>, update: &mut StateUpdate) -> bool { if data.inputs.climb.is_some() && data.physics.on_wall.is_some() && data.physics.on_ground.is_none() @@ -557,7 +566,7 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) -> bool { } /// Checks that player can Swap Weapons and updates `Loadout` if so -pub fn attempt_swap_equipped_weapons(data: &JoinData, update: &mut StateUpdate) { +pub fn attempt_swap_equipped_weapons(data: &JoinData<'_>, update: &mut StateUpdate) { if data .inventory .equipped(EquipSlot::InactiveMainhand) @@ -573,7 +582,7 @@ pub fn attempt_swap_equipped_weapons(data: &JoinData, update: &mut StateUpdate) /// Handles inventory manipulations that affect the loadout pub fn handle_manipulate_loadout( - data: &JoinData, + data: &JoinData<'_>, update: &mut StateUpdate, inv_action: InventoryAction, ) { @@ -619,7 +628,7 @@ pub fn handle_manipulate_loadout( } /// Checks that player can wield the glider and updates `CharacterState` if so -pub fn attempt_glide_wield(data: &JoinData, update: &mut StateUpdate) { +pub fn attempt_glide_wield(data: &JoinData<'_>, update: &mut StateUpdate) { if data.inventory.equipped(EquipSlot::Glider).is_some() && !data .physics @@ -633,7 +642,7 @@ pub fn attempt_glide_wield(data: &JoinData, update: &mut StateUpdate) { } /// Checks that player can jump and sends jump event if so -pub fn handle_jump(data: &JoinData, update: &mut StateUpdate, strength: f32) -> bool { +pub fn handle_jump(data: &JoinData<'_>, update: &mut StateUpdate, strength: f32) -> bool { (input_is_pressed(data, InputKind::Jump) && data.physics.on_ground.is_some()) .then(|| data.body.jump_impulse()) .flatten() @@ -646,7 +655,7 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate, strength: f32) -> .is_some() } -fn handle_ability(data: &JoinData, update: &mut StateUpdate, input: InputKind) { +fn handle_ability(data: &JoinData<'_>, update: &mut StateUpdate, input: InputKind) { let hands = get_hands(data); // Mouse1 and Skill1 always use the MainHand slot @@ -699,12 +708,13 @@ fn handle_ability(data: &JoinData, update: &mut StateUpdate, input: InputKind) { matches!(equip_slot, EquipSlot::ActiveOffhand), input, ), + data, )); } } } -pub fn handle_ability_input(data: &JoinData, update: &mut StateUpdate) { +pub fn handle_ability_input(data: &JoinData<'_>, update: &mut StateUpdate) { if let Some(input) = data .controller .queued_inputs @@ -715,7 +725,7 @@ pub fn handle_ability_input(data: &JoinData, update: &mut StateUpdate) { } } -pub fn handle_input(data: &JoinData, update: &mut StateUpdate, input: InputKind) { +pub fn handle_input(data: &JoinData<'_>, update: &mut StateUpdate, input: InputKind) { match input { InputKind::Primary | InputKind::Secondary | InputKind::Ability(_) => { handle_ability(data, update, input) @@ -729,7 +739,7 @@ pub fn handle_input(data: &JoinData, update: &mut StateUpdate, input: InputKind) } } -pub fn attempt_input(data: &JoinData, update: &mut StateUpdate) { +pub fn attempt_input(data: &JoinData<'_>, update: &mut StateUpdate) { // TODO: look into using first() when it becomes stable if let Some(input) = data.controller.queued_inputs.keys().next() { handle_input(data, update, *input); @@ -737,7 +747,7 @@ pub fn attempt_input(data: &JoinData, update: &mut StateUpdate) { } /// Checks that player can block, then attempts to block -pub fn handle_block_input(data: &JoinData, update: &mut StateUpdate) { +pub fn handle_block_input(data: &JoinData<'_>, update: &mut StateUpdate) { let can_block = |equip_slot| matches!(unwrap_tool_data(data, equip_slot), Some(tool) if tool.can_block()); let hands = get_hands(data); @@ -750,6 +760,7 @@ pub fn handle_block_input(data: &JoinData, update: &mut StateUpdate) { update.character = CharacterState::from(( &ability, AbilityInfo::from_input(data, false, InputKind::Roll), + data, )); } } @@ -757,13 +768,14 @@ pub fn handle_block_input(data: &JoinData, update: &mut StateUpdate) { /// Checks that player can perform a dodge, then /// attempts to perform their dodge ability -pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { +pub fn handle_dodge_input(data: &JoinData<'_>, update: &mut StateUpdate) { if input_is_pressed(data, InputKind::Roll) && data.body.is_humanoid() { let ability = CharacterAbility::default_roll().adjusted_by_skills(data.skill_set, None); if ability.requirements_paid(data, update) { update.character = CharacterState::from(( &ability, AbilityInfo::from_input(data, false, InputKind::Roll), + data, )); if let CharacterState::ComboMelee(c) = data.character { if let CharacterState::Roll(roll) = &mut update.character { @@ -783,7 +795,7 @@ pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { } } -pub fn is_strafing(data: &JoinData, update: &StateUpdate) -> bool { +pub fn is_strafing(data: &JoinData<'_>, update: &StateUpdate) -> bool { // TODO: Don't always check `character.is_aimed()`, allow the frontend to // control whether the player strafes during an aimed `CharacterState`. (update.character.is_aimed() || update.should_strafe) && data.body.can_strafe() @@ -797,7 +809,7 @@ pub fn unwrap_tool_data<'a>(data: &'a JoinData, equip_slot: EquipSlot) -> Option } } -pub fn get_hands(data: &JoinData) -> (Option, Option) { +pub fn get_hands(data: &JoinData<'_>) -> (Option, Option) { let hand = |slot| { if let Some(ItemKind::Tool(tool)) = data.inventory.equipped(slot).map(|i| i.kind()) { Some(tool.hands) @@ -813,7 +825,7 @@ pub fn get_hands(data: &JoinData) -> (Option, Option) { /// Returns (critical chance, critical multiplier) which is calculated from /// equipped weapon and equipped armor respectively -pub fn get_crit_data(data: &JoinData, ai: AbilityInfo) -> (f32, f32) { +pub fn get_crit_data(data: &JoinData<'_>, ai: AbilityInfo) -> (f32, f32) { const DEFAULT_CRIT_CHANCE: f32 = 0.1; let crit_chance = ai @@ -838,7 +850,7 @@ pub fn get_crit_data(data: &JoinData, ai: AbilityInfo) -> (f32, f32) { } /// Returns buff strength from the weapon used in the ability -pub fn get_buff_strength(data: &JoinData, ai: AbilityInfo) -> f32 { +pub fn get_buff_strength(data: &JoinData<'_>, ai: AbilityInfo) -> f32 { ai.hand .map(|hand| match hand { HandInfo::TwoHanded | HandInfo::MainHand => EquipSlot::ActiveMainhand, @@ -855,21 +867,25 @@ pub fn get_buff_strength(data: &JoinData, ai: AbilityInfo) -> f32 { .unwrap_or(1.0) } -pub fn handle_state_interrupt(data: &JoinData, update: &mut StateUpdate, attacks_interrupt: bool) { +pub fn handle_state_interrupt( + data: &JoinData<'_>, + update: &mut StateUpdate, + attacks_interrupt: bool, +) { if attacks_interrupt { handle_ability_input(data, update); } handle_dodge_input(data, update); } -pub fn input_is_pressed(data: &JoinData, input: InputKind) -> bool { +pub fn input_is_pressed(data: &JoinData<'_>, input: InputKind) -> bool { data.controller.queued_inputs.contains_key(&input) } /// Checked `Duration` addition. Computes `timer` + `dt`, applying relevant stat /// attack modifiers and `other_modifiers`, returning None if overflow occurred. pub fn checked_tick_attack( - data: &JoinData, + data: &JoinData<'_>, timer: Duration, other_modifier: Option, ) -> Option { @@ -880,7 +896,7 @@ pub fn checked_tick_attack( /// Ticks `timer` by `dt`, applying relevant stat attack modifiers and /// `other_modifier`. Returns `Duration::default()` if overflow occurs pub fn tick_attack_or_default( - data: &JoinData, + data: &JoinData<'_>, timer: Duration, other_modifier: Option, ) -> Duration { @@ -926,7 +942,7 @@ pub enum MovementDirection { } impl MovementDirection { - pub fn get_2d_dir(self, data: &JoinData) -> Vec2 { + pub fn get_2d_dir(self, data: &JoinData<'_>) -> Vec2 { use MovementDirection::*; match self { Look => data @@ -951,7 +967,7 @@ pub struct AbilityInfo { } impl AbilityInfo { - pub fn from_input(data: &JoinData, from_offhand: bool, input: InputKind) -> Self { + pub fn from_input(data: &JoinData<'_>, from_offhand: bool, input: InputKind) -> Self { let tool_data = if from_offhand { unwrap_tool_data(data, EquipSlot::ActiveOffhand) } else { From c48a7c0072178b53c50ada12f2f3076c72f46286 Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Wed, 21 Jul 2021 16:46:14 -0700 Subject: [PATCH 5/6] Used integer types to store combo values --- common/src/comp/ability.rs | 2 +- common/src/states/basic_aura.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 495e2f671e..0fc4959b78 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1923,7 +1923,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { range: *range, ability_info, scales_with_combo: *scales_with_combo, - combo_at_cast: data.combo.counter() as f32, + combo_at_cast: data.combo.counter(), specifier: *specifier, }, timer: Duration::default(), diff --git a/common/src/states/basic_aura.rs b/common/src/states/basic_aura.rs index 76ad142c18..0d9b6a5b41 100644 --- a/common/src/states/basic_aura.rs +++ b/common/src/states/basic_aura.rs @@ -35,7 +35,7 @@ pub struct StaticData { /// Whether the aura's effect scales with the user's current combo pub scales_with_combo: bool, /// Combo at the time the aura is first cast - pub combo_at_cast: f32, + pub combo_at_cast: u32, /// Used to specify aura to the frontend pub specifier: Specifier, } @@ -87,8 +87,9 @@ impl CharacterBehavior for Data { category: _, source: _, } => { - data.strength *= - 1.0 + self.static_data.combo_at_cast.max(1.0_f32).log(2.0_f32); + data.strength *= 1.0 + + (std::cmp::max(self.static_data.combo_at_cast, 1) as f32) + .log(2.0); }, } update.server_events.push_front(ServerEvent::ComboChange { From 7ce9a3e28424bbdd503a94e9eeacc4824b1d6f91 Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Wed, 21 Jul 2021 20:20:27 -0700 Subject: [PATCH 6/6] Removed exhausted check from BasicAura and reformat max call --- common/src/comp/ability.rs | 1 - common/src/states/basic_aura.rs | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 0fc4959b78..98f5935bc7 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1928,7 +1928,6 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState { }, timer: Duration::default(), stage_section: StageSection::Buildup, - exhausted: false, }), CharacterAbility::Blink { buildup_duration, diff --git a/common/src/states/basic_aura.rs b/common/src/states/basic_aura.rs index 0d9b6a5b41..ff5bf6fd61 100644 --- a/common/src/states/basic_aura.rs +++ b/common/src/states/basic_aura.rs @@ -49,8 +49,6 @@ pub struct Data { pub timer: Duration, /// What section the character stage is in pub stage_section: StageSection, - /// Whether the aura has been cast already or not - pub exhausted: bool, } impl CharacterBehavior for Data { @@ -69,8 +67,8 @@ impl CharacterBehavior for Data { timer: tick_attack_or_default(data, self.timer, None), ..*self }); - } else if true { - // Creates aura if it hasn't been created already + } else { + // Creates aura let targets = AuraTarget::from((Some(self.static_data.targets), Some(data.uid))); let mut aura = self.static_data.aura.to_aura( @@ -87,9 +85,8 @@ impl CharacterBehavior for Data { category: _, source: _, } => { - data.strength *= 1.0 - + (std::cmp::max(self.static_data.combo_at_cast, 1) as f32) - .log(2.0); + data.strength *= + 1.0 + (self.static_data.combo_at_cast.max(1) as f32).log(2.0); }, } update.server_events.push_front(ServerEvent::ComboChange { @@ -105,7 +102,6 @@ impl CharacterBehavior for Data { update.character = CharacterState::BasicAura(Data { timer: Duration::default(), stage_section: StageSection::Cast, - exhausted: true, ..*self }); }