Demo: Implement Summoner and Imp
This commit is contained in:
parent
51012571ae
commit
2451cf801f
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=33 format=3 uid="uid://ooigbfhfy4wa"]
|
||||
[gd_scene load_steps=36 format=3 uid="uid://ooigbfhfy4wa"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dlo1ine6p5di4" path="res://demo/assets/agent_bobby.png" id="1_1u51b"]
|
||||
[ext_resource type="Script" path="res://demo/agents/scripts/agent_base.gd" id="1_n8vy2"]
|
||||
|
@ -43,6 +43,34 @@ scale_min = 0.8
|
|||
scale_max = 1.2
|
||||
scale_curve = SubResource("CurveTexture_sb0wp")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_e33mb"]
|
||||
_data = [Vector2(0, 0.010989), 0.0, 0.0, 0, 0, Vector2(0.151111, 1), 1.3559, 1.3559, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_qti8k"]
|
||||
curve = SubResource("Curve_e33mb")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_gmal1"]
|
||||
lifetime_randomness = 0.5
|
||||
particle_flag_disable_z = true
|
||||
emission_shape = 3
|
||||
emission_box_extents = Vector3(40, 1, 1)
|
||||
direction = Vector3(0, -1, 0)
|
||||
spread = 90.0
|
||||
initial_velocity_min = 150.0
|
||||
initial_velocity_max = 250.0
|
||||
angular_velocity_min = -90.0
|
||||
angular_velocity_max = 90.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
radial_accel_min = -90.0
|
||||
radial_accel_max = 90.0
|
||||
damping_min = 200.0
|
||||
damping_max = 200.0
|
||||
scale_min = 0.8
|
||||
scale_max = 1.2
|
||||
scale_curve = SubResource("CurveTexture_qti8k")
|
||||
color = Color(0.913725, 0.8, 0.898039, 1)
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_0c228"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_nvm4d"]
|
||||
|
@ -3247,7 +3275,6 @@ tracks/17/keys = {
|
|||
|
||||
[sub_resource type="Animation" id="Animation_5mxvi"]
|
||||
resource_name = "summon"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
|
@ -3255,7 +3282,7 @@ tracks/0/path = NodePath("Root/Rig/LegL:position")
|
|||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(-29, 65), Vector2(-29, 65)]
|
||||
|
@ -3267,7 +3294,7 @@ tracks/1/path = NodePath("Root/Rig/LegL:rotation")
|
|||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 0.0]
|
||||
|
@ -3279,7 +3306,7 @@ tracks/2/path = NodePath("Root/Rig/LegL:scale")
|
|||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1), Vector2(1, 1)]
|
||||
|
@ -3291,7 +3318,7 @@ tracks/3/path = NodePath("Root/Rig/LegR:position")
|
|||
tracks/3/interp = 2
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(31, 65), Vector2(47, 54), Vector2(43, 56.75), Vector2(47, 54), Vector2(43, 56.75), Vector2(31, 65)]
|
||||
|
@ -3303,7 +3330,7 @@ tracks/4/path = NodePath("Root/Rig/LegR:rotation")
|
|||
tracks/4/interp = 2
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, -0.40126, -0.768424, -0.40126, -0.768424, 0.0]
|
||||
|
@ -3315,7 +3342,7 @@ tracks/5/path = NodePath("Root/Rig/LegR:scale")
|
|||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)]
|
||||
|
@ -3327,7 +3354,7 @@ tracks/6/path = NodePath("Root/Rig/Body:position")
|
|||
tracks/6/interp = 2
|
||||
tracks/6/loop_wrap = true
|
||||
tracks/6/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.3, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.6, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(5, 53), Vector2(5, 53), Vector2(5, 53), Vector2(5, 53)]
|
||||
|
@ -3339,7 +3366,7 @@ tracks/7/path = NodePath("Root/Rig/Body:rotation")
|
|||
tracks/7/interp = 2
|
||||
tracks/7/loop_wrap = true
|
||||
tracks/7/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.3, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.6, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, -0.179614, -0.179614, 0.0]
|
||||
|
@ -3351,7 +3378,7 @@ tracks/8/path = NodePath("Root/Rig/Body:scale")
|
|||
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),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1), Vector2(1, 1), Vector2(0.9, 1.1), Vector2(1, 1), Vector2(0.9, 1.1), Vector2(1, 1)]
|
||||
|
@ -3363,7 +3390,7 @@ tracks/9/path = NodePath("Root/Rig/Body/Hat:position")
|
|||
tracks/9/interp = 2
|
||||
tracks/9/loop_wrap = true
|
||||
tracks/9/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(2, -91), Vector2(2, -91)]
|
||||
|
@ -3375,7 +3402,7 @@ tracks/10/path = NodePath("Root/Rig/Body/Hat:rotation")
|
|||
tracks/10/interp = 2
|
||||
tracks/10/loop_wrap = true
|
||||
tracks/10/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 0.0]
|
||||
|
@ -3387,7 +3414,7 @@ tracks/11/path = NodePath("Root/Rig/Body/Hat:scale")
|
|||
tracks/11/interp = 1
|
||||
tracks/11/loop_wrap = true
|
||||
tracks/11/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1), Vector2(1, 1)]
|
||||
|
@ -3399,7 +3426,7 @@ tracks/12/path = NodePath("Root/Rig/Body/HandL:position")
|
|||
tracks/12/interp = 2
|
||||
tracks/12/loop_wrap = true
|
||||
tracks/12/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(-60, -53), Vector2(-71.1271, -84.0591), Vector2(-76.1533, -94.4691), Vector2(-71.1271, -84.0591), Vector2(-76.1533, -94.4691), Vector2(-60, -53)]
|
||||
|
@ -3411,7 +3438,7 @@ tracks/13/path = NodePath("Root/Rig/Body/HandL:rotation")
|
|||
tracks/13/interp = 2
|
||||
tracks/13/loop_wrap = true
|
||||
tracks/13/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 0.0, -0.836345, 0.0, -0.836345, 0.0]
|
||||
|
@ -3423,7 +3450,7 @@ tracks/14/path = NodePath("Root/Rig/Body/HandL:scale")
|
|||
tracks/14/interp = 1
|
||||
tracks/14/loop_wrap = true
|
||||
tracks/14/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)]
|
||||
|
@ -3435,7 +3462,7 @@ tracks/15/path = NodePath("Root/Rig/Body/HandR:position")
|
|||
tracks/15/interp = 2
|
||||
tracks/15/loop_wrap = true
|
||||
tracks/15/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(51, -51), Vector2(61.8744, -83.286), Vector2(62.8802, -95.0655), Vector2(61.8744, -83.286), Vector2(62.8802, -95.0655), Vector2(51, -51)]
|
||||
|
@ -3447,7 +3474,7 @@ tracks/16/path = NodePath("Root/Rig/Body/HandR:rotation")
|
|||
tracks/16/interp = 2
|
||||
tracks/16/loop_wrap = true
|
||||
tracks/16/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 0.0, -0.887813, 0.0, -0.887813, 0.0]
|
||||
|
@ -3459,7 +3486,7 @@ tracks/17/path = NodePath("Root/Rig/Body/HandR:scale")
|
|||
tracks/17/interp = 1
|
||||
tracks/17/loop_wrap = true
|
||||
tracks/17/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)]
|
||||
|
@ -4322,6 +4349,7 @@ region_rect = Rect2(111, 34, 26.9272, 26.6298)
|
|||
[node name="WeaponNinjaStar" type="Sprite2D" parent="Root"]
|
||||
visible = false
|
||||
position = Vector2(-55, -76)
|
||||
scale = Vector2(0.999985, 0.999984)
|
||||
texture = ExtResource("4_1c5xq")
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="Root"]
|
||||
|
@ -4329,6 +4357,7 @@ position = Vector2(50, 0)
|
|||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
script = ExtResource("5_taq6b")
|
||||
damage = null
|
||||
knockback_strength = 1000.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Root/Hitbox"]
|
||||
|
@ -4370,6 +4399,17 @@ one_shot = true
|
|||
explosiveness = 0.7
|
||||
fixed_fps = 60
|
||||
|
||||
[node name="Summoned" type="GPUParticles2D" parent="FX"]
|
||||
position = Vector2(0, 83)
|
||||
emitting = false
|
||||
amount = 16
|
||||
process_material = SubResource("ParticleProcessMaterial_gmal1")
|
||||
texture = ExtResource("4_mnb6v")
|
||||
lifetime = 1.4
|
||||
one_shot = true
|
||||
explosiveness = 0.5
|
||||
fixed_fps = 60
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
visible = false
|
||||
position = Vector2(-1, -7)
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://730bthc0ywhd"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ooigbfhfy4wa" path="res://demo/agents/agent_base.tscn" id="1_c1bsr"]
|
||||
[ext_resource type="Texture2D" uid="uid://h70okn6hmxum" path="res://demo/assets/agent_imp.png" id="2_vnje4"]
|
||||
[ext_resource type="BehaviorTree" uid="uid://c2bxoo68ywb27" path="res://demo/ai/trees/enemy_melee_imp.tres" id="3_u821b"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_aog23"]
|
||||
var/speed/name = "speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[node name="AgentImp" instance=ExtResource("1_c1bsr")]
|
||||
|
||||
[node name="LegL" parent="Root/Rig" index="1"]
|
||||
texture = ExtResource("2_vnje4")
|
||||
|
||||
[node name="LegR" parent="Root/Rig" index="2"]
|
||||
texture = ExtResource("2_vnje4")
|
||||
|
||||
[node name="Body" parent="Root/Rig" index="3"]
|
||||
texture = ExtResource("2_vnje4")
|
||||
|
||||
[node name="Hat" parent="Root/Rig/Body" index="0"]
|
||||
texture = ExtResource("2_vnje4")
|
||||
|
||||
[node name="HandL" parent="Root/Rig/Body" index="1"]
|
||||
texture = ExtResource("2_vnje4")
|
||||
|
||||
[node name="HandR" parent="Root/Rig/Body" index="2"]
|
||||
texture = ExtResource("2_vnje4")
|
||||
|
||||
[node name="Health" parent="." index="3"]
|
||||
max_health = 5.0
|
||||
|
||||
[node name="BTPlayer" type="BTPlayer" parent="." index="5"]
|
||||
behavior_tree = ExtResource("3_u821b")
|
||||
blackboard_plan = SubResource("BlackboardPlan_aog23")
|
|
@ -1,10 +1,10 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://comfxjrcylgb"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://1dnm7tuik8xo"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ooigbfhfy4wa" path="res://demo/agents/agent_base.tscn" id="1_l180o"]
|
||||
[ext_resource type="Texture2D" uid="uid://cw8s50856x8ct" path="res://demo/assets/agent_melee_simple.png" id="2_bvbes"]
|
||||
[ext_resource type="BehaviorTree" uid="uid://bpdm5jnegi38" path="res://demo/ai/trees/enemy_melee_simple.tres" id="3_tb7cx"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_jbvam"]
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_s08ac"]
|
||||
var/speed/name = "speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
|
@ -13,13 +13,13 @@ var/speed/hint_string = "10,1000,10"
|
|||
|
||||
[node name="AgentMeleeSimple" instance=ExtResource("1_l180o")]
|
||||
|
||||
[node name="LegL" parent="Root/Rig" index="0"]
|
||||
[node name="LegL" parent="Root/Rig" index="1"]
|
||||
texture = ExtResource("2_bvbes")
|
||||
|
||||
[node name="LegR" parent="Root/Rig" index="1"]
|
||||
[node name="LegR" parent="Root/Rig" index="2"]
|
||||
texture = ExtResource("2_bvbes")
|
||||
|
||||
[node name="Body" parent="Root/Rig" index="2"]
|
||||
[node name="Body" parent="Root/Rig" index="3"]
|
||||
texture = ExtResource("2_bvbes")
|
||||
|
||||
[node name="Hat" parent="Root/Rig/Body" index="0"]
|
||||
|
@ -31,6 +31,6 @@ texture = ExtResource("2_bvbes")
|
|||
[node name="HandR" parent="Root/Rig/Body" index="2"]
|
||||
texture = ExtResource("2_bvbes")
|
||||
|
||||
[node name="BTPlayer" type="BTPlayer" parent="." index="4"]
|
||||
[node name="BTPlayer" type="BTPlayer" parent="." index="5"]
|
||||
behavior_tree = ExtResource("3_tb7cx")
|
||||
blackboard_plan = SubResource("BlackboardPlan_jbvam")
|
||||
blackboard_plan = SubResource("BlackboardPlan_s08ac")
|
||||
|
|
|
@ -1,17 +1,25 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://bycvi2fb0f7ue"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://bycvi2fb0f7ue"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ooigbfhfy4wa" path="res://demo/agents/agent_base.tscn" id="1_neifu"]
|
||||
[ext_resource type="Texture2D" uid="uid://ombnpn2edldt" path="res://demo/assets/agent_summoner.png" id="2_fcti4"]
|
||||
[ext_resource type="BehaviorTree" uid="uid://cpxk7jnqpwwlc" path="res://demo/ai/trees/enemy_summoner.tres" id="3_bunpq"]
|
||||
|
||||
[node name="Bobby" instance=ExtResource("1_neifu")]
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_bqv3d"]
|
||||
var/speed/name = "speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 300.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[node name="LegL" parent="Root/Rig" index="0"]
|
||||
[node name="AgentSummoner" instance=ExtResource("1_neifu")]
|
||||
|
||||
[node name="LegL" parent="Root/Rig" index="1"]
|
||||
texture = ExtResource("2_fcti4")
|
||||
|
||||
[node name="LegR" parent="Root/Rig" index="1"]
|
||||
[node name="LegR" parent="Root/Rig" index="2"]
|
||||
texture = ExtResource("2_fcti4")
|
||||
|
||||
[node name="Body" parent="Root/Rig" index="2"]
|
||||
[node name="Body" parent="Root/Rig" index="3"]
|
||||
texture = ExtResource("2_fcti4")
|
||||
|
||||
[node name="Hat" parent="Root/Rig/Body" index="0"]
|
||||
|
@ -22,3 +30,7 @@ texture = ExtResource("2_fcti4")
|
|||
|
||||
[node name="HandR" parent="Root/Rig/Body" index="2"]
|
||||
texture = ExtResource("2_fcti4")
|
||||
|
||||
[node name="BTPlayer" type="BTPlayer" parent="." index="5"]
|
||||
behavior_tree = ExtResource("3_bunpq")
|
||||
blackboard_plan = SubResource("BlackboardPlan_bqv3d")
|
||||
|
|
|
@ -12,6 +12,7 @@ extends CharacterBody2D
|
|||
|
||||
## Base agent script.
|
||||
|
||||
const MINION_RESOURCE := "res://demo/agents/agent_imp.tscn"
|
||||
const NinjaStar := preload("res://demo/agents/ninja_star/ninja_star.tscn")
|
||||
const Fireball := preload("res://demo/agents/fireball/fireball.tscn")
|
||||
|
||||
|
@ -19,6 +20,7 @@ const Fireball := preload("res://demo/agents/fireball/fireball.tscn")
|
|||
@onready var health: Health = $Health
|
||||
@onready var root: Node2D = $Root
|
||||
@onready var collision_shape_2d: CollisionShape2D = $CollisionShape2D
|
||||
@onready var summoning_effect: GPUParticles2D = $FX/Summoned
|
||||
|
||||
|
||||
var _frames_since_facing_update: int = 0
|
||||
|
@ -43,7 +45,8 @@ func face_dir(dir: float) -> void:
|
|||
root.scale.x = -1.0;
|
||||
_frames_since_facing_update = 0
|
||||
|
||||
|
||||
## Returns 1.0 when agent is facing right.
|
||||
## Returns -1.0 when agent is facing left.
|
||||
func get_facing() -> float:
|
||||
return signf(root.scale.x)
|
||||
|
||||
|
@ -62,6 +65,27 @@ func spit_fire() -> void:
|
|||
fireball.global_position = global_position + Vector2.RIGHT * 100.0 * get_facing()
|
||||
|
||||
|
||||
func summon_minion(p_position: Vector2) -> void:
|
||||
var minion: CharacterBody2D = load(MINION_RESOURCE).instantiate()
|
||||
get_parent().add_child(minion)
|
||||
minion.position = p_position
|
||||
minion.play_summoning_effect()
|
||||
|
||||
|
||||
func play_summoning_effect() -> void:
|
||||
summoning_effect.emitting = true
|
||||
|
||||
|
||||
## Is specified position inside the arena (not inside obstacle)?
|
||||
func is_good_position(p_position: Vector2) -> bool:
|
||||
var space_state := get_world_2d().direct_space_state
|
||||
var params := PhysicsPointQueryParameters2D.new()
|
||||
params.position = p_position
|
||||
params.collision_mask = 1 # Obstacle layer has value 1
|
||||
var collision := space_state.intersect_point(params)
|
||||
return collision.is_empty()
|
||||
|
||||
|
||||
func _damaged(_amount: float, knockback: Vector2) -> void:
|
||||
apply_knockback(knockback)
|
||||
animation_player.play(&"hurt")
|
||||
|
|
|
@ -6,7 +6,7 @@ extends BTAction
|
|||
## Maximum distance to the desired position.
|
||||
@export var range_min: float = 300.0
|
||||
@export var range_max: float = 500.0
|
||||
@export var position_var: String = "_pos"
|
||||
@export var position_var: String = "pos"
|
||||
|
||||
# Display a customized name (requires @tool).
|
||||
func _generate_name() -> String:
|
||||
|
@ -16,8 +16,13 @@ func _generate_name() -> String:
|
|||
|
||||
# Called each time this task is ticked (aka executed).
|
||||
func _tick(_delta: float) -> Status:
|
||||
var angle: float = randf() * TAU
|
||||
var rand_distance: float = randf_range(range_min, range_max)
|
||||
var pos: Vector2 = agent.global_position + Vector2(sin(angle), cos(angle)) * rand_distance
|
||||
var pos: Vector2
|
||||
var is_good_position: bool = false
|
||||
while not is_good_position:
|
||||
# Randomize until we find a good position (in other words, not outside the arena)
|
||||
var angle: float = randf() * TAU
|
||||
var rand_distance: float = randf_range(range_min, range_max)
|
||||
pos = agent.global_position + Vector2(sin(angle), cos(angle)) * rand_distance
|
||||
is_good_position = agent.is_good_position(pos)
|
||||
blackboard.set_var(position_var, pos)
|
||||
return SUCCESS
|
||||
|
|
|
@ -31,6 +31,7 @@ custom_name = "Chill"
|
|||
children = [SubResource("BTPlayAnimation_p3e7a"), SubResource("BTRandomWait_j6cjm")]
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_oms7a"]
|
||||
trigger_on_failure = true
|
||||
children = [SubResource("BTSequence_5thv4")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ohfp7"]
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=32 format=3 uid="uid://c2bxoo68ywb27"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_sqcak"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="2_b40lk"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="3_j237c"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="4_fqn6n"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="5_wlc74"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"]
|
||||
var/speed/name = "speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_5j8nr"]
|
||||
script = ExtResource("1_sqcak")
|
||||
group = &"player"
|
||||
output_var = "target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_3y70b"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_klk26"]
|
||||
animation_player = SubResource("BBNode_3y70b")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_wjm6d"]
|
||||
script = ExtResource("3_j237c")
|
||||
target_var = "target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_chmiy"]
|
||||
script = ExtResource("4_fqn6n")
|
||||
range_min = 200.0
|
||||
range_max = 500.0
|
||||
position_var = "pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_5kivl"]
|
||||
script = ExtResource("5_wlc74")
|
||||
target_position_var = "pos"
|
||||
speed_var = "speed"
|
||||
tolerance = 50.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_k184c"]
|
||||
custom_name = "Chaotic Walk"
|
||||
children = [SubResource("BTAction_5j8nr"), SubResource("BTPlayAnimation_klk26"), SubResource("BTAction_wjm6d"), SubResource("BTAction_chmiy"), SubResource("BTAction_5kivl")]
|
||||
|
||||
[sub_resource type="BTProbability" id="BTProbability_ifsry"]
|
||||
run_chance = 0.6
|
||||
children = [SubResource("BTSequence_k184c")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_nrd4b"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qiw21"]
|
||||
animation_player = SubResource("BBNode_nrd4b")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"]
|
||||
min_duration = 0.7
|
||||
max_duration = 1.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_yhjh1"]
|
||||
custom_name = "Pause before action"
|
||||
children = [SubResource("BTPlayAnimation_qiw21"), SubResource("BTRandomWait_xlud8")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_wpj6d"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_olf37"]
|
||||
animation_player = SubResource("BBNode_wpj6d")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ulbrf"]
|
||||
script = ExtResource("1_sqcak")
|
||||
group = &"player"
|
||||
output_var = "target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_a4jqi"]
|
||||
script = ExtResource("2_b40lk")
|
||||
target_var = "target"
|
||||
speed_var = "speed"
|
||||
approach_distance = 100.0
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_xek5v"]
|
||||
time_limit = 2.0
|
||||
children = [SubResource("BTAction_a4jqi")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_1xfnq"]
|
||||
custom_name = "Pursue player"
|
||||
children = [SubResource("BTPlayAnimation_olf37"), SubResource("BTAction_ulbrf"), SubResource("BTTimeLimit_xek5v")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_kidxn"]
|
||||
script = ExtResource("3_j237c")
|
||||
target_var = "target"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_tadkc"]
|
||||
duration = 0.1
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_s8evu"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_ppmxd"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_s8evu")
|
||||
animation_name = &"attack_1"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_ww5v2"]
|
||||
custom_name = "Melee attack"
|
||||
children = [SubResource("BTAction_kidxn"), SubResource("BTWait_tadkc"), SubResource("BTPlayAnimation_ppmxd")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_pxl2k"]
|
||||
custom_name = "Engage player"
|
||||
children = [SubResource("BTSequence_yhjh1"), SubResource("BTSequence_1xfnq"), SubResource("BTSequence_ww5v2")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_y3llm"]
|
||||
children = [SubResource("BTProbability_ifsry"), SubResource("BTSequence_pxl2k")]
|
||||
|
||||
[resource]
|
||||
blackboard_plan = SubResource("BlackboardPlan_46tbn")
|
||||
root_task = SubResource("BTSelector_y3llm")
|
|
@ -0,0 +1,124 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=28 format=3 uid="uid://cpxk7jnqpwwlc"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="1_sgn0p"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_pshl2"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_58oq1"]
|
||||
var/speed/name = "speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 300.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
var/summon_cooldown/name = "summon_cooldown"
|
||||
var/summon_cooldown/type = 1
|
||||
var/summon_cooldown/value = false
|
||||
var/summon_cooldown/hint = 0
|
||||
var/summon_cooldown/hint_string = ""
|
||||
|
||||
[sub_resource type="BTComment" id="BTComment_ef6y0"]
|
||||
custom_name = "Variable $summon_cooldown is updated by the Cooldown task below"
|
||||
|
||||
[sub_resource type="BBVariant" id="BBVariant_hgde2"]
|
||||
type = 1
|
||||
saved_value = false
|
||||
resource_name = "false"
|
||||
|
||||
[sub_resource type="BTCheckVar" id="BTCheckVar_hc3o3"]
|
||||
variable = "summon_cooldown"
|
||||
value = SubResource("BBVariant_hgde2")
|
||||
children = [SubResource("BTComment_ef6y0")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_q8bei"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_6leni"]
|
||||
animation_player = SubResource("BBNode_q8bei")
|
||||
animation_name = &"summon"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_8og18"]
|
||||
duration = 0.5
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_yeyns"]
|
||||
script = ExtResource("1_sgn0p")
|
||||
range_min = 300.0
|
||||
range_max = 500.0
|
||||
position_var = "minion_pos"
|
||||
|
||||
[sub_resource type="BBVariant" id="BBVariant_wfjwy"]
|
||||
type = 5
|
||||
value_source = 1
|
||||
variable = "minion_pos"
|
||||
resource_name = "$minion_pos"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_v271m"]
|
||||
saved_value = NodePath(".")
|
||||
resource_name = "."
|
||||
|
||||
[sub_resource type="BTCallMethod" id="BTCallMethod_4ath5"]
|
||||
node = SubResource("BBNode_v271m")
|
||||
method = &"summon_minion"
|
||||
args = Array[BBVariant]([SubResource("BBVariant_wfjwy")])
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_25f70"]
|
||||
cooldown_state_var = "summon_cooldown"
|
||||
children = [SubResource("BTCallMethod_4ath5")]
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_tdhfn"]
|
||||
duration = 0.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_2n742"]
|
||||
custom_name = "Summon"
|
||||
children = [SubResource("BTCheckVar_hc3o3"), SubResource("BTPlayAnimation_6leni"), SubResource("BTWait_8og18"), SubResource("BTAction_yeyns"), SubResource("BTCooldown_25f70"), SubResource("BTWait_tdhfn")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_33wje"]
|
||||
script = ExtResource("1_sgn0p")
|
||||
range_min = 300.0
|
||||
range_max = 700.0
|
||||
position_var = "pos"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_w5fh2"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qbxm8"]
|
||||
animation_player = SubResource("BBNode_w5fh2")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_dfifw"]
|
||||
script = ExtResource("2_pshl2")
|
||||
target_position_var = "pos"
|
||||
speed_var = "speed"
|
||||
tolerance = 50.0
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_i05cm"]
|
||||
time_limit = 3.0
|
||||
children = [SubResource("BTAction_dfifw")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_vinxt"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_t7drr"]
|
||||
animation_player = SubResource("BBNode_vinxt")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_axjfh"]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_ks71q"]
|
||||
custom_name = "Chill"
|
||||
children = [SubResource("BTPlayAnimation_t7drr"), SubResource("BTRandomWait_axjfh")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_dss4d"]
|
||||
custom_name = "Reposition"
|
||||
children = [SubResource("BTAction_33wje"), SubResource("BTPlayAnimation_qbxm8"), SubResource("BTTimeLimit_i05cm"), SubResource("BTSequence_ks71q")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_gp6q5"]
|
||||
children = [SubResource("BTSequence_2n742"), SubResource("BTSequence_dss4d")]
|
||||
|
||||
[resource]
|
||||
blackboard_plan = SubResource("BlackboardPlan_58oq1")
|
||||
root_task = SubResource("BTSelector_gp6q5")
|
Loading…
Reference in New Issue