mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Bird large beam offset hack
This commit is contained in:
parent
1ad107f4a7
commit
7a73e4240b
@ -343,18 +343,15 @@ fn default_main_tool(body: &Body) -> Item {
|
||||
)),
|
||||
},
|
||||
Body::BirdLarge(bird_large) => match (bird_large.species, bird_large.body_type) {
|
||||
(bird_large::Species::Cockatrice, _) => Some(Item::new_from_asset_expect(
|
||||
"common.items.npc_weapons.unique.birdlargebreathe",
|
||||
)),
|
||||
(bird_large::Species::Cockatrice | bird_large::Species::FlameWyvern, _) => Some(
|
||||
Item::new_from_asset_expect("common.items.npc_weapons.unique.birdlargebreathe"),
|
||||
),
|
||||
(bird_large::Species::Phoenix, _) => Some(Item::new_from_asset_expect(
|
||||
"common.items.npc_weapons.unique.birdlargefire",
|
||||
)),
|
||||
(bird_large::Species::Roc, _) => Some(Item::new_from_asset_expect(
|
||||
"common.items.npc_weapons.unique.birdlargebasic",
|
||||
)),
|
||||
(bird_large::Species::FlameWyvern, _) => Some(Item::new_from_asset_expect(
|
||||
"common.items.npc_weapons.unique.birdlargebreathe",
|
||||
)),
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
|
@ -12,6 +12,7 @@ use crate::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
terrain::Block,
|
||||
uid::Uid,
|
||||
util::Dir,
|
||||
};
|
||||
@ -160,9 +161,16 @@ impl CharacterBehavior for Data {
|
||||
))
|
||||
.prerotated(pitch)
|
||||
};
|
||||
// Velocity relative to the current ground
|
||||
let rel_vel = data.vel.0 - data.physics.ground_vel;
|
||||
// Gets offsets
|
||||
let body_offsets =
|
||||
beam_offsets(data.body, data.inputs.look_dir, update.ori.look_vec());
|
||||
let body_offsets = beam_offsets(
|
||||
data.body,
|
||||
data.inputs.look_dir,
|
||||
update.ori.look_vec(),
|
||||
rel_vel,
|
||||
data.physics.on_ground,
|
||||
);
|
||||
let pos = Pos(data.pos.0 + body_offsets);
|
||||
|
||||
// Create beam segment
|
||||
@ -219,9 +227,17 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
}
|
||||
|
||||
fn height_offset(body: &Body, look_dir: Dir) -> f32 {
|
||||
fn height_offset(body: &Body, look_dir: Dir, velocity: Vec3<f32>, on_ground: Option<Block>) -> f32 {
|
||||
match body {
|
||||
Body::BirdLarge(_) => body.height() * 0.8,
|
||||
// Hack to make the beam offset correspond to the animation
|
||||
Body::BirdLarge(_) => {
|
||||
body.height() * 0.3
|
||||
+ if on_ground.is_none() {
|
||||
(2.0 - velocity.xy().magnitude() * 0.25).max(-1.0)
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
},
|
||||
Body::Golem(_) => {
|
||||
const DIR_COEFF: f32 = 2.0;
|
||||
body.height() * 0.9 + look_dir.z * DIR_COEFF
|
||||
@ -234,10 +250,15 @@ fn height_offset(body: &Body, look_dir: Dir) -> f32 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn beam_offsets(body: &Body, look_dir: Dir, ori: Vec3<f32>) -> Vec3<f32> {
|
||||
pub fn beam_offsets(
|
||||
body: &Body,
|
||||
look_dir: Dir,
|
||||
ori: Vec3<f32>,
|
||||
velocity: Vec3<f32>,
|
||||
on_ground: Option<Block>,
|
||||
) -> Vec3<f32> {
|
||||
let body_radius = body.min_radius();
|
||||
let body_offsets_z = height_offset(body, look_dir);
|
||||
|
||||
let body_offsets_z = height_offset(body, look_dir, velocity, on_ground);
|
||||
Vec3::new(
|
||||
body_radius * ori.x * 1.1,
|
||||
body_radius * ori.y * 1.1,
|
||||
|
@ -1884,6 +1884,9 @@ impl<'a> AgentData<'a> {
|
||||
body,
|
||||
controller.inputs.look_dir,
|
||||
self.ori.look_vec(),
|
||||
// Try to match animation by getting some context
|
||||
self.vel.0 - self.physics_state.ground_vel,
|
||||
self.physics_state.on_ground,
|
||||
)
|
||||
});
|
||||
let aim_to = Vec3::new(
|
||||
|
@ -106,14 +106,16 @@ impl Animation for BreatheAnimation {
|
||||
next.tail_rear.orientation =
|
||||
Quaternion::rotation_x(-movement1abs * 0.1 + movement2abs * 0.1 + twitch2 * -0.2);
|
||||
} else {
|
||||
if velocity.xy().magnitude() < 1.0 {
|
||||
next.neck.orientation =
|
||||
Quaternion::rotation_x(movement1abs * -0.4 - movement2abs * 0.5);
|
||||
next.neck.orientation = Quaternion::rotation_x(
|
||||
movement1abs * -0.4
|
||||
+ movement2abs * (-0.5 + velocity.xy().magnitude() * 0.2).min(0.0),
|
||||
);
|
||||
|
||||
next.head.orientation = Quaternion::rotation_x(
|
||||
movement1abs * 0.5 - movement2abs * 0.5 + look_dir.z * 0.4,
|
||||
);
|
||||
};
|
||||
next.head.orientation = Quaternion::rotation_x(
|
||||
movement1abs * 0.5
|
||||
+ movement2abs * (-0.5 + velocity.xy().magnitude() * 0.2).min(0.0)
|
||||
+ look_dir.z * 0.4,
|
||||
);
|
||||
}
|
||||
|
||||
next
|
||||
|
@ -241,10 +241,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Roc, _) => (-0.4),
|
||||
(FlameWyvern, _) => (-0.65),
|
||||
},
|
||||
wyvern: match (body.species, body.body_type) {
|
||||
(FlameWyvern, _) => true,
|
||||
_ => false,
|
||||
},
|
||||
wyvern: matches!((body.species, body.body_type), (FlameWyvern, _)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user