Fix Gnarling Speed

This commit is contained in:
Sylv 2024-05-30 10:41:55 +00:00 committed by crabman
parent c065b689ac
commit 44a56be25b
13 changed files with 40 additions and 29 deletions

View File

@ -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,

View File

@ -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,
)),
)),

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,