From 9c0b75b18515a8dc84a74953133ad347dc4e67ae Mon Sep 17 00:00:00 2001 From: Adonis Stavridis <adonis-ioannis.stavridis@etu.unistra.fr> Date: Wed, 25 Mar 2020 21:51:13 +0100 Subject: [PATCH] #112 fix close attacks --- server/entities/characters/player.gd | 11 ++-- server/entities/characters/player.tscn | 74 ++++++++++++++------------ 2 files changed, 48 insertions(+), 37 deletions(-) diff --git a/server/entities/characters/player.gd b/server/entities/characters/player.gd index 71db91c..2a3a6cf 100644 --- a/server/entities/characters/player.gd +++ b/server/entities/characters/player.gd @@ -61,7 +61,7 @@ var idleTime:float = 0 # Stun when hit + prevent spam # Punch attack parameters onready var punchHitArea:Area = $punchHitArea var punchAttackDmg:float = 5.0 -var punchAttackDist:float = 0.5 +var punchAttackDist:float = 1 var punchAttackWait:float = 0.6 var punch1AttackDuration:float = 0.1 var punch2AttackDuration:float = 0.4 @@ -70,10 +70,11 @@ var punchAttackDirection:Vector3 = Vector3(1,1.5,0) # Strength of the attack (multiply the normalized vector) var punchAttackStrength:float = 0.5 -# Punch 2 attack parameters +# Kick attack parameters onready var kickHitArea:Area = $kickHitArea var kickAttackDmg:float = 10.0 -var kickAttackDist:float = 0.9 +var kick1AttackDist:float = 1.7 +var kick2AttackDist:float = 1.4 var kickAttackWait:float = 0.75 var kick1AttackDuration:float = 0.2 var kick2AttackDuration:float = 0.3 @@ -243,6 +244,7 @@ func processAttack(attackType:int): attack(ID_PUNCH_2) else: broadcastAnimation(ANIM_JUMP_KICK_SIDE) + attack(ID_KICK_1) KICK: if self.is_on_floor(): if (!animSequence): @@ -271,11 +273,12 @@ func attack(idAttack:int): duration = punch2AttackDuration else: hitArea = kickHitArea - distance = kickAttackDist wait = kickAttackWait if (idAttack == ID_KICK_1): + distance = kick1AttackDist duration = kick1AttackDuration else: + distance = kick2AttackDist duration = kick2AttackDuration # Set active the hitbox of the attack, its visual feedback on server diff --git a/server/entities/characters/player.tscn b/server/entities/characters/player.tscn index dc28c08..5fc9174 100644 --- a/server/entities/characters/player.tscn +++ b/server/entities/characters/player.tscn @@ -1,12 +1,21 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://entities/characters/Class1/class1.gd" type="Script" id=1] -[sub_resource type="BoxShape" id=1] -extents = Vector3( 0.175, 0.275, 0.7 ) +[sub_resource type="BoxShape" id=5] +extents = Vector3( 0.176075, 0.669145, 0.351434 ) -[sub_resource type="BoxShape" id=2] -extents = Vector3( 0.544245, 0.192381, 0.312851 ) +[sub_resource type="CubeMesh" id=6] + +[sub_resource type="SphereMesh" id=7] + +[sub_resource type="CubeMesh" id=2] + +[sub_resource type="ConvexPolygonShape" id=8] +points = PoolVector3Array( -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1 ) + +[sub_resource type="ConvexPolygonShape" id=9] +points = PoolVector3Array( -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1 ) [node name="player" type="KinematicBody"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0033226, -0.0126846, 0.0060811 ) @@ -15,54 +24,53 @@ collision_mask = 3 script = ExtResource( 1 ) [node name="collisionShape" type="CollisionShape" parent="."] -transform = Transform( 1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0.65, 0 ) -shape = SubResource( 1 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.678055, 0 ) +shape = SubResource( 5 ) [node name="model" type="Spatial" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.67638e-08, 0 ) -[node name="CSGBox" type="CSGBox" parent="model"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.513621, 0 ) -width = 0.35 -height = 1.05787 -depth = 0.684 +[node name="body" type="MeshInstance" parent="model"] +transform = Transform( 0.174564, 0, 0, 0, 0.532433, 0, 0, 0, 0.360351, 0, 0.545559, 0 ) +mesh = SubResource( 6 ) +material/0 = null -[node name="CSGSphere" type="CSGSphere" parent="model"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.17856, 0 ) -radius = 0.2 -radial_segments = 24 +[node name="head" type="MeshInstance" parent="model"] +transform = Transform( 0.177349, 0, 0, 0, 0.177349, 0, 0, 0, 0.177349, 0, 1.19631, 0 ) +mesh = SubResource( 7 ) +material/0 = null [node name="punchHitArea" type="Area" parent="."] +transform = Transform( 1, 0, 0, 0, 0.640341, 0, 0, 0, 1, 0, 0.892016, 0 ) visible = false monitoring = false collision_layer = 0 collision_mask = 2 -[node name="punchHitCol" type="CollisionShape" parent="punchHitArea"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.420072, 0.815, 0 ) -shape = SubResource( 2 ) +[node name="punchMesh" type="MeshInstance" parent="punchHitArea"] +transform = Transform( 0.130706, 0, 0, 0, 0.179953, 0, 0, 0, 0.320349, 0, 0, 0 ) +mesh = SubResource( 2 ) +material/0 = null -[node name="punchHitCSG" type="CSGBox" parent="punchHitArea"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.419673, 0.815, 0 ) -width = 1.09437 -height = 0.400067 -depth = 0.618424 +[node name="punchCollider" type="CollisionShape" parent="punchHitArea"] +transform = Transform( 0.130706, 0, 0, 0, 0.179953, 0, 0, 0, 0.320349, 0, 0, 0 ) +shape = SubResource( 8 ) [node name="kickHitArea" type="Area" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.378735, 0 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.730753, 0 ) visible = false monitoring = false collision_layer = 0 collision_mask = 2 -[node name="kickHitCol" type="CollisionShape" parent="kickHitArea"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.42, 0.2, 0 ) -shape = SubResource( 2 ) +[node name="kickMesh" type="MeshInstance" parent="kickHitArea"] +transform = Transform( 0.130706, 0, 0, 0, 0.115231, 0, 0, 0, 0.320349, 0, 0, 0 ) +mesh = SubResource( 2 ) +material/0 = null -[node name="kickHitCSG" type="CSGBox" parent="kickHitArea"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.42, 0.2, 0 ) -width = 1.09437 -height = 0.400067 -depth = 0.618424 +[node name="kickCollider" type="CollisionShape" parent="kickHitArea"] +transform = Transform( 0.130706, 0, 0, 0, 0.115231, 0, 0, 0, 0.320349, 0, 0.161263, 0 ) +shape = SubResource( 9 ) [node name="attackTween" type="Tween" parent="."] [connection signal="body_entered" from="punchHitArea" to="." method="_on_punchHitArea_body_entered"] -- GitLab