|
@@ -47,53 +47,53 @@ export var tickrate = 4
|
|
|
|
|
|
var blockmapenemy = {}
|
|
|
|
|
|
-func _physics_process(delta):
|
|
|
-
|
|
|
-#setting tickrate, to reduce executions per second
|
|
|
-# tick += 1
|
|
|
-# if fmod(tick,tickrate) == 0:
|
|
|
- if true:
|
|
|
-
|
|
|
-#dict of aprox positions of players
|
|
|
- var blockmap = {}
|
|
|
- if get_node('../players').get_child_count() == 0: return
|
|
|
- for z in get_node('../players').get_children():
|
|
|
- var x = int(z.global_position.x/20)
|
|
|
- var y = int(z.global_position.y/20)
|
|
|
- blockmap[Vector2(x,y)] = z
|
|
|
-
|
|
|
-#yes this abomination controls the enemies, ECS code looks ugly as fuck in this engine
|
|
|
- for i in dict.arraytarget.size():
|
|
|
-
|
|
|
-# death checking
|
|
|
- if dict.arrayvida[i] > 0 and dict.enabled[i]:
|
|
|
-
|
|
|
-#picking new targets if the last one is invalid
|
|
|
- if dict.arraytarget[i] == null:
|
|
|
- if get_node('../players').get_child_count() == 0: return
|
|
|
- var array = get_node('../players').get_children()
|
|
|
- if array.size() > 0:
|
|
|
- dict.arraytarget[i] = array[randi()%array.size()]
|
|
|
-
|
|
|
-#exclusive movmenet code
|
|
|
- if fmod(tick, dict.arraydirtime[i]) == 0:
|
|
|
- if is_instance_valid(dict.arraytarget[i]):
|
|
|
- dict.arraymotion[i] = (dict.arraytarget[i].global_position - dict.arraypos[i]).normalized() * speed
|
|
|
- dict.arraypos[i] += dict.arraymotion[i]
|
|
|
-
|
|
|
-# enemy attak on players
|
|
|
- var x = int(dict.arraypos[i].x/20)
|
|
|
- var y = int(dict.arraypos[i].y/20)
|
|
|
- if blockmap.has(Vector2(x,y)):
|
|
|
- blockmap[Vector2(x,y)].damage( -enemydmg, '')
|
|
|
-#recycling enemies
|
|
|
- elif dict.enabled[i]:
|
|
|
- var rot = rand_range(-PI,PI)
|
|
|
- dict.arraypos[i] = (Vector2(sin(rot), cos(rot)) * rand_range(400,800)) + Vector2(320,180)
|
|
|
- dict.arrayvida[i] = 100
|
|
|
- dict.arraytarget[i] = null
|
|
|
- death_count(dict.attacker[i])
|
|
|
-
|
|
|
+#func _physics_process(delta):
|
|
|
+#
|
|
|
+##setting tickrate, to reduce executions per second
|
|
|
+## tick += 1
|
|
|
+## if fmod(tick,tickrate) == 0:
|
|
|
+# if true:
|
|
|
+#
|
|
|
+##dict of aprox positions of players
|
|
|
+# var blockmap = {}
|
|
|
+# if get_node('../players').get_child_count() == 0: return
|
|
|
+# for z in get_node('../players').get_children():
|
|
|
+# var x = int(z.global_position.x/20)
|
|
|
+# var y = int(z.global_position.y/20)
|
|
|
+# blockmap[Vector2(x,y)] = z
|
|
|
+#
|
|
|
+##yes this abomination controls the enemies, ECS code looks ugly as fuck in this engine
|
|
|
+# for i in dict.arraytarget.size():
|
|
|
+#
|
|
|
+## death checking
|
|
|
+# if dict.arrayvida[i] > 0 and dict.enabled[i]:
|
|
|
+#
|
|
|
+##picking new targets if the last one is invalid
|
|
|
+# if dict.arraytarget[i] == null:
|
|
|
+# if get_node('../players').get_child_count() == 0: return
|
|
|
+# var array = get_node('../players').get_children()
|
|
|
+# if array.size() > 0:
|
|
|
+# dict.arraytarget[i] = array[randi()%array.size()]
|
|
|
+#
|
|
|
+##exclusive movmenet code
|
|
|
+# if fmod(tick, dict.arraydirtime[i]) == 0:
|
|
|
+# if is_instance_valid(dict.arraytarget[i]):
|
|
|
+# dict.arraymotion[i] = (dict.arraytarget[i].global_position - dict.arraypos[i]).normalized() * speed
|
|
|
+# dict.arraypos[i] += dict.arraymotion[i]
|
|
|
+#
|
|
|
+## enemy attak on players
|
|
|
+# var x = int(dict.arraypos[i].x/20)
|
|
|
+# var y = int(dict.arraypos[i].y/20)
|
|
|
+# if blockmap.has(Vector2(x,y)):
|
|
|
+# blockmap[Vector2(x,y)].damage( -enemydmg, '')
|
|
|
+##recycling enemies
|
|
|
+# elif dict.enabled[i]:
|
|
|
+# var rot = rand_range(-PI,PI)
|
|
|
+# dict.arraypos[i] = (Vector2(sin(rot), cos(rot)) * rand_range(400,800)) + Vector2(320,180)
|
|
|
+# dict.arrayvida[i] = 100
|
|
|
+# dict.arraytarget[i] = null
|
|
|
+# death_count(dict.attacker[i])
|
|
|
+#
|
|
|
|
|
|
func damage_detection(arg,dmg, attacker):
|
|
|
blockmapenemy = {}
|