diff --git a/CHANGELOG.md b/CHANGELOG.md index 38dad4e0ed..48badb9df2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Changed crafting recipes involving shiny gems to use diamonds instead. - Cave scatter now includes all 6 gems. - Adjusted Stonework Defender loot table to remove mindflayer drops (bag, staff, glider). +- Made humanoid NPCs use gliders (if equipped) when falling - Changed default controller key bindings - Improved network efficiency by ≈ factor 10 by using tokio. - Added item tooltips to trade window. diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index ff81dcf0df..0486993624 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -316,6 +316,9 @@ impl LoadoutBuilder { 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), _ => None, }) + .glider(Some(Item::new_from_asset_expect( + "common.items.glider.glider_starter", + ))) .build(), Bandit => LoadoutBuilder::new() .active_item(active_item) @@ -341,6 +344,9 @@ impl LoadoutBuilder { 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), _ => None, }) + .glider(Some(Item::new_from_asset_expect( + "common.items.glider.glider_starter", + ))) .build(), CultistNovice => LoadoutBuilder::new() .active_item(active_item) @@ -369,6 +375,9 @@ impl LoadoutBuilder { 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), _ => None, }) + .glider(Some(Item::new_from_asset_expect( + "common.items.glider.glider_blue", + ))) .build(), CultistAcolyte => LoadoutBuilder::new() .active_item(active_item) @@ -397,6 +406,9 @@ impl LoadoutBuilder { 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), _ => None, }) + .glider(Some(Item::new_from_asset_expect( + "common.items.glider.glider_blue", + ))) .build(), Warlord => LoadoutBuilder::new() .active_item(active_item) @@ -425,6 +437,9 @@ impl LoadoutBuilder { 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), _ => None, }) + .glider(Some(Item::new_from_asset_expect( + "common.items.glider.glider_cultist", + ))) .build(), Warlock => LoadoutBuilder::new() .active_item(active_item) @@ -453,6 +468,9 @@ impl LoadoutBuilder { 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), _ => None, }) + .glider(Some(Item::new_from_asset_expect( + "common.items.glider.glider_cultist", + ))) .build(), Villager => LoadoutBuilder::new() .active_item(active_item) diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index 8d3c76d8c2..00a634c6b4 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -166,6 +166,12 @@ impl<'a> System<'a> for Sys { alignment.copied() }; + let glider_equipped = inventory.equipped(EquipSlot::Glider).as_ref().map_or(false, |item| { + matches!(item.kind(), comp::item::ItemKind::Glider(_)) + }); + + let is_gliding = matches!(char_states.get(entity), Some(CharacterState::GlideWield) | Some(CharacterState::Glide)) && !physics_state.on_ground; + controller.reset(); let mut event_emitter = event_bus.emitter(); // Light lanterns at night @@ -374,7 +380,7 @@ impl<'a> System<'a> for Sys { } // Put away weapon - if thread_rng().gen::() < 0.005 { + if thread_rng().gen::() < 0.005 && matches!(char_states.get(entity), Some(CharacterState::Wielding)) { controller.actions.push(ControlAction::Unwield); } @@ -384,7 +390,9 @@ impl<'a> System<'a> for Sys { } } - controller.actions.push(ControlAction::Unwield); + if physics_state.on_ground { + controller.actions.push(ControlAction::Unwield); + } // Sometimes try searching for new targets if thread_rng().gen::() < 0.1 { @@ -439,7 +447,7 @@ impl<'a> System<'a> for Sys { timer, } => { if let Some(body) = body { - if body.can_strafe() { + if body.can_strafe() && !is_gliding { // Keep glider open if already gliding controller.actions.push(ControlAction::Unwield); } } @@ -1437,6 +1445,15 @@ impl<'a> System<'a> for Sys { } } + if glider_equipped && !physics_state.on_ground { + if let Some(velocity) = velocities.get(entity) { + // toggle glider when vertical velocity is above some threshold (here ~ glider fall vertical speed) + if velocity.0.z < -26.0 { + controller.actions.push(ControlAction::GlideWield); + } + } + } + if do_idle { agent.activity = Activity::Idle { bearing: Vec2::zero(),