From a0cef620e081564e8b46a6c9297594854775c669 Mon Sep 17 00:00:00 2001 From: tonydero Date: Wed, 16 Oct 2024 15:04:44 -0600 Subject: [PATCH] add enums for attack types, add angle calc --- scripts/AbilityPlayer.gd | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/AbilityPlayer.gd b/scripts/AbilityPlayer.gd index a84bf26..d5e4ce0 100644 --- a/scripts/AbilityPlayer.gd +++ b/scripts/AbilityPlayer.gd @@ -2,12 +2,15 @@ class_name AbilityPlayer extends TextureRect +enum TARGTYPES { SINGLE, CLEAVE, CHAIN, SWIPE, WAVE, AREA, RAY } +enum PDMGTYPES { SLICE, PUNCTURE, BASH, HACK, SHRED } +enum MDMGTYPES { BURN, FREEZE, SHOCK, POISON, LIFE, RADIANT, ARCANE, FORCE } var middleX var playerPos @export var attack_range := 0 -@export var attack_type := "single_target" +@export var attack_type := TARGTYPES.SINGLE @export var attack_damage := 200 @export var attack_speed := 1.0 @@ -31,17 +34,21 @@ func _get_num_enemies() -> int: return enemies.size() -func _get_distance_to_player(enemy: Node) -> float: +func _get_distsq_to_player(enemy: Node) -> float: return enemy.position.distance_squared_to(playerPos) +func _get_angle_to_player(enemy: Node) -> float: + return enemy.position.angle_to_point(playerPos) + + func _get_target(enemies) -> Node: # var numEnemies := _get_num_enemies() # TODO implement range, i.e. closest within range var enemyDists var closestEnemy # get list of distances by mapping distance to each node in enemies - enemyDists = enemies.map(_get_distance_to_player) + enemyDists = enemies.map(_get_distsq_to_player) # get closest enemy by finding first index with min dist closestEnemy = enemies[enemyDists.find(enemyDists.min())]