From c2afc3a83a0ec41193a5879767c27759cf466696 Mon Sep 17 00:00:00 2001
From: Canopteks <thomas.duhamel@protonmail.com>
Date: Thu, 5 Mar 2020 11:20:03 +0100
Subject: [PATCH] momentum fixed git add .! throws fancyness ++

---
 client/levels/test/game.tscn         |  2 +-
 client/project.godot                 |  1 +
 server/entities/characters/player.gd | 12 ++++++++----
 server/levels/test/game.tscn         |  2 +-
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/client/levels/test/game.tscn b/client/levels/test/game.tscn
index 0c1ce37..4f05771 100644
--- a/client/levels/test/game.tscn
+++ b/client/levels/test/game.tscn
@@ -13,7 +13,7 @@ fov = 30.0
 [node name="structure" type="Spatial" parent="."]
 
 [node name="bloc" parent="structure" instance=ExtResource( 2 )]
-transform = Transform( 10, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
+transform = Transform( 30, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
 
 [node name="bloc2" parent="structure" instance=ExtResource( 2 )]
 transform = Transform( 5, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.15191, 0 )
diff --git a/client/project.godot b/client/project.godot
index 936fcb6..a3b0c06 100644
--- a/client/project.godot
+++ b/client/project.godot
@@ -35,6 +35,7 @@ movementJump={
 "deadzone": 0.5,
 "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
 , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null)
  ]
 }
 movementRight={
diff --git a/server/entities/characters/player.gd b/server/entities/characters/player.gd
index e514a60..cb9a8fb 100644
--- a/server/entities/characters/player.gd
+++ b/server/entities/characters/player.gd
@@ -16,7 +16,8 @@ var isSprinting:bool = false
 # Acceleration values
 const ACCEL:float = 8.5
 const SPRINT_ACCEL:float = 16.0
-const DEACCEL:float = 16.0
+const MVMNT_MOMENTUM:float = 10.0
+const THROW_MOMENTUM:float = 2.0
 
 # Jump and fall values
 const JUMP_SPEED:float = 16.0
@@ -73,12 +74,12 @@ func _physics_process(delta):
 # Called from the game script to update the vars
 func getPlayerInputs(movementInput, jumpInput, jumpId, sprintInput, attackTypeInput):
 	motion = 0
-
 	# Prevent the player from moving when attacking
 	if isAttacking:
 		return
 	
 	motion = movementInput
+		
 	isSprinting = sprintInput
 	isJumping = false
 	
@@ -107,6 +108,7 @@ func processMovement(delta):
 		currentJump = 0
 		# Reset the last striker
 		lastStrikerId = ownId
+		
 	elif currentJump == 0 && !isJumping:
 		# Initial jump prevented
 		currentJump = 1
@@ -137,8 +139,10 @@ func processMovement(delta):
 			accel = SPRINT_ACCEL
 		else:
 			accel = ACCEL
+	elif !is_on_floor()&&!isJumping:
+		accel = THROW_MOMENTUM
 	else:
-		accel = DEACCEL
+		accel = MVMNT_MOMENTUM
 
 	# Interpolating speed and acceleration through time and getting it
 	vel.x = hvel.linear_interpolate(target, accel * delta).x
@@ -205,7 +209,7 @@ func secondaryAttack():
 # Called when detected by an attack's hitbox
 func hurt(damages:int, sourceId:int, force:Vector3):
 	hp += damages
-	vel += Vector3(force.x*hp,force.y,force.z)
+	vel += Vector3(force.x*hp/2,force.y,force.z)
 	lastStrikerId = sourceId
 	rpc_unreliable_id(ownId, "hurt", hp)
 
diff --git a/server/levels/test/game.tscn b/server/levels/test/game.tscn
index 0e4f930..3fc5373 100644
--- a/server/levels/test/game.tscn
+++ b/server/levels/test/game.tscn
@@ -16,7 +16,7 @@ fov = 30.0
 [node name="structure" type="Spatial" parent="."]
 
 [node name="bloc" parent="structure" instance=ExtResource( 2 )]
-transform = Transform( 10, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
+transform = Transform( 30, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
 
 [node name="bloc2" parent="structure" instance=ExtResource( 2 )]
 transform = Transform( 5, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.15191, 0 )
-- 
GitLab