mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added randomized NPC names veloren/veloren#133
This commit is contained in:
parent
04d4dc1da5
commit
eb80459872
26
Cargo.lock
generated
26
Cargo.lock
generated
@ -1207,6 +1207,11 @@ dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.1.15"
|
||||
@ -2158,6 +2163,11 @@ dependencies = [
|
||||
"stb_truetype 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.4"
|
||||
@ -2236,6 +2246,16 @@ dependencies = [
|
||||
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shared_library"
|
||||
version = "0.1.9"
|
||||
@ -2567,10 +2587,11 @@ dependencies = [
|
||||
"lz4-compress 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mio 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"specs 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sphynx 0.1.0 (git+https://gitlab.com/veloren/sphynx.git)",
|
||||
"threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -2968,6 +2989,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
|
||||
"checksum instant 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d6706e8fb9de9be6143801a75747fa2209855b13d74ee994e30d86b38afdf77f"
|
||||
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
|
||||
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
|
||||
"checksum jpeg-decoder 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c8b7d43206b34b3f94ea9445174bda196e772049b9bddbc620c9d29b2d20110d"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum khronos_api 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "037ab472c33f67b5fbd3e9163a2645319e5356fcd355efa6d4eb7fff4bbcb554"
|
||||
@ -3077,6 +3099,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
|
||||
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
"checksum rusttype 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "25951e85bb2647960969f72c559392245a5bd07446a589390bf427dda31cdc4a"
|
||||
"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f"
|
||||
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
|
||||
"checksum scan_fmt 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b87497427f9fbe539ee6b9626f5a5e899331fdf1c1d62f14c637a462969db30"
|
||||
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
||||
@ -3087,6 +3110,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd"
|
||||
"checksum serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "101b495b109a3e3ca8c4cbe44cf62391527cdfb6ba15821c5ce80bcd5ea23f9f"
|
||||
"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d"
|
||||
"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
|
||||
"checksum shred 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6ea122e6133568144fcfb5888737d4ac776ebc959f989dd65b907136ac22bfed"
|
||||
"checksum shred-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fcf34e5e5302d3024aba7afc291f6d1ca7573ed035d3c0796976ba3f10691a1"
|
||||
|
@ -16,9 +16,10 @@ mio = "0.6"
|
||||
mio-extras = "2.0"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0.39"
|
||||
bincode = "1.1"
|
||||
log = "0.4"
|
||||
rand = "0.5"
|
||||
rand = "0.6.5"
|
||||
rayon = "1.0"
|
||||
lazy_static = "1.3"
|
||||
lz4-compress = "0.1"
|
||||
|
210
common/assets/npc_names.json
Normal file
210
common/assets/npc_names.json
Normal file
@ -0,0 +1,210 @@
|
||||
{
|
||||
"wolf": [
|
||||
"Achak",
|
||||
"Adalwolf",
|
||||
"Akela",
|
||||
"Alaska",
|
||||
"Aleu",
|
||||
"Amarok",
|
||||
"Apisi",
|
||||
"Archer",
|
||||
"Ares",
|
||||
"Arrax",
|
||||
"Artic",
|
||||
"Aspen",
|
||||
"Aura",
|
||||
"Axel",
|
||||
"Balto",
|
||||
"Barwolf",
|
||||
"Basil",
|
||||
"Beja",
|
||||
"Beowulf",
|
||||
"Borris",
|
||||
"Brassa",
|
||||
"Bruno",
|
||||
"Chronos",
|
||||
"Colt",
|
||||
"Comet",
|
||||
"Cronus",
|
||||
"Czar",
|
||||
"Dakota",
|
||||
"Dash",
|
||||
"Diego",
|
||||
"Dire",
|
||||
"Duke",
|
||||
"Echo",
|
||||
"Elda",
|
||||
"Eskimo",
|
||||
"Essos",
|
||||
"Frey",
|
||||
"Gabu",
|
||||
"Ghost",
|
||||
"Giro",
|
||||
"Grey Wind",
|
||||
"Gunner",
|
||||
"Harou",
|
||||
"Havoc",
|
||||
"Hera",
|
||||
"Hunter",
|
||||
"Inuit",
|
||||
"Jacob",
|
||||
"Jenna",
|
||||
"Juno",
|
||||
"Kar",
|
||||
"Khal",
|
||||
"Kiba",
|
||||
"Kimbra",
|
||||
"Kodi",
|
||||
"Lady",
|
||||
"Lakota",
|
||||
"Larka",
|
||||
"Leah",
|
||||
"Leto",
|
||||
"Lobo",
|
||||
"Loki",
|
||||
"Lotus",
|
||||
"Louve",
|
||||
"Lupa",
|
||||
"Major",
|
||||
"Mathias",
|
||||
"Moro",
|
||||
"Murdock",
|
||||
"Nomad",
|
||||
"Okami",
|
||||
"Orbit",
|
||||
"Palla",
|
||||
"Pyro",
|
||||
"Radolf",
|
||||
"Raven",
|
||||
"Rhea",
|
||||
"Rider",
|
||||
"Rollo",
|
||||
"Rune",
|
||||
"Sable",
|
||||
"Saga",
|
||||
"Sarge",
|
||||
"Shiro",
|
||||
"Siku",
|
||||
"Sky",
|
||||
"Stark",
|
||||
"Storm",
|
||||
"Suki",
|
||||
"Tala",
|
||||
"Thor",
|
||||
"Tiva",
|
||||
"Tyr",
|
||||
"Ubba",
|
||||
"Ulva",
|
||||
"Valor",
|
||||
"Wolf",
|
||||
"Wolfgang",
|
||||
"Yara",
|
||||
"Zeus",
|
||||
"Ziva",
|
||||
"Zylo"
|
||||
],
|
||||
"pig": [
|
||||
"Acorn",
|
||||
"Adeline",
|
||||
"Ajna",
|
||||
"Athena",
|
||||
"Avacado",
|
||||
"Babe",
|
||||
"Bella",
|
||||
"Buddy",
|
||||
"Buttons",
|
||||
"Charlie",
|
||||
"Charlotte",
|
||||
"Chubbs",
|
||||
"Cinnamon",
|
||||
"Clarence",
|
||||
"Clover",
|
||||
"Cookie",
|
||||
"Corky",
|
||||
"Cupcake",
|
||||
"Daisy",
|
||||
"Dani",
|
||||
"Delilah",
|
||||
"Dexter",
|
||||
"Dolly",
|
||||
"Dottie",
|
||||
"Dudley",
|
||||
"Ellie",
|
||||
"Erwin",
|
||||
"Evie",
|
||||
"Gertrude",
|
||||
"Gilly",
|
||||
"Ginger",
|
||||
"Gizmo",
|
||||
"Gwenivere",
|
||||
"Hagrid",
|
||||
"Hazel",
|
||||
"Hector",
|
||||
"Herman",
|
||||
"Hermione",
|
||||
"Hoover",
|
||||
"Huck",
|
||||
"Iggy",
|
||||
"Jake",
|
||||
"Josie",
|
||||
"Leonardo",
|
||||
"Lily",
|
||||
"Lola",
|
||||
"Lottie",
|
||||
"Lucy",
|
||||
"Lulu",
|
||||
"Mabel",
|
||||
"Madeline",
|
||||
"Maisie",
|
||||
"Millie",
|
||||
"Mimzy",
|
||||
"Nooch",
|
||||
"Nutmeg",
|
||||
"Oinkers",
|
||||
"Okja",
|
||||
"Oliver",
|
||||
"Olivia",
|
||||
"Panda",
|
||||
"Pasley",
|
||||
"Peanut",
|
||||
"Penelope",
|
||||
"Peppa",
|
||||
"Petunia",
|
||||
"Phoebe",
|
||||
"Piggie Smalls",
|
||||
"Piggles",
|
||||
"Piglet",
|
||||
"Pinto Bean",
|
||||
"Piper",
|
||||
"Poly",
|
||||
"Popcorn",
|
||||
"Poppy",
|
||||
"Punky",
|
||||
"Rey",
|
||||
"Rooter",
|
||||
"Rosie",
|
||||
"Ruby",
|
||||
"Sadie",
|
||||
"Scouter",
|
||||
"Skittles",
|
||||
"Snowball",
|
||||
"Snuffles",
|
||||
"Sonny",
|
||||
"Sprout",
|
||||
"Squiggles",
|
||||
"Sweetie Pie",
|
||||
"Theo",
|
||||
"Toffuti",
|
||||
"Trixie",
|
||||
"Violet",
|
||||
"Vishnu",
|
||||
"Wee Wee",
|
||||
"Wilbur",
|
||||
"Willow",
|
||||
"Winnie",
|
||||
"Wrinkles",
|
||||
"Ziggy",
|
||||
"Zoe",
|
||||
"Zoinks"
|
||||
]
|
||||
}
|
@ -25,6 +25,7 @@ pub mod terrain;
|
||||
pub mod util;
|
||||
pub mod vol;
|
||||
pub mod volumes;
|
||||
pub mod npc;
|
||||
|
||||
/// The networking module containing high-level wrappers of `TcpListener` and `TcpStream` (`PostOffice` and `PostBox` respectively) and data types used by both the server and client.
|
||||
/// # Examples
|
||||
|
34
common/src/npc.rs
Normal file
34
common/src/npc.rs
Normal file
@ -0,0 +1,34 @@
|
||||
use serde_json;
|
||||
use rand::seq::SliceRandom;
|
||||
use std::fs::File;
|
||||
|
||||
pub enum NpcKind {
|
||||
Wolf,
|
||||
Pig
|
||||
}
|
||||
|
||||
impl NpcKind {
|
||||
fn as_str(&self) -> &'static str {
|
||||
match *self {
|
||||
NpcKind::Wolf => "wolf",
|
||||
NpcKind::Pig => "pig"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_npc_name(npc_type: NpcKind) -> String {
|
||||
let file = File::open("common/assets/npc_names.json").expect("file should open read only");
|
||||
let json: serde_json::Value =
|
||||
serde_json::from_reader(file).expect("file should be proper JSON");
|
||||
let npc_names = json
|
||||
.get(npc_type.as_str())
|
||||
.expect("accessing json using NPC type provided as key")
|
||||
.as_array()
|
||||
.expect("parsing accessed json value into an array");
|
||||
let npc_name = npc_names
|
||||
.choose(&mut rand::thread_rng())
|
||||
.expect("getting a random NPC name")
|
||||
.as_str()
|
||||
.expect("parsing NPC name json value into a &str");
|
||||
String::from(npc_name)
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
//! and provide a handler function.
|
||||
|
||||
use crate::Server;
|
||||
use common::{comp, msg::ServerMsg};
|
||||
use common::{comp, msg::ServerMsg, npc::{NpcKind, get_npc_name}};
|
||||
use specs::{Builder, Entity as EcsEntity, Join};
|
||||
use vek::*;
|
||||
|
||||
@ -228,7 +228,7 @@ fn handle_pet_pig(server: &mut Server, entity: EcsEntity, args: String, action:
|
||||
server
|
||||
.create_npc(
|
||||
pos,
|
||||
"Bungo".to_owned(),
|
||||
get_npc_name(NpcKind::Pig),
|
||||
comp::Body::Quadruped(comp::QuadrupedBody::random()),
|
||||
)
|
||||
.with(comp::Agent::Pet {
|
||||
@ -256,7 +256,7 @@ fn handle_pet_wolf(server: &mut Server, entity: EcsEntity, args: String, action:
|
||||
server
|
||||
.create_npc(
|
||||
pos,
|
||||
"Tobermory".to_owned(),
|
||||
get_npc_name(NpcKind::Wolf),
|
||||
comp::Body::QuadrupedMedium(comp::QuadrupedMediumBody::random()),
|
||||
)
|
||||
.with(comp::Agent::Pet {
|
||||
@ -284,7 +284,7 @@ fn handle_enemy(server: &mut Server, entity: EcsEntity, args: String, action: &C
|
||||
server
|
||||
.create_npc(
|
||||
pos,
|
||||
"Tobermory".to_owned(),
|
||||
get_npc_name(NpcKind::Wolf),
|
||||
comp::Body::Humanoid(comp::HumanoidBody::random()),
|
||||
)
|
||||
.with(comp::Agent::Enemy { target: None })
|
||||
|
Loading…
Reference in New Issue
Block a user