mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix bow AI
This commit is contained in:
parent
faf5b40576
commit
ef38d9778f
@ -14,10 +14,10 @@ use common::{
|
|||||||
Item, ItemDesc, ItemKind,
|
Item, ItemDesc, ItemKind,
|
||||||
},
|
},
|
||||||
skills::{AxeSkill, BowSkill, HammerSkill, Skill, StaffSkill, SwordSkill},
|
skills::{AxeSkill, BowSkill, HammerSkill, Skill, StaffSkill, SwordSkill},
|
||||||
Agent, Alignment, BehaviorCapability, BehaviorState, Body, CharacterState, ControlAction,
|
Agent, Alignment, BehaviorCapability, BehaviorState, Body, CharacterAbility,
|
||||||
ControlEvent, Controller, Energy, Health, HealthChange, InputKind, Inventory,
|
CharacterState, ControlAction, ControlEvent, Controller, Energy, Health, HealthChange,
|
||||||
InventoryAction, LightEmitter, MountState, Ori, PhysicsState, Pos, Scale, SkillSet, Stats,
|
InputKind, Inventory, InventoryAction, LightEmitter, MountState, Ori, PhysicsState, Pos,
|
||||||
UnresolvedChatMsg, Vel,
|
Scale, SkillSet, Stats, UnresolvedChatMsg, Vel,
|
||||||
},
|
},
|
||||||
effect::{BuffEffect, Effect},
|
effect::{BuffEffect, Effect},
|
||||||
event::{Emitter, EventBus, ServerEvent},
|
event::{Emitter, EventBus, ServerEvent},
|
||||||
@ -1805,12 +1805,39 @@ impl<'a> AgentData<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tactic::Bow => {
|
Tactic::Bow => {
|
||||||
if self.body.map(|b| b.is_humanoid()).unwrap_or(false)
|
if dist_sqrd < (2.0 * min_attack_dist).powi(2) {
|
||||||
&& dist_sqrd < (2.0 * min_attack_dist).powi(2)
|
if self.body.map(|b| b.is_humanoid()).unwrap_or(false)
|
||||||
{
|
&& self.energy.current()
|
||||||
controller
|
> CharacterAbility::default_roll().get_energy_cost()
|
||||||
.actions
|
{
|
||||||
.push(ControlAction::basic_input(InputKind::Roll));
|
controller
|
||||||
|
.actions
|
||||||
|
.push(ControlAction::basic_input(InputKind::Roll));
|
||||||
|
} else {
|
||||||
|
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||||
|
&*terrain,
|
||||||
|
self.pos.0,
|
||||||
|
self.vel.0,
|
||||||
|
// Away from the target (ironically)
|
||||||
|
self.pos.0
|
||||||
|
+ (self.pos.0 - tgt_pos.0)
|
||||||
|
.try_normalized()
|
||||||
|
.unwrap_or_else(Vec3::unit_y)
|
||||||
|
* 50.0,
|
||||||
|
TraversalConfig {
|
||||||
|
min_tgt_dist: 1.25,
|
||||||
|
..self.traversal_config
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
controller.inputs.move_dir =
|
||||||
|
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
|
||||||
|
self.jump_if(controller, bearing.z > 1.5);
|
||||||
|
controller.inputs.move_z = bearing.z;
|
||||||
|
}
|
||||||
|
controller
|
||||||
|
.actions
|
||||||
|
.push(ControlAction::basic_input(InputKind::Primary));
|
||||||
|
}
|
||||||
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
|
||||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||||
&*terrain,
|
&*terrain,
|
||||||
|
Loading…
Reference in New Issue
Block a user