From 44a56be25b90c9706349ba8cb3ff99806b0791db Mon Sep 17 00:00:00 2001 From: Sylv Date: Thu, 30 May 2024 10:41:55 +0000 Subject: [PATCH] Fix Gnarling Speed --- assets/common/abilities/gnarling/axe/chop.ron | 6 ++-- .../abilities/gnarling/blowgun/dart.ron | 6 ++-- .../common/abilities/gnarling/dagger/stab.ron | 6 ++-- .../biped_small/gnarling/chest/mugger.ron | 2 +- .../biped_small/gnarling/foot/mugger.ron | 2 +- .../biped_small/gnarling/hand/mugger.ron | 2 +- .../biped_small/gnarling/head/mugger.ron | 2 +- .../biped_small/gnarling/pants/mugger.ron | 2 +- .../biped_small/gnarling/tail/mugger.ron | 2 +- .../biped_small/gnarling/mugger.ron | 2 +- .../biped_small/gnarling/stalker.ron | 2 +- common/src/states/utils.rs | 1 + server/agent/src/attack.rs | 34 ++++++++++++------- 13 files changed, 40 insertions(+), 29 deletions(-) diff --git a/assets/common/abilities/gnarling/axe/chop.ron b/assets/common/abilities/gnarling/axe/chop.ron index 9a5734236c..7bebf0a47c 100644 --- a/assets/common/abilities/gnarling/axe/chop.ron +++ b/assets/common/abilities/gnarling/axe/chop.ron @@ -1,17 +1,17 @@ BasicMelee( energy_cost: 0, - buildup_duration: 0.3, + buildup_duration: 0.4, swing_duration: 0.05, hit_timing: 0.8, recover_duration: 0.45, melee_constructor: ( kind: Slash( - damage: 9, + damage: 4, poise: 5, knockback: 0, energy_regen: 0, ), - range: 3, + range: 2.5, angle: 30, ), ori_modifier: 1.0, diff --git a/assets/common/abilities/gnarling/blowgun/dart.ron b/assets/common/abilities/gnarling/blowgun/dart.ron index 8074efab77..dc36f40a41 100644 --- a/assets/common/abilities/gnarling/blowgun/dart.ron +++ b/assets/common/abilities/gnarling/blowgun/dart.ron @@ -5,12 +5,12 @@ BasicRanged( projectile: ( kind: Pointed, attack: Some(( - damage: 4, + damage: 2, energy: 0, buff: Some(( kind: Bleeding, - dur_secs: 10, - strength: DamageFraction(0.1), + dur_secs: 5, + strength: DamageFraction(0.4), chance: 0.1, )), )), diff --git a/assets/common/abilities/gnarling/dagger/stab.ron b/assets/common/abilities/gnarling/dagger/stab.ron index 503ecd8dbc..04074bc033 100644 --- a/assets/common/abilities/gnarling/dagger/stab.ron +++ b/assets/common/abilities/gnarling/dagger/stab.ron @@ -1,17 +1,17 @@ BasicMelee( energy_cost: 0, - buildup_duration: 0.15, + buildup_duration: 0.2, swing_duration: 0.05, hit_timing: 0.4, recover_duration: 0.375, melee_constructor: ( kind: Stab( - damage: 6, + damage: 2.5, poise: 0, knockback: 0, energy_regen: 0, ), - range: 2, + range: 3, angle: 15, ), ori_modifier: 1.0, diff --git a/assets/common/items/npc_armor/biped_small/gnarling/chest/mugger.ron b/assets/common/items/npc_armor/biped_small/gnarling/chest/mugger.ron index c4d973aa7e..3c10de333a 100644 --- a/assets/common/items/npc_armor/biped_small/gnarling/chest/mugger.ron +++ b/assets/common/items/npc_armor/biped_small/gnarling/chest/mugger.ron @@ -8,7 +8,7 @@ ItemDef( poise_resilience: Some(Normal(1.0)), energy_max: Some(2.7), energy_reward: Some(0.027), - precision_power: Some(0.025), + precision_power: Some(0.150), )), )), quality: Low, diff --git a/assets/common/items/npc_armor/biped_small/gnarling/foot/mugger.ron b/assets/common/items/npc_armor/biped_small/gnarling/foot/mugger.ron index 5af7c4b748..dd6ee83b87 100644 --- a/assets/common/items/npc_armor/biped_small/gnarling/foot/mugger.ron +++ b/assets/common/items/npc_armor/biped_small/gnarling/foot/mugger.ron @@ -8,7 +8,7 @@ ItemDef( poise_resilience: Some(Normal(1.0)), energy_max: Some(0.9), energy_reward: Some(0.009), - precision_power: Some(0.008), + precision_power: Some(0.048), )), )), quality: Low, diff --git a/assets/common/items/npc_armor/biped_small/gnarling/hand/mugger.ron b/assets/common/items/npc_armor/biped_small/gnarling/hand/mugger.ron index d0add40070..d5ad89a3b3 100644 --- a/assets/common/items/npc_armor/biped_small/gnarling/hand/mugger.ron +++ b/assets/common/items/npc_armor/biped_small/gnarling/hand/mugger.ron @@ -8,7 +8,7 @@ ItemDef( poise_resilience: Some(Normal(1.0)), energy_max: Some(0.9), energy_reward: Some(0.009), - precision_power: Some(0.008), + precision_power: Some(0.048), )), )), quality: Low, diff --git a/assets/common/items/npc_armor/biped_small/gnarling/head/mugger.ron b/assets/common/items/npc_armor/biped_small/gnarling/head/mugger.ron index 58cbcefae4..3734804241 100644 --- a/assets/common/items/npc_armor/biped_small/gnarling/head/mugger.ron +++ b/assets/common/items/npc_armor/biped_small/gnarling/head/mugger.ron @@ -8,7 +8,7 @@ ItemDef( poise_resilience: Some(Normal(1.0)), energy_max: Some(1.8), energy_reward: Some(0.02), - precision_power: Some(0.016), + precision_power: Some(0.096), )), )), quality: Low, diff --git a/assets/common/items/npc_armor/biped_small/gnarling/pants/mugger.ron b/assets/common/items/npc_armor/biped_small/gnarling/pants/mugger.ron index 16514f357b..65204fdab1 100644 --- a/assets/common/items/npc_armor/biped_small/gnarling/pants/mugger.ron +++ b/assets/common/items/npc_armor/biped_small/gnarling/pants/mugger.ron @@ -8,7 +8,7 @@ ItemDef( poise_resilience: Some(Normal(1.0)), energy_max: Some(1.8), energy_reward: Some(0.02), - precision_power: Some(0.016), + precision_power: Some(0.096), )), )), quality: Low, diff --git a/assets/common/items/npc_armor/biped_small/gnarling/tail/mugger.ron b/assets/common/items/npc_armor/biped_small/gnarling/tail/mugger.ron index ce54acebfa..b00700669c 100644 --- a/assets/common/items/npc_armor/biped_small/gnarling/tail/mugger.ron +++ b/assets/common/items/npc_armor/biped_small/gnarling/tail/mugger.ron @@ -8,7 +8,7 @@ ItemDef( poise_resilience: Some(Normal(1.0)), energy_max: Some(0.4), energy_reward: Some(0.005), - precision_power: Some(0.004), + precision_power: Some(0.024), )), )), quality: Low, diff --git a/assets/common/items/npc_weapons/biped_small/gnarling/mugger.ron b/assets/common/items/npc_weapons/biped_small/gnarling/mugger.ron index 0b83e2d846..55a17d580b 100644 --- a/assets/common/items/npc_weapons/biped_small/gnarling/mugger.ron +++ b/assets/common/items/npc_weapons/biped_small/gnarling/mugger.ron @@ -6,7 +6,7 @@ ItemDef( hands: Two, stats: ( equip_time_secs: 0.0, - power: 0.3, + power: 1.0, effect_power: 1.0, speed: 1.0, range: 1.0, diff --git a/assets/common/items/npc_weapons/biped_small/gnarling/stalker.ron b/assets/common/items/npc_weapons/biped_small/gnarling/stalker.ron index 87962c4b77..10c8680317 100644 --- a/assets/common/items/npc_weapons/biped_small/gnarling/stalker.ron +++ b/assets/common/items/npc_weapons/biped_small/gnarling/stalker.ron @@ -6,7 +6,7 @@ ItemDef( hands: Two, stats: ( equip_time_secs: 0.0, - power: 0.3, + power: 1.0, effect_power: 0.8, speed: 0.6, range: 1.0, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 2dddc09de3..3309462384 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -125,6 +125,7 @@ impl Body { Body::BipedSmall(biped_small) => match biped_small.species { biped_small::Species::Haniwa => 65.0, biped_small::Species::Boreal => 100.0, + biped_small::Species::Gnarling => 70.0, _ => 80.0, }, Body::Object(_) => 0.0, diff --git a/server/agent/src/attack.rs b/server/agent/src/attack.rs index d66fbe1257..79c4f8c6bf 100644 --- a/server/agent/src/attack.rs +++ b/server/agent/src/attack.rs @@ -122,11 +122,11 @@ impl<'a> AgentData<'a> { tgt_data: &TargetData, read_data: &ReadData, ) { - // Handle attacking of agent - if attack_data.in_min_range() && attack_data.angle < 30.0 { - controller.push_basic_input(InputKind::Primary); - controller.inputs.move_dir = Vec2::zero(); - } + // Behaviour parameters + const STRAFE_DIST: f32 = 4.5; + const STRAFE_SPEED_MULT: f32 = 0.75; + const STRATE_SPIRAL_MULT: f32 = 0.8; // how quickly they close gap while strafing + const BACKSTAB_SPEED_MULT: f32 = 0.3; // Handle movement of agent let target_ori = agent @@ -135,9 +135,15 @@ impl<'a> AgentData<'a> { .map(|ori| ori.look_vec()) .unwrap_or_default(); let dist = attack_data.dist_sqrd.sqrt(); - let in_front_of_target = target_ori.dot(self.pos.0 - tgt_data.pos.0) > 0.0; - if attack_data.dist_sqrd < MAX_PATH_DIST.powi(2) { + + // Handle attacking of agent + if attack_data.in_min_range() && attack_data.angle < 30.0 { + controller.push_basic_input(InputKind::Primary); + controller.inputs.move_dir = Vec2::zero(); + } + + if attack_data.dist_sqrd < STRAFE_DIST.powi(2) { // If in front of the target, circle to try and get behind, else just make a // beeline for the back of the agent let vec_to_target = (tgt_data.pos.0 - self.pos.0).xy(); @@ -159,13 +165,14 @@ impl<'a> AgentData<'a> { .iter() .find(|move_dir| target_ori.xy().dot(**move_dir) < 0.0) { - controller.inputs.move_dir = *move_dir; + controller.inputs.move_dir = + STRAFE_SPEED_MULT * (*move_dir - STRATE_SPIRAL_MULT * target_ori.xy()); } } else { // Aim for a point a given distance behind the target to prevent sideways // movement let move_target = tgt_data.pos.0.xy() - dist / 2. * target_ori.xy(); - controller.inputs.move_dir = (move_target - self.pos.0) + controller.inputs.move_dir = ((move_target - self.pos.0) * BACKSTAB_SPEED_MULT) .try_normalized() .unwrap_or_default(); } @@ -189,6 +196,10 @@ impl<'a> AgentData<'a> { tgt_data: &TargetData, read_data: &ReadData, ) { + // Behaviour parameters + const PREF_DIST: f32 = 30.0; + const RETREAT_DIST: f32 = 8.0; + let line_of_sight_with_target = || { entities_have_line_of_sight( self.pos, @@ -200,15 +211,14 @@ impl<'a> AgentData<'a> { read_data, ) }; - let elevation = self.pos.0.z - tgt_data.pos.0.z; - const PREF_DIST: f32 = 30_f32; + if attack_data.angle_xy < 30.0 && (elevation > 10.0 || attack_data.dist_sqrd > PREF_DIST.powi(2)) && line_of_sight_with_target() { controller.push_basic_input(InputKind::Primary); - } else if attack_data.dist_sqrd < (PREF_DIST / 2.).powi(2) { + } else if attack_data.dist_sqrd < RETREAT_DIST.powi(2) { // Attempt to move quickly away from target if too close if let Some((bearing, _)) = agent.chaser.chase( &*read_data.terrain,