mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Initial ice drake AI
This commit is contained in:
parent
86803c43bf
commit
5a83f85779
@ -543,12 +543,12 @@
|
||||
),
|
||||
// TODO: Allow ability sets to expand other ability sets
|
||||
Custom("Ice Drake"): (
|
||||
primary: Simple(None, "common.abilities.custom.icedrake.triplestrike"),
|
||||
secondary: Simple(None, "common.abilities.custom.icedrake.singlestrike"),
|
||||
primary: Simple(None, "common.abilities.custom.icedrake.multi_bite"),
|
||||
secondary: Simple(None, "common.abilities.custom.icedrake.icy_bite"),
|
||||
abilities: [
|
||||
Simple(None, "common.abilities.custom.icedrake.icebombs"),
|
||||
Simple(None, "common.abilities.custom.icedrake.icebreath"),
|
||||
],
|
||||
],
|
||||
),
|
||||
Custom("Dagon"): (
|
||||
primary: Simple(None, "common.abilities.custom.dagon.dagonbombs"),
|
||||
|
@ -2,15 +2,14 @@ BasicRanged(
|
||||
energy_cost: 0,
|
||||
buildup_duration: 0.5,
|
||||
recover_duration: 0.9,
|
||||
projectile: IceBomb(
|
||||
projectile: Frostball(
|
||||
damage: 30.0,
|
||||
radius: 3.0,
|
||||
knockback: 12.0,
|
||||
min_falloff: 0.1,
|
||||
),
|
||||
projectile_body: Object(IceBomb),
|
||||
projectile_speed: 25.0,
|
||||
num_projectiles: 5,
|
||||
projectile_spread: 0.07,
|
||||
move_efficiency: 0.3,
|
||||
move_efficiency: 0.75,
|
||||
)
|
||||
|
@ -4,12 +4,12 @@ BasicBeam(
|
||||
beam_duration: 0.5,
|
||||
damage: 10.0,
|
||||
tick_rate: 3.0,
|
||||
range: 15.0,
|
||||
range: 25.0,
|
||||
max_angle: 22.5,
|
||||
damage_effect: Some(Buff((
|
||||
kind: Frozen,
|
||||
dur_secs: 10.0,
|
||||
strength: DamageFraction(0.5),
|
||||
strength: DamageFraction(0.25),
|
||||
chance: 0.25,
|
||||
))),
|
||||
energy_regen: 0,
|
||||
|
31
assets/common/abilities/custom/icedrake/icy_bite.ron
Normal file
31
assets/common/abilities/custom/icedrake/icy_bite.ron
Normal file
@ -0,0 +1,31 @@
|
||||
ComboMelee2(
|
||||
strikes: [
|
||||
(
|
||||
melee_constructor: (
|
||||
kind: Bash(
|
||||
damage: 40,
|
||||
poise: 28,
|
||||
knockback: 3,
|
||||
energy_regen: 0,
|
||||
),
|
||||
range: 2.0,
|
||||
angle: 60.0,
|
||||
damage_effect: Some(Buff((
|
||||
kind: Frozen,
|
||||
dur_secs: 10.0,
|
||||
strength: DamageFraction(0.5),
|
||||
chance: 1.0,
|
||||
))),
|
||||
),
|
||||
buildup_duration: 1.2,
|
||||
swing_duration: 0.07,
|
||||
hit_timing: 0.5,
|
||||
recover_duration: 0.8,
|
||||
movement: (
|
||||
swing: Some(Forward(3.0)),
|
||||
),
|
||||
ori_modifier: 0.6,
|
||||
),
|
||||
],
|
||||
energy_cost_per_strike: 0,
|
||||
)
|
65
assets/common/abilities/custom/icedrake/multi_bite.ron
Normal file
65
assets/common/abilities/custom/icedrake/multi_bite.ron
Normal file
@ -0,0 +1,65 @@
|
||||
ComboMelee2(
|
||||
strikes: [
|
||||
(
|
||||
melee_constructor: (
|
||||
kind: Bash(
|
||||
damage: 28,
|
||||
poise: 15,
|
||||
knockback: 3,
|
||||
energy_regen: 0,
|
||||
),
|
||||
range: 2.2,
|
||||
angle: 30.0,
|
||||
),
|
||||
buildup_duration: 1.3,
|
||||
swing_duration: 0.07,
|
||||
hit_timing: 0.5,
|
||||
recover_duration: 0.6,
|
||||
movement: (
|
||||
swing: Some(Forward(2.0)),
|
||||
),
|
||||
ori_modifier: 0.65,
|
||||
),
|
||||
(
|
||||
melee_constructor: (
|
||||
kind: Bash(
|
||||
damage: 28,
|
||||
poise: 18,
|
||||
knockback: 3,
|
||||
energy_regen: 0,
|
||||
),
|
||||
range: 2.2,
|
||||
angle: 30.0,
|
||||
),
|
||||
buildup_duration: 0.8,
|
||||
swing_duration: 0.07,
|
||||
hit_timing: 0.5,
|
||||
recover_duration: 0.6,
|
||||
movement: (
|
||||
swing: Some(Forward(1.5)),
|
||||
),
|
||||
ori_modifier: 0.65,
|
||||
),
|
||||
(
|
||||
melee_constructor: (
|
||||
kind: Bash(
|
||||
damage: 28,
|
||||
poise: 20,
|
||||
knockback: 3,
|
||||
energy_regen: 0,
|
||||
),
|
||||
range: 2.2,
|
||||
angle: 30.0,
|
||||
),
|
||||
buildup_duration: 0.8,
|
||||
swing_duration: 0.07,
|
||||
hit_timing: 0.5,
|
||||
recover_duration: 0.6,
|
||||
movement: (
|
||||
swing: Some(Forward(1.5)),
|
||||
),
|
||||
ori_modifier: 0.65,
|
||||
),
|
||||
],
|
||||
energy_cost_per_strike: 0,
|
||||
)
|
@ -1,27 +0,0 @@
|
||||
ComboMelee(
|
||||
stage_data: [
|
||||
(
|
||||
stage: 1,
|
||||
base_damage: 40.0,
|
||||
damage_increase: 0,
|
||||
base_poise_damage: 28,
|
||||
poise_damage_increase: 0,
|
||||
knockback: 3.0,
|
||||
range: 2.0,
|
||||
angle: 60.0,
|
||||
base_buildup_duration: 1.2,
|
||||
base_swing_duration: 0.07,
|
||||
hit_timing: 0.5,
|
||||
base_recover_duration: 0.8,
|
||||
forward_movement: 3.0,
|
||||
damage_kind: Crushing,
|
||||
),
|
||||
],
|
||||
initial_energy_gain: 0,
|
||||
max_energy_gain: 0,
|
||||
energy_increase: 0,
|
||||
speed_increase: 0.0,
|
||||
max_speed_increase: 0.0,
|
||||
scales_from_combo: 0,
|
||||
ori_modifier: 0.6,
|
||||
)
|
@ -1,59 +0,0 @@
|
||||
ComboMelee(
|
||||
stage_data: [
|
||||
(
|
||||
stage: 1,
|
||||
base_damage: 28.0,
|
||||
damage_increase: 0,
|
||||
base_poise_damage: 15,
|
||||
poise_damage_increase: 0,
|
||||
knockback: 3.0,
|
||||
range: 2.2,
|
||||
angle: 30.0,
|
||||
base_buildup_duration: 1.3,
|
||||
base_swing_duration: 0.07,
|
||||
hit_timing: 0.5,
|
||||
base_recover_duration: 0.6,
|
||||
forward_movement: 2.0,
|
||||
damage_kind: Crushing,
|
||||
),
|
||||
(
|
||||
stage: 2,
|
||||
base_damage: 28.0,
|
||||
damage_increase: 0,
|
||||
base_poise_damage: 18,
|
||||
poise_damage_increase: 0,
|
||||
knockback: 3.0,
|
||||
range: 2.2,
|
||||
angle: 30.0,
|
||||
base_buildup_duration: 0.8,
|
||||
base_swing_duration: 0.07,
|
||||
hit_timing: 0.5,
|
||||
base_recover_duration: 0.6,
|
||||
forward_movement: 1.5,
|
||||
damage_kind: Crushing,
|
||||
),
|
||||
(
|
||||
stage: 3,
|
||||
base_damage: 28.0,
|
||||
damage_increase: 0,
|
||||
base_poise_damage: 20,
|
||||
poise_damage_increase: 0,
|
||||
knockback: 3.0,
|
||||
range: 2.2,
|
||||
angle: 30.0,
|
||||
base_buildup_duration: 0.8,
|
||||
base_swing_duration: 0.07,
|
||||
hit_timing: 0.5,
|
||||
base_recover_duration: 0.6,
|
||||
forward_movement: 1.5,
|
||||
damage_kind: Crushing,
|
||||
),
|
||||
],
|
||||
initial_energy_gain: 0,
|
||||
max_energy_gain: 0,
|
||||
energy_increase: 0,
|
||||
speed_increase: 0.0,
|
||||
max_speed_increase: 0.0,
|
||||
scales_from_combo: 0,
|
||||
ori_modifier: 0.65,
|
||||
)
|
@ -1017,6 +1017,7 @@ impl<'a> AgentData<'a> {
|
||||
"Adlet Hunter" => Tactic::AdletHunter,
|
||||
"Adlet Icepicker" => Tactic::AdletIcepicker,
|
||||
"Adlet Tracker" => Tactic::AdletTracker,
|
||||
"Ice Drake" => Tactic::IceDrake,
|
||||
_ => Tactic::SimpleMelee,
|
||||
},
|
||||
AbilitySpec::Tool(tool_kind) => tool_tactic(*tool_kind),
|
||||
@ -1469,6 +1470,9 @@ impl<'a> AgentData<'a> {
|
||||
Tactic::AdletTracker => {
|
||||
self.handle_adlet_tracker(agent, controller, &attack_data, tgt_data, read_data)
|
||||
},
|
||||
Tactic::IceDrake => {
|
||||
self.handle_icedrake(agent, controller, &attack_data, tgt_data, read_data, rng)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4715,4 +4715,81 @@ impl<'a> AgentData<'a> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_icedrake(
|
||||
&self,
|
||||
agent: &mut Agent,
|
||||
controller: &mut Controller,
|
||||
attack_data: &AttackData,
|
||||
tgt_data: &TargetData,
|
||||
read_data: &ReadData,
|
||||
rng: &mut impl Rng,
|
||||
) {
|
||||
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)
|
||||
}),
|
||||
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,
|
||||
};
|
||||
|
||||
match self.char_state.ability_info().map(|ai| ai.input) {
|
||||
Some(input @ InputKind::Primary) => {
|
||||
if !matches!(self.char_state.stage_section(), Some(StageSection::Recover))
|
||||
&& could_use_input(input)
|
||||
{
|
||||
controller.push_basic_input(input)
|
||||
}
|
||||
},
|
||||
Some(input @ InputKind::Ability(1)) => {
|
||||
if self
|
||||
.char_state
|
||||
.timer()
|
||||
.map_or(false, |t| t.as_secs_f32() < 3.0)
|
||||
&& could_use_input(input)
|
||||
{
|
||||
controller.push_basic_input(input)
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
let move_forwards = if could_use_input(InputKind::Primary) && rng.gen_bool(0.4) {
|
||||
controller.push_basic_input(InputKind::Primary);
|
||||
false
|
||||
} else if could_use_input(InputKind::Secondary) && rng.gen_bool(0.8) {
|
||||
controller.push_basic_input(InputKind::Secondary);
|
||||
false
|
||||
} else if could_use_input(InputKind::Ability(1)) && rng.gen_bool(0.9) {
|
||||
controller.push_basic_input(InputKind::Ability(1));
|
||||
true
|
||||
} else if could_use_input(InputKind::Ability(0)) {
|
||||
controller.push_basic_input(InputKind::Ability(0));
|
||||
true
|
||||
} else {
|
||||
true
|
||||
};
|
||||
|
||||
if move_forwards && attack_data.dist_sqrd > 3_f32.powi(2) {
|
||||
self.path_toward_target(
|
||||
agent,
|
||||
controller,
|
||||
tgt_data.pos.0,
|
||||
read_data,
|
||||
Path::Separate,
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +173,7 @@ pub enum Tactic {
|
||||
BorealHammer,
|
||||
Dullahan,
|
||||
Cyclops,
|
||||
IceDrake,
|
||||
|
||||
// Adlets
|
||||
AdletHunter,
|
||||
@ -355,6 +356,12 @@ pub enum AbilityData {
|
||||
vertical_leap: f32,
|
||||
leap_dur: f32,
|
||||
},
|
||||
BasicBeam {
|
||||
energy_drain: f32,
|
||||
range: f32,
|
||||
angle: f32,
|
||||
ori_rate: f32,
|
||||
},
|
||||
}
|
||||
|
||||
impl AbilityData {
|
||||
@ -509,6 +516,18 @@ impl AbilityData {
|
||||
forward_leap: *forward_leap_strength,
|
||||
vertical_leap: *vertical_leap_strength,
|
||||
},
|
||||
BasicBeam {
|
||||
range,
|
||||
max_angle,
|
||||
ori_rate,
|
||||
energy_drain,
|
||||
..
|
||||
} => Self::BasicBeam {
|
||||
range: *range,
|
||||
angle: *max_angle,
|
||||
ori_rate: *ori_rate,
|
||||
energy_drain: *energy_drain,
|
||||
},
|
||||
_ => return None,
|
||||
};
|
||||
Some(inner)
|
||||
@ -568,6 +587,20 @@ impl AbilityData {
|
||||
read_data,
|
||||
)
|
||||
};
|
||||
let beam_check = |range: f32, angle, ori_rate: f32| {
|
||||
let angle_inc = ori_rate.to_degrees();
|
||||
attack_data.dist_sqrd < range.powi(2)
|
||||
&& attack_data.angle < angle + angle_inc
|
||||
&& entities_have_line_of_sight(
|
||||
agent_data.pos,
|
||||
agent_data.body,
|
||||
agent_data.scale,
|
||||
tgt_data.pos,
|
||||
tgt_data.body,
|
||||
tgt_data.scale,
|
||||
read_data,
|
||||
)
|
||||
};
|
||||
use AbilityData::*;
|
||||
match self {
|
||||
ComboMelee {
|
||||
@ -694,6 +727,12 @@ impl AbilityData {
|
||||
});
|
||||
melee_check(*range, *angle, forced_move) && energy_check(*energy)
|
||||
},
|
||||
BasicBeam {
|
||||
energy_drain,
|
||||
range,
|
||||
angle,
|
||||
ori_rate,
|
||||
} => beam_check(*range, *angle, *ori_rate) && energy_check(*energy_drain * 3.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
109
voxygen/anim/src/quadruped_low/combomelee.rs
Normal file
109
voxygen/anim/src/quadruped_low/combomelee.rs
Normal file
@ -0,0 +1,109 @@
|
||||
use super::{
|
||||
super::{vek::*, Animation},
|
||||
QuadrupedLowSkeleton, SkeletonAttr,
|
||||
};
|
||||
use common::states::utils::{AbilityInfo, StageSection};
|
||||
|
||||
pub struct ComboAnimation;
|
||||
impl Animation for ComboAnimation {
|
||||
type Dependency<'a> = (
|
||||
Option<&'a str>,
|
||||
Option<StageSection>,
|
||||
Option<AbilityInfo>,
|
||||
usize,
|
||||
f32,
|
||||
f32,
|
||||
);
|
||||
type Skeleton = QuadrupedLowSkeleton;
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
const UPDATE_FN: &'static [u8] = b"character_combo\0";
|
||||
|
||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_combo")]
|
||||
fn update_skeleton_inner(
|
||||
skeleton: &Self::Skeleton,
|
||||
(ability_id, stage_section, _ability_info, current_strike, global_time, timer): Self::Dependency<'_>,
|
||||
anim_time: f32,
|
||||
rate: &mut f32,
|
||||
_s_a: &SkeletonAttr,
|
||||
) -> Self::Skeleton {
|
||||
*rate = 1.0;
|
||||
let mut next = (*skeleton).clone();
|
||||
|
||||
let _multi_strike_pullback = 1.0
|
||||
- if matches!(stage_section, Some(StageSection::Recover)) {
|
||||
anim_time.powi(4)
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
for strike in 0..=current_strike {
|
||||
match ability_id {
|
||||
Some(
|
||||
"common.abilities.custom.icedrake.multi_bite"
|
||||
| "common.abilities.custom.icedrake.icy_bite",
|
||||
) => {
|
||||
let (movement1base, movement2base, movement3) = match stage_section {
|
||||
Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0),
|
||||
Some(StageSection::Action) => (1.0, anim_time.powi(4), 0.0),
|
||||
Some(StageSection::Recover) => (1.0, 1.0, anim_time),
|
||||
_ => (0.0, 0.0, 0.0),
|
||||
};
|
||||
let pullback = 1.0 - movement3;
|
||||
let subtract = global_time - timer;
|
||||
let check = subtract - subtract.trunc();
|
||||
let mirror = (check - 0.5).signum();
|
||||
let twitch3 = (mirror * movement3 * 9.0).sin();
|
||||
let movement1 = mirror * movement1base * pullback;
|
||||
let movement2 = mirror * movement2base * pullback;
|
||||
let movement1abs = movement1base * pullback;
|
||||
let movement2abs = movement2base * pullback;
|
||||
|
||||
match strike {
|
||||
0 | 2 => {
|
||||
next.head_upper.orientation = Quaternion::rotation_z(twitch3 * -0.7);
|
||||
|
||||
next.head_lower.orientation =
|
||||
Quaternion::rotation_x(movement1abs * 0.35 + movement2abs * -0.9)
|
||||
* Quaternion::rotation_y(movement1 * 0.7 + movement2 * -1.0);
|
||||
|
||||
next.jaw.orientation =
|
||||
Quaternion::rotation_x(movement1abs * -0.5 + movement2abs * 0.5);
|
||||
next.chest.orientation =
|
||||
Quaternion::rotation_y(movement1 * -0.08 + movement2 * 0.15)
|
||||
* Quaternion::rotation_z(movement1 * -0.2 + movement2 * 0.6);
|
||||
|
||||
next.tail_front.orientation = Quaternion::rotation_x(0.15)
|
||||
* Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2);
|
||||
|
||||
next.tail_rear.orientation = Quaternion::rotation_x(-0.12)
|
||||
* Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2);
|
||||
},
|
||||
1 => {
|
||||
next.head_upper.orientation = Quaternion::rotation_z(twitch3 * 0.2);
|
||||
|
||||
next.head_lower.orientation =
|
||||
Quaternion::rotation_x(movement1abs * 0.15 + movement2abs * -0.6)
|
||||
* Quaternion::rotation_y(movement1 * -0.1 + movement2 * 0.15);
|
||||
|
||||
next.jaw.orientation =
|
||||
Quaternion::rotation_x(movement1abs * -0.9 + movement2abs * 0.9);
|
||||
next.chest.orientation =
|
||||
Quaternion::rotation_y(movement1 * 0.08 + movement2 * -0.15)
|
||||
* Quaternion::rotation_z(movement1 * 0.2 + movement2 * -0.3);
|
||||
|
||||
next.tail_front.orientation = Quaternion::rotation_x(0.15)
|
||||
* Quaternion::rotation_z(movement1 * 0.4 + movement2 * 0.2);
|
||||
|
||||
next.tail_rear.orientation = Quaternion::rotation_x(-0.12)
|
||||
* Quaternion::rotation_z(movement1 * 0.4 + movement2 * 0.2);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
next
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
pub mod alpha;
|
||||
pub mod beta;
|
||||
pub mod breathe;
|
||||
pub mod combomelee;
|
||||
pub mod dash;
|
||||
pub mod idle;
|
||||
pub mod jump;
|
||||
@ -13,10 +14,10 @@ pub mod tailwhip;
|
||||
|
||||
// Reexports
|
||||
pub use self::{
|
||||
alpha::AlphaAnimation, beta::BetaAnimation, breathe::BreatheAnimation, dash::DashAnimation,
|
||||
idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation, shockwave::ShockwaveAnimation,
|
||||
shoot::ShootAnimation, spritesummon::SpriteSummonAnimation, stunned::StunnedAnimation,
|
||||
tailwhip::TailwhipAnimation,
|
||||
alpha::AlphaAnimation, beta::BetaAnimation, breathe::BreatheAnimation,
|
||||
combomelee::ComboAnimation, dash::DashAnimation, idle::IdleAnimation, jump::JumpAnimation,
|
||||
run::RunAnimation, shockwave::ShockwaveAnimation, shoot::ShootAnimation,
|
||||
spritesummon::SpriteSummonAnimation, stunned::StunnedAnimation, tailwhip::TailwhipAnimation,
|
||||
};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
|
@ -2991,6 +2991,38 @@ impl FigureMgr {
|
||||
},
|
||||
}
|
||||
},
|
||||
CharacterState::ComboMelee2(s) => {
|
||||
let timer = s.timer.as_secs_f32();
|
||||
let current_strike = s.completed_strikes % s.static_data.strikes.len();
|
||||
let strike_data = s.static_data.strikes[current_strike];
|
||||
let progress = match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
timer / strike_data.buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Action => {
|
||||
timer / strike_data.swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
timer / strike_data.recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
};
|
||||
|
||||
anim::quadruped_low::ComboAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(
|
||||
ability_id,
|
||||
Some(s.stage_section),
|
||||
Some(s.static_data.ability_info),
|
||||
current_strike,
|
||||
time,
|
||||
state.state_time,
|
||||
),
|
||||
progress,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
CharacterState::ComboMelee(s) => {
|
||||
let stage_index = (s.stage - 1) as usize;
|
||||
let stage_time = s.timer.as_secs_f32();
|
||||
|
Loading…
Reference in New Issue
Block a user