From c61a4bbbf1f61356098d4711cdf87bd054c34543 Mon Sep 17 00:00:00 2001
From: Adonis Stavridis <adonis-ioannis.stavridis@etu.unistra.fr>
Date: Sun, 29 Mar 2020 16:05:08 +0200
Subject: [PATCH] #116 last changes before merge

---
 server/autoloads/gamestate.gd        |  2 +-
 server/entities/characters/player.gd | 20 ++++++++++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/server/autoloads/gamestate.gd b/server/autoloads/gamestate.gd
index 86335ac..12fa5c5 100644
--- a/server/autoloads/gamestate.gd
+++ b/server/autoloads/gamestate.gd
@@ -3,7 +3,7 @@ extends Node
 const GAMEPATH = "/root/game/"
 
 const PORT = 10001
-const MAX_CLIENTS = 2
+const MAX_CLIENTS = 1
 
 var players = {}
 
diff --git a/server/entities/characters/player.gd b/server/entities/characters/player.gd
index 820dc7d..c76d6d9 100644
--- a/server/entities/characters/player.gd
+++ b/server/entities/characters/player.gd
@@ -149,7 +149,8 @@ func getPlayerInputs(movementInput:int, jumpId:int, attackTypeInput:int,
 mouseX:int, mouseY:int):
 	# Prevent the player from moving when attacking
 	if (isAttacking):
-		motion = 0
+		if (is_on_floor()):
+			motion = 0
 		return
 
 	motion = movementInput
@@ -159,20 +160,23 @@ mouseX:int, mouseY:int):
 		lastJumpId = jumpId
 		isJumping = true
 	
-	# Execute attack
+	# Execute attack in direction
 	if (attackTypeInput != NONE):
-		attackDirection = MOUSE_UP
-		if (mouseX < 0 && mouseX <= mouseY):
-			attackDirection = MOUSE_LEFT
+		if (mouseX < 0):
 			bodyRotation = -1
 			set_rotation_degrees(Vector3(0, 180, 0))
 			broadcastTurn(bodyRotation)
-		elif (mouseX >= 0 && mouseX >= -mouseY):
-			attackDirection = MOUSE_RIGHT
+		else:
 			bodyRotation = 1
 			set_rotation_degrees(Vector3(0, 0, 0))
 			broadcastTurn(bodyRotation)
-		if (!is_on_floor() && mouseY > 0 && mouseX < mouseY && mouseX > -mouseY):
+		attackDirection = MOUSE_UP
+		if (mouseX < 0 && 1.5*mouseX <= mouseY):
+			attackDirection = MOUSE_LEFT
+		elif (mouseX >= 0 && 1.5*mouseX >= -mouseY):
+			attackDirection = MOUSE_RIGHT
+		if (!is_on_floor() && mouseY > 0 && 1.5*mouseX < mouseY
+			&& 1.5*mouseX > -mouseY):
 			attackDirection = MOUSE_DOWN
 		processAttack(attackTypeInput)
 
-- 
GitLab