diff --git a/Cargo.lock b/Cargo.lock index 4466efcfbb..e981dbdde1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4866,7 +4866,8 @@ dependencies = [ [[package]] name = "vek" version = "0.10.0" -source = "git+https://github.com/Imberflur/vek?branch=is_normalized#43bef0a9e953fbf6b00a073aef914c48b784c995" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c98f7e1c1400d5b1704baee82cbc56a3fde406769555ead0f2306e43ebab967" dependencies = [ "approx 0.3.2", "num-integer", diff --git a/Cargo.toml b/Cargo.toml index 4c8b444279..f4a8194459 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,3 @@ debug = false [profile.releasedebuginfo] inherits = 'release' debug = 1 - -[patch.crates-io] -vek = {git = "https://github.com/Imberflur/vek", branch = "is_normalized"} diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 2fb685db2f..34743a0bb4 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -80,6 +80,8 @@ impl Asset for Item { } impl Item { + // TODO: consider alternatives such as default abilities that can be added to a + // loadout when no weapon is present pub fn empty() -> Self { Self { name: "Empty Item".to_owned(), diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 2090c6d60a..580eef21b5 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -2,7 +2,6 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate}, states::utils::*, sys::character_behavior::*, - util::Dir, }; use std::time::Duration; use vek::Vec3; @@ -98,8 +97,6 @@ impl CharacterBehavior for Data { } } - update.ori.0 = Dir::slerp_to_vec3(update.ori.0, update.vel.0, 9.0 * data.dt.0); - update } } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 6f44ab4273..cf06820cf6 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -13,7 +13,6 @@ use vek::vec::Vec2; pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; const BASE_HUMANOID_ACCEL: f32 = 100.0; const BASE_HUMANOID_SPEED: f32 = 170.0; -const NPC_HUMANOID_SPEED: f32 = 170.0; const BASE_HUMANOID_AIR_ACCEL: f32 = 15.0; const BASE_HUMANOID_AIR_SPEED: f32 = 8.0; const BASE_HUMANOID_WATER_ACCEL: f32 = 70.0; @@ -43,14 +42,7 @@ pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { /// Updates components to move player as if theyre on ground or in air fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { let (accel, speed): (f32, f32) = if data.physics.on_ground { - ( - BASE_HUMANOID_ACCEL, - if data.agent.is_some() { - NPC_HUMANOID_SPEED - } else { - BASE_HUMANOID_SPEED - }, - ) + (BASE_HUMANOID_ACCEL, BASE_HUMANOID_SPEED) } else { (BASE_HUMANOID_AIR_ACCEL, BASE_HUMANOID_AIR_SPEED) }; diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 1882879954..fbd1414398 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - Agent, Attacking, Body, CharacterState, ControlAction, Controller, ControllerInputs, - Energy, Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, + Attacking, Body, CharacterState, ControlAction, Controller, ControllerInputs, Energy, + Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -50,7 +50,6 @@ pub struct JoinData<'a> { pub body: &'a Body, pub physics: &'a PhysicsState, pub attacking: Option<&'a Attacking>, - pub agent: Option<&'a Agent>, pub updater: &'a LazyUpdate, } @@ -68,7 +67,6 @@ pub type JoinTuple<'a> = ( &'a Body, &'a PhysicsState, Option<&'a Attacking>, - Option<&'a Agent>, ); fn incorporate_update(tuple: &mut JoinTuple, state_update: StateUpdate) { @@ -97,7 +95,6 @@ impl<'a> JoinData<'a> { body: j.10, physics: j.11, attacking: j.12, - agent: j.13, updater, dt, } @@ -128,7 +125,6 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Body>, ReadStorage<'a, PhysicsState>, ReadStorage<'a, Attacking>, - ReadStorage<'a, Agent>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, ); @@ -153,7 +149,6 @@ impl<'a> System<'a> for Sys { bodies, physics_states, attacking_storage, - agent_storage, uids, mountings, ): Self::SystemData, @@ -175,7 +170,6 @@ impl<'a> System<'a> for Sys { &bodies, &physics_states, attacking_storage.maybe(), - agent_storage.maybe(), ) .join(); diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 02cc2f5c0a..1d2675e679 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -110,11 +110,14 @@ impl<'a> System<'a> for Sys { // Weapon gives base damage let mut healthchange = attack.base_healthchange as f32; - //// NPCs do less damage: + // TODO: remove this, either it will remain unused or be used as a temporary + // gameplay balance + //// NPCs do less damage //if agent_maybe.is_some() { // healthchange = (healthchange / 1.5).min(-1.0); //} + // TODO: remove this when there is a better way to target healing // Don't heal npc's hp if agent_b_maybe.is_some() && healthchange > 0.0 { healthchange = 0.0; diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index b46e3ffbd6..9f34e6d8ed 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -67,6 +67,16 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { ecs.entity_from_uid(possessor_uid.into()), ecs.entity_from_uid(possesse_uid.into()), ) { + // Check that entities still exist + if !(possessor.gen().is_alive() && ecs.is_alive(possessor)) + || !(possesse.gen().is_alive() && ecs.is_alive(possesse)) + { + error!( + "Error possessing! either the possessor entity or possesse entity no longer exists" + ); + return; + } + // You can't possess other players let mut clients = ecs.write_storage::(); if clients.get_mut(possesse).is_none() { @@ -89,14 +99,16 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { if let item::ItemKind::Tool(tool) = item.kind { let mut abilities = tool.get_abilities(); let mut ability_drain = abilities.drain(..); - loadout.active_item = Some(comp::ItemConfig { + let debug_item = comp::ItemConfig { item, ability1: ability_drain.next(), ability2: ability_drain.next(), ability3: ability_drain.next(), block_ability: None, dodge_ability: None, - }); + }; + std::mem::swap(&mut loadout.active_item, &mut loadout.second_item); + loadout.active_item = Some(debug_item); } // Move player component