mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added angle check for new npcs.
This commit is contained in:
parent
aa344baa45
commit
201fe2a19c
@ -245,7 +245,6 @@ pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
|
|||||||
/// Updates components to move player as if theyre on ground or in air
|
/// Updates components to move player as if theyre on ground or in air
|
||||||
#[allow(clippy::assign_op_pattern)] // TODO: Pending review in #587
|
#[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 accel = if data.physics.on_ground {
|
let accel = if data.physics.on_ground {
|
||||||
data.body.base_accel()
|
data.body.base_accel()
|
||||||
} else {
|
} else {
|
||||||
|
@ -2611,6 +2611,7 @@ impl<'a> AgentData<'a> {
|
|||||||
// 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)
|
||||||
&& can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd)
|
&& can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd)
|
||||||
|
&& angle < 15.0
|
||||||
{
|
{
|
||||||
// Fireball
|
// Fireball
|
||||||
controller
|
controller
|
||||||
@ -2669,7 +2670,10 @@ impl<'a> AgentData<'a> {
|
|||||||
move_dir.xy().try_normalized().unwrap_or_else(Vec2::zero) * 2.0;
|
move_dir.xy().try_normalized().unwrap_or_else(Vec2::zero) * 2.0;
|
||||||
controller.inputs.move_z = move_dir.z - 0.5;
|
controller.inputs.move_z = move_dir.z - 0.5;
|
||||||
// If further than 4 blocks and random chance
|
// If further than 4 blocks and random chance
|
||||||
if thread_rng().gen_bool(0.05) && dist_sqrd > (4.0 * min_attack_dist).powi(2) {
|
if thread_rng().gen_bool(0.05)
|
||||||
|
&& dist_sqrd > (4.0 * min_attack_dist).powi(2)
|
||||||
|
&& angle < 15.0
|
||||||
|
{
|
||||||
// Fireball
|
// Fireball
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2677,7 +2681,9 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If further than 4 blocks and random chance
|
// If further than 4 blocks and random chance
|
||||||
else if thread_rng().gen_bool(0.05) && dist_sqrd > (4.0 * min_attack_dist).powi(2)
|
else if thread_rng().gen_bool(0.05)
|
||||||
|
&& dist_sqrd > (4.0 * min_attack_dist).powi(2)
|
||||||
|
&& angle < 15.0
|
||||||
{
|
{
|
||||||
// Fireball
|
// Fireball
|
||||||
controller
|
controller
|
||||||
@ -2724,7 +2730,7 @@ impl<'a> AgentData<'a> {
|
|||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
.push(ControlAction::basic_input(InputKind::Ability(0)));
|
||||||
} else {
|
} else if angle < 45.0 {
|
||||||
// Triple strike
|
// Triple strike
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2740,6 +2746,7 @@ impl<'a> AgentData<'a> {
|
|||||||
if dist_sqrd > 30.0_f32.powi(2) {
|
if dist_sqrd > 30.0_f32.powi(2) {
|
||||||
if thread_rng().gen_bool(0.05)
|
if thread_rng().gen_bool(0.05)
|
||||||
&& can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd)
|
&& can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd)
|
||||||
|
&& angle < 15.0
|
||||||
{
|
{
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2788,12 +2795,17 @@ impl<'a> AgentData<'a> {
|
|||||||
controller.inputs.move_dir =
|
controller.inputs.move_dir =
|
||||||
move_dir.xy().try_normalized().unwrap_or_else(Vec2::zero) * 2.0;
|
move_dir.xy().try_normalized().unwrap_or_else(Vec2::zero) * 2.0;
|
||||||
controller.inputs.move_z = move_dir.z - 0.5;
|
controller.inputs.move_z = move_dir.z - 0.5;
|
||||||
if thread_rng().gen_bool(0.05) && dist_sqrd > (4.0 * min_attack_dist).powi(2) {
|
if thread_rng().gen_bool(0.05)
|
||||||
|
&& dist_sqrd > (4.0 * min_attack_dist).powi(2)
|
||||||
|
&& angle < 15.0
|
||||||
|
{
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Primary));
|
.push(ControlAction::basic_input(InputKind::Primary));
|
||||||
}
|
}
|
||||||
} else if thread_rng().gen_bool(0.05) && dist_sqrd > (4.0 * min_attack_dist).powi(2)
|
} else if thread_rng().gen_bool(0.05)
|
||||||
|
&& dist_sqrd > (4.0 * min_attack_dist).powi(2)
|
||||||
|
&& angle < 15.0
|
||||||
{
|
{
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
@ -2825,12 +2837,12 @@ impl<'a> AgentData<'a> {
|
|||||||
self.jump_if(controller, bearing.z > 1.5);
|
self.jump_if(controller, bearing.z > 1.5);
|
||||||
controller.inputs.move_z = bearing.z;
|
controller.inputs.move_z = bearing.z;
|
||||||
}
|
}
|
||||||
} else if self.energy.current() > 600 && agent.action_timer < 3.0 {
|
} else if self.energy.current() > 600 && agent.action_timer < 3.0 && angle < 15.0 {
|
||||||
controller
|
controller
|
||||||
.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 {
|
} else if agent.action_timer < 6.0 && angle < 45.0 {
|
||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Secondary));
|
.push(ControlAction::basic_input(InputKind::Secondary));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user