mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'james/fix-bird-auto-fly' into 'master'
Set bird default to not flying and give non-strafing NPCs a larger attack angle See merge request veloren/veloren!2209
This commit is contained in:
commit
5948025327
@ -242,18 +242,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
can_fly: body.map(|b| b.fly_thrust().is_some()).unwrap_or(false),
|
can_fly: body.map(|b| b.fly_thrust().is_some()).unwrap_or(false),
|
||||||
};
|
};
|
||||||
|
|
||||||
if traversal_config.can_fly {
|
|
||||||
// hack (kinda): Never turn off flight for entities that can fly at all,
|
|
||||||
// since it results in stuttering and falling back to the ground.
|
|
||||||
|
|
||||||
// If we need to be able to have entities (dragons maybe?) both fly and
|
|
||||||
// run/jump, we probably need to refactor to avoid resetting the controller
|
|
||||||
// every frame.
|
|
||||||
controller
|
|
||||||
.actions
|
|
||||||
.push(ControlAction::basic_input(InputKind::Fly));
|
|
||||||
}
|
|
||||||
|
|
||||||
let flees = alignment
|
let flees = alignment
|
||||||
.map(|a| !matches!(a, Alignment::Enemy | Alignment::Owned(_)))
|
.map(|a| !matches!(a, Alignment::Enemy | Alignment::Owned(_)))
|
||||||
.unwrap_or(true);
|
.unwrap_or(true);
|
||||||
@ -263,6 +251,14 @@ impl<'a> System<'a> for Sys {
|
|||||||
.get(entity)
|
.get(entity)
|
||||||
.and_then(|rtsim_ent| rtsim.get_entity(rtsim_ent.0));
|
.and_then(|rtsim_ent| rtsim.get_entity(rtsim_ent.0));
|
||||||
|
|
||||||
|
if traversal_config.can_fly && rtsim_entity.is_some() {
|
||||||
|
// hack (kinda): Never turn off flight for rtsim entities that can fly
|
||||||
|
// at all, since it results in stuttering and falling back to the ground.
|
||||||
|
controller
|
||||||
|
.actions
|
||||||
|
.push(ControlAction::basic_input(InputKind::Fly));
|
||||||
|
}
|
||||||
|
|
||||||
// Package all this agent's data into a convenient struct
|
// Package all this agent's data into a convenient struct
|
||||||
let data = AgentData {
|
let data = AgentData {
|
||||||
entity: &entity,
|
entity: &entity,
|
||||||
@ -2049,7 +2045,7 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::StoneGolemBoss => {
|
Tactic::StoneGolemBoss => {
|
||||||
if dist_sqrd < min_attack_dist.powi(2) && angle < 45.0 {
|
if dist_sqrd < min_attack_dist.powi(2) && angle < 90.0 {
|
||||||
// 2.0 is temporary correction factor to allow them to melee with their
|
// 2.0 is temporary correction factor to allow them to melee with their
|
||||||
// large hitbox
|
// large hitbox
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
@ -2073,7 +2069,7 @@ impl<'a> AgentData<'a> {
|
|||||||
..self.traversal_config
|
..self.traversal_config
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) && angle < 45.0 {
|
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) && angle < 90.0 {
|
||||||
controller.inputs.move_dir =
|
controller.inputs.move_dir =
|
||||||
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
|
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
|
||||||
if agent.action_timer > 5.0 {
|
if agent.action_timer > 5.0 {
|
||||||
@ -2099,8 +2095,7 @@ impl<'a> AgentData<'a> {
|
|||||||
radius,
|
radius,
|
||||||
circle_time,
|
circle_time,
|
||||||
} => {
|
} => {
|
||||||
if dist_sqrd < min_attack_dist.powi(2) && thread_rng().gen_bool(0.5) && angle < 45.0
|
if dist_sqrd < min_attack_dist.powi(2) && thread_rng().gen_bool(0.5) {
|
||||||
{
|
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2134,7 +2129,7 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
controller.inputs.move_dir = move_dir;
|
controller.inputs.move_dir = move_dir;
|
||||||
agent.action_timer += dt.0;
|
agent.action_timer += dt.0;
|
||||||
} else if agent.action_timer < circle_time as f32 + 0.5 && angle < 45.0 {
|
} else if agent.action_timer < circle_time as f32 + 0.5 {
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||||
@ -2160,7 +2155,7 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
controller.inputs.move_dir = move_dir;
|
controller.inputs.move_dir = move_dir;
|
||||||
agent.action_timer += dt.0;
|
agent.action_timer += dt.0;
|
||||||
} else if agent.action_timer < 2.0 * circle_time as f32 + 1.0 && angle < 45.0 {
|
} else if agent.action_timer < 2.0 * circle_time as f32 + 1.0 {
|
||||||
if agent.action_timer < 2.0 * circle_time as f32 {
|
if agent.action_timer < 2.0 * circle_time as f32 {
|
||||||
agent.action_timer = 2.0 * circle_time as f32;
|
agent.action_timer = 2.0 * circle_time as f32;
|
||||||
}
|
}
|
||||||
@ -2192,7 +2187,7 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::QuadLowRanged => {
|
Tactic::QuadLowRanged => {
|
||||||
if dist_sqrd < (3.0 * min_attack_dist).powi(2) && angle < 45.0 {
|
if dist_sqrd < (3.0 * min_attack_dist).powi(2) && angle < 90.0 {
|
||||||
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
|
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
|
||||||
.xy()
|
.xy()
|
||||||
.try_normalized()
|
.try_normalized()
|
||||||
@ -2250,7 +2245,7 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::TailSlap => {
|
Tactic::TailSlap => {
|
||||||
if dist_sqrd < (1.5 * min_attack_dist).powi(2) && angle < 45.0 {
|
if dist_sqrd < (1.5 * min_attack_dist).powi(2) && angle < 90.0 {
|
||||||
if agent.action_timer > 4.0 {
|
if agent.action_timer > 4.0 {
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2293,14 +2288,14 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::QuadLowQuick => {
|
Tactic::QuadLowQuick => {
|
||||||
if dist_sqrd < (1.5 * min_attack_dist).powi(2) && angle < 45.0 {
|
if dist_sqrd < (1.5 * min_attack_dist).powi(2) && angle < 90.0 {
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||||
} else if dist_sqrd < (3.0 * min_attack_dist).powi(2)
|
} else if dist_sqrd < (3.0 * min_attack_dist).powi(2)
|
||||||
&& dist_sqrd > (2.0 * min_attack_dist).powi(2)
|
&& dist_sqrd > (2.0 * min_attack_dist).powi(2)
|
||||||
&& angle < 45.0
|
&& angle < 90.0
|
||||||
{
|
{
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2335,12 +2330,12 @@ impl<'a> AgentData<'a> {
|
|||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
if agent.action_timer > 5.0 {
|
if agent.action_timer > 5.0 {
|
||||||
agent.action_timer = 0.0;
|
agent.action_timer = 0.0;
|
||||||
} else if agent.action_timer > 2.0 && angle < 45.0 {
|
} else if agent.action_timer > 2.0 && angle < 90.0 {
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||||
agent.action_timer += dt.0;
|
agent.action_timer += dt.0;
|
||||||
} else if angle < 45.0 {
|
} else if angle < 90.0 {
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Primary));
|
.push(ControlAction::basic_input(InputKind::Primary));
|
||||||
@ -2367,7 +2362,7 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::QuadMedJump => {
|
Tactic::QuadMedJump => {
|
||||||
if dist_sqrd < (1.5 * min_attack_dist).powi(2) && angle < 45.0 {
|
if dist_sqrd < (1.5 * min_attack_dist).powi(2) && angle < 90.0 {
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2405,7 +2400,7 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::QuadMedBasic => {
|
Tactic::QuadMedBasic => {
|
||||||
if dist_sqrd < min_attack_dist.powi(2) && angle < 45.0 {
|
if dist_sqrd < min_attack_dist.powi(2) && angle < 90.0 {
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
if agent.action_timer < 2.0 {
|
if agent.action_timer < 2.0 {
|
||||||
controller
|
controller
|
||||||
@ -2441,7 +2436,7 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::Lavadrake | Tactic::QuadLowBeam => {
|
Tactic::Lavadrake | Tactic::QuadLowBeam => {
|
||||||
if dist_sqrd < (2.5 * min_attack_dist).powi(2) && angle < 45.0 {
|
if dist_sqrd < (2.5 * min_attack_dist).powi(2) && angle < 90.0 {
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2496,7 +2491,7 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::Theropod => {
|
Tactic::Theropod => {
|
||||||
if dist_sqrd < (2.0 * min_attack_dist).powi(2) && angle < 45.0 {
|
if dist_sqrd < (2.0 * min_attack_dist).powi(2) && angle < 90.0 {
|
||||||
controller.inputs.move_dir = Vec2::zero();
|
controller.inputs.move_dir = Vec2::zero();
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2633,11 +2628,6 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::BirdLargeFire => {
|
Tactic::BirdLargeFire => {
|
||||||
// Set fly to false
|
|
||||||
controller
|
|
||||||
.actions
|
|
||||||
.push(ControlAction::CancelInput(InputKind::Fly));
|
|
||||||
// If further than 30 blocks
|
|
||||||
if dist_sqrd > 30.0_f32.powi(2) {
|
if dist_sqrd > 30.0_f32.powi(2) {
|
||||||
// If random chance and can see target
|
// If random chance and can see target
|
||||||
if thread_rng().gen_bool(0.05)
|
if thread_rng().gen_bool(0.05)
|
||||||
@ -2761,7 +2751,7 @@ impl<'a> AgentData<'a> {
|
|||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||||
} else if angle < 45.0 {
|
} else if angle < 90.0 {
|
||||||
// Triple strike
|
// Triple strike
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2873,7 +2863,7 @@ impl<'a> AgentData<'a> {
|
|||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||||
agent.action_timer += dt.0;
|
agent.action_timer += dt.0;
|
||||||
} else if agent.action_timer < 6.0 && angle < 45.0 {
|
} else if agent.action_timer < 6.0 && angle < 90.0 {
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||||
|
Loading…
Reference in New Issue
Block a user