mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'juliancoffee/fix_zombie_birds' into 'master'
Wake birds up See merge request veloren/veloren!2661
This commit is contained in:
commit
aac6a35d86
@ -115,6 +115,13 @@ impl<'a> System<'a> for Sys {
|
|||||||
));
|
));
|
||||||
|
|
||||||
let rtsim_entity = Some(RtSimEntity(id));
|
let rtsim_entity = Some(RtSimEntity(id));
|
||||||
|
|
||||||
|
// TODO: this should be a bit more intelligent
|
||||||
|
let loadout = match body {
|
||||||
|
comp::Body::Humanoid(_) => entity.get_loadout(),
|
||||||
|
_ => LoadoutBuilder::new().with_default_maintool(&body).build(),
|
||||||
|
};
|
||||||
|
|
||||||
let event = match body {
|
let event = match body {
|
||||||
comp::Body::Ship(ship) => ServerEvent::CreateShip {
|
comp::Body::Ship(ship) => ServerEvent::CreateShip {
|
||||||
pos,
|
pos,
|
||||||
@ -128,10 +135,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
stats: comp::Stats::new(entity.get_name()),
|
stats: comp::Stats::new(entity.get_name()),
|
||||||
skill_set: comp::SkillSet::default(),
|
skill_set: comp::SkillSet::default(),
|
||||||
health: Some(comp::Health::new(body, 10)),
|
health: Some(comp::Health::new(body, 10)),
|
||||||
loadout: match body {
|
loadout,
|
||||||
comp::Body::Humanoid(_) => entity.get_loadout(),
|
|
||||||
_ => LoadoutBuilder::new().build(),
|
|
||||||
},
|
|
||||||
poise: comp::Poise::new(body),
|
poise: comp::Poise::new(body),
|
||||||
body,
|
body,
|
||||||
agent,
|
agent,
|
||||||
|
@ -60,6 +60,7 @@ struct AgentData<'a> {
|
|||||||
body: Option<&'a Body>,
|
body: Option<&'a Body>,
|
||||||
inventory: &'a Inventory,
|
inventory: &'a Inventory,
|
||||||
skill_set: &'a SkillSet,
|
skill_set: &'a SkillSet,
|
||||||
|
#[allow(dead_code)] // may be useful for pathing
|
||||||
physics_state: &'a PhysicsState,
|
physics_state: &'a PhysicsState,
|
||||||
alignment: Option<&'a Alignment>,
|
alignment: Option<&'a Alignment>,
|
||||||
traversal_config: TraversalConfig,
|
traversal_config: TraversalConfig,
|
||||||
@ -492,10 +493,19 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// If falling fast and can glide, save yourself!
|
// Falling damage starts from 30.0 as of time of writing
|
||||||
if data.glider_equipped && data.physics_state.on_ground.is_none() {
|
// But keep in mind our 25 m/s gravity
|
||||||
// toggle glider when vertical velocity is above some
|
let is_falling_dangerous = data.vel.0.z < -20.0;
|
||||||
// threshold (here ~ glider fall vertical speed)
|
|
||||||
|
// If falling velocity is critical, throw everything
|
||||||
|
// and save yourself!
|
||||||
|
//
|
||||||
|
// If can fly - fly.
|
||||||
|
// If have glider - glide.
|
||||||
|
// Else, rest in peace.
|
||||||
|
if is_falling_dangerous && data.traversal_config.can_fly {
|
||||||
|
data.fly_upward(controller)
|
||||||
|
} else if is_falling_dangerous && data.glider_equipped {
|
||||||
data.glider_fall(controller);
|
data.glider_fall(controller);
|
||||||
} else if let Some(target_info) = agent.target {
|
} else if let Some(target_info) = agent.target {
|
||||||
let Target {
|
let Target {
|
||||||
@ -695,7 +705,6 @@ impl<'a> AgentData<'a> {
|
|||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
|
||||||
fn glider_fall(&self, controller: &mut Controller) {
|
fn glider_fall(&self, controller: &mut Controller) {
|
||||||
if self.vel.0.z < -15.0 {
|
|
||||||
controller.actions.push(ControlAction::GlideWield);
|
controller.actions.push(ControlAction::GlideWield);
|
||||||
|
|
||||||
let flight_direction =
|
let flight_direction =
|
||||||
@ -710,9 +719,14 @@ impl<'a> AgentData<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let (_, look_dir) = look_dir.into_scalar_and_vec3();
|
let (_, look_dir) = look_dir.into_scalar_and_vec3();
|
||||||
controller.inputs.look_dir =
|
controller.inputs.look_dir = Dir::from_unnormalized(look_dir).unwrap_or_else(Dir::forward);
|
||||||
Dir::from_unnormalized(look_dir).unwrap_or_else(Dir::forward);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fly_upward(&self, controller: &mut Controller) {
|
||||||
|
controller
|
||||||
|
.actions
|
||||||
|
.push(ControlAction::basic_input(InputKind::Fly));
|
||||||
|
controller.inputs.move_z = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn idle(&self, agent: &mut Agent, controller: &mut Controller, read_data: &ReadData) {
|
fn idle(&self, agent: &mut Agent, controller: &mut Controller, read_data: &ReadData) {
|
||||||
@ -3298,9 +3312,6 @@ impl<'a> AgentData<'a> {
|
|||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Fly));
|
.push(ControlAction::basic_input(InputKind::Fly));
|
||||||
controller
|
|
||||||
.actions
|
|
||||||
.push(ControlAction::basic_input(InputKind::Jump));
|
|
||||||
controller.inputs.move_z = 1.0;
|
controller.inputs.move_z = 1.0;
|
||||||
} else {
|
} else {
|
||||||
// Jump
|
// Jump
|
||||||
@ -3359,9 +3370,6 @@ impl<'a> AgentData<'a> {
|
|||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Fly));
|
.push(ControlAction::basic_input(InputKind::Fly));
|
||||||
controller
|
|
||||||
.actions
|
|
||||||
.push(ControlAction::basic_input(InputKind::Jump));
|
|
||||||
controller.inputs.move_z = 1.0;
|
controller.inputs.move_z = 1.0;
|
||||||
}
|
}
|
||||||
// If further than 2.5 blocks and random chance
|
// If further than 2.5 blocks and random chance
|
||||||
@ -3428,9 +3436,6 @@ impl<'a> AgentData<'a> {
|
|||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Fly));
|
.push(ControlAction::basic_input(InputKind::Fly));
|
||||||
controller
|
|
||||||
.actions
|
|
||||||
.push(ControlAction::basic_input(InputKind::Jump));
|
|
||||||
controller.inputs.move_z = 1.0;
|
controller.inputs.move_z = 1.0;
|
||||||
} else {
|
} else {
|
||||||
self.jump_if(controller, bearing.z > 1.5);
|
self.jump_if(controller, bearing.z > 1.5);
|
||||||
@ -3477,9 +3482,6 @@ impl<'a> AgentData<'a> {
|
|||||||
controller
|
controller
|
||||||
.actions
|
.actions
|
||||||
.push(ControlAction::basic_input(InputKind::Fly));
|
.push(ControlAction::basic_input(InputKind::Fly));
|
||||||
controller
|
|
||||||
.actions
|
|
||||||
.push(ControlAction::basic_input(InputKind::Jump));
|
|
||||||
controller.inputs.move_z = 1.0;
|
controller.inputs.move_z = 1.0;
|
||||||
} else if attack_data.dist_sqrd > (3.0 * attack_data.min_attack_dist).powi(2) {
|
} else if attack_data.dist_sqrd > (3.0 * attack_data.min_attack_dist).powi(2) {
|
||||||
self.path_toward_target(agent, controller, tgt_data, read_data, true, false, None);
|
self.path_toward_target(agent, controller, tgt_data, read_data, true, false, None);
|
||||||
|
Loading…
Reference in New Issue
Block a user