diff --git a/demo/demo/agents/01_agent_melee_simple.tscn b/demo/demo/agents/01_agent_melee_simple.tscn index 11d7f0b..c80a81d 100644 --- a/demo/demo/agents/01_agent_melee_simple.tscn +++ b/demo/demo/agents/01_agent_melee_simple.tscn @@ -31,6 +31,13 @@ texture = ExtResource("2_bvbes") [node name="HandR" parent="Root/Rig/Body" index="2"] texture = ExtResource("2_bvbes") +[node name="WeaponNinjaStar" parent="Root" index="1"] +position = Vector2(-55, -76) +rotation = 0.0 + +[node name="Health" parent="." index="3"] +max_health = 3.0 + [node name="BTPlayer" type="BTPlayer" parent="." index="5"] behavior_tree = ExtResource("3_tb7cx") blackboard_plan = SubResource("BlackboardPlan_s08ac") diff --git a/demo/demo/agents/02_agent_charger.tscn b/demo/demo/agents/02_agent_charger.tscn index c51dc00..956e3c2 100644 --- a/demo/demo/agents/02_agent_charger.tscn +++ b/demo/demo/agents/02_agent_charger.tscn @@ -36,6 +36,12 @@ texture = ExtResource("2_y7pic") [node name="HandR" parent="Root/Rig/Body" index="2"] texture = ExtResource("2_y7pic") +[node name="Hitbox" parent="Root" index="2"] +damage = 2.0 + +[node name="Health" parent="." index="3"] +max_health = 8.0 + [node name="BTPlayer" type="BTPlayer" parent="." index="4"] behavior_tree = ExtResource("3_nacc3") blackboard_plan = SubResource("BlackboardPlan_pmyhf") diff --git a/demo/demo/agents/03_agent_imp.tscn b/demo/demo/agents/03_agent_imp.tscn index 85d260e..7d9d089 100644 --- a/demo/demo/agents/03_agent_imp.tscn +++ b/demo/demo/agents/03_agent_imp.tscn @@ -31,8 +31,12 @@ texture = ExtResource("2_xd5s8") [node name="HandR" parent="Root/Rig/Body" index="2"] texture = ExtResource("2_xd5s8") +[node name="WeaponNinjaStar" parent="Root" index="1"] +position = Vector2(-55, -76) +rotation = 0.0 + [node name="Health" parent="." index="3"] -max_health = 5.0 +max_health = 4.0 [node name="BTPlayer" type="BTPlayer" parent="." index="5"] behavior_tree = ExtResource("3_furh3") diff --git a/demo/demo/agents/04_agent_skirmisher.tscn b/demo/demo/agents/04_agent_skirmisher.tscn index db8a98d..41f8370 100644 --- a/demo/demo/agents/04_agent_skirmisher.tscn +++ b/demo/demo/agents/04_agent_skirmisher.tscn @@ -41,6 +41,13 @@ texture = ExtResource("2_w8tqw") [node name="HandR" parent="Root/Rig/Body" index="2"] texture = ExtResource("2_w8tqw") +[node name="WeaponNinjaStar" parent="Root" index="1"] +position = Vector2(-55, -76) +rotation = 0.0 + +[node name="Health" parent="." index="3"] +max_health = 7.0 + [node name="BTPlayer" type="BTPlayer" parent="." index="4"] behavior_tree = ExtResource("3_bhfkv") blackboard_plan = SubResource("BlackboardPlan_vjbry") diff --git a/demo/demo/agents/05_agent_ranged.tscn b/demo/demo/agents/05_agent_ranged.tscn index df2cea8..f725d3a 100644 --- a/demo/demo/agents/05_agent_ranged.tscn +++ b/demo/demo/agents/05_agent_ranged.tscn @@ -31,6 +31,13 @@ texture = ExtResource("2_37lvn") [node name="HandR" parent="Root/Rig/Body" index="2"] texture = ExtResource("2_37lvn") +[node name="WeaponNinjaStar" parent="Root" index="1"] +position = Vector2(-55, -76) +rotation = 0.0 + +[node name="Health" parent="." index="3"] +max_health = 6.0 + [node name="BTPlayer" type="BTPlayer" parent="." index="4"] behavior_tree = ExtResource("3_f7r5w") blackboard_plan = SubResource("BlackboardPlan_2kwy7") diff --git a/demo/demo/agents/06_agent_melee_combo.tscn b/demo/demo/agents/06_agent_melee_combo.tscn index b382b78..5a20923 100644 --- a/demo/demo/agents/06_agent_melee_combo.tscn +++ b/demo/demo/agents/06_agent_melee_combo.tscn @@ -37,8 +37,13 @@ texture = ExtResource("2_4rqld") texture = ExtResource("2_4rqld") [node name="WeaponNinjaStar" parent="Root" index="1"] +position = Vector2(-55, -76) +rotation = 0.0 scale = Vector2(0.999983, 0.999976) +[node name="Health" parent="." index="3"] +max_health = 6.0 + [node name="BTPlayer" type="BTPlayer" parent="." index="4"] behavior_tree = ExtResource("3_l805q") blackboard_plan = SubResource("BlackboardPlan_67ric") diff --git a/demo/demo/agents/07_agent_melee_nuanced.tscn b/demo/demo/agents/07_agent_melee_nuanced.tscn index 0c4c572..87ee530 100644 --- a/demo/demo/agents/07_agent_melee_nuanced.tscn +++ b/demo/demo/agents/07_agent_melee_nuanced.tscn @@ -36,6 +36,13 @@ texture = ExtResource("2_e51r0") [node name="HandR" parent="Root/Rig/Body" index="2"] texture = ExtResource("2_e51r0") +[node name="WeaponNinjaStar" parent="Root" index="1"] +position = Vector2(-55, -76) +rotation = 0.0 + +[node name="Health" parent="." index="3"] +max_health = 6.0 + [node name="BTPlayer" type="BTPlayer" parent="." index="4"] behavior_tree = ExtResource("3_b8kcf") blackboard_plan = SubResource("BlackboardPlan_tnf02") diff --git a/demo/demo/agents/08_agent_demon.tscn b/demo/demo/agents/08_agent_demon.tscn index 11d42bd..870b64e 100644 --- a/demo/demo/agents/08_agent_demon.tscn +++ b/demo/demo/agents/08_agent_demon.tscn @@ -31,6 +31,13 @@ texture = ExtResource("2_cb5f2") [node name="HandR" parent="Root/Rig/Body" index="2"] texture = ExtResource("2_cb5f2") +[node name="WeaponNinjaStar" parent="Root" index="1"] +position = Vector2(-55, -76) +rotation = 0.0 + +[node name="Health" parent="." index="3"] +max_health = 8.0 + [node name="BTPlayer" type="BTPlayer" parent="." index="5"] behavior_tree = ExtResource("3_ebd57") blackboard_plan = SubResource("BlackboardPlan_5sr4g") diff --git a/demo/demo/agents/09_agent_summoner.tscn b/demo/demo/agents/09_agent_summoner.tscn index 7eef9b1..1f5ccd5 100644 --- a/demo/demo/agents/09_agent_summoner.tscn +++ b/demo/demo/agents/09_agent_summoner.tscn @@ -10,6 +10,11 @@ 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 = "" [node name="AgentSummoner" instance=ExtResource("1_neifu")] @@ -31,6 +36,13 @@ texture = ExtResource("2_fcti4") [node name="HandR" parent="Root/Rig/Body" index="2"] texture = ExtResource("2_fcti4") +[node name="WeaponNinjaStar" parent="Root" index="1"] +position = Vector2(-55, -76) +rotation = 0.0 + +[node name="Health" parent="." index="3"] +max_health = 8.0 + [node name="BTPlayer" type="BTPlayer" parent="." index="5"] behavior_tree = ExtResource("3_bunpq") blackboard_plan = SubResource("BlackboardPlan_bqv3d") diff --git a/demo/demo/agents/agent_base.tscn b/demo/demo/agents/agent_base.tscn index c95961b..a10bfc4 100644 --- a/demo/demo/agents/agent_base.tscn +++ b/demo/demo/agents/agent_base.tscn @@ -306,7 +306,7 @@ tracks/18/keys = { tracks/19/type = "value" tracks/19/imported = false tracks/19/enabled = true -tracks/19/path = NodePath("Root/Hitbox/CollisionShape2D:disabled") +tracks/19/path = NodePath("Root/Hitbox/HitboxCollisionShape2D:disabled") tracks/19/interp = 1 tracks/19/loop_wrap = true tracks/19/keys = { @@ -659,7 +659,7 @@ tracks/20/keys = { tracks/21/type = "value" tracks/21/imported = false tracks/21/enabled = true -tracks/21/path = NodePath("Root/Hitbox/CollisionShape2D:disabled") +tracks/21/path = NodePath("Root/Hitbox/HitboxCollisionShape2D:disabled") tracks/21/interp = 1 tracks/21/loop_wrap = true tracks/21/keys = { @@ -928,7 +928,7 @@ tracks/20/keys = { tracks/21/type = "value" tracks/21/imported = false tracks/21/enabled = true -tracks/21/path = NodePath("Root/Hitbox/CollisionShape2D:disabled") +tracks/21/path = NodePath("Root/Hitbox/HitboxCollisionShape2D:disabled") tracks/21/interp = 1 tracks/21/loop_wrap = true tracks/21/keys = { @@ -1173,7 +1173,7 @@ tracks/18/keys = { tracks/19/type = "value" tracks/19/imported = false tracks/19/enabled = true -tracks/19/path = NodePath("Root/Hitbox/CollisionShape2D:disabled") +tracks/19/path = NodePath("Root/Hitbox/HitboxCollisionShape2D:disabled") tracks/19/interp = 1 tracks/19/loop_wrap = true tracks/19/keys = { @@ -1455,7 +1455,7 @@ tracks/20/keys = { tracks/21/type = "value" tracks/21/imported = false tracks/21/enabled = true -tracks/21/path = NodePath("Root/Hitbox/CollisionShape2D:disabled") +tracks/21/path = NodePath("Root/Hitbox/HitboxCollisionShape2D:disabled") tracks/21/interp = 1 tracks/21/loop_wrap = true tracks/21/keys = { @@ -1990,6 +1990,274 @@ tracks/20/keys = { "values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] } +[sub_resource type="Animation" id="Animation_msfb2"] +resource_name = "dash" +length = 0.4 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Root/Rig:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1, 0.4), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(0, -76), Vector2(0, -38), Vector2(0, -76)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Root/Rig:rotation") +tracks/1/interp = 2 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 2, +"values": [0.0, 2.35619, 6.28319, 12.5664] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Root/Rig:scale") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1, 0.5), Vector2(1, 0.5), Vector2(1, 0.5), Vector2(1, 1)] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Root/Rig/LegL:position") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(-29, 65), Vector2(-24.8287, 40.1066), Vector2(-24.8287, 40.1066), Vector2(-29, 65)] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Root/Rig/LegL:rotation") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [0.0, 0.0, 0.0, 0.0] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Root/Rig/LegL:scale") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] +} +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("Root/Rig/LegR:position") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(31, 65), Vector2(26.1794, 41.8884), Vector2(26.1794, 41.8884), Vector2(31, 65)] +} +tracks/7/type = "value" +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/path = NodePath("Root/Rig/LegR:rotation") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [0.0, 0.0, 0.0, 0.0] +} +tracks/8/type = "value" +tracks/8/imported = false +tracks/8/enabled = true +tracks/8/path = NodePath("Root/Rig/LegR:scale") +tracks/8/interp = 1 +tracks/8/loop_wrap = true +tracks/8/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] +} +tracks/9/type = "value" +tracks/9/imported = false +tracks/9/enabled = true +tracks/9/path = NodePath("Root/Rig/Body:position") +tracks/9/interp = 1 +tracks/9/loop_wrap = true +tracks/9/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(5, 53), Vector2(5, 53), Vector2(5, 53), Vector2(5, 53)] +} +tracks/10/type = "value" +tracks/10/imported = false +tracks/10/enabled = true +tracks/10/path = NodePath("Root/Rig/Body:rotation") +tracks/10/interp = 1 +tracks/10/loop_wrap = true +tracks/10/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [0.0, 0.0, 0.0, 0.0] +} +tracks/11/type = "value" +tracks/11/imported = false +tracks/11/enabled = true +tracks/11/path = NodePath("Root/Rig/Body:scale") +tracks/11/interp = 1 +tracks/11/loop_wrap = true +tracks/11/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] +} +tracks/12/type = "value" +tracks/12/imported = false +tracks/12/enabled = true +tracks/12/path = NodePath("Root/Rig/Body/Hat:position") +tracks/12/interp = 1 +tracks/12/loop_wrap = true +tracks/12/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(2, -91), Vector2(2, -91), Vector2(2, -91), Vector2(2, -91)] +} +tracks/13/type = "value" +tracks/13/imported = false +tracks/13/enabled = true +tracks/13/path = NodePath("Root/Rig/Body/Hat:rotation") +tracks/13/interp = 1 +tracks/13/loop_wrap = true +tracks/13/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [0.0, 0.0, 0.0, 0.0] +} +tracks/14/type = "value" +tracks/14/imported = false +tracks/14/enabled = true +tracks/14/path = NodePath("Root/Rig/Body/Hat:scale") +tracks/14/interp = 1 +tracks/14/loop_wrap = true +tracks/14/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] +} +tracks/15/type = "value" +tracks/15/imported = false +tracks/15/enabled = true +tracks/15/path = NodePath("Root/Rig/Body/HandL:position") +tracks/15/interp = 1 +tracks/15/loop_wrap = true +tracks/15/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(-60, -53), Vector2(-19.9999, -52.9358), Vector2(-19.9999, -52.9358), Vector2(-60, -53)] +} +tracks/16/type = "value" +tracks/16/imported = false +tracks/16/enabled = true +tracks/16/path = NodePath("Root/Rig/Body/HandL:rotation") +tracks/16/interp = 1 +tracks/16/loop_wrap = true +tracks/16/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [0.0, 0.0, 0.0, 0.0] +} +tracks/17/type = "value" +tracks/17/imported = false +tracks/17/enabled = true +tracks/17/path = NodePath("Root/Rig/Body/HandL:scale") +tracks/17/interp = 1 +tracks/17/loop_wrap = true +tracks/17/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] +} +tracks/18/type = "value" +tracks/18/imported = false +tracks/18/enabled = true +tracks/18/path = NodePath("Root/Rig/Body/HandR:position") +tracks/18/interp = 1 +tracks/18/loop_wrap = true +tracks/18/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(51, -51), Vector2(21.9955, -54.1155), Vector2(21.9955, -54.1155), Vector2(51, -51)] +} +tracks/19/type = "value" +tracks/19/imported = false +tracks/19/enabled = true +tracks/19/path = NodePath("Root/Rig/Body/HandR:rotation") +tracks/19/interp = 1 +tracks/19/loop_wrap = true +tracks/19/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [0.0, 0.0, 0.0, 0.0] +} +tracks/20/type = "value" +tracks/20/imported = false +tracks/20/enabled = true +tracks/20/path = NodePath("Root/Rig/Body/HandR:scale") +tracks/20/interp = 1 +tracks/20/loop_wrap = true +tracks/20/keys = { +"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] +} +tracks/21/type = "value" +tracks/21/imported = false +tracks/21/enabled = true +tracks/21/path = NodePath("Root/Hitbox/HitboxCollisionShape2D:disabled") +tracks/21/interp = 1 +tracks/21/loop_wrap = true +tracks/21/keys = { +"times": PackedFloat32Array(0, 0.4), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, true] +} + [sub_resource type="Animation" id="Animation_wei72"] resource_name = "death" length = 0.5 @@ -2282,6 +2550,18 @@ tracks/23/keys = { "update": 1, "values": [false, true, false] } +tracks/24/type = "value" +tracks/24/imported = false +tracks/24/enabled = true +tracks/24/path = NodePath("Root/WeaponNinjaStar:visible") +tracks/24/interp = 1 +tracks/24/loop_wrap = true +tracks/24/keys = { +"times": PackedFloat32Array(0, 0.5), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [false, false] +} [sub_resource type="Animation" id="Animation_gowr5"] resource_name = "hurt" @@ -2518,7 +2798,7 @@ tracks/18/keys = { tracks/19/type = "value" tracks/19/imported = false tracks/19/enabled = true -tracks/19/path = NodePath("Root/Hitbox/CollisionShape2D:disabled") +tracks/19/path = NodePath("Root/Hitbox/HitboxCollisionShape2D:disabled") tracks/19/interp = 1 tracks/19/loop_wrap = true tracks/19/keys = { @@ -2796,261 +3076,17 @@ tracks/18/keys = { "update": 1, "values": [false] } - -[sub_resource type="Animation" id="Animation_msfb2"] -resource_name = "roll" -length = 0.4 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Root/Rig:position") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.1, 0.4), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [Vector2(0, -76), Vector2(0, -38), Vector2(0, -76)] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Root/Rig:rotation") -tracks/1/interp = 2 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0, 0.1, 0.2, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 2, -"values": [0.0, 2.35619, 6.28319, 12.5664] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Root/Rig:scale") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1), -"update": 0, -"values": [Vector2(1, 1), Vector2(1, 0.5), Vector2(1, 0.5), Vector2(1, 0.5), Vector2(1, 1)] -} -tracks/3/type = "value" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath("Root/Rig/LegL:position") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(-29, 65), Vector2(-24.8287, 40.1066), Vector2(-24.8287, 40.1066), Vector2(-29, 65)] -} -tracks/4/type = "value" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath("Root/Rig/LegL:rotation") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [0.0, 0.0, 0.0, 0.0] -} -tracks/5/type = "value" -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/path = NodePath("Root/Rig/LegL:scale") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] -} -tracks/6/type = "value" -tracks/6/imported = false -tracks/6/enabled = true -tracks/6/path = NodePath("Root/Rig/LegR:position") -tracks/6/interp = 1 -tracks/6/loop_wrap = true -tracks/6/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(31, 65), Vector2(26.1794, 41.8884), Vector2(26.1794, 41.8884), Vector2(31, 65)] -} -tracks/7/type = "value" -tracks/7/imported = false -tracks/7/enabled = true -tracks/7/path = NodePath("Root/Rig/LegR:rotation") -tracks/7/interp = 1 -tracks/7/loop_wrap = true -tracks/7/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [0.0, 0.0, 0.0, 0.0] -} -tracks/8/type = "value" -tracks/8/imported = false -tracks/8/enabled = true -tracks/8/path = NodePath("Root/Rig/LegR:scale") -tracks/8/interp = 1 -tracks/8/loop_wrap = true -tracks/8/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] -} -tracks/9/type = "value" -tracks/9/imported = false -tracks/9/enabled = true -tracks/9/path = NodePath("Root/Rig/Body:position") -tracks/9/interp = 1 -tracks/9/loop_wrap = true -tracks/9/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(5, 53), Vector2(5, 53), Vector2(5, 53), Vector2(5, 53)] -} -tracks/10/type = "value" -tracks/10/imported = false -tracks/10/enabled = true -tracks/10/path = NodePath("Root/Rig/Body:rotation") -tracks/10/interp = 1 -tracks/10/loop_wrap = true -tracks/10/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [0.0, 0.0, 0.0, 0.0] -} -tracks/11/type = "value" -tracks/11/imported = false -tracks/11/enabled = true -tracks/11/path = NodePath("Root/Rig/Body:scale") -tracks/11/interp = 1 -tracks/11/loop_wrap = true -tracks/11/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] -} -tracks/12/type = "value" -tracks/12/imported = false -tracks/12/enabled = true -tracks/12/path = NodePath("Root/Rig/Body/Hat:position") -tracks/12/interp = 1 -tracks/12/loop_wrap = true -tracks/12/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(2, -91), Vector2(2, -91), Vector2(2, -91), Vector2(2, -91)] -} -tracks/13/type = "value" -tracks/13/imported = false -tracks/13/enabled = true -tracks/13/path = NodePath("Root/Rig/Body/Hat:rotation") -tracks/13/interp = 1 -tracks/13/loop_wrap = true -tracks/13/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [0.0, 0.0, 0.0, 0.0] -} -tracks/14/type = "value" -tracks/14/imported = false -tracks/14/enabled = true -tracks/14/path = NodePath("Root/Rig/Body/Hat:scale") -tracks/14/interp = 1 -tracks/14/loop_wrap = true -tracks/14/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] -} -tracks/15/type = "value" -tracks/15/imported = false -tracks/15/enabled = true -tracks/15/path = NodePath("Root/Rig/Body/HandL:position") -tracks/15/interp = 1 -tracks/15/loop_wrap = true -tracks/15/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(-60, -53), Vector2(-19.9999, -52.9358), Vector2(-19.9999, -52.9358), Vector2(-60, -53)] -} -tracks/16/type = "value" -tracks/16/imported = false -tracks/16/enabled = true -tracks/16/path = NodePath("Root/Rig/Body/HandL:rotation") -tracks/16/interp = 1 -tracks/16/loop_wrap = true -tracks/16/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [0.0, 0.0, 0.0, 0.0] -} -tracks/17/type = "value" -tracks/17/imported = false -tracks/17/enabled = true -tracks/17/path = NodePath("Root/Rig/Body/HandL:scale") -tracks/17/interp = 1 -tracks/17/loop_wrap = true -tracks/17/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] -} -tracks/18/type = "value" -tracks/18/imported = false -tracks/18/enabled = true -tracks/18/path = NodePath("Root/Rig/Body/HandR:position") -tracks/18/interp = 1 -tracks/18/loop_wrap = true -tracks/18/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(51, -51), Vector2(21.9955, -54.1155), Vector2(21.9955, -54.1155), Vector2(51, -51)] -} tracks/19/type = "value" tracks/19/imported = false tracks/19/enabled = true -tracks/19/path = NodePath("Root/Rig/Body/HandR:rotation") +tracks/19/path = NodePath("Root/Hitbox/HitboxCollisionShape2D:disabled") tracks/19/interp = 1 tracks/19/loop_wrap = true tracks/19/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [0.0, 0.0, 0.0, 0.0] -} -tracks/20/type = "value" -tracks/20/imported = false -tracks/20/enabled = true -tracks/20/path = NodePath("Root/Rig/Body/HandR:scale") -tracks/20/interp = 1 -tracks/20/loop_wrap = true -tracks/20/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3, 0.4), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)] +"times": PackedFloat32Array(0, 0.4), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, true] } [sub_resource type="Animation" id="Animation_uow76"] @@ -4263,6 +4299,18 @@ tracks/18/keys = { "update": 1, "values": [false] } +tracks/19/type = "value" +tracks/19/imported = false +tracks/19/enabled = true +tracks/19/path = NodePath("Root/Hitbox/HitboxCollisionShape2D:disabled") +tracks/19/interp = 1 +tracks/19/loop_wrap = true +tracks/19/keys = { +"times": PackedFloat32Array(0, 0.6), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, true] +} [sub_resource type="AnimationLibrary" id="AnimationLibrary_ws2ti"] _data = { @@ -4273,10 +4321,10 @@ _data = { "charge": SubResource("Animation_jcwlt"), "charge_prepare": SubResource("Animation_sva81"), "dance": SubResource("Animation_5k1rd"), +"dash": SubResource("Animation_msfb2"), "death": SubResource("Animation_wei72"), "hurt": SubResource("Animation_gowr5"), "idle": SubResource("Animation_gnqgt"), -"roll": SubResource("Animation_msfb2"), "spit": SubResource("Animation_uow76"), "summon": SubResource("Animation_5mxvi"), "throw": SubResource("Animation_yn0t6"), @@ -4348,7 +4396,8 @@ region_rect = Rect2(111, 34, 26.9272, 26.6298) [node name="WeaponNinjaStar" type="Sprite2D" parent="Root"] visible = false -position = Vector2(-55, -76) +position = Vector2(20.8026, -11.5702) +rotation = -1.60228 scale = Vector2(0.999985, 0.999984) texture = ExtResource("4_1c5xq") @@ -4357,10 +4406,9 @@ 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"] +[node name="HitboxCollisionShape2D" type="CollisionShape2D" parent="Root/Hitbox"] shape = SubResource("RectangleShape2D_2k81i") disabled = true debug_color = Color(0.933131, 0.0801983, 0.605982, 0.42) @@ -4372,7 +4420,7 @@ collision_mask = 0 script = ExtResource("6_jnvxm") health = NodePath("../../Health") -[node name="CollisionShape2D" type="CollisionShape2D" parent="Root/Hurtbox"] +[node name="HurtboxCollisionShape2D" type="CollisionShape2D" parent="Root/Hurtbox"] shape = SubResource("RectangleShape2D_26abe") debug_color = Color(0.466325, 0.590206, 0.107862, 0.42) metadata/_edit_lock_ = true diff --git a/demo/demo/agents/player/DashState.gd b/demo/demo/agents/player/DashState.gd new file mode 100644 index 0000000..ff22449 --- /dev/null +++ b/demo/demo/agents/player/DashState.gd @@ -0,0 +1,39 @@ +extends LimboState +## Idle state. + + +@export var animation_player: AnimationPlayer +@export var animation: StringName +@export var duration: float = 0.4 +@export var dash_speed: float = 1000.0 +@export var hurtbox_collision: CollisionShape2D + +var move_dir: Vector2 +var elapsed_time: float + + +func _enter() -> void: + elapsed_time = 0.0 + hurtbox_collision.disabled = true + + var horizontal_move: float = Input.get_axis(&"move_left", &"move_right") + if is_zero_approx(horizontal_move): + move_dir = Vector2.RIGHT * agent.get_facing() + else: + move_dir = Vector2.RIGHT * signf(horizontal_move) + agent.face_dir(move_dir.x) + + animation_player.play(animation, 0.1) + + +func _exit() -> void: + hurtbox_collision.disabled = false + + +func _update(p_delta: float) -> void: + elapsed_time += p_delta + var desired_velocity: Vector2 = move_dir * dash_speed + agent.velocity = lerp(agent.velocity, desired_velocity, 0.2) + agent.move_and_slide() + if elapsed_time > duration: + get_root().dispatch(EVENT_FINISHED) diff --git a/demo/demo/agents/player/player.gd b/demo/demo/agents/player/player.gd index a9777f1..cbc2c04 100644 --- a/demo/demo/agents/player/player.gd +++ b/demo/demo/agents/player/player.gd @@ -12,20 +12,31 @@ extends "res://demo/agents/scripts/agent_base.gd" ## Player. +@export var dash_cooldown: float = 0.4 + @onready var hsm: LimboHSM = $LimboHSM @onready var idle_state: LimboState = $LimboHSM/IdleState @onready var move_state: LimboState = $LimboHSM/MoveState @onready var attack_state: LimboState = $LimboHSM/AttackState +@onready var dash_state: LimboState = $LimboHSM/DashState + +var can_dash: bool = true func _ready() -> void: super._ready() + can_dash = true _init_state_machine() + death.connect(func(): remove_from_group(&"player")) func _unhandled_input(event: InputEvent) -> void: - if event.is_action_pressed("attack") and event.is_echo() == false: + if event.is_echo(): + return + if event.is_action_pressed("attack"): hsm.dispatch("attack!") + if event.is_action_pressed("dash"): + hsm.dispatch("dash!") func _init_state_machine() -> void: @@ -34,5 +45,21 @@ func _init_state_machine() -> void: hsm.add_transition(idle_state, attack_state, "attack!") hsm.add_transition(move_state, attack_state, "attack!") hsm.add_transition(attack_state, move_state, attack_state.EVENT_FINISHED) + hsm.add_transition(hsm.ANYSTATE, dash_state, "dash!") + hsm.add_transition(dash_state, move_state, dash_state.EVENT_FINISHED) + dash_state.set_guard(_can_dash) hsm.initialize(self) hsm.set_active(true) + hsm.set_guard(_can_dash) + + +func set_victorious() -> void: + idle_state.idle_animation = &"dance" + + +func _can_dash() -> bool: + if can_dash: + can_dash = false + get_tree().create_timer(dash_cooldown).timeout.connect(func(): can_dash = true) + return true + return false diff --git a/demo/demo/agents/player/player.tscn b/demo/demo/agents/player/player.tscn index 638d104..8b51b49 100644 --- a/demo/demo/agents/player/player.tscn +++ b/demo/demo/agents/player/player.tscn @@ -1,38 +1,58 @@ -[gd_scene load_steps=6 format=3 uid="uid://d07ag5dcje13i"] +[gd_scene load_steps=8 format=3 uid="uid://d07ag5dcje13i"] [ext_resource type="PackedScene" uid="uid://ooigbfhfy4wa" path="res://demo/agents/agent_base.tscn" id="1_mswd4"] [ext_resource type="Script" path="res://demo/agents/player/player.gd" id="2_24nyi"] [ext_resource type="Script" path="res://demo/agents/player/states/idle_state.gd" id="3_ekb12"] [ext_resource type="Script" path="res://demo/agents/player/states/move_state.gd" id="4_paikn"] [ext_resource type="Script" path="res://demo/agents/player/states/attack_state.gd" id="5_mpgu6"] +[ext_resource type="Script" path="res://demo/agents/player/DashState.gd" id="6_hdeid"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_8pofm"] +size = Vector2(130, 45) [node name="Player" groups=["player"] instance=ExtResource("1_mswd4")] collision_layer = 0 collision_mask = 1 script = ExtResource("2_24nyi") +dash_cooldown = 0.4 -[node name="WeaponNinjaStar" parent="Root" index="2"] +[node name="WeaponNinjaStar" parent="Root" index="1"] +position = Vector2(-55, -76) +rotation = 0.0 scale = Vector2(0.999983, 0.999976) -[node name="Hitbox" parent="Root" index="3"] +[node name="Hitbox" parent="Root" index="2"] collision_mask = 8 -[node name="Hurtbox" parent="Root" index="4"] +[node name="HitboxCollisionShape2D" parent="Root/Hitbox" index="0"] +shape = SubResource("RectangleShape2D_8pofm") + +[node name="Hurtbox" parent="Root" index="3"] collision_layer = 4 +[node name="Health" parent="." index="3"] +max_health = 30.0 + [node name="LimboHSM" type="LimboHSM" parent="." index="4"] [node name="IdleState" type="LimboState" parent="LimboHSM" index="0" node_paths=PackedStringArray("animation_player")] script = ExtResource("3_ekb12") animation_player = NodePath("../../AnimationPlayer") -animation = &"idle" +idle_animation = &"idle" [node name="MoveState" type="LimboState" parent="LimboHSM" index="1" node_paths=PackedStringArray("animation_player")] script = ExtResource("4_paikn") animation_player = NodePath("../../AnimationPlayer") animation = &"walk" -[node name="AttackState" type="LimboState" parent="LimboHSM" index="2" node_paths=PackedStringArray("animation_player")] +[node name="AttackState" type="LimboState" parent="LimboHSM" index="2" node_paths=PackedStringArray("animation_player", "hitbox")] script = ExtResource("5_mpgu6") animation_player = NodePath("../../AnimationPlayer") animations = Array[StringName]([&"attack_1", &"attack_2", &"attack_3"]) +hitbox = NodePath("../../Root/Hitbox") + +[node name="DashState" type="LimboState" parent="LimboHSM" index="3" node_paths=PackedStringArray("animation_player", "hurtbox_collision")] +script = ExtResource("6_hdeid") +animation_player = NodePath("../../AnimationPlayer") +animation = &"dash" +hurtbox_collision = NodePath("../../Root/Hurtbox/HurtboxCollisionShape2D") diff --git a/demo/demo/agents/player/states/attack_state.gd b/demo/demo/agents/player/states/attack_state.gd index b9a339d..5868875 100644 --- a/demo/demo/agents/player/states/attack_state.gd +++ b/demo/demo/agents/player/states/attack_state.gd @@ -14,6 +14,7 @@ extends LimboState @export var animation_player: AnimationPlayer @export var animations: Array[StringName] +@export var hitbox: Hitbox var attack_pressed: int @@ -27,7 +28,9 @@ func _unhandled_input(event: InputEvent) -> void: func _enter() -> void: attack_pressed = 0 + hitbox.damage = 1 for idx in animations.size(): + hitbox.damage = 2 if idx == 2 else 1 # deal 2 damage on third attack animation_player.play(animations[idx]) await animation_player.animation_finished if attack_pressed <= 0 or not is_active(): @@ -37,3 +40,7 @@ func _enter() -> void: attack_pressed -= 1 if is_active(): get_root().dispatch(EVENT_FINISHED) + + +func _exit() -> void: + hitbox.damage = 1 diff --git a/demo/demo/agents/player/states/idle_state.gd b/demo/demo/agents/player/states/idle_state.gd index 5fa7401..4f91c40 100644 --- a/demo/demo/agents/player/states/idle_state.gd +++ b/demo/demo/agents/player/states/idle_state.gd @@ -13,11 +13,11 @@ extends LimboState @export var animation_player: AnimationPlayer -@export var animation: StringName +@export var idle_animation: StringName func _enter() -> void: - animation_player.play(animation, 0.1) + animation_player.play(idle_animation, 0.1) func _update(_delta: float) -> void: diff --git a/demo/demo/agents/scripts/agent_base.gd b/demo/demo/agents/scripts/agent_base.gd index a1084cf..6ec0f16 100644 --- a/demo/demo/agents/scripts/agent_base.gd +++ b/demo/demo/agents/scripts/agent_base.gd @@ -9,9 +9,10 @@ #* ============================================================================= #* extends CharacterBody2D - ## Base agent script that is shared by all agents. +signal death + # Resource file to use in summon_minion() method. const MINION_RESOURCE := "res://demo/agents/03_agent_imp.tscn" @@ -19,15 +20,15 @@ const MINION_RESOURCE := "res://demo/agents/03_agent_imp.tscn" const NinjaStar := preload("res://demo/agents/ninja_star/ninja_star.tscn") const Fireball := preload("res://demo/agents/fireball/fireball.tscn") +var _frames_since_facing_update: int = 0 +var _is_dead: bool = false + @onready var animation_player: AnimationPlayer = $AnimationPlayer @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 -var _is_dead: bool = false - func _ready() -> void: health.damaged.connect(_damaged) @@ -120,6 +121,7 @@ func apply_knockback(knockback: Vector2, frames: int = 10) -> void: func die() -> void: if _is_dead: return + death.emit() _is_dead = true root.process_mode = Node.PROCESS_MODE_DISABLED animation_player.play(&"death") @@ -129,5 +131,10 @@ func die() -> void: if child is BTPlayer or child is LimboHSM: child.set_active(false) - await get_tree().create_timer(10.0).timeout - queue_free() + if get_tree(): + await get_tree().create_timer(10.0).timeout + queue_free() + + +func get_health() -> Health: + return health diff --git a/demo/demo/ai/trees/02_agent_charger.tres b/demo/demo/ai/trees/02_agent_charger.tres index cc382e9..b91833c 100644 --- a/demo/demo/ai/trees/02_agent_charger.tres +++ b/demo/demo/ai/trees/02_agent_charger.tres @@ -1,4 +1,4 @@ -[gd_resource type="BehaviorTree" load_steps=27 format=3 uid="uid://ylife72ym5et"] +[gd_resource type="BehaviorTree" load_steps=28 format=3 uid="uid://ylife72ym5et"] [ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_657p6"] [ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="2_t3udh"] @@ -28,8 +28,7 @@ animation_name = &"idle" blend = 0.1 [sub_resource type="BTRandomWait" id="BTRandomWait_cedqr"] -min_duration = 2.0 -max_duration = 5.0 +max_duration = 3.0 [sub_resource type="BTSequence" id="BTSequence_l3v31"] custom_name = "Short break" @@ -63,9 +62,13 @@ target_position_var = "flank_pos" speed_var = "speed" tolerance = 50.0 +[sub_resource type="BTTimeLimit" id="BTTimeLimit_is5ag"] +time_limit = 3.0 +children = [SubResource("BTAction_87mi0")] + [sub_resource type="BTSequence" id="BTSequence_p6pgg"] custom_name = "Flank target" -children = [SubResource("BTAction_pp23y"), SubResource("BTAction_pmvd0"), SubResource("BTPlayAnimation_h0poo"), SubResource("BTAction_87mi0")] +children = [SubResource("BTAction_pp23y"), SubResource("BTAction_pmvd0"), SubResource("BTPlayAnimation_h0poo"), SubResource("BTTimeLimit_is5ag")] [sub_resource type="BTAction" id="BTAction_q5g4a"] script = ExtResource("4_xwjl7") diff --git a/demo/demo/ai/trees/03_agent_imp.tres b/demo/demo/ai/trees/03_agent_imp.tres index b17b042..9a69ab3 100644 --- a/demo/demo/ai/trees/03_agent_imp.tres +++ b/demo/demo/ai/trees/03_agent_imp.tres @@ -1,4 +1,4 @@ -[gd_resource type="BehaviorTree" load_steps=30 format=3 uid="uid://c2bxoo68ywb27"] +[gd_resource type="BehaviorTree" load_steps=35 format=3 uid="uid://c2bxoo68ywb27"] [ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="1_cdtqu"] [ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_31fsn"] @@ -13,6 +13,24 @@ var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" +[sub_resource type="BBNode" id="BBNode_6xa35"] +saved_value = NodePath("AnimationPlayer") +resource_name = "AnimationPlayer" + +[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_4q5m7"] +animation_player = SubResource("BBNode_6xa35") +animation_name = &"idle" +blend = 0.1 + +[sub_resource type="BTRandomWait" id="BTRandomWait_025eh"] + +[sub_resource type="BTSequence" id="BTSequence_ds6uq"] +custom_name = "Idle" +children = [SubResource("BTPlayAnimation_4q5m7"), SubResource("BTRandomWait_025eh")] + +[sub_resource type="BTCooldown" id="BTCooldown_u2lrv"] +children = [SubResource("BTSequence_ds6uq")] + [sub_resource type="BBNode" id="BBNode_3y70b"] saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" @@ -52,7 +70,7 @@ animation_name = &"idle" blend = 0.1 [sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"] -min_duration = 0.7 +min_duration = 0.5 max_duration = 1.5 [sub_resource type="BTSequence" id="BTSequence_yhjh1"] @@ -112,7 +130,7 @@ 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")] +children = [SubResource("BTCooldown_u2lrv"), SubResource("BTProbability_ifsry"), SubResource("BTSequence_pxl2k")] [resource] blackboard_plan = SubResource("BlackboardPlan_46tbn") diff --git a/demo/demo/ai/trees/04_agent_skirmisher.tres b/demo/demo/ai/trees/04_agent_skirmisher.tres index 8d231aa..0933e1e 100644 --- a/demo/demo/ai/trees/04_agent_skirmisher.tres +++ b/demo/demo/ai/trees/04_agent_skirmisher.tres @@ -1,4 +1,4 @@ -[gd_resource type="BehaviorTree" load_steps=36 format=3 uid="uid://qqmjvbeibatn"] +[gd_resource type="BehaviorTree" load_steps=39 format=3 uid="uid://qqmjvbeibatn"] [ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_2883n"] [ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="2_cjso2"] @@ -34,60 +34,25 @@ animation_name = &"idle" blend = 0.1 [sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"] -min_duration = 1.5 max_duration = 3.0 -[sub_resource type="BTAction" id="BTAction_ulbrf"] -script = ExtResource("1_2883n") -group = &"player" -output_var = "target" - [sub_resource type="BTSequence" id="BTSequence_yhjh1"] -custom_name = "Pause before action" -children = [SubResource("BTPlayAnimation_qiw21"), SubResource("BTRandomWait_xlud8"), SubResource("BTAction_ulbrf")] +custom_name = "Summoning sickness" +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 -speed = 1.2 - -[sub_resource type="BTAction" id="BTAction_g5ayy"] -script = ExtResource("2_cjso2") -target_var = "target" -closest_side = false -flank_side = 2 -range_min = 100 -range_max = 100 -position_var = "flank_pos" - -[sub_resource type="BTAction" id="BTAction_tv4lt"] -script = ExtResource("3_treio") -target_position_var = "flank_pos" -speed_var = "fast_speed" -tolerance = 50.0 - -[sub_resource type="BTSequence" id="BTSequence_rgwic"] -children = [SubResource("BTAction_g5ayy"), SubResource("BTAction_tv4lt")] - -[sub_resource type="BTTimeLimit" id="BTTimeLimit_xek5v"] -time_limit = 4.0 -children = [SubResource("BTSequence_rgwic")] - -[sub_resource type="BTAction" id="BTAction_kidxn"] -script = ExtResource("4_57x51") -target_var = "target" +[sub_resource type="BTRunLimit" id="BTRunLimit_tq3e1"] +children = [SubResource("BTSequence_yhjh1")] [sub_resource type="BTCondition" id="BTCondition_uk4dg"] script = ExtResource("5_p5dih") -distance_min = 50.0 +distance_min = 0.0 distance_max = 170.0 target_var = "target" +[sub_resource type="BTAction" id="BTAction_kidxn"] +script = ExtResource("4_57x51") +target_var = "target" + [sub_resource type="BTWait" id="BTWait_tadkc"] duration = 0.1 @@ -102,24 +67,17 @@ animation_name = &"attack_3" [sub_resource type="BTSequence" id="BTSequence_ww5v2"] custom_name = "Melee attack" -children = [SubResource("BTCondition_uk4dg"), SubResource("BTWait_tadkc"), SubResource("BTPlayAnimation_ppmxd")] +children = [SubResource("BTCondition_uk4dg"), SubResource("BTAction_kidxn"), SubResource("BTWait_tadkc"), SubResource("BTPlayAnimation_ppmxd")] -[sub_resource type="BBNode" id="BBNode_wtnf2"] -saved_value = NodePath("AnimationPlayer") -resource_name = "AnimationPlayer" +[sub_resource type="BTCooldown" id="BTCooldown_ksvfy"] +duration = 2.0 +children = [SubResource("BTSequence_ww5v2")] -[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_k86qc"] -animation_player = SubResource("BBNode_wtnf2") -animation_name = &"idle" -blend = 0.1 - -[sub_resource type="BTRandomWait" id="BTRandomWait_m447o"] -min_duration = 0.3 -max_duration = 0.6 - -[sub_resource type="BTSequence" id="BTSequence_b00uw"] -custom_name = "Short break" -children = [SubResource("BTPlayAnimation_k86qc"), SubResource("BTRandomWait_m447o")] +[sub_resource type="BTCondition" id="BTCondition_fpufi"] +script = ExtResource("5_p5dih") +distance_min = 0.0 +distance_max = 250.0 +target_var = "target" [sub_resource type="BBNode" id="BBNode_3iqcf"] saved_value = NodePath("AnimationPlayer") @@ -140,17 +98,68 @@ max_angle_deviation = 0.7 time_limit = 1.5 children = [SubResource("BTAction_4ye2y")] +[sub_resource type="BTAlwaysSucceed" id="BTAlwaysSucceed_nw4ep"] +children = [SubResource("BTTimeLimit_cns1i")] + +[sub_resource type="BBNode" id="BBNode_81x7t"] +saved_value = NodePath("AnimationPlayer") +resource_name = "AnimationPlayer" + +[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_e61er"] +animation_player = SubResource("BBNode_81x7t") +animation_name = &"idle" +blend = 0.1 + +[sub_resource type="BTRandomWait" id="BTRandomWait_jw0cm"] + +[sub_resource type="BTSequence" id="BTSequence_bhacl"] +custom_name = "Chill" +children = [SubResource("BTPlayAnimation_e61er"), SubResource("BTRandomWait_jw0cm")] + [sub_resource type="BTSequence" id="BTSequence_y12eg"] custom_name = "Back away" -children = [SubResource("BTPlayAnimation_ee0ff"), SubResource("BTTimeLimit_cns1i")] +children = [SubResource("BTCondition_fpufi"), SubResource("BTPlayAnimation_ee0ff"), SubResource("BTAlwaysSucceed_nw4ep"), SubResource("BTSequence_bhacl")] -[sub_resource type="BTSequence" id="BTSequence_1xfnq"] +[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 +speed = 1.2 + +[sub_resource type="BTAction" id="BTAction_ulbrf"] +script = ExtResource("1_2883n") +group = &"player" +output_var = "target" + +[sub_resource type="BTAction" id="BTAction_g5ayy"] +script = ExtResource("2_cjso2") +target_var = "target" +flank_side = 2 +range_min = 100 +range_max = 100 +position_var = "flank_pos" + +[sub_resource type="BTAction" id="BTAction_tv4lt"] +script = ExtResource("3_treio") +target_position_var = "flank_pos" +speed_var = "fast_speed" +tolerance = 50.0 + +[sub_resource type="BTTimeLimit" id="BTTimeLimit_xek5v"] +time_limit = 4.0 +children = [SubResource("BTAction_tv4lt")] + +[sub_resource type="BTSequence" id="BTSequence_rgwic"] custom_name = "Skirmish" -children = [SubResource("BTPlayAnimation_olf37"), SubResource("BTTimeLimit_xek5v"), SubResource("BTAction_kidxn"), SubResource("BTSequence_ww5v2"), SubResource("BTSequence_b00uw"), SubResource("BTSequence_y12eg")] +children = [SubResource("BTPlayAnimation_olf37"), SubResource("BTAction_ulbrf"), SubResource("BTAction_g5ayy"), SubResource("BTTimeLimit_xek5v")] -[sub_resource type="BTSequence" id="BTSequence_pxl2k"] -children = [SubResource("BTSequence_yhjh1"), SubResource("BTSequence_1xfnq")] +[sub_resource type="BTSelector" id="BTSelector_2jnau"] +children = [SubResource("BTRunLimit_tq3e1"), SubResource("BTCooldown_ksvfy"), SubResource("BTSequence_y12eg"), SubResource("BTSequence_rgwic")] [resource] blackboard_plan = SubResource("BlackboardPlan_46tbn") -root_task = SubResource("BTSequence_pxl2k") +root_task = SubResource("BTSelector_2jnau") diff --git a/demo/demo/ai/trees/05_agent_ranged.tres b/demo/demo/ai/trees/05_agent_ranged.tres index 0f59ddf..f72120f 100644 --- a/demo/demo/ai/trees/05_agent_ranged.tres +++ b/demo/demo/ai/trees/05_agent_ranged.tres @@ -74,7 +74,6 @@ children = [SubResource("BTSequence_0gdqn")] [sub_resource type="BTAction" id="BTAction_kuuw2"] script = ExtResource("4_53hao") target_var = "target" -closest_side = true flank_side = 0 range_min = 400 range_max = 1000 diff --git a/demo/demo/ai/trees/07_agent_melee_nuanced.tres b/demo/demo/ai/trees/07_agent_melee_nuanced.tres index 350a511..64d1bde 100644 --- a/demo/demo/ai/trees/07_agent_melee_nuanced.tres +++ b/demo/demo/ai/trees/07_agent_melee_nuanced.tres @@ -1,4 +1,4 @@ -[gd_resource type="BehaviorTree" load_steps=45 format=3 uid="uid://c2u6sljqkim0n"] +[gd_resource type="BehaviorTree" load_steps=46 format=3 uid="uid://c2u6sljqkim0n"] [ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_08fik"] [ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="2_te3yo"] @@ -28,7 +28,6 @@ animation_name = &"idle" blend = 0.1 [sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"] -max_duration = 3.0 [sub_resource type="BTAction" id="BTAction_c4cxo"] script = ExtResource("1_08fik") @@ -52,7 +51,6 @@ speed = 1.5 [sub_resource type="BTAction" id="BTAction_6e48s"] script = ExtResource("2_te3yo") target_var = "target" -closest_side = false flank_side = 1 range_min = 400 range_max = 600 @@ -124,7 +122,6 @@ metadata/_weight_ = 4.0 [sub_resource type="BTAction" id="BTAction_mf87t"] script = ExtResource("2_te3yo") target_var = "target" -closest_side = false flank_side = 0 range_min = 350 range_max = 600 @@ -145,6 +142,10 @@ target_position_var = "pos" speed_var = "speed" tolerance = 50.0 +[sub_resource type="BTTimeLimit" id="BTTimeLimit_tidwl"] +time_limit = 3.0 +children = [SubResource("BTAction_6nx58")] + [sub_resource type="BTAction" id="BTAction_8q20y"] script = ExtResource("4_mvsyw") target_var = "target" @@ -160,7 +161,6 @@ blend = 0.1 speed = 0.7 [sub_resource type="BTWait" id="BTWait_gbcyb"] -duration = 1.3 [sub_resource type="BBNode" id="BBNode_qkfqt"] saved_value = NodePath("AnimationPlayer") @@ -181,11 +181,11 @@ node = SubResource("BBNode_1yxc5") method = &"throw_ninja_star" [sub_resource type="BTRandomWait" id="BTRandomWait_2pmoe"] -min_duration = 1.5 +max_duration = 1.5 [sub_resource type="BTSequence" id="BTSequence_rgbq3"] custom_name = "Throw ninja star" -children = [SubResource("BTAction_mf87t"), SubResource("BTPlayAnimation_mfbeu"), SubResource("BTAction_6nx58"), SubResource("BTAction_8q20y"), SubResource("BTPlayAnimation_qa8jy"), SubResource("BTWait_gbcyb"), SubResource("BTPlayAnimation_0ktds"), SubResource("BTCallMethod_yx4fk"), SubResource("BTRandomWait_2pmoe")] +children = [SubResource("BTAction_mf87t"), SubResource("BTPlayAnimation_mfbeu"), SubResource("BTTimeLimit_tidwl"), SubResource("BTAction_8q20y"), SubResource("BTPlayAnimation_qa8jy"), SubResource("BTWait_gbcyb"), SubResource("BTPlayAnimation_0ktds"), SubResource("BTCallMethod_yx4fk"), SubResource("BTRandomWait_2pmoe")] metadata/_weight_ = 2.0 [sub_resource type="BTProbabilitySelector" id="BTProbabilitySelector_rjsiq"] diff --git a/demo/demo/ai/trees/08_agent_demon.tres b/demo/demo/ai/trees/08_agent_demon.tres index adc6a56..27838be 100644 --- a/demo/demo/ai/trees/08_agent_demon.tres +++ b/demo/demo/ai/trees/08_agent_demon.tres @@ -41,7 +41,7 @@ output_var = "target" [sub_resource type="BTCondition" id="BTCondition_7a5nv"] script = ExtResource("2_atyuj") -distance_min = 50.0 +distance_min = 0.0 distance_max = 150.0 target_var = "target" @@ -115,7 +115,6 @@ blend = 0.1 [sub_resource type="BTAction" id="BTAction_4mmh0"] script = ExtResource("5_dho0d") target_var = "target" -closest_side = false flank_side = 0 range_min = 300 range_max = 700 diff --git a/demo/demo/ai/trees/09_agent_summoner.tres b/demo/demo/ai/trees/09_agent_summoner.tres index a458b12..97eda70 100644 --- a/demo/demo/ai/trees/09_agent_summoner.tres +++ b/demo/demo/ai/trees/09_agent_summoner.tres @@ -1,4 +1,4 @@ -[gd_resource type="BehaviorTree" load_steps=28 format=3 uid="uid://cpxk7jnqpwwlc"] +[gd_resource type="BehaviorTree" load_steps=33 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"] @@ -15,6 +15,24 @@ var/summon_cooldown/value = false var/summon_cooldown/hint = 0 var/summon_cooldown/hint_string = "" +[sub_resource type="BBNode" id="BBNode_b7euf"] +saved_value = NodePath("AnimationPlayer") +resource_name = "AnimationPlayer" + +[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_sot6a"] +animation_player = SubResource("BBNode_b7euf") +animation_name = &"idle" +blend = 0.1 + +[sub_resource type="BTRandomWait" id="BTRandomWait_0wc6p"] + +[sub_resource type="BTSequence" id="BTSequence_kwkxc"] +custom_name = "Summoning sickness" +children = [SubResource("BTPlayAnimation_sot6a"), SubResource("BTRandomWait_0wc6p")] + +[sub_resource type="BTRunLimit" id="BTRunLimit_x2jr4"] +children = [SubResource("BTSequence_kwkxc")] + [sub_resource type="BTComment" id="BTComment_ef6y0"] custom_name = "Variable $summon_cooldown is updated by the Cooldown task below" @@ -62,6 +80,7 @@ method = &"summon_minion" args = Array[BBVariant]([SubResource("BBVariant_wfjwy")]) [sub_resource type="BTCooldown" id="BTCooldown_25f70"] +duration = 6.0 cooldown_state_var = "summon_cooldown" children = [SubResource("BTCallMethod_4ath5")] @@ -117,7 +136,7 @@ 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")] +children = [SubResource("BTRunLimit_x2jr4"), SubResource("BTSequence_2n742"), SubResource("BTSequence_dss4d")] [resource] blackboard_plan = SubResource("BlackboardPlan_58oq1") diff --git a/demo/demo/assets/ui.theme b/demo/demo/assets/ui.theme index 77d3f34..8053661 100644 Binary files a/demo/demo/assets/ui.theme and b/demo/demo/assets/ui.theme differ diff --git a/demo/demo/props/gong.gd b/demo/demo/props/gong.gd new file mode 100644 index 0000000..adf21ed --- /dev/null +++ b/demo/demo/props/gong.gd @@ -0,0 +1,15 @@ +extends StaticBody2D + +signal gong_struck + +var enabled: bool = true + +@onready var animation_player: AnimationPlayer = $AnimationPlayer + + +func _on_health_damaged(_amount: float, _knockback: Vector2) -> void: + if not enabled: + return + animation_player.play(&"struck") + gong_struck.emit() + enabled = false diff --git a/demo/demo/props/gong.tscn b/demo/demo/props/gong.tscn index ea6bf6b..e65295c 100644 --- a/demo/demo/props/gong.tscn +++ b/demo/demo/props/gong.tscn @@ -1,15 +1,18 @@ -[gd_scene load_steps=8 format=3 uid="uid://bpd1wmw2f7bvg"] +[gd_scene load_steps=12 format=3 uid="uid://bpd1wmw2f7bvg"] +[ext_resource type="Script" path="res://demo/props/gong.gd" id="1_77c1i"] [ext_resource type="Texture2D" uid="uid://i476iia1ua8q" path="res://demo/assets/env_gong.png" id="1_kbnv6"] [ext_resource type="Texture2D" uid="uid://dwhhxj5557qrb" path="res://demo/assets/shadow.png" id="1_vl1mv"] [ext_resource type="Texture2D" uid="uid://dj4oayt5ttvh8" path="res://demo/assets/fx.png" id="2_dib3m"] +[ext_resource type="Script" path="res://demo/agents/scripts/hurtbox.gd" id="5_xeb5y"] +[ext_resource type="Script" path="res://demo/agents/scripts/health.gd" id="6_6a3q1"] [sub_resource type="Animation" id="Animation_i5ovs"] length = 0.001 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("Gong:position") +tracks/0/path = NodePath("Root/Gong:position") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { @@ -21,7 +24,7 @@ tracks/0/keys = { tracks/1/type = "value" tracks/1/imported = false tracks/1/enabled = true -tracks/1/path = NodePath("Gong:rotation") +tracks/1/path = NodePath("Root/Gong:rotation") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { @@ -33,7 +36,7 @@ tracks/1/keys = { tracks/2/type = "value" tracks/2/imported = false tracks/2/enabled = true -tracks/2/path = NodePath("Gong:scale") +tracks/2/path = NodePath("Root/Gong:scale") tracks/2/interp = 1 tracks/2/loop_wrap = true tracks/2/keys = { @@ -408,7 +411,7 @@ resource_name = "struck" tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("Gong:position") +tracks/0/path = NodePath("Root/Gong:position") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { @@ -420,7 +423,7 @@ tracks/0/keys = { tracks/1/type = "value" tracks/1/imported = false tracks/1/enabled = true -tracks/1/path = NodePath("Gong:rotation") +tracks/1/path = NodePath("Root/Gong:rotation") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { @@ -432,7 +435,7 @@ tracks/1/keys = { tracks/2/type = "value" tracks/2/imported = false tracks/2/enabled = true -tracks/2/path = NodePath("Gong:scale") +tracks/2/path = NodePath("Root/Gong:scale") tracks/2/interp = 1 tracks/2/loop_wrap = true tracks/2/keys = { @@ -812,20 +815,29 @@ _data = { radius = 20.91 height = 186.37 +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ru7jf"] +radius = 39.2 +height = 253.42 + [node name="Gong" type="StaticBody2D"] +script = ExtResource("1_77c1i") metadata/_edit_horizontal_guides_ = [111.0] -[node name="Shadow" type="Sprite2D" parent="."] +[node name="Root" type="Node2D" parent="."] +metadata/_edit_lock_ = true + +[node name="Shadow" type="Sprite2D" parent="Root"] modulate = Color(1, 1, 1, 0.329412) position = Vector2(0, -8) scale = Vector2(2.31, 1.7) texture = ExtResource("1_vl1mv") -[node name="Gong" type="Sprite2D" parent="."] +[node name="Gong" type="Sprite2D" parent="Root"] texture = ExtResource("1_kbnv6") offset = Vector2(0, -110) [node name="FX" type="Node2D" parent="."] +metadata/_edit_lock_ = true [node name="WaveL1" type="Sprite2D" parent="FX"] visible = false @@ -898,3 +910,21 @@ libraries = { position = Vector2(0, -14.395) rotation = 1.5708 shape = SubResource("CapsuleShape2D_nixvt") + +[node name="Hurtbox" type="Area2D" parent="." node_paths=PackedStringArray("health")] +collision_layer = 8 +collision_mask = 0 +script = ExtResource("5_xeb5y") +health = NodePath("../Health") + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="Hurtbox"] +position = Vector2(0, -14.395) +rotation = 1.5708 +shape = SubResource("CapsuleShape2D_ru7jf") +debug_color = Color(0.886275, 0.109804, 0.756863, 0.419608) + +[node name="Health" type="Node" parent="."] +script = ExtResource("6_6a3q1") +max_health = 1e+11 + +[connection signal="damaged" from="Health" to="." method="_on_health_damaged"] diff --git a/demo/demo/scenes/demo.gd b/demo/demo/scenes/demo.gd new file mode 100644 index 0000000..6453a55 --- /dev/null +++ b/demo/demo/scenes/demo.gd @@ -0,0 +1,83 @@ +extends Node2D + +const Simple := preload("res://demo/agents/01_agent_melee_simple.tscn") +const Charger := preload("res://demo/agents/02_agent_charger.tscn") +const Imp := preload("res://demo/agents/03_agent_imp.tscn") +const Skirmisher := preload("res://demo/agents/04_agent_skirmisher.tscn") +const Ranged := preload("res://demo/agents/05_agent_ranged.tscn") +const Combo := preload("res://demo/agents/06_agent_melee_combo.tscn") +const Nuanced := preload("res://demo/agents/07_agent_melee_nuanced.tscn") +const Demon := preload("res://demo/agents/08_agent_demon.tscn") +const Summoner := preload("res://demo/agents/09_agent_summoner.tscn") + +const WAVES: Array = [ + [Simple, Simple, Nuanced], + [Simple, Nuanced, Charger], + [Simple, Simple, Ranged, Nuanced], + [Simple, Simple, Summoner], + [Ranged, Skirmisher, Nuanced, Simple], + [Nuanced, Nuanced, Combo, Ranged], + [Demon, Charger, Simple, Simple, Skirmisher], + [Demon, Nuanced, Combo, Demon], + [Summoner, Ranged, Nuanced, Nuanced, Ranged, Skirmisher], + + [Demon, Demon, Summoner, Skirmisher, Nuanced, Nuanced, Combo], +] + +@export var wave_index: int = -1 +@export var agents_alive: int = 0 + +@onready var gong: StaticBody2D = $Gong +@onready var player: CharacterBody2D = $Player +@onready var spawn_points: Node2D = $SpawnPoints +@onready var hp_bar: TextureProgressBar = %HPBar +@onready var round_counter: Label = %RoundCounter + + +func _ready() -> void: + hp_bar.max_value = player.get_health().max_health + player.get_health().damaged.connect(func(_a,_b): hp_bar.value = player.get_health().get_current()) + player.death.connect(_on_player_death) + round_counter.hide() + + +func _update_round_counter() -> void: + round_counter.show() + round_counter.text = "Round %s/%s" % [wave_index + 1, WAVES.size()] + + +func _on_gong_gong_struck() -> void: + _start_round() + + +func _start_round() -> void: + wave_index += 1 + if wave_index >= WAVES.size(): + player.set_victorious() + round_counter.text = "Victorious!" + return + + await get_tree().create_timer(3.0).timeout + _update_round_counter() + + var spawns: Array = spawn_points.get_children() + spawns.shuffle() + for i in WAVES[wave_index].size(): + var agent_resource: PackedScene = WAVES[wave_index][i] + var agent: CharacterBody2D = agent_resource.instantiate() + add_child(agent) + agent.global_position = spawns[i].global_position + agent.death.connect(_on_agent_death) + agent.play_summoning_effect() + agents_alive += 1 + + +func _on_agent_death() -> void: + agents_alive -= 1 + if agents_alive == 0: + _start_round() + + +func _on_player_death() -> void: + await get_tree().create_timer(3.0).timeout + get_tree().reload_current_scene() diff --git a/demo/demo/scenes/demo.tscn b/demo/demo/scenes/demo.tscn index 961fc9d..cb8879d 100644 --- a/demo/demo/scenes/demo.tscn +++ b/demo/demo/scenes/demo.tscn @@ -1,13 +1,148 @@ -[gd_scene load_steps=3 format=3 uid="uid://clyhgbpfpmtw7"] +[gd_scene load_steps=15 format=3 uid="uid://clyhgbpfpmtw7"] +[ext_resource type="Script" path="res://demo/scenes/demo.gd" id="1_foif6"] [ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/arena.tscn" id="1_rab6h"] +[ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/ui.theme" id="2_e6mlj"] +[ext_resource type="PackedScene" uid="uid://bpd1wmw2f7bvg" path="res://demo/props/gong.tscn" id="3_nbeay"] +[ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="3_t7by8"] +[ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="4_xx6j3"] +[ext_resource type="Script" path="res://demo/scenes/toggle_fullscreen.gd" id="5_2oy30"] [ext_resource type="PackedScene" uid="uid://d07ag5dcje13i" path="res://demo/agents/player/player.tscn" id="5_cmgoj"] +[ext_resource type="Texture2D" uid="uid://dlw15foygohrk" path="res://demo/assets/hp_under.png" id="6_3dtym"] +[ext_resource type="Texture2D" uid="uid://cls8jtnu413o8" path="res://demo/assets/hp_over.png" id="7_3xolo"] +[ext_resource type="Texture2D" uid="uid://hnwi23oef752" path="res://demo/assets/hp_bar.png" id="8_ee1p0"] + +[sub_resource type="LabelSettings" id="LabelSettings_628x3"] +font = ExtResource("4_xx6j3") +font_size = 36 +font_color = Color(1, 1, 0.239216, 1) +outline_size = 20 +outline_color = Color(0.211521, 0.23888, 0.290166, 1) + +[sub_resource type="LabelSettings" id="LabelSettings_0r6iv"] +font = ExtResource("4_xx6j3") +font_size = 37 +outline_size = 15 +outline_color = Color(0.211521, 0.23888, 0.290166, 1) + +[sub_resource type="LabelSettings" id="LabelSettings_qvxvp"] +font = ExtResource("4_xx6j3") +font_size = 33 +outline_size = 11 +outline_color = Color(0.258915, 0.234974, 0.191974, 1) [node name="Demo" type="Node2D"] y_sort_enabled = true +script = ExtResource("1_foif6") + +[node name="UI Layer" type="CanvasLayer" parent="."] + +[node name="Control" type="Control" parent="UI Layer"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("2_e6mlj") + +[node name="Logo" type="TextureRect" parent="UI Layer/Control"] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -1899.0 +offset_top = -130.0 +offset_right = -1643.0 +offset_bottom = -45.0 +grow_horizontal = 0 +grow_vertical = 0 +texture = ExtResource("3_t7by8") + +[node name="Demo project" type="Label" parent="UI Layer/Control/Logo"] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -316.0 +offset_top = -72.0 +offset_right = 13.0 +offset_bottom = 74.0 +grow_horizontal = 0 +grow_vertical = 0 +text = "demo project" +label_settings = SubResource("LabelSettings_628x3") +horizontal_alignment = 2 +vertical_alignment = 1 + +[node name="ToggleFullscreen" type="Button" parent="UI Layer/Control"] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -214.0 +offset_top = 30.0 +offset_right = -31.0 +offset_bottom = 75.0 +grow_horizontal = 0 +focus_mode = 0 +theme_override_fonts/font = ExtResource("4_xx6j3") +theme_override_font_sizes/font_size = 22 +text = "Toggle Fullscreen" +script = ExtResource("5_2oy30") + +[node name="VBoxContainer" type="VBoxContainer" parent="UI Layer/Control"] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -394.0 +offset_top = -231.0 +offset_right = 99.0 +offset_bottom = 39.0 +grow_horizontal = 0 +grow_vertical = 0 + +[node name="Label" type="Label" parent="UI Layer/Control/VBoxContainer"] +layout_mode = 2 +text = "Move WASD +Attack ENTER or F +Dash SPACE" +label_settings = SubResource("LabelSettings_0r6iv") + +[node name="HPBar" type="TextureProgressBar" parent="UI Layer/Control"] +unique_name_in_owner = true +layout_mode = 0 +offset_left = 25.0 +offset_top = 24.0 +offset_right = 405.0 +offset_bottom = 84.0 +value = 100.0 +texture_under = ExtResource("6_3dtym") +texture_over = ExtResource("7_3xolo") +texture_progress = ExtResource("8_ee1p0") + +[node name="RoundCounter" type="Label" parent="UI Layer/Control"] +unique_name_in_owner = true +layout_mode = 1 +offset_left = 441.0 +offset_top = 29.0 +offset_right = 610.0 +offset_bottom = 81.0 +text = "Round: 0/1" +label_settings = SubResource("LabelSettings_qvxvp") [node name="Arena" parent="." instance=ExtResource("1_rab6h")] +[node name="Gong" parent="." instance=ExtResource("3_nbeay")] +position = Vector2(923, -21) + [node name="Player" parent="." instance=ExtResource("5_cmgoj")] position = Vector2(843, 455) @@ -19,3 +154,37 @@ drag_horizontal_enabled = true drag_vertical_enabled = true drag_top_margin = 0.1 drag_bottom_margin = 0.1 + +[node name="SpawnPoints" type="Node2D" parent="."] + +[node name="SpawnPosition1" type="Marker2D" parent="SpawnPoints"] +position = Vector2(512, -180) + +[node name="SpawnPosition2" type="Marker2D" parent="SpawnPoints"] +position = Vector2(1421, -150) + +[node name="SpawnPosition3" type="Marker2D" parent="SpawnPoints"] +position = Vector2(1512, 300) + +[node name="SpawnPosition4" type="Marker2D" parent="SpawnPoints"] +position = Vector2(2264, 345) + +[node name="SpawnPosition5" type="Marker2D" parent="SpawnPoints"] +position = Vector2(1655, 789) + +[node name="SpawnPosition6" type="Marker2D" parent="SpawnPoints"] +position = Vector2(823, 826) + +[node name="SpawnPosition7" type="Marker2D" parent="SpawnPoints"] +position = Vector2(67, 648) + +[node name="SpawnPosition8" type="Marker2D" parent="SpawnPoints"] +position = Vector2(-399, 434) + +[node name="SpawnPosition9" type="Marker2D" parent="SpawnPoints"] +position = Vector2(629, 417) + +[node name="SpawnPosition10" type="Marker2D" parent="SpawnPoints"] +position = Vector2(1859, 3) + +[connection signal="gong_struck" from="Gong" to="." method="_on_gong_gong_struck"] diff --git a/demo/project.godot b/demo/project.godot index 7810c0e..a6727da 100644 --- a/demo/project.godot +++ b/demo/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="LimboAI Demo" -run/main_scene="res://demo/scenes/arena.tscn" +run/main_scene="res://demo/scenes/demo.tscn" config/features=PackedStringArray("4.2", "Forward Plus") config/icon="res://demo/icon.svg" @@ -48,7 +48,13 @@ move_down={ attack={ "deadzone": 0.5, "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"echo":false,"script":null) +] +} +dash={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null) ] }