cooldown
This commit is contained in:
parent
b58e56241c
commit
826e8f1184
@ -14,6 +14,8 @@ extends CharacterBody2D
|
|||||||
@export var state: String = "Idle"
|
@export var state: String = "Idle"
|
||||||
@export var damage: int = 5
|
@export var damage: int = 5
|
||||||
@export var maxAtks: int = 1
|
@export var maxAtks: int = 1
|
||||||
|
@export var currentcooldown: float = 0
|
||||||
|
@export var maxcooldown: float = 0.5
|
||||||
|
|
||||||
@onready var killcount: int = 0
|
@onready var killcount: int = 0
|
||||||
@onready var currAtks: int = 0
|
@onready var currAtks: int = 0
|
||||||
@ -69,34 +71,16 @@ func _process(delta):
|
|||||||
if state != "Attack" && state != "Attack2":
|
if state != "Attack" && state != "Attack2":
|
||||||
is_facing_left = velocity.x > 0 && !(velocity.x < 0)
|
is_facing_left = velocity.x > 0 && !(velocity.x < 0)
|
||||||
|
|
||||||
|
if currentcooldown > 0.:
|
||||||
|
currentcooldown -= delta
|
||||||
# AI STUFF
|
# AI STUFF
|
||||||
velocity += processAI(list) * delta
|
velocity += processAI(list) * delta
|
||||||
#var x = 0
|
|
||||||
#var y = 0
|
|
||||||
|
|
||||||
#if Input.is_action_pressed("ui_left"):
|
|
||||||
# # Move as long as the key/button is pressed.
|
|
||||||
# x -= delta * 50
|
|
||||||
#elif Input.is_action_pressed("ui_right"):
|
|
||||||
# # Move as long as the key/button is pressed.
|
|
||||||
# x += delta * 50
|
|
||||||
#else:
|
|
||||||
# velocity.x *= 0.8
|
|
||||||
#if Input.is_action_pressed("ui_up"):
|
|
||||||
# Move as long as the key/button is pressed.
|
|
||||||
# y -= delta * 50
|
|
||||||
#elif Input.is_action_pressed("ui_down"):
|
|
||||||
# Move as long as the key/button is pressed.
|
|
||||||
# y += delta * 50
|
|
||||||
#else:
|
|
||||||
# velocity.y *= 0.8
|
|
||||||
while velocity.length() > 100:
|
while velocity.length() > 100:
|
||||||
velocity.x *= 0.99
|
velocity.x *= 0.99
|
||||||
velocity.y *= 0.99
|
velocity.y *= 0.99
|
||||||
velocity.x *= 0.97
|
velocity.x *= 0.97
|
||||||
velocity.y *= 0.97
|
velocity.y *= 0.97
|
||||||
#velocity.x += x
|
|
||||||
#velocity.y += y
|
|
||||||
|
|
||||||
if !hitanim.is_emitting():
|
if !hitanim.is_emitting():
|
||||||
anim.modulate.a = 1
|
anim.modulate.a = 1
|
||||||
@ -119,7 +103,9 @@ func processAI(objs):
|
|||||||
else:
|
else:
|
||||||
weight = obj.priority * position.distance_to(obj.position) * ((maxhp + 1) / hp)
|
weight = obj.priority * position.distance_to(obj.position) * ((maxhp + 1) / hp)
|
||||||
vec = weight * -position.direction_to(obj.position)
|
vec = weight * -position.direction_to(obj.position)
|
||||||
|
if currentcooldown <= 0:
|
||||||
attack()
|
attack()
|
||||||
|
currentcooldown = maxcooldown
|
||||||
|
|
||||||
if vec.length() < 5 && objs.size() > 1:
|
if vec.length() < 5 && objs.size() > 1:
|
||||||
vec.y *= 3
|
vec.y *= 3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user