mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix spawn command placement to be random to improve AI responsivity and not spawn directly on player
This commit is contained in:
parent
cac780c5b9
commit
4893ab5c2a
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -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)",
|
||||
|
@ -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"
|
||||
serde_derive = "1.0"
|
||||
rand = "0.5.6"
|
||||
|
@ -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::<comp::Pos>(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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user