Skip to content
Snippets Groups Projects
Commit 1ac19a0b authored by Canopteks's avatar Canopteks
Browse files

Time to merge git add .!

parent 5d227713
Branches teamrocket
Tags
No related merge requests found
...@@ -53,7 +53,9 @@ onready var primaryHitArea:Area = $primaryHitArea ...@@ -53,7 +53,9 @@ onready var primaryHitArea:Area = $primaryHitArea
var primaryAttackDmg:float = 15.0 var primaryAttackDmg:float = 15.0
var primaryAttackDist:float = 1.2 var primaryAttackDist:float = 1.2
var primaryAttackDuration:float = 0.4 var primaryAttackDuration:float = 0.4
# General direction (normalized anyway)
var primaryAttackDirection:Vector3 = Vector3(3,1,0) var primaryAttackDirection:Vector3 = Vector3(3,1,0)
# Strength of the attack (multiply the normalized vector)
var primaryAttackStrength:float = 1.5 var primaryAttackStrength:float = 1.5
# Secondary attack parameters # Secondary attack parameters
...@@ -212,9 +214,16 @@ func secondaryAttack(): ...@@ -212,9 +214,16 @@ func secondaryAttack():
# Called when detected by an attack's hitbox # Called when detected by an attack's hitbox
func hurt(damages:int, sourceId:int, direction:Vector3, strength:float): func hurt(damages:int, sourceId:int, direction:Vector3, strength:float):
# Add damages to your bar
hp += damages hp += damages
# Projection: normalized vector * direction * strength added to the velocity of the player
vel += strength*hp*direction vel += strength*hp*direction
# Update the last played who hit you
lastStrikerId = sourceId lastStrikerId = sourceId
# Feedback on the player's client
rpc_unreliable_id(ownId, "hurt", hp) rpc_unreliable_id(ownId, "hurt", hp)
func die(): func die():
...@@ -224,23 +233,29 @@ func die(): ...@@ -224,23 +233,29 @@ func die():
######## SIGNALS ######## ######## SIGNALS ########
# Primary hit has landed on something # General function on attack's hitboxes
func _on_primaryHitArea_body_entered(body:Node): func _on_generalHitArea_entered(damageVar:int, directionVar:Vector3, strengthVar:float, body:Node):
var direction:Vector3 = primaryAttackDirection.normalized() # Don't hurt yourself
direction.x*=bodyRotation
if int(body.name)==ownId: if int(body.name)==ownId:
return return
# Normalized projection vector
var direction:Vector3 = directionVar.normalized()
# Rotate the vector depending on the player orientation
direction.x*=bodyRotation
print("body named " + body.name + " hit: primary") print("body named " + body.name + " hit: primary")
body.hurt(primaryAttackDmg, ownId, direction, primaryAttackStrength)
# Call the function on the affected player
body.hurt(damageVar, ownId, direction, strengthVar)
# Primary hit has landed on something
func _on_primaryHitArea_body_entered(body:Node):
_on_generalHitArea_entered(primaryAttackDmg, primaryAttackDirection, primaryAttackStrength, body)
# Secondary hit has landed on something # Secondary hit has landed on something
func _on_secondaryHitArea_body_entered(body:Node): func _on_secondaryHitArea_body_entered(body:Node):
var direction:Vector3 = secondaryAttackDirection.normalized() _on_generalHitArea_entered(secondaryAttackDmg, secondaryAttackDirection, secondaryAttackStrength, body)
direction.x*=bodyRotation
if int(body.name)==ownId:
return
print("body named " + body.name + " hit: secondary")
body.hurt(secondaryAttackDmg, ownId, direction, secondaryAttackStrength)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment