mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Taught adlet elder how to use leap
This commit is contained in:
parent
7739aaff78
commit
fd3c377d1c
@ -22,6 +22,6 @@ LeapMelee(
|
||||
))),
|
||||
),
|
||||
forward_leap_strength: 30.0,
|
||||
vertical_leap_strength: 25.0,
|
||||
vertical_leap_strength: 15.0,
|
||||
specifier: Some(ElderLeap),
|
||||
)
|
@ -1501,7 +1501,7 @@ impl<'a> AgentData<'a> {
|
||||
abilities,
|
||||
),
|
||||
Tactic::AdletElder => {
|
||||
self.handle_adlet_elder(agent, controller, &attack_data, tgt_data, read_data)
|
||||
self.handle_adlet_elder(agent, controller, &attack_data, tgt_data, read_data, rng)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -4723,6 +4723,7 @@ impl<'a> AgentData<'a> {
|
||||
attack_data: &AttackData,
|
||||
tgt_data: &TargetData,
|
||||
read_data: &ReadData,
|
||||
rng: &mut impl Rng,
|
||||
) {
|
||||
const TRAP_TIMER: usize = 0;
|
||||
agent.action_state.timers[TRAP_TIMER] -= read_data.dt.0;
|
||||
@ -4731,6 +4732,10 @@ impl<'a> AgentData<'a> {
|
||||
}
|
||||
let primary = self.extract_ability(AbilityInput::Primary);
|
||||
let secondary = self.extract_ability(AbilityInput::Secondary);
|
||||
let abilities = [
|
||||
self.extract_ability(AbilityInput::Auxiliary(0)),
|
||||
self.extract_ability(AbilityInput::Auxiliary(1)),
|
||||
];
|
||||
let could_use_input = |input| match input {
|
||||
InputKind::Primary => primary.as_ref().map_or(false, |p| {
|
||||
p.could_use(attack_data, self, tgt_data, read_data, 0.0)
|
||||
@ -4738,6 +4743,9 @@ impl<'a> AgentData<'a> {
|
||||
InputKind::Secondary => secondary.as_ref().map_or(false, |s| {
|
||||
s.could_use(attack_data, self, tgt_data, read_data, 0.0)
|
||||
}),
|
||||
InputKind::Ability(x) => abilities[x].as_ref().map_or(false, |a| {
|
||||
a.could_use(attack_data, self, tgt_data, read_data, 0.0)
|
||||
}),
|
||||
_ => false,
|
||||
};
|
||||
let move_forwards = if matches!(self.char_state, CharacterState::DashMelee(s) if s.stage_section != StageSection::Recover)
|
||||
@ -4750,13 +4758,25 @@ impl<'a> AgentData<'a> {
|
||||
} else if could_use_input(InputKind::Primary) {
|
||||
controller.push_basic_input(InputKind::Primary);
|
||||
false
|
||||
} else if could_use_input(InputKind::Secondary) {
|
||||
} else if could_use_input(InputKind::Secondary) && rng.gen_bool(0.5) {
|
||||
controller.push_basic_input(InputKind::Secondary);
|
||||
false
|
||||
} else if could_use_input(InputKind::Ability(1)) {
|
||||
controller.push_basic_input(InputKind::Ability(1));
|
||||
false
|
||||
} else {
|
||||
true
|
||||
};
|
||||
|
||||
if matches!(self.char_state, CharacterState::LeapMelee(_)) {
|
||||
let tgt_vec = tgt_data.pos.0.xy() - self.pos.0.xy();
|
||||
if tgt_vec.magnitude_squared() > 2_f32.powi(2) {
|
||||
if let Some(look_dir) = Dir::from_unnormalized(Vec3::from(tgt_vec)) {
|
||||
controller.inputs.look_dir = look_dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if move_forwards && attack_data.dist_sqrd > 2_f32.powi(2) {
|
||||
self.path_toward_target(
|
||||
agent,
|
||||
|
@ -603,23 +603,26 @@ impl AbilityData {
|
||||
desired_energy: f32,
|
||||
) -> bool {
|
||||
let melee_check = |range: f32, angle, forced_movement: Option<ForcedMovement>| {
|
||||
let range_inc = forced_movement.map_or(0.0, |fm| match fm {
|
||||
ForcedMovement::Forward(speed) => speed * 15.0,
|
||||
ForcedMovement::Reverse(speed) => -speed,
|
||||
let (range_inc, min_mult) = forced_movement.map_or((0.0, 0.0), |fm| match fm {
|
||||
ForcedMovement::Forward(speed) => (speed * 15.0, 1.0),
|
||||
ForcedMovement::Reverse(speed) => (-speed, 1.0),
|
||||
ForcedMovement::Leap {
|
||||
vertical, forward, ..
|
||||
} => {
|
||||
} => (
|
||||
{
|
||||
let dur = vertical * 2.0 / GRAVITY;
|
||||
// 0.75 factor to allow for fact that agent looks down as they approach, so
|
||||
// won't go as far
|
||||
forward * dur * 0.75
|
||||
},
|
||||
_ => 0.0,
|
||||
0.0,
|
||||
),
|
||||
_ => (0.0, 0.0),
|
||||
});
|
||||
let body_rad = agent_data.body.map_or(0.0, |b| b.max_radius());
|
||||
attack_data.dist_sqrd < (range + range_inc + body_rad).powi(2)
|
||||
&& attack_data.angle < angle
|
||||
&& attack_data.dist_sqrd > range_inc.powi(2)
|
||||
&& attack_data.dist_sqrd > (range_inc * min_mult).powi(2)
|
||||
};
|
||||
let energy_check = |energy: f32| {
|
||||
agent_data.energy.current() >= energy
|
||||
|
Loading…
Reference in New Issue
Block a user