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:
@ -343,18 +343,15 @@ fn default_main_tool(body: &Body) -> Item {
|
|||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
Body::BirdLarge(bird_large) => match (bird_large.species, bird_large.body_type) {
|
Body::BirdLarge(bird_large) => match (bird_large.species, bird_large.body_type) {
|
||||||
(bird_large::Species::Cockatrice, _) => Some(Item::new_from_asset_expect(
|
(bird_large::Species::Cockatrice | bird_large::Species::FlameWyvern, _) => Some(
|
||||||
"common.items.npc_weapons.unique.birdlargebreathe",
|
Item::new_from_asset_expect("common.items.npc_weapons.unique.birdlargebreathe"),
|
||||||
)),
|
),
|
||||||
(bird_large::Species::Phoenix, _) => Some(Item::new_from_asset_expect(
|
(bird_large::Species::Phoenix, _) => Some(Item::new_from_asset_expect(
|
||||||
"common.items.npc_weapons.unique.birdlargefire",
|
"common.items.npc_weapons.unique.birdlargefire",
|
||||||
)),
|
)),
|
||||||
(bird_large::Species::Roc, _) => Some(Item::new_from_asset_expect(
|
(bird_large::Species::Roc, _) => Some(Item::new_from_asset_expect(
|
||||||
"common.items.npc_weapons.unique.birdlargebasic",
|
"common.items.npc_weapons.unique.birdlargebasic",
|
||||||
)),
|
)),
|
||||||
(bird_large::Species::FlameWyvern, _) => Some(Item::new_from_asset_expect(
|
|
||||||
"common.items.npc_weapons.unique.birdlargebreathe",
|
|
||||||
)),
|
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,7 @@ use crate::{
|
|||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
utils::*,
|
utils::*,
|
||||||
},
|
},
|
||||||
|
terrain::Block,
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
util::Dir,
|
util::Dir,
|
||||||
};
|
};
|
||||||
@ -160,9 +161,16 @@ impl CharacterBehavior for Data {
|
|||||||
))
|
))
|
||||||
.prerotated(pitch)
|
.prerotated(pitch)
|
||||||
};
|
};
|
||||||
|
// Velocity relative to the current ground
|
||||||
|
let rel_vel = data.vel.0 - data.physics.ground_vel;
|
||||||
// Gets offsets
|
// Gets offsets
|
||||||
let body_offsets =
|
let body_offsets = beam_offsets(
|
||||||
beam_offsets(data.body, data.inputs.look_dir, update.ori.look_vec());
|
data.body,
|
||||||
|
data.inputs.look_dir,
|
||||||
|
update.ori.look_vec(),
|
||||||
|
rel_vel,
|
||||||
|
data.physics.on_ground,
|
||||||
|
);
|
||||||
let pos = Pos(data.pos.0 + body_offsets);
|
let pos = Pos(data.pos.0 + body_offsets);
|
||||||
|
|
||||||
// Create beam segment
|
// 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 {
|
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(_) => {
|
Body::Golem(_) => {
|
||||||
const DIR_COEFF: f32 = 2.0;
|
const DIR_COEFF: f32 = 2.0;
|
||||||
body.height() * 0.9 + look_dir.z * DIR_COEFF
|
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_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(
|
Vec3::new(
|
||||||
body_radius * ori.x * 1.1,
|
body_radius * ori.x * 1.1,
|
||||||
body_radius * ori.y * 1.1,
|
body_radius * ori.y * 1.1,
|
||||||
|
@ -1884,6 +1884,9 @@ impl<'a> AgentData<'a> {
|
|||||||
body,
|
body,
|
||||||
controller.inputs.look_dir,
|
controller.inputs.look_dir,
|
||||||
self.ori.look_vec(),
|
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(
|
let aim_to = Vec3::new(
|
||||||
|
@ -106,14 +106,16 @@ impl Animation for BreatheAnimation {
|
|||||||
next.tail_rear.orientation =
|
next.tail_rear.orientation =
|
||||||
Quaternion::rotation_x(-movement1abs * 0.1 + movement2abs * 0.1 + twitch2 * -0.2);
|
Quaternion::rotation_x(-movement1abs * 0.1 + movement2abs * 0.1 + twitch2 * -0.2);
|
||||||
} else {
|
} else {
|
||||||
if velocity.xy().magnitude() < 1.0 {
|
next.neck.orientation = Quaternion::rotation_x(
|
||||||
next.neck.orientation =
|
movement1abs * -0.4
|
||||||
Quaternion::rotation_x(movement1abs * -0.4 - movement2abs * 0.5);
|
+ movement2abs * (-0.5 + velocity.xy().magnitude() * 0.2).min(0.0),
|
||||||
|
);
|
||||||
|
|
||||||
next.head.orientation = Quaternion::rotation_x(
|
next.head.orientation = Quaternion::rotation_x(
|
||||||
movement1abs * 0.5 - movement2abs * 0.5 + look_dir.z * 0.4,
|
movement1abs * 0.5
|
||||||
);
|
+ movement2abs * (-0.5 + velocity.xy().magnitude() * 0.2).min(0.0)
|
||||||
};
|
+ look_dir.z * 0.4,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
next
|
next
|
||||||
|
@ -241,10 +241,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
|||||||
(Roc, _) => (-0.4),
|
(Roc, _) => (-0.4),
|
||||||
(FlameWyvern, _) => (-0.65),
|
(FlameWyvern, _) => (-0.65),
|
||||||
},
|
},
|
||||||
wyvern: match (body.species, body.body_type) {
|
wyvern: matches!((body.species, body.body_type), (FlameWyvern, _)),
|
||||||
(FlameWyvern, _) => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user