Fix crash while attacking nothing
This commit is contained in:
parent
15b477ca71
commit
b200913a78
@ -78,7 +78,7 @@ func move(movement : Vector2):
|
||||
z_index = 100
|
||||
|
||||
|
||||
func attack(damage : int, points : int, pattern : PoolVector2Array): #TODO
|
||||
func attack(damage : int, points : int, pattern : PoolVector2Array):
|
||||
if attack_points != 0:
|
||||
#change animation to attacking
|
||||
$AnimationPlayer.play("Attack front")
|
||||
@ -87,9 +87,10 @@ func attack(damage : int, points : int, pattern : PoolVector2Array): #TODO
|
||||
# and calls their attacked method
|
||||
for i in range(pattern.size()):
|
||||
var coord = Grid.position_to_coordinates(position, height)
|
||||
var selected_name = Grid.grid[coord.x + pattern[i].x][coord.y + pattern[i].y][0]
|
||||
var selected_name = Grid.grid[coord.x + pattern[i].x][coord.y + pattern[i].y]
|
||||
print(coord.x + pattern[i].x, coord.y + pattern[i].y)
|
||||
if selected_name:
|
||||
get_node(("../" + selected_name)).attacked(damage, "") #TODO effects implementation
|
||||
get_node(("../" + selected_name[0])).attacked(damage, "") #TODO effects implementation
|
||||
|
||||
#change the attack points left
|
||||
attack_points = max(attack_points - points, 0) #keep >= 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user