From 8ff438bb5bbdc7dfc7de939a7cf0016ef4fed660 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Thu, 11 Aug 2022 18:57:13 +0100 Subject: [PATCH] Smol animals --- common/src/cmd.rs | 1 + common/systems/src/mount.rs | 8 +++++--- server/src/cmd.rs | 6 +++--- voxygen/src/scene/figure/mod.rs | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common/src/cmd.rs b/common/src/cmd.rs index 7431e7e271..46ff446b85 100644 --- a/common/src/cmd.rs +++ b/common/src/cmd.rs @@ -654,6 +654,7 @@ impl ServerChatCommand { Enum("entity", ENTITIES.clone(), Required), Integer("amount", 1, Optional), Boolean("ai", "true".to_string(), Optional), + Float("ai", 1.0, Optional), ], "Spawn a test entity", Some(Admin), diff --git a/common/systems/src/mount.rs b/common/systems/src/mount.rs index 1cfb25e68d..997442f12e 100644 --- a/common/systems/src/mount.rs +++ b/common/systems/src/mount.rs @@ -1,5 +1,5 @@ use common::{ - comp::{Body, Controller, InputKind, Ori, Pos, Vel}, + comp::{Body, Controller, InputKind, Ori, Pos, Vel, Scale}, link::Is, mounting::Mount, uid::UidAllocator, @@ -24,6 +24,7 @@ impl<'a> System<'a> for Sys { WriteStorage<'a, Vel>, WriteStorage<'a, Ori>, ReadStorage<'a, Body>, + ReadStorage<'a, Scale>, ); const NAME: &'static str = "mount"; @@ -41,6 +42,7 @@ impl<'a> System<'a> for Sys { mut velocities, mut orientations, bodies, + scales, ): Self::SystemData, ) { // For each mount... @@ -67,8 +69,8 @@ impl<'a> System<'a> for Sys { let vel = velocities.get(entity).copied(); if let (Some(pos), Some(ori), Some(vel)) = (pos, ori, vel) { let mounter_body = bodies.get(rider); - let mounting_offset = body.map_or(Vec3::unit_z(), Body::mount_offset) - + mounter_body.map_or(Vec3::zero(), Body::rider_offset); + let mounting_offset = body.map_or(Vec3::unit_z(), Body::mount_offset) * scales.get(entity).map_or(1.0, |s| s.0) + + mounter_body.map_or(Vec3::zero(), Body::rider_offset) * scales.get(rider).map_or(1.0, |s| s.0); let _ = positions.insert(rider, Pos(pos.0 + ori.to_quat() * mounting_offset)); let _ = orientations.insert(rider, ori); let _ = velocities.insert(rider, vel); diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 70c678ff74..a1e486b3f0 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -1189,8 +1189,8 @@ fn handle_spawn( args: Vec, action: &ServerChatCommand, ) -> CmdResult<()> { - match parse_cmd_args!(args, String, npc::NpcBody, u32, bool) { - (Some(opt_align), Some(npc::NpcBody(id, mut body)), opt_amount, opt_ai) => { + match parse_cmd_args!(args, String, npc::NpcBody, u32, bool, f32) { + (Some(opt_align), Some(npc::NpcBody(id, mut body)), opt_amount, opt_ai, opt_scale) => { let uid = uid(server, target, "target")?; let alignment = parse_alignment(uid, &opt_align)?; let amount = opt_amount.filter(|x| *x > 0).unwrap_or(1).min(50); @@ -1227,7 +1227,7 @@ fn handle_spawn( body, ) .with(comp::Vel(vel)) - .with(body.scale()) + .with(opt_scale.map(comp::Scale).unwrap_or(body.scale())) .with(alignment); if ai { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 2340e40b5c..d1d71dafb9 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -809,7 +809,7 @@ impl FigureMgr { const MIN_PERFECT_RATE_DIST: f32 = 100.0; if (i as u64 + tick) - % (((pos.0.distance_squared(focus_pos).powf(0.25) - MIN_PERFECT_RATE_DIST.sqrt()) + % ((((pos.0.distance_squared(focus_pos) / scale.map_or(1.0, |s| s.0)).powf(0.25) - MIN_PERFECT_RATE_DIST.sqrt()) .max(0.0) / 3.0) as u64) .saturating_add(1)