diff --git a/Cargo.lock b/Cargo.lock index a1c93e5cbb..71b818287a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2766,6 +2766,7 @@ version = "0.2.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "scan_fmt 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/server/Cargo.toml b/server/Cargo.toml index b0b4738783..98fab7922b 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -16,4 +16,5 @@ lazy_static = "1.3.0" scan_fmt = "0.1.3" ron = "0.5.1" serde = "1.0" -serde_derive = "1.0" \ No newline at end of file +serde_derive = "1.0" +rand = "0.5.6" diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 1f9fe7ed0a..e5a2bd9f4b 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -9,6 +9,7 @@ use common::{ npc::{get_npc_name, NpcKind}, state::TimeOfDay, }; +use rand::Rng; use specs::{Builder, Entity as EcsEntity, Join}; use vek::*; @@ -314,12 +315,18 @@ fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &C match (opt_agent, opt_id, opt_amount) { (Some(agent), Some(id), Some(amount)) => { match server.state.read_component_cloned::(entity) { - Some(mut pos) => { - pos.0.x += 1.0; // Temp fix TODO: Solve NaN issue with positions of pets + Some(pos) => { for _ in 0..amount { + let vel = Vec3::new( + rand::thread_rng().gen_range(-2.0, 3.0), + rand::thread_rng().gen_range(-2.0, 3.0), + 10.0, + ); + let body = kind_to_body(id); server .create_npc(pos, get_npc_name(id), body) + .with(comp::Vel(vel)) .with(agent) .build(); }