From fd745a4d11d11b9c13e68c5c9e8222978b0971e8 Mon Sep 17 00:00:00 2001
From: Sam <samuelkeiffer@gmail.com>
Date: Tue, 21 Jul 2020 16:07:30 -0400
Subject: [PATCH] Removed energy refund on M2 attacks. Re-added custom heights
 on creatures. Tweaked movement on triple strike.

---
 common/src/comp/body.rs            | 26 ++++++++++++++++++++++++--
 common/src/states/dash_melee.rs    |  8 --------
 common/src/states/leap_melee.rs    |  8 --------
 common/src/states/spin_melee.rs    |  8 --------
 common/src/states/triple_strike.rs |  9 +++++++--
 5 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs
index 18d915ddbd..ee87f053df 100644
--- a/common/src/comp/body.rs
+++ b/common/src/comp/body.rs
@@ -128,8 +128,30 @@ impl Body {
         }
     }
 
-    // Note: currently assumes sphericality
-    pub fn height(&self) -> f32 { self.radius() * 2.0 }
+    pub fn height(&self) -> f32 {
+        match self {
+            Body::Humanoid(humanoid) => match humanoid.species {
+                humanoid::Species::Danari => 0.8,
+                humanoid::Species::Dwarf => 0.9,
+                humanoid::Species::Orc => 1.14,
+                humanoid::Species::Undead => 0.95,
+                _ => 1.0,
+            },
+            Body::QuadrupedSmall(_) => 0.6,
+            Body::QuadrupedMedium(_) => 0.5,
+            Body::Critter(_) => 0.4,
+            Body::BirdMedium(_) => 1.2,
+            Body::FishMedium(_) => 1.0,
+            Body::Dragon(_) => 5.0,
+            Body::BirdSmall(_) => 0.4,
+            Body::FishSmall(_) => 0.4,
+            Body::BipedLarge(_) => 4.0,
+            Body::Golem(_) => 5.0,
+            Body::QuadrupedLow(_) => 0.5,
+            Body::Object(_) => 0.6,
+            // _ => 0.5,
+        }
+    }
 
     pub fn base_health(&self) -> u32 {
         match self {
diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs
index b330a35232..557b4fa3a4 100644
--- a/common/src/states/dash_melee.rs
+++ b/common/src/states/dash_melee.rs
@@ -90,14 +90,6 @@ impl CharacterBehavior for Data {
             data.updater.remove::<Attacking>(data.entity);
         }
 
-        // Grant energy on successful hit
-        if let Some(attack) = data.attacking {
-            if attack.applied && attack.hit_count > 0 {
-                data.updater.remove::<Attacking>(data.entity);
-                update.energy.change_by(0, EnergySource::HitEnemy);
-            }
-        }
-
         update
     }
 }
diff --git a/common/src/states/leap_melee.rs b/common/src/states/leap_melee.rs
index d908952de4..8dcfcd36c5 100644
--- a/common/src/states/leap_melee.rs
+++ b/common/src/states/leap_melee.rs
@@ -110,14 +110,6 @@ impl CharacterBehavior for Data {
             data.updater.remove::<Attacking>(data.entity);
         }
 
-        // Grant energy on successful hit
-        if let Some(attack) = data.attacking {
-            if attack.applied && attack.hit_count > 0 {
-                data.updater.remove::<Attacking>(data.entity);
-                update.energy.change_by(100, EnergySource::HitEnemy);
-            }
-        }
-
         update
     }
 }
diff --git a/common/src/states/spin_melee.rs b/common/src/states/spin_melee.rs
index 55d00c14db..1bb1141fa2 100644
--- a/common/src/states/spin_melee.rs
+++ b/common/src/states/spin_melee.rs
@@ -133,14 +133,6 @@ impl CharacterBehavior for Data {
             data.updater.remove::<Attacking>(data.entity);
         }
 
-        // Grant energy on successful hit
-        if let Some(attack) = data.attacking {
-            if attack.applied && attack.hit_count > 0 {
-                data.updater.remove::<Attacking>(data.entity);
-                update.energy.change_by(10, EnergySource::HitEnemy);
-            }
-        }
-
         update
     }
 }
diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs
index 42cad17188..1224cd08a1 100644
--- a/common/src/states/triple_strike.rs
+++ b/common/src/states/triple_strike.rs
@@ -120,13 +120,14 @@ impl CharacterBehavior for Data {
 
             // Move player forward while in first third of each stage
             if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) {
-                update.vel.0 += data.dt.0
-                    * ( adjusted_accel * Vec3::from(data.ori.0.xy())); 
+                update.vel.0 += data.dt.0 * (adjusted_accel * Vec3::from(data.ori.0.xy()));
                 let mag2 = update.vel.0.magnitude_squared();
                 if mag2 > BASE_SPEED.powf(2.0) {
                     update.vel.0 = update.vel.0.normalized() * BASE_SPEED;
                 }
             };
+        // update.vel.0 = Vec3::new(data.inputs.move_dir.x,
+        // data.inputs.move_dir.y, 0.0) * 5.0;
         } else {
             handle_orientation(data, &mut update, 50.0);
         }
@@ -141,6 +142,8 @@ impl CharacterBehavior for Data {
                 Stage::Third => (self.base_damage as f32 * 1.5) as u32,
             };
 
+            update.vel.0 = Vec3::new(data.inputs.move_dir.x, data.inputs.move_dir.y, 0.0) * 5.0;
+
             // Try to deal damage in second half of stage
             data.updater.insert(data.entity, Attacking {
                 base_healthchange: -(dmg as i32),
@@ -173,6 +176,8 @@ impl CharacterBehavior for Data {
             // Player messed up inputs, don't transition
             else { None };
 
+            update.vel.0 = Vec3::new(data.inputs.move_dir.x, data.inputs.move_dir.y, 0.0) * 5.0;
+
             if let Some(stage) = next_stage {
                 CharacterState::TripleStrike(Data {
                     base_damage: self.base_damage,