From 160bd3ef0c6b4dc7b6715829624b1003ba378e0e Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 16 Apr 2021 13:44:11 -0400 Subject: [PATCH] Crippling strike now functional. Crippled debuff added. --- .../common/abilities/ability_set_manifest.ron | 4 +-- .../abilities/custom/beastclaws/basic.ron | 1 + .../custom/minotaur/cripplingstrike.ron | 34 +++++++++---------- .../abilities/custom/quadmedhoof/basic.ron | 1 + assets/common/abilities/dagger/tempbasic.ron | 1 + assets/common/abilities/empty/basic.ron | 1 + assets/common/abilities/farming/basic.ron | 1 + assets/common/abilities/pick/swing.ron | 1 + assets/common/abilities/shield/tempbasic.ron | 1 + common/src/comp/ability.rs | 4 +++ common/src/comp/buff.rs | 20 ++++++++++- common/src/comp/stats.rs | 4 +++ common/src/states/basic_melee.rs | 15 +++++--- common/src/states/dash_melee.rs | 1 - common/src/states/spin_melee.rs | 1 - common/src/states/utils.rs | 7 ++++ common/systems/src/buff.rs | 3 ++ voxygen/src/hud/mod.rs | 4 +++ voxygen/src/hud/util.rs | 6 ++-- 19 files changed, 81 insertions(+), 29 deletions(-) diff --git a/assets/common/abilities/ability_set_manifest.ron b/assets/common/abilities/ability_set_manifest.ron index 1fc621ade6..33150c51e5 100644 --- a/assets/common/abilities/ability_set_manifest.ron +++ b/assets/common/abilities/ability_set_manifest.ron @@ -208,10 +208,10 @@ ], ), Custom("Minotaur"): ( - primary: "common.abilities.custom.minotaur.charge", + primary: "common.abilities.custom.minotaur.cleave", secondary: "common.abilities.custom.minotaur.cripplingstrike", abilities: [ - (None, "common.abilities.custom.minotaur.cleave"), + (None, "common.abilities.custom.minotaur.charge"), (None, "common.abilities.custom.minotaur.frenzy"), ], ), diff --git a/assets/common/abilities/custom/beastclaws/basic.ron b/assets/common/abilities/custom/beastclaws/basic.ron index 6104f35b8b..449aa4b206 100644 --- a/assets/common/abilities/custom/beastclaws/basic.ron +++ b/assets/common/abilities/custom/beastclaws/basic.ron @@ -8,4 +8,5 @@ BasicMelee( base_poise_damage: 40, range: 5.0, max_angle: 120.0, + damage_effect: None, ) diff --git a/assets/common/abilities/custom/minotaur/cripplingstrike.ron b/assets/common/abilities/custom/minotaur/cripplingstrike.ron index f57f8d2839..fbc946b9ed 100644 --- a/assets/common/abilities/custom/minotaur/cripplingstrike.ron +++ b/assets/common/abilities/custom/minotaur/cripplingstrike.ron @@ -1,19 +1,17 @@ -DashMelee( +BasicMelee( energy_cost: 0, - base_damage: 300, - scaled_damage: 1200, - base_poise_damage: 25, - scaled_poise_damage: 100, - base_knockback: 10.0, - scaled_knockback: 30.0, - range: 7.5, - angle: 90.0, - energy_drain: 0, - forward_speed: 5.0, - buildup_duration: 0.4, - charge_duration: 4.0, - swing_duration: 0.1, - recover_duration: 0.5, - infinite_charge: false, - is_interruptible: false, -) \ No newline at end of file + buildup_duration: 0.3, + swing_duration: 0.2, + recover_duration: 0.6, + base_damage: 250.0, + base_poise_damage: 60.0, + knockback: 25.0, + range: 5.0, + max_angle: 90.0, + damage_effect: Some(Buff(( + kind: Crippled, + dur_secs: 15.0, + strength: Value(0.5), + chance: 1.0, + ))), +) diff --git a/assets/common/abilities/custom/quadmedhoof/basic.ron b/assets/common/abilities/custom/quadmedhoof/basic.ron index a451c250e0..73c4e7d739 100644 --- a/assets/common/abilities/custom/quadmedhoof/basic.ron +++ b/assets/common/abilities/custom/quadmedhoof/basic.ron @@ -8,4 +8,5 @@ BasicMelee( knockback: 25.0, range: 1.2, max_angle: 50.0, + damage_effect: None, ) diff --git a/assets/common/abilities/dagger/tempbasic.ron b/assets/common/abilities/dagger/tempbasic.ron index 27bed0eca3..5149caf41c 100644 --- a/assets/common/abilities/dagger/tempbasic.ron +++ b/assets/common/abilities/dagger/tempbasic.ron @@ -8,4 +8,5 @@ BasicMelee( knockback: 0.0, range: 3.5, max_angle: 20.0, + damage_effect: None, ) diff --git a/assets/common/abilities/empty/basic.ron b/assets/common/abilities/empty/basic.ron index e6c7d2f0ff..10d9ae81d8 100644 --- a/assets/common/abilities/empty/basic.ron +++ b/assets/common/abilities/empty/basic.ron @@ -8,4 +8,5 @@ BasicMelee( knockback: 0.0, range: 3.5, max_angle: 15.0, + damage_effect: None, ) diff --git a/assets/common/abilities/farming/basic.ron b/assets/common/abilities/farming/basic.ron index 2d8ff06774..44e52a5711 100644 --- a/assets/common/abilities/farming/basic.ron +++ b/assets/common/abilities/farming/basic.ron @@ -8,4 +8,5 @@ BasicMelee( knockback: 0.0, range: 3.5, max_angle: 20.0, + damage_effect: None, ) diff --git a/assets/common/abilities/pick/swing.ron b/assets/common/abilities/pick/swing.ron index 2d8ff06774..44e52a5711 100644 --- a/assets/common/abilities/pick/swing.ron +++ b/assets/common/abilities/pick/swing.ron @@ -8,4 +8,5 @@ BasicMelee( knockback: 0.0, range: 3.5, max_angle: 20.0, + damage_effect: None, ) diff --git a/assets/common/abilities/shield/tempbasic.ron b/assets/common/abilities/shield/tempbasic.ron index 6998b394b5..5e7e156fe7 100644 --- a/assets/common/abilities/shield/tempbasic.ron +++ b/assets/common/abilities/shield/tempbasic.ron @@ -8,4 +8,5 @@ BasicMelee( knockback: 0.0, range: 3.0, max_angle: 120.0, + damage_effect: None, ) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index e9a1de7c2c..5ec986c363 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -66,6 +66,7 @@ pub enum CharacterAbility { knockback: f32, range: f32, max_angle: f32, + damage_effect: Option, }, BasicRanged { energy_cost: f32, @@ -282,6 +283,7 @@ impl Default for CharacterAbility { knockback: 0.0, range: 3.5, max_angle: 15.0, + damage_effect: None, } } } @@ -1164,6 +1166,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { knockback, range, max_angle, + damage_effect, energy_cost: _, } => CharacterState::BasicMelee(basic_melee::Data { static_data: basic_melee::StaticData { @@ -1175,6 +1178,7 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { knockback: *knockback, range: *range, max_angle: *max_angle, + damage_effect: *damage_effect, ability_info, }, timer: Duration::default(), diff --git a/common/src/comp/buff.rs b/common/src/comp/buff.rs index 790313db6c..f93c419855 100644 --- a/common/src/comp/buff.rs +++ b/common/src/comp/buff.rs @@ -36,6 +36,8 @@ pub enum BuffKind { Invulnerability, /// Reduces incoming damage ProtectingWard, + /// Reduces movement speed and causes bleeding damage + Crippled, } #[cfg(not(target_arch = "wasm32"))] @@ -54,6 +56,7 @@ impl BuffKind { BuffKind::Invulnerability => true, BuffKind::ProtectingWard => true, BuffKind::Burning => false, + BuffKind::Crippled => false, } } @@ -118,6 +121,8 @@ pub enum BuffEffect { kind: ModifierKind, target_fraction: f32, }, + /// Modifies move speed of target + MovementSpeed(f32), } /// Actual de/buff. @@ -174,6 +179,8 @@ impl Buff { cat_ids: Vec, source: BuffSource, ) -> Self { + // Normalized nonlinear scaling + let nn_scaling = |a| a / (a + 0.5); let (effects, time) = match kind { BuffKind::Bleeding => ( vec![BuffEffect::HealthChangeOverTime { @@ -235,7 +242,7 @@ impl Buff { // Causes non-linearity in effect strength, but necessary to allow for tool // power and other things to affect the strength. 0.5 also still provides 50% // damage reduction. - data.strength / (0.5 + data.strength), + nn_scaling(data.strength), )], data.duration, ), @@ -247,6 +254,17 @@ impl Buff { }], data.duration, ), + BuffKind::Crippled => ( + vec![ + BuffEffect::MovementSpeed(1.0 - nn_scaling(data.strength)), + BuffEffect::HealthChangeOverTime { + rate: -data.strength * 100.0, + accumulated: 0.0, + kind: ModifierKind::Additive, + }, + ], + data.duration, + ), }; Buff { kind, diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index 55a49ae343..b7d428102d 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -25,6 +25,7 @@ pub struct Stats { pub name: String, pub damage_reduction: f32, pub max_health_modifier: f32, + pub move_speed_modifier: f32, } impl Stats { @@ -33,6 +34,7 @@ impl Stats { name, damage_reduction: 0.0, max_health_modifier: 1.0, + move_speed_modifier: 1.0, } } @@ -43,6 +45,7 @@ impl Stats { name: "".to_owned(), damage_reduction: 0.0, max_health_modifier: 1.0, + move_speed_modifier: 1.0, } } @@ -50,6 +53,7 @@ impl Stats { pub fn reset_temp_modifiers(&mut self) { self.damage_reduction = 0.0; self.max_health_modifier = 1.0; + self.move_speed_modifier = 1.0; } } diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 7346190829..844c3ea2f4 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -29,6 +29,8 @@ pub struct StaticData { pub range: f32, /// Max angle (45.0 will give you a 90.0 angle window) pub max_angle: f32, + /// Adds an effect onto the main damage of the attack + pub damage_effect: Option, /// What key is used to press ability pub ability_info: AbilityInfo, } @@ -97,15 +99,20 @@ impl CharacterBehavior for Data { .with_requirement(CombatRequirement::AnyDamage); let energy = AttackEffect::new(None, CombatEffect::EnergyReward(50.0)) .with_requirement(CombatRequirement::AnyDamage); - let buff = CombatEffect::Buff(CombatBuff::default_physical()); - let damage = AttackDamage::new( + let mut damage = AttackDamage::new( Damage { source: DamageSource::Melee, value: self.static_data.base_damage as f32, }, Some(GroupTarget::OutOfGroup), - ) - .with_effect(buff); + ); + match self.static_data.damage_effect { + Some(effect) => damage = damage.with_effect(effect), + None => { + let buff = CombatEffect::Buff(CombatBuff::default_physical()); + damage = damage.with_effect(buff); + }, + } let (crit_chance, crit_mult) = get_crit_data(data, self.static_data.ability_info); let attack = Attack::default() diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index f7f0a58e39..9e4fe43d9f 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -71,7 +71,6 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_orientation(data, &mut update, 1.0); handle_move(data, &mut update, 0.1); match self.stage_section { diff --git a/common/src/states/spin_melee.rs b/common/src/states/spin_melee.rs index 232a84b1b1..8730d86f34 100644 --- a/common/src/states/spin_melee.rs +++ b/common/src/states/spin_melee.rs @@ -175,7 +175,6 @@ impl CharacterBehavior for Data { }, 0.1, ); - handle_orientation(data, &mut update, 1.0); } // Swings diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index b8fadff6c0..e50d70cf81 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -243,6 +243,8 @@ 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) { + let efficiency = efficiency * data.stats.move_speed_modifier; + let accel = if data.physics.on_ground { data.body.base_accel() } else { @@ -267,6 +269,8 @@ pub fn handle_forced_movement( movement: ForcedMovement, efficiency: f32, ) { + let efficiency = efficiency * data.stats.move_speed_modifier; + match movement { ForcedMovement::Forward { strength } => { if let Some(accel) = data.physics.on_ground.then_some(data.body.base_accel()) { @@ -324,6 +328,7 @@ 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 { + let efficiency = efficiency * data.stats.move_speed_modifier; if let Some(force) = data.body.swim_thrust() { let force = efficiency * force; let mut water_accel = force / data.mass.0; @@ -361,6 +366,8 @@ 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 { + let efficiency = efficiency * data.stats.move_speed_modifier; + let glider = match data.character { CharacterState::Glide(data) => Some(data), _ => None, diff --git a/common/systems/src/buff.rs b/common/systems/src/buff.rs index 9d379af810..71137c4540 100644 --- a/common/systems/src/buff.rs +++ b/common/systems/src/buff.rs @@ -189,6 +189,9 @@ impl<'a> System<'a> for Sys { stat.max_health_modifier *= current_fraction; } }, + BuffEffect::MovementSpeed(ms) => { + stat.move_speed_modifier *= *ms; + }, }; } } diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 339e5a2cbf..3fe30786da 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -3626,6 +3626,8 @@ pub fn get_buff_image(buff: BuffKind, imgs: &Imgs) -> conrod_core::image::Id { BuffKind::Bleeding { .. } => imgs.debuff_bleed_0, BuffKind::Cursed { .. } => imgs.debuff_skull_0, BuffKind::Burning { .. } => imgs.debuff_burning_0, + // TODO: Get buff icon + BuffKind::Crippled { .. } => imgs.debuff_bleed_0, } } @@ -3644,6 +3646,7 @@ pub fn get_buff_title(buff: BuffKind, localized_strings: &Localization) -> &str BuffKind::Bleeding { .. } => localized_strings.get("buff.title.bleed"), BuffKind::Cursed { .. } => localized_strings.get("buff.title.cursed"), BuffKind::Burning { .. } => localized_strings.get("buff.title.burn"), + BuffKind::Crippled { .. } => localized_strings.get("buff.title.crippled"), } } @@ -3674,6 +3677,7 @@ pub fn get_buff_desc(buff: BuffKind, data: BuffData, localized_strings: &Localiz BuffKind::Bleeding { .. } => Cow::Borrowed(localized_strings.get("buff.desc.bleed")), BuffKind::Cursed { .. } => Cow::Borrowed(localized_strings.get("buff.desc.cursed")), BuffKind::Burning { .. } => Cow::Borrowed(localized_strings.get("buff.desc.burn")), + BuffKind::Crippled { .. } => Cow::Borrowed(localized_strings.get("buff.desc.crippled")), } } diff --git a/voxygen/src/hud/util.rs b/voxygen/src/hud/util.rs index c61eee530f..e9cdc8d0cf 100644 --- a/voxygen/src/hud/util.rs +++ b/voxygen/src/hud/util.rs @@ -118,7 +118,8 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> String { | BuffKind::Burning | BuffKind::CampfireHeal | BuffKind::Cursed - | BuffKind::ProtectingWard => continue, + | BuffKind::ProtectingWard + | BuffKind::Crippled => continue, }; write!(&mut description, "{}", buff_desc).unwrap(); @@ -138,7 +139,8 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> String { | BuffKind::Potion | BuffKind::CampfireHeal | BuffKind::Cursed - | BuffKind::ProtectingWard => continue, + | BuffKind::ProtectingWard + | BuffKind::Crippled => continue, } } else if let BuffKind::Saturation | BuffKind::Regeneration = buff.kind { i18n.get("buff.text.every_second").to_string()