More phoenix AI work

More phoenix AI work
This commit is contained in:
Snowram 2021-04-23 01:34:37 +02:00
parent 0cf7e7114f
commit 8f54a0bf31
15 changed files with 288 additions and 280 deletions

View File

@ -4,7 +4,7 @@ BasicRanged(
recover_duration: 0.3,
projectile: Arrow(
damage: 70.0,
knockback: 1.0,
knockback: 5.0,
energy_regen: 40,
),
projectile_body: Object(Arrow),

View File

@ -0,0 +1,17 @@
BasicRanged(
energy_cost: 0,
buildup_duration: 0.5,
recover_duration: 0.35,
projectile: Fireball(
damage: 100.0,
radius: 5.0,
energy_regen: 50,
),
projectile_body: Object(BoltFire),
/*projectile_light: Some(LightEmitter {
col: (1.0, 0.75, 0.11).into(),
..Default::default()
}),*/
projectile_gravity: Some(Gravity(0.15)),
projectile_speed: 60.0,
)

View File

@ -208,16 +208,17 @@
],
),
Unique(BirdLargeBreathe): (
primary: "common.abilities.unique.birdlargebreathe.flamethrower",
primary: "common.abilities.unique.birdlargebreathe.firebomb",
secondary: "common.abilities.unique.birdlargebreathe.triplestrike",
abilities: [],
abilities: [
(None, "common.abilities.unique.birdlargebreathe.flamethrower"),
],
),
Unique(BirdLargeFire): (
primary: "common.abilities.unique.birdlargefire.flamethrower",
primary: "common.abilities.unique.birdlargefire.firebomb",
secondary: "common.abilities.unique.birdlargefire.triplestrike",
abilities: [
(None, "common.abilities.staff.fireshockwave"),
(None, "common.abilities.staff.firebomb"),
(None, "common.abilities.unique.birdlargefire.fireshockwave"),
],
),
Debug: (

Binary file not shown.

View File

@ -153,7 +153,7 @@ impl Body {
let d = match self {
// based on a house sparrow (Passer domesticus)
Body::BirdMedium(_) => 700.0,
Body::BirdLarge(_) => 700.0,
Body::BirdLarge(_) => 2_200.0,
// based on its mass divided by the volume of a bird scaled up to the size of the dragon
Body::Dragon(_) => 3_700.0,
@ -184,8 +184,7 @@ impl Body {
// ravens are 0.69-2 kg, crows are 0.51 kg on average
Body::BirdMedium(_) => 1.0,
// australian magpies are around 0.22-0.35 kg
Body::BirdLarge(_) => 0.3,
Body::BirdLarge(_) => 200.0,
Body::Dragon(_) => 20_000.0,
Body::FishMedium(_) => 2.5,
@ -283,7 +282,7 @@ impl Body {
},
Body::BipedSmall(_) => Vec3::new(1.0, 0.75, 1.4),
Body::BirdMedium(_) => Vec3::new(2.0, 1.0, 1.1),
Body::BirdLarge(_) => Vec3::new(2.0, 1.0, 1.8),
Body::BirdLarge(_) => Vec3::new(2.0, 5.5, 3.8),
Body::Dragon(_) => Vec3::new(16.0, 10.0, 16.0),
Body::FishMedium(_) => Vec3::new(0.5, 2.0, 0.8),
Body::FishSmall(_) => Vec3::new(0.3, 1.2, 0.6),
@ -436,7 +435,7 @@ impl Body {
},
Body::FishMedium(_) => 50,
Body::Dragon(_) => 5000,
Body::BirdLarge(_) => 9999999,
Body::BirdLarge(_) => 3000,
Body::FishSmall(_) => 20,
Body::BipedLarge(biped_large) => match biped_large.species {
biped_large::Species::Ogre => 2500,
@ -548,7 +547,7 @@ impl Body {
},
Body::FishMedium(_) => 10,
Body::Dragon(_) => 500,
Body::BirdLarge(_) => 10,
Body::BirdLarge(_) => 120,
Body::FishSmall(_) => 10,
Body::BipedLarge(biped_large) => match biped_large.species {
biped_large::Species::Ogre => 70,

View File

@ -188,7 +188,7 @@ impl Body {
pub fn fly_thrust(&self) -> Option<f32> {
match self {
Body::BirdMedium(_) => Some(GRAVITY * self.mass().0 * 2.0),
Body::BirdLarge(_) => Some(GRAVITY * self.mass().0 * 3.0),
Body::BirdLarge(_) => Some(GRAVITY * self.mass().0 * 0.5),
Body::Dragon(_) => Some(200_000.0),
Body::Ship(ship::Body::DefaultAirship) => Some(300_000.0),
_ => None,

View File

@ -38,12 +38,18 @@ impl Entity {
match self.rng(PERM_GENUS).gen::<f32>() {
// we want 5% airships, 45% birds, 50% humans
x if x < 0.05 => comp::Body::Ship(comp::ship::Body::DefaultAirship),
x if x < 0.50 => {
x if x < 0.45 => {
let species = *(&comp::bird_medium::ALL_SPECIES)
.choose(&mut self.rng(PERM_SPECIES))
.unwrap();
comp::bird_medium::Body::random_with(&mut self.rng(PERM_BODY), &species).into()
},
x if x < 0.50 => {
let species = *(&comp::bird_large::ALL_SPECIES)
.choose(&mut self.rng(PERM_SPECIES))
.unwrap();
comp::bird_large::Body::random_with(&mut self.rng(PERM_BODY), &species).into()
},
_ => {
let species = *(&comp::humanoid::ALL_SPECIES)
.choose(&mut self.rng(PERM_SPECIES))
@ -60,7 +66,7 @@ impl Entity {
comp::Body::BirdMedium(b) => {
get_npc_name(&npc_names.bird_medium, b.species).to_string()
},
comp::Body::BirdLarge(_) => "Warbler".to_string(),
comp::Body::BirdLarge(b) => get_npc_name(&npc_names.bird_large, b.species).to_string(),
comp::Body::Dragon(b) => get_npc_name(&npc_names.dragon, b.species).to_string(),
comp::Body::Humanoid(b) => get_npc_name(&npc_names.humanoid, b.species).to_string(),
comp::Body::Ship(_) => "Veloren Air".to_string(),

View File

@ -2590,6 +2590,137 @@ impl<'a> AgentData<'a> {
}
},
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 random chance and can see target
if thread_rng().gen_bool(0.05)
&& can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd)
{
// Fireball
controller
.actions
.push(ControlAction::basic_input(InputKind::Primary));
}
// If some target
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
self.pos.0,
self.vel.0,
tgt_pos.0,
TraversalConfig {
min_tgt_dist: 1.25,
..self.traversal_config
},
) {
// Walk to target
controller.inputs.move_dir =
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
// If less than 20 blocks higher than target
if (self.pos.0.z - tgt_pos.0.z) < 20.0 {
// Fly upward
controller
.actions
.push(ControlAction::basic_input(InputKind::Fly));
controller
.actions
.push(ControlAction::basic_input(InputKind::Jump));
controller.inputs.move_z = 1.0;
} else {
// Jump
self.jump_if(controller, bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
}
}
// If higher than 2 blocks
else if !read_data
.terrain
.ray(self.pos.0, self.pos.0 - (Vec3::unit_z() * 2.0))
.until(Block::is_solid)
.cast()
.1
.map_or(true, |b| b.is_some())
{
// Do not increment the timer during this movement
// The next stage shouldn't trigger until the entity
// is on the ground
// Fly to target
controller
.actions
.push(ControlAction::basic_input(InputKind::Fly));
let move_dir = tgt_pos.0 - self.pos.0;
controller.inputs.move_dir =
move_dir.xy().try_normalized().unwrap_or_else(Vec2::zero) * 2.0;
controller.inputs.move_z = move_dir.z - 0.5;
// If further than 4 blocks and random chance
if thread_rng().gen_bool(0.05) && dist_sqrd > (4.0 * min_attack_dist).powi(2) {
// Fireball
controller
.actions
.push(ControlAction::basic_input(InputKind::Primary));
}
}
// 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)
{
// Fireball
controller
.actions
.push(ControlAction::basic_input(InputKind::Primary));
}
// If random chance and less than 20 blocks higher than target and further than 4
// blocks
else if thread_rng().gen_bool(0.5)
&& (self.pos.0.z - tgt_pos.0.z) < 15.0
&& dist_sqrd > (4.0 * min_attack_dist).powi(2)
{
controller
.actions
.push(ControlAction::basic_input(InputKind::Fly));
controller
.actions
.push(ControlAction::basic_input(InputKind::Jump));
controller.inputs.move_z = 1.0;
}
// If further than 2.5 blocks and random chance
else if dist_sqrd > (2.5 * min_attack_dist).powi(2) {
// If some target
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
self.pos.0,
self.vel.0,
tgt_pos.0,
TraversalConfig {
min_tgt_dist: 1.25,
..self.traversal_config
},
) {
// Walk to target
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;
}
}
// If energy higher than 600 and random chance
else if self.energy.current() > 600 && thread_rng().gen_bool(0.4) {
// Shockwave
controller
.actions
.push(ControlAction::basic_input(InputKind::Ability(0)));
} else {
// Triple strike
controller
.actions
.push(ControlAction::basic_input(InputKind::Secondary));
}
},
// Mostly identical to BirdLargeFire but tweaked for flamethrower instead of shockwave
Tactic::BirdLargeBreathe => {
// Set fly to false
controller
.actions
@ -2600,7 +2731,7 @@ impl<'a> AgentData<'a> {
{
controller
.actions
.push(ControlAction::basic_input(InputKind::Ability(1)));
.push(ControlAction::basic_input(InputKind::Primary));
}
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
@ -2612,7 +2743,6 @@ impl<'a> AgentData<'a> {
..self.traversal_config
},
) {
dbg!("fly towards target");
controller.inputs.move_dir =
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed;
if (self.pos.0.z - tgt_pos.0.z) < 20.0 {
@ -2628,197 +2758,46 @@ impl<'a> AgentData<'a> {
controller.inputs.move_z = bearing.z;
}
}
} else if agent.action_timer < 3.0 {
if thread_rng().gen_bool(0.1) {
if thread_rng().gen_bool(0.5) {
controller
.actions
.push(ControlAction::basic_input(InputKind::Ability(1)));
}
} else if thread_rng().gen_bool(0.5) && (self.pos.0.z - tgt_pos.0.z) < 15.0 {
dbg!("fly");
controller
.actions
.push(ControlAction::basic_input(InputKind::Fly));
controller
.actions
.push(ControlAction::basic_input(InputKind::Jump));
controller.inputs.move_z = 1.0;
}
agent.action_timer += dt.0;
} else if !self.physics_state.on_ground {
} else if !read_data
.terrain
.ray(self.pos.0, self.pos.0 - (Vec3::unit_z() * 2.0))
.until(Block::is_solid)
.cast()
.1
.map_or(true, |b| b.is_some())
{
// Do not increment the timer during this movement
// The next stage shouldn't trigger until the entity
// is on the ground
controller
.actions
.push(ControlAction::basic_input(InputKind::Fly));
dbg!("fly to player2");
let move_dir = tgt_pos.0 - self.pos.0;
controller.inputs.move_dir =
move_dir.xy().try_normalized().unwrap_or_else(Vec2::zero) * 2.0;
controller.inputs.move_z = move_dir.z - 0.5;
} else if agent.action_timer < 7.0 {
if dist_sqrd < (2.5 * min_attack_dist).powi(2) {
if self.energy.current() > 600 && thread_rng().gen_bool(0.3) {
dbg!("shockwave");
controller
.actions
.push(ControlAction::basic_input(InputKind::Ability(0)));
} else {
dbg!("triple strike");
controller
.actions
.push(ControlAction::basic_input(InputKind::Secondary));
}
} else {
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
self.pos.0,
self.vel.0,
tgt_pos.0,
TraversalConfig {
min_tgt_dist: 1.25,
..self.traversal_config
},
) {
if thread_rng().gen_bool(0.2)
&& can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd)
{
dbg!("fireball1");
controller
.actions
.push(ControlAction::basic_input(InputKind::Ability(1)));
agent.action_timer = 0.0;
}
dbg!("walk to player1");
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;
}
if thread_rng().gen_bool(0.05) && dist_sqrd > (4.0 * min_attack_dist).powi(2) {
controller
.actions
.push(ControlAction::basic_input(InputKind::Primary));
}
agent.action_timer += dt.0;
}
if agent.action_timer > 7.0 {
agent.action_timer = 0.0;
}
/*
} else {
if read_data
.terrain
.ray(self.pos.0, self.pos.0 - (Vec3::unit_z() * 5.0))
.until(Block::is_solid)
.cast()
.1
.map_or(true, |b| b.is_some())
{
controller.inputs.move_z = 1.0;
}
if self.energy.current() > 50 {
if thread_rng().gen_bool(0.99) {
if dist_sqrd < (3.5 * min_attack_dist).powi(2) {
dbg!("flamethrower1");
controller
.actions
.push(ControlAction::basic_input(InputKind::Primary));
} else {
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
self.pos.0,
self.vel.0,
tgt_pos.0,
TraversalConfig {
min_tgt_dist: 1.25,
..self.traversal_config
},
) {
if can_see_tgt(&*terrain, self.pos, tgt_pos, dist_sqrd) {
if agent.action_timer > 3.0 {
dbg!("fireball2");
controller.actions.push(ControlAction::basic_input(
InputKind::Ability(1),
));
agent.action_timer = 0.0;
} else {
dbg!("fly to player1");
controller.inputs.move_dir = bearing
.xy()
.rotated_z(thread_rng().gen_range(-1.57..-0.5))
.try_normalized()
.unwrap_or_else(Vec2::zero)
* speed;
agent.action_timer += dt.0;
}
} else {
dbg!("fly to player2");
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;
}
}
}
} else {
dbg!("land1");
controller.inputs.move_z = -1.0;
controller
.actions
.push(ControlAction::CancelInput(InputKind::Fly));
}
} else {
if dist_sqrd < (2.5 * min_attack_dist).powi(2) {
dbg!("land2");
controller.inputs.move_z = -1.0;
controller
.actions
.push(ControlAction::CancelInput(InputKind::Fly));
} else {
dbg!("fly to player");
}
}
}
*/
},
Tactic::BirdLargeBreathe => {
if dist_sqrd < (2.5 * min_attack_dist).powi(2) {
controller.inputs.move_dir = Vec2::zero();
} else if thread_rng().gen_bool(0.05) && dist_sqrd > (4.0 * min_attack_dist).powi(2)
{
controller
.actions
.push(ControlAction::basic_input(InputKind::Secondary));
} else if dist_sqrd < (7.0 * min_attack_dist).powi(2) {
if agent.action_timer < 2.0 {
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
.xy()
.rotated_z(0.47 * PI)
.try_normalized()
.unwrap_or_else(Vec2::unit_y);
controller
.actions
.push(ControlAction::basic_input(InputKind::Primary));
agent.action_timer += dt.0;
} else if agent.action_timer < 4.0 {
controller.inputs.move_dir = (tgt_pos.0 - self.pos.0)
.xy()
.rotated_z(-0.47 * PI)
.try_normalized()
.unwrap_or_else(Vec2::unit_y);
controller
.actions
.push(ControlAction::basic_input(InputKind::Primary));
agent.action_timer += dt.0;
} else if agent.action_timer < 6.0 {
controller
.actions
.push(ControlAction::basic_input(InputKind::Ability(0)));
agent.action_timer += dt.0;
} else {
agent.action_timer = 0.0;
}
} else if dist_sqrd < MAX_CHASE_DIST.powi(2) {
.push(ControlAction::basic_input(InputKind::Primary));
} else if thread_rng().gen_bool(0.5)
&& (self.pos.0.z - tgt_pos.0.z) < 15.0
&& dist_sqrd > (4.0 * min_attack_dist).powi(2)
{
controller
.actions
.push(ControlAction::basic_input(InputKind::Fly));
controller
.actions
.push(ControlAction::basic_input(InputKind::Jump));
controller.inputs.move_z = 1.0;
} else if dist_sqrd > (3.0 * min_attack_dist).powi(2) {
if let Some((bearing, speed)) = agent.chaser.chase(
&*terrain,
self.pos.0,
@ -2834,8 +2813,18 @@ impl<'a> AgentData<'a> {
self.jump_if(controller, bearing.z > 1.5);
controller.inputs.move_z = bearing.z;
}
} else if self.energy.current() > 600 && agent.action_timer < 3.0 {
controller
.actions
.push(ControlAction::basic_input(InputKind::Ability(0)));
agent.action_timer += dt.0;
} else if agent.action_timer < 6.0 {
controller
.actions
.push(ControlAction::basic_input(InputKind::Secondary));
agent.action_timer += dt.0;
} else {
agent.target = None;
agent.action_timer = 0.0;
}
},
}

View File

@ -7,7 +7,7 @@ use common::states::utils::StageSection;
pub struct AlphaAnimation;
impl Animation for AlphaAnimation {
type Dependency = (Option<StageSection>, Vec3<f32>, Vec3<f32>, f32, f32);
type Dependency = (Option<StageSection>, Vec3<f32>, Vec3<f32>, bool);
type Skeleton = BirdLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -16,7 +16,7 @@ impl Animation for AlphaAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_alpha")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(stage_section, orientation, last_ori, _global_time, _timer): Self::Dependency,
(stage_section, orientation, last_ori, on_ground): Self::Dependency,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
@ -73,28 +73,35 @@ impl Animation for AlphaAnimation {
next.beak.position = Vec3::new(0.0, s_a.beak.0, s_a.beak.1);
next.beak.orientation = Quaternion::rotation_x(wave_slow_cos * -0.02 - 0.02);
next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
next.tail_front.orientation = Quaternion::rotation_x(-move1 * 0.2);
next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
next.tail_rear.orientation = Quaternion::rotation_x(0.0);
if on_ground {
next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
next.tail_front.orientation = Quaternion::rotation_x(-move1 * 0.2);
next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
next.tail_rear.orientation = Quaternion::rotation_x(0.0);
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_l.orientation =
Quaternion::rotation_y(-1.0 + wave_slow_cos * 0.06) * Quaternion::rotation_z(0.2);
next.wing_in_r.orientation =
Quaternion::rotation_y(1.0 - wave_slow_cos * 0.06) * Quaternion::rotation_z(-0.2);
next.wing_in_l.orientation =
Quaternion::rotation_y(-1.0 + wave_slow_cos * 0.06) * Quaternion::rotation_z(0.2);
next.wing_in_r.orientation =
Quaternion::rotation_y(1.0 - wave_slow_cos * 0.06) * Quaternion::rotation_z(-0.2);
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_l.orientation = Quaternion::rotation_y(-0.1) * Quaternion::rotation_z(0.7);
next.wing_mid_r.orientation = Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-0.7);
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_l.orientation =
Quaternion::rotation_y(-0.1) * Quaternion::rotation_z(0.7);
next.wing_mid_r.orientation =
Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-0.7);
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_l.orientation = Quaternion::rotation_y(-0.2) * Quaternion::rotation_z(0.2);
next.wing_out_r.orientation = Quaternion::rotation_y(0.2) * Quaternion::rotation_z(-0.2);
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_l.orientation =
Quaternion::rotation_y(-0.2) * Quaternion::rotation_z(0.2);
next.wing_out_r.orientation =
Quaternion::rotation_y(0.2) * Quaternion::rotation_z(-0.2);
} else {
}
next
}

View File

@ -7,7 +7,6 @@ use common::{states::utils::StageSection, util::Dir};
pub struct BreatheAnimation;
type BreatheAnimationDependency = (
f32,
f32,
Vec3<f32>,
Vec3<f32>,
@ -27,7 +26,7 @@ impl Animation for BreatheAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_breathe")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_velocity, global_time, orientation, last_ori, stage_section, timer, look_dir, on_ground): Self::Dependency,
(global_time, orientation, last_ori, stage_section, timer, look_dir, on_ground): Self::Dependency,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,

View File

@ -8,7 +8,7 @@ pub struct ShockwaveAnimation;
impl Animation for ShockwaveAnimation {
#[allow(clippy::type_complexity)]
type Dependency = (f32, f32, Option<StageSection>);
type Dependency = (Option<StageSection>, bool);
type Skeleton = BirdLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -17,7 +17,7 @@ impl Animation for ShockwaveAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_shockwave")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_global_time, _velocity, stage_section): Self::Dependency,
(stage_section, on_ground): Self::Dependency,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
@ -64,35 +64,42 @@ impl Animation for ShockwaveAnimation {
next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
next.tail_rear.orientation = Quaternion::rotation_x(-0.2);
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
if on_ground {
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_l.orientation =
Quaternion::rotation_y(-0.8 + movement1abs * 1.6 + movement2abs * -1.6)
* Quaternion::rotation_z(0.2 + movement1abs * -0.8);
next.wing_in_r.orientation =
Quaternion::rotation_y(0.8 + movement1abs * -1.6 + movement2abs * 1.6)
* Quaternion::rotation_z(-0.2 + movement1abs * 0.8);
next.wing_in_l.orientation =
Quaternion::rotation_y(-0.8 + movement1abs * 1.6 + movement2abs * -1.6)
* Quaternion::rotation_z(0.2 + movement1abs * -0.8);
next.wing_in_r.orientation =
Quaternion::rotation_y(0.8 + movement1abs * -1.6 + movement2abs * 1.6)
* Quaternion::rotation_z(-0.2 + movement1abs * 0.8);
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_l.orientation = Quaternion::rotation_y(-0.1) * Quaternion::rotation_z(0.7);
next.wing_mid_r.orientation = Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-0.7);
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_l.orientation =
Quaternion::rotation_y(-0.1) * Quaternion::rotation_z(0.7);
next.wing_mid_r.orientation =
Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-0.7);
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_l.orientation = Quaternion::rotation_y(-0.4) * Quaternion::rotation_z(0.2);
next.wing_out_r.orientation = Quaternion::rotation_y(0.4) * Quaternion::rotation_z(-0.2);
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_l.orientation =
Quaternion::rotation_y(-0.4) * Quaternion::rotation_z(0.2);
next.wing_out_r.orientation =
Quaternion::rotation_y(0.4) * Quaternion::rotation_z(-0.2);
next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2) / 8.0;
next.leg_l.orientation = Quaternion::rotation_x(0.0);
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2) / 8.0;
next.leg_r.orientation = Quaternion::rotation_x(0.0);
next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2) / 8.0;
next.leg_l.orientation = Quaternion::rotation_x(0.0);
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2) / 8.0;
next.leg_r.orientation = Quaternion::rotation_x(0.0);
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(0.0);
next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(0.0);
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(0.0);
next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(0.0);
} else {
}
next
}

View File

@ -27,7 +27,16 @@ impl Animation for ShootAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_shoot")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_velocity, global_time, orientation, last_ori, stage_section, timer, look_dir, on_ground): Self::Dependency,
(
_velocity,
global_time,
_orientation,
_last_ori,
stage_section,
timer,
look_dir,
on_ground,
): Self::Dependency,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
@ -67,9 +76,6 @@ impl Animation for ShootAnimation {
) * s_a.scaler
/ 8.0;
next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
next.neck.orientation = Quaternion::rotation_x(movement1abs * 0.5 - movement2abs * 0.5);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation =
Quaternion::rotation_x(movement1abs * 0.5 - movement2abs * 0.5 + look_dir.z * 0.4);
@ -78,6 +84,9 @@ impl Animation for ShootAnimation {
next.beak.orientation = Quaternion::rotation_x(movement1abs * -0.7 + twitch2 * 0.1);
if on_ground {
next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
next.neck.orientation = Quaternion::rotation_x(movement1abs * 0.5 - movement2abs * 0.5);
next.chest.orientation =
Quaternion::rotation_x(movement1abs * 0.1 - movement2abs * 0.1);
@ -112,23 +121,6 @@ impl Animation for ShootAnimation {
next.tail_rear.orientation =
Quaternion::rotation_x(-movement1abs * 0.1 + movement2abs * 0.1 + twitch2 * 0.02);
} else {
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()
&& ori.angle_between(last_ori).is_finite()
{
ori.angle_between(last_ori).min(0.2)
* last_ori.determine_side(Vec2::zero(), ori).signum()
} else {
0.0
} * 1.3;
next.chest.orientation =
Quaternion::rotation_x(movement1abs * 0.1 - movement2abs * 0.1)
* Quaternion::rotation_y(tilt * 1.8);
}
next

View File

@ -8,7 +8,7 @@ pub struct SwimAnimation;
impl Animation for SwimAnimation {
#[allow(clippy::type_complexity)]
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f32);
type Dependency = f32;
type Skeleton = BirdLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -17,7 +17,7 @@ impl Animation for SwimAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_swim")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_velocity, _orientation, _last_ori, global_time): Self::Dependency,
global_time: Self::Dependency,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,

View File

@ -3335,13 +3335,7 @@ impl FigureMgr {
// Swim
(_, true, _) => anim::bird_large::SwimAnimation::update_skeleton(
&BirdLargeSkeleton::default(),
(
rel_vel,
// TODO: Update to use the quaternion.
ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
time,
),
time,
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -3380,7 +3374,6 @@ impl FigureMgr {
anim::bird_large::BreatheAnimation::update_skeleton(
&target_base,
(
rel_vel.magnitude(),
time,
ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
@ -3425,8 +3418,7 @@ impl FigureMgr {
Some(s.stage_section),
ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
time,
state.state_time,
physics.on_ground,
),
stage_progress,
&mut state_animation_rate,
@ -3479,7 +3471,7 @@ impl FigureMgr {
};
anim::bird_large::ShockwaveAnimation::update_skeleton(
&target_base,
(time, rel_vel.magnitude(), Some(s.stage_section)),
(Some(s.stage_section), physics.on_ground),
stage_progress,
&mut state_animation_rate,
skeleton_attr,

View File

@ -522,7 +522,6 @@ impl PlayState for SessionState {
select_pos,
target_entity.map(|t| t.0),
);
dbg!(self.key_state.fly);
},
GameInput::Climb => {
self.key_state.climb_up = state;