2024-01-29 01:52:01 +01:00
|
|
|
extends Area2D
|
|
|
|
var velocity: Vector2 = Vector2()
|
2024-01-29 03:42:38 +01:00
|
|
|
var direction
|
|
|
|
var speed = 100
|
2024-06-17 23:08:25 +02:00
|
|
|
var speciality
|
2024-01-29 03:42:38 +01:00
|
|
|
var btype
|
2024-03-24 19:23:12 +01:00
|
|
|
var isvisible
|
2024-05-16 00:51:17 +02:00
|
|
|
var attack
|
|
|
|
var crit
|
2024-01-29 01:52:01 +01:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2024-03-24 19:23:12 +01:00
|
|
|
isvisible = $VisibleOnScreenNotifier2D
|
2024-01-29 03:42:38 +01:00
|
|
|
add_to_group(btype)
|
|
|
|
#pass # Replace with function body.
|
2024-01-29 01:52:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(delta):
|
|
|
|
pass
|
|
|
|
|
|
|
|
func _physics_process(delta):
|
2024-06-15 23:11:43 +02:00
|
|
|
if isvisible.is_on_screen() && Global.live != 4:
|
2024-03-24 19:23:12 +01:00
|
|
|
if direction == null:
|
|
|
|
position += velocity * delta
|
|
|
|
else:
|
|
|
|
position += speed * delta * direction
|
2024-01-29 01:52:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _on_body_entered(body):
|
2024-01-29 03:42:38 +01:00
|
|
|
if !body.is_in_group(btype):
|
2024-05-19 21:12:02 +02:00
|
|
|
if body.is_in_group("players") && Global.dificulty != 1:
|
2024-01-30 04:05:17 +01:00
|
|
|
if body.weakness == 3:
|
2024-04-23 00:19:53 +02:00
|
|
|
print("weakness")
|
2024-09-26 22:06:33 +02:00
|
|
|
Global.result[3] += attack * crit
|
2024-06-17 23:08:25 +02:00
|
|
|
#Input.start_joy_vibration(0,0,1,3)
|
2024-05-16 00:51:17 +02:00
|
|
|
if Global.debug:
|
2024-05-19 21:12:02 +02:00
|
|
|
if Global.dstats[Global.dparty[Global.dcpchar][0]][0] > (attack * crit):
|
|
|
|
Global.dstats[Global.dparty[Global.dcpchar][0]][0] -= attack * crit
|
|
|
|
else:
|
|
|
|
Global.dstats[Global.dparty[Global.dcpchar][0]][0] = 0
|
2024-05-16 00:51:17 +02:00
|
|
|
else:
|
2024-05-19 21:12:02 +02:00
|
|
|
if Global.cstats[Global.party[Global.cpchar][0]][0] > (attack * crit):
|
|
|
|
Global.cstats[Global.party[Global.cpchar][0]][0] -= attack * crit
|
|
|
|
else:
|
|
|
|
Global.cstats[Global.party[Global.cpchar][0]][0] = 0
|
2024-04-23 00:19:53 +02:00
|
|
|
else:
|
2024-09-26 22:06:33 +02:00
|
|
|
Global.result[3] += attack
|
2024-06-17 23:08:25 +02:00
|
|
|
#Input.start_joy_vibration(0,1,0,2)
|
2024-05-16 00:51:17 +02:00
|
|
|
if Global.debug:
|
2024-05-19 21:12:02 +02:00
|
|
|
if Global.dstats[Global.dparty[Global.dcpchar][0]][0] > attack:
|
|
|
|
Global.dstats[Global.dparty[Global.dcpchar][0]][0] -= attack
|
|
|
|
else:
|
|
|
|
Global.dstats[Global.dparty[Global.dcpchar][0]][0] = 0
|
2024-05-16 00:51:17 +02:00
|
|
|
else:
|
2024-05-19 21:12:02 +02:00
|
|
|
if Global.cstats[Global.party[Global.cpchar][0]][0] > attack:
|
|
|
|
Global.cstats[Global.party[Global.cpchar][0]][0] -= attack
|
|
|
|
else:
|
|
|
|
Global.cstats[Global.party[Global.cpchar][0]][0] = 0
|
2024-06-17 23:08:25 +02:00
|
|
|
elif body.is_in_group("boss") && Global.dificulty != 1 && Global.cboss[1] != null:
|
|
|
|
if body.weakness == 3:
|
2024-05-19 21:12:02 +02:00
|
|
|
print("weakness")
|
2024-06-17 23:08:25 +02:00
|
|
|
if Global.cboss[1] >= (attack * crit):
|
|
|
|
Global.cboss[1] -= attack * crit
|
|
|
|
else:
|
|
|
|
Global.cboss[1] = 0
|
|
|
|
else:
|
|
|
|
if Global.cboss[1] >= (attack):
|
|
|
|
Global.cboss[1] -= attack
|
|
|
|
else:
|
|
|
|
Global.cboss[1] = 0
|
2024-05-19 21:12:02 +02:00
|
|
|
elif body.is_in_group("enemies") && Global.dificulty != 1:
|
2024-06-17 23:08:25 +02:00
|
|
|
if body.weakness == 3:
|
2024-04-23 00:19:53 +02:00
|
|
|
print("weakness")
|
2024-01-29 01:52:01 +01:00
|
|
|
#if body.is_in_group("players"):
|
|
|
|
# Global.live = 2
|
|
|
|
#elif body.is_in_group("enemies"):
|
|
|
|
# Global.live = 3
|
2024-01-29 01:57:21 +01:00
|
|
|
#elif body.is_in_group("boss"):
|
|
|
|
# Global.live = 3
|
2024-01-29 03:42:38 +01:00
|
|
|
queue_free()
|
2024-01-29 01:52:01 +01:00
|
|
|
|
|
|
|
|
2024-01-29 03:42:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _on_area_entered(area):
|
|
|
|
if !area.is_in_group(btype):
|
|
|
|
queue_free()
|
|
|
|
#pass # Replace with function body.
|