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
var primaryAttackDmg:float = 15.0
var primaryAttackDist:float = 1.2
var primaryAttackDuration:float = 0.4
# General direction (normalized anyway)
var primaryAttackDirection:Vector3 = Vector3(3,1,0)
# Strength of the attack (multiply the normalized vector)
var primaryAttackStrength:float = 1.5
# Secondary attack parameters
......@@ -212,9 +214,16 @@ func secondaryAttack():
# Called when detected by an attack's hitbox
func hurt(damages:int, sourceId:int, direction:Vector3, strength:float):
# Add damages to your bar
hp += damages
# Projection: normalized vector * direction * strength added to the velocity of the player
vel += strength*hp*direction
# Update the last played who hit you
lastStrikerId = sourceId
# Feedback on the player's client
rpc_unreliable_id(ownId, "hurt", hp)
func die():
......@@ -224,23 +233,29 @@ func die():
######## SIGNALS ########
# Primary hit has landed on something
func _on_primaryHitArea_body_entered(body:Node):
var direction:Vector3 = primaryAttackDirection.normalized()
direction.x*=bodyRotation
# General function on attack's hitboxes
func _on_generalHitArea_entered(damageVar:int, directionVar:Vector3, strengthVar:float, body:Node):
# Don't hurt yourself
if int(body.name)==ownId:
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")
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
func _on_secondaryHitArea_body_entered(body:Node):
var direction:Vector3 = secondaryAttackDirection.normalized()
direction.x*=bodyRotation
if int(body.name)==ownId:
return
print("body named " + body.name + " hit: secondary")
body.hurt(secondaryAttackDmg, ownId, direction, secondaryAttackStrength)
_on_generalHitArea_entered(secondaryAttackDmg, secondaryAttackDirection, secondaryAttackStrength, body)
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