From 1f223c83107d6a8ecd302cd90f019dd27c13665f Mon Sep 17 00:00:00 2001
From: ubruntu <bryantdeters@gmail.com>
Date: Fri, 15 Jan 2021 00:42:57 +0000
Subject: [PATCH] Slightly better bird pathing

---
 common/sys/src/agent.rs    | 12 ++++++++++--
 server/src/rtsim/entity.rs |  4 ++--
 server/src/rtsim/mod.rs    |  2 +-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/common/sys/src/agent.rs b/common/sys/src/agent.rs
index e5a456febc..748ebb589b 100644
--- a/common/sys/src/agent.rs
+++ b/common/sys/src/agent.rs
@@ -223,8 +223,16 @@ impl<'a> System<'a> for Sys {
                     match &mut agent.activity {
                         Activity::Idle { bearing, chaser } => {
                             if let Some(travel_to) = agent.rtsim_controller.travel_to {
-                                //if it has an rtsim destination and can fly then it should
-                                inputs.fly.set_state(traversal_config.can_fly);
+                                // if it has an rtsim destination and can fly then it should
+                                // if it is flying and bumps something above it then it should move down
+                                inputs.fly.set_state(traversal_config.can_fly && !terrain
+                                    .ray(
+                                        pos.0,
+                                        pos.0 + (Vec3::unit_z() * 3.0))
+                                    .until(Block::is_solid)
+                                    .cast()
+                                    .1
+                                    .map_or(true, |b| b.is_some()));
                                 if let Some((bearing, speed)) =
                                     chaser.chase(&*terrain, pos.0, vel.0, travel_to, TraversalConfig {
                                         min_tgt_dist: 1.25,
diff --git a/server/src/rtsim/entity.rs b/server/src/rtsim/entity.rs
index e5737de144..0b17227e01 100644
--- a/server/src/rtsim/entity.rs
+++ b/server/src/rtsim/entity.rs
@@ -27,8 +27,8 @@ impl Entity {
 
     pub fn get_body(&self) -> comp::Body {
         match self.rng(PERM_GENUS).gen::<f32>() {
-            //we want 75% birds, 25% humans for now
-            x if x < 0.75 => {
+            //we want 50% birds, 50% humans for now
+            x if x < 0.50 => {
                 let species = *(&comp::bird_medium::ALL_SPECIES)
                     .choose(&mut self.rng(PERM_SPECIES))
                     .unwrap();
diff --git a/server/src/rtsim/mod.rs b/server/src/rtsim/mod.rs
index 0bf58d0c49..98a99abc6e 100644
--- a/server/src/rtsim/mod.rs
+++ b/server/src/rtsim/mod.rs
@@ -88,7 +88,7 @@ pub fn init(state: &mut State, #[cfg(feature = "worldgen")] world: &world::World
     #[cfg(not(feature = "worldgen"))]
     let mut rtsim = RtSim::new(Vec2::new(40, 40));
 
-    for _ in 0..10000 {
+    for _ in 0..5000 {
         let pos = rtsim
             .chunks
             .size()