monster 03 ai初版
parent
b63fa26966
commit
c4a721dfa0
@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="CoreCfg" load_steps=2 format=3 uid="uid://duhgn52hssk87"]
|
||||
|
||||
[ext_resource type="Script" path="res://script/config/core_cfg.gd" id="1_e8a6y"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_e8a6y")
|
||||
name = ""
|
||||
type = 2
|
||||
@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="CoreCfg" load_steps=2 format=3 uid="uid://b63634fi2nms7"]
|
||||
|
||||
[ext_resource type="Script" path="res://script/config/core_cfg.gd" id="1_grj3e"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_grj3e")
|
||||
name = ""
|
||||
type = 2
|
||||
@ -0,0 +1,29 @@
|
||||
[gd_resource type="Resource" script_class="SkillCfg" load_steps=8 format=3 uid="uid://dslyyl3uqjwi1"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://btg40rn2f36c2" path="res://config/attack/sharp_normal_hit_back.tres" id="1_sp2tj"]
|
||||
[ext_resource type="Resource" uid="uid://bv4uoey1liqoq" path="res://config/attack/sharp_heavy_hit_blow.tres" id="1_txo8b"]
|
||||
[ext_resource type="Resource" uid="uid://bnfnjdw0tms3h" path="res://config/attack_box/box_large.tres" id="2_8iiyr"]
|
||||
[ext_resource type="Resource" uid="uid://diedb7vw7eyxp" path="res://config/attack_box/box_mid.tres" id="2_tp3t7"]
|
||||
[ext_resource type="Script" path="res://script/config/skill_cfg.gd" id="3_oagn5"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://bac4ype7w4wr7" path="res://resource/animation/character/monster03_skill.aseprite" id="5_jfqys"]
|
||||
[ext_resource type="Animation" uid="uid://2oxeq83bpofb" path="res://resource/skill_animation/monster03_slash02.tres" id="6_yqy3u"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("3_oagn5")
|
||||
name = ""
|
||||
skill_animation = ExtResource("6_yqy3u")
|
||||
range = 2.0
|
||||
free_lock = false
|
||||
ignore_push = true
|
||||
attack1 = ExtResource("1_sp2tj")
|
||||
attack1_box = ExtResource("2_tp3t7")
|
||||
attack2 = ExtResource("1_txo8b")
|
||||
attack2_box = ExtResource("2_8iiyr")
|
||||
stance_from = 100
|
||||
stance_to = 0
|
||||
break_level = 3
|
||||
is_charging = false
|
||||
mp_cost = 1
|
||||
refresh_animation = false
|
||||
sprite_frames = ExtResource("5_jfqys")
|
||||
animation_name = "skill02"
|
||||
@ -0,0 +1,25 @@
|
||||
[gd_resource type="Resource" script_class="SkillCfg" load_steps=6 format=3 uid="uid://1hson47yrtgq"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://qmivx7ntfrki" path="res://config/attack/sharp_mid_hit.tres" id="1_iexxu"]
|
||||
[ext_resource type="Resource" uid="uid://bnfnjdw0tms3h" path="res://config/attack_box/box_large.tres" id="2_p4b1w"]
|
||||
[ext_resource type="Script" path="res://script/config/skill_cfg.gd" id="3_n02wr"]
|
||||
[ext_resource type="Animation" uid="uid://co8bivpp1fm6g" path="res://resource/skill_animation/monster03_slash03.tres" id="4_cip05"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://bac4ype7w4wr7" path="res://resource/animation/character/monster03_skill.aseprite" id="5_0ny0c"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("3_n02wr")
|
||||
name = ""
|
||||
skill_animation = ExtResource("4_cip05")
|
||||
range = 4.0
|
||||
free_lock = false
|
||||
ignore_push = false
|
||||
attack1 = ExtResource("1_iexxu")
|
||||
attack1_box = ExtResource("2_p4b1w")
|
||||
stance_from = 100
|
||||
stance_to = 0
|
||||
break_level = 3
|
||||
is_charging = false
|
||||
mp_cost = 1
|
||||
refresh_animation = false
|
||||
sprite_frames = ExtResource("5_0ny0c")
|
||||
animation_name = "skill03"
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 7.0 KiB |
@ -0,0 +1,149 @@
|
||||
[gd_resource type="Animation" load_steps=2 format=3 uid="uid://2oxeq83bpofb"]
|
||||
|
||||
[ext_resource type="SpriteFrames" uid="uid://bac4ype7w4wr7" path="res://resource/animation/character/monster03_skill.aseprite" id="1_arqnp"]
|
||||
|
||||
[resource]
|
||||
resource_name = "monster03_slash02"
|
||||
length = 2.9
|
||||
step = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("View:sprite_frames")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("1_arqnp")]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("View:animation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": ["skill02"]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Status:break_level")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 2.2, 2.4),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 3, 4]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("Status:speed_up_rate")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0.1, 0.8, 1.1, 1.3, 1.6, 1.8),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [-0.5, -1.0, -0.5, -1.0, -0.5, -1.0]
|
||||
}
|
||||
tracks/4/type = "value"
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/path = NodePath("Status:skill_move_speed")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/keys = {
|
||||
"times": PackedFloat32Array(0.7, 0.9, 1.2, 1.4, 1.7, 1.9),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [3.0, 0.0, 2.0, 0.0, 3.0, 0.0]
|
||||
}
|
||||
tracks/5/type = "method"
|
||||
tracks/5/imported = false
|
||||
tracks/5/enabled = true
|
||||
tracks/5/path = NodePath("Battle")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/keys = {
|
||||
"times": PackedFloat32Array(0.9, 1.4, 1.9),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"attack1"
|
||||
}, {
|
||||
"args": [],
|
||||
"method": &"attack1"
|
||||
}, {
|
||||
"args": [],
|
||||
"method": &"attack2"
|
||||
}]
|
||||
}
|
||||
tracks/6/type = "method"
|
||||
tracks/6/imported = false
|
||||
tracks/6/enabled = true
|
||||
tracks/6/path = NodePath("Effect")
|
||||
tracks/6/interp = 1
|
||||
tracks/6/loop_wrap = true
|
||||
tracks/6/keys = {
|
||||
"times": PackedFloat32Array(0.8, 1.3, 1.8),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"cast_attack_particle1"
|
||||
}, {
|
||||
"args": [],
|
||||
"method": &"cast_attack_particle2"
|
||||
}, {
|
||||
"args": [],
|
||||
"method": &"cast_attack_particle3"
|
||||
}]
|
||||
}
|
||||
tracks/7/type = "value"
|
||||
tracks/7/imported = false
|
||||
tracks/7/enabled = true
|
||||
tracks/7/path = NodePath("%Status:skill_move_stop")
|
||||
tracks/7/interp = 1
|
||||
tracks/7/loop_wrap = true
|
||||
tracks/7/keys = {
|
||||
"times": PackedFloat32Array(1, 1.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [false, false]
|
||||
}
|
||||
tracks/8/type = "value"
|
||||
tracks/8/imported = false
|
||||
tracks/8/enabled = true
|
||||
tracks/8/path = NodePath("View:frame")
|
||||
tracks/8/interp = 1
|
||||
tracks/8/loop_wrap = true
|
||||
tracks/8/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]
|
||||
}
|
||||
tracks/9/type = "method"
|
||||
tracks/9/imported = false
|
||||
tracks/9/enabled = true
|
||||
tracks/9/path = NodePath("%Battle")
|
||||
tracks/9/interp = 1
|
||||
tracks/9/loop_wrap = true
|
||||
tracks/9/keys = {
|
||||
"times": PackedFloat32Array(1, 1.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"change_dir"
|
||||
}, {
|
||||
"args": [],
|
||||
"method": &"change_dir"
|
||||
}]
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
[gd_resource type="Animation" load_steps=2 format=3 uid="uid://co8bivpp1fm6g"]
|
||||
|
||||
[ext_resource type="SpriteFrames" uid="uid://bac4ype7w4wr7" path="res://resource/animation/character/monster03_skill.aseprite" id="1_bo7dx"]
|
||||
|
||||
[resource]
|
||||
resource_name = "monster03_slash03"
|
||||
length = 1.8
|
||||
step = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("View:sprite_frames")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("1_bo7dx")]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("View:animation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": ["skill03"]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Status:break_level")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 1.1, 1.3),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 3, 4]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("Status:speed_up_rate")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0.1, 0.7),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [-0.5, -1.0]
|
||||
}
|
||||
tracks/4/type = "value"
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/path = NodePath("Status:skill_move_speed")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/keys = {
|
||||
"times": PackedFloat32Array(0.6, 0.9),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [10.0, 0.0]
|
||||
}
|
||||
tracks/5/type = "method"
|
||||
tracks/5/imported = false
|
||||
tracks/5/enabled = true
|
||||
tracks/5/path = NodePath("Battle")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/keys = {
|
||||
"times": PackedFloat32Array(0.9, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"attack1"
|
||||
}, {
|
||||
"args": [],
|
||||
"method": &"stop"
|
||||
}]
|
||||
}
|
||||
tracks/6/type = "method"
|
||||
tracks/6/imported = false
|
||||
tracks/6/enabled = true
|
||||
tracks/6/path = NodePath("Effect")
|
||||
tracks/6/interp = 1
|
||||
tracks/6/loop_wrap = true
|
||||
tracks/6/keys = {
|
||||
"times": PackedFloat32Array(0.8),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"cast_attack_particle1"
|
||||
}]
|
||||
}
|
||||
tracks/7/type = "value"
|
||||
tracks/7/imported = false
|
||||
tracks/7/enabled = true
|
||||
tracks/7/path = NodePath("View:frame")
|
||||
tracks/7/interp = 1
|
||||
tracks/7/loop_wrap = true
|
||||
tracks/7/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://c37rf5ecfrvwn"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://8rcvw1vnjcf7" path="res://scene/character/character.tscn" id="1_eshlr"]
|
||||
[ext_resource type="Script" path="res://script/character/ai/ai.gd" id="2_7ei2q"]
|
||||
[ext_resource type="Script" path="res://script/character/ai/monster_ai.gd" id="2_e8lqw"]
|
||||
|
||||
[node name="Character" instance=ExtResource("1_eshlr")]
|
||||
|
||||
[node name="MonsterAI" type="Node3D" parent="." index="10"]
|
||||
script = ExtResource("2_7ei2q")
|
||||
[node name="MonsterAI" type="Node3D" parent="." index="11"]
|
||||
script = ExtResource("2_e8lqw")
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c7s7omfjy0r8m"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b2h4pcmlii7dg" path="res://scene/effect/particle/_particle_slash1.tscn" id="1_x3fg4"]
|
||||
|
||||
[node name="Particle" instance=ExtResource("1_x3fg4")]
|
||||
transform = Transform3D(1, 0, 0, 0, -0.707107, 0.353553, 0, -0.707107, -0.353553, 0, 0, 0)
|
||||
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://h5gbbs3adi4r"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b2h4pcmlii7dg" path="res://scene/effect/particle/_particle_slash1.tscn" id="1_7tpc0"]
|
||||
|
||||
[node name="Particle" instance=ExtResource("1_7tpc0")]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.707107, -0.353553, 0, 0.707107, 0.353553, 0, 0, 0)
|
||||
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://damjb16ouflry"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b2h4pcmlii7dg" path="res://scene/effect/particle/_particle_slash1.tscn" id="1_f5wcv"]
|
||||
|
||||
[node name="Particle" instance=ExtResource("1_f5wcv")]
|
||||
transform = Transform3D(1.6, 0, 0, 0, 0.707107, -0.353553, 0, 0.707107, 0.353553, 0, 0, 0)
|
||||
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dmqr8g8x4gcny"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b2h4pcmlii7dg" path="res://scene/effect/particle/_particle_slash1.tscn" id="1_m433m"]
|
||||
|
||||
[node name="Particle" instance=ExtResource("1_m433m")]
|
||||
transform = Transform3D(1, 0, 0, 0, -0.707107, 0.353553, 0, -0.707107, -0.353553, 0, 0, 0)
|
||||
@ -0,0 +1,3 @@
|
||||
@icon("res://addons/beehave/icons/category_leaf.svg")
|
||||
class_name ActionRoleCheck
|
||||
extends Action
|
||||
@ -0,0 +1,10 @@
|
||||
extends ActionRoleCheck
|
||||
class_name ActionRoleCheckIs
|
||||
|
||||
@export var key: Enum.EAIRoleType = Enum.EAIRoleType.None
|
||||
|
||||
|
||||
func run(character: Character, blackboard: Blackboard) -> int:
|
||||
if character.get_status("ai_role") == key:
|
||||
return SUCCESS
|
||||
return FAILURE
|
||||
@ -0,0 +1,10 @@
|
||||
extends ActionRoleCheck
|
||||
class_name ActionRoleCheckIsNot
|
||||
|
||||
@export var key: Enum.EAIRoleType = Enum.EAIRoleType.None
|
||||
|
||||
|
||||
func run(character: Character, blackboard: Blackboard) -> int:
|
||||
if character.get_status("ai_role") != key:
|
||||
return SUCCESS
|
||||
return FAILURE
|
||||
@ -0,0 +1,30 @@
|
||||
extends ActionWithTarget
|
||||
class_name ActionCastSkill
|
||||
|
||||
func execute(character: Character, target: Character, blackboard: Blackboard) -> int:
|
||||
var skill: Skill = character.skill
|
||||
var status: Status = character.status
|
||||
var dir: Vector2 = target.pos2D() - character.pos2D()
|
||||
if status.is_skill_running:
|
||||
character.move_to(dir)
|
||||
return RUNNING
|
||||
var dist: float = dir.length()
|
||||
for skill_cfg: SkillCfg in skill.skill_dict.values():
|
||||
#检查姿态
|
||||
var stance_from: int = skill_cfg.stance_from
|
||||
var check_any_ground: bool = (stance_from == Enum.EStance.GroundAny) and status.is_on_floor
|
||||
var check_any_air: bool = (stance_from == Enum.EStance.AirAny) and not status.is_on_floor
|
||||
var check_any: bool = (stance_from == Enum.EStance.Any) or check_any_ground or check_any_air
|
||||
if (stance_from != int(status.stance)) and not check_any:
|
||||
continue
|
||||
#检查距离
|
||||
if dist > skill_cfg.range:
|
||||
continue
|
||||
#检查远程最小释放距离
|
||||
if dist < skill_cfg.range - 2:
|
||||
continue
|
||||
#施放技能
|
||||
var ret: bool = skill.cast_skill(skill_cfg, dir)
|
||||
if ret:
|
||||
return SUCCESS
|
||||
return FAILURE
|
||||
@ -0,0 +1,16 @@
|
||||
extends ActionWithTarget
|
||||
class_name ActionMoveTo
|
||||
|
||||
@export var dist_min: float = 0
|
||||
@export var dist_max: float = 5
|
||||
|
||||
|
||||
func execute(character: Character, target: Character, blackboard: Blackboard) -> int:
|
||||
var dir: Vector2 = target.pos2D() - character.pos2D()
|
||||
var dist: float = dir.length()
|
||||
if (dist > dist_min ) and (dist < dist_max):
|
||||
character.move_stop()
|
||||
return SUCCESS
|
||||
var is_far: bool = dist >= dist_max
|
||||
character.move_to(dir if is_far else -dir)
|
||||
return FAILURE
|
||||
@ -1,5 +1,12 @@
|
||||
extends AI
|
||||
class_name MonsterAI
|
||||
|
||||
func on_process(delta):
|
||||
pass
|
||||
@onready var core: Core = (%Core as Core)
|
||||
|
||||
|
||||
func on_init()->void:
|
||||
var core_list: Array[CoreCfg] = character.status.cfg.get_core_cfg_list()
|
||||
var index: int = 0
|
||||
for core_cfg in core_list:
|
||||
core.set_active_core(index, core_cfg)
|
||||
index += 1
|
||||
@ -0,0 +1,41 @@
|
||||
extends Node3D
|
||||
class_name AIManager
|
||||
|
||||
var tick_time: float = 1
|
||||
var tick_time_left: float = 1
|
||||
var role_num_1: int = 2 #近战
|
||||
var role_num_2: int = 1 #刺客
|
||||
var role_num_3: int = 2 #远程
|
||||
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
func _process(delta) -> void:
|
||||
tick_time_left -= delta
|
||||
if tick_time_left <= 0:
|
||||
tick_time_left = tick_time
|
||||
tick_time_left = 0
|
||||
if tick_time_left > 0:
|
||||
return
|
||||
var player: Character = Global.character_mgr.get_player()
|
||||
if not player: return
|
||||
var enemy_list: Array[Character] = Global.character_mgr.get_enemy_list(player.id())
|
||||
if not enemy_list: return
|
||||
var pos_player: Vector2 = player.pos2D()
|
||||
enemy_list.sort_custom(func(a: Character, b: Character): return a.pos2D().distance_squared_to(pos_player) < b.pos2D().distance_squared_to(pos_player))
|
||||
var index: int = 0
|
||||
for enemy in enemy_list:
|
||||
if enemy.get_status("is_stagger") or enemy.get_status("is_stun"):
|
||||
enemy.set_status("ai_role", Enum.EAIRoleType.None)
|
||||
continue
|
||||
if index < role_num_1:
|
||||
enemy.set_status("ai_role", Enum.EAIRoleType.Saber)
|
||||
elif index < role_num_1 + role_num_2:
|
||||
enemy.set_status("ai_role", Enum.EAIRoleType.Assassin)
|
||||
elif index < role_num_1 + role_num_2 + role_num_3:
|
||||
enemy.set_status("ai_role", Enum.EAIRoleType.Caster)
|
||||
else:
|
||||
enemy.set_status("ai_role", Enum.EAIRoleType.None)
|
||||
index += 1
|
||||
Loading…
Reference in New Issue