From b8d3cb02af9a1ea9383d4c733f4ea310076b982e Mon Sep 17 00:00:00 2001 From: Raxki Date: Fri, 20 Sep 2024 17:22:44 -0400 Subject: [PATCH] Add pillar walls, fix AI going through walls when repositioning --- Hiro/hiro_ai.tscn | 2 +- Scripts/hiro_ai.gd | 12 +++++-- world/long wood pillar .png | 3 ++ world/long wood pillar .png.import | 34 ++++++++++++++++++ world/pillar.tscn | 32 +++++++++++++++++ world/walls.png | 3 ++ world/walls.png.import | 34 ++++++++++++++++++ world/wood pillar.png | 3 ++ world/wood pillar.png.import | 34 ++++++++++++++++++ world/world.tscn | 56 +++++++++++++++++++++++++++--- 10 files changed, 206 insertions(+), 7 deletions(-) create mode 100644 world/long wood pillar .png create mode 100644 world/long wood pillar .png.import create mode 100644 world/pillar.tscn create mode 100644 world/walls.png create mode 100644 world/walls.png.import create mode 100644 world/wood pillar.png create mode 100644 world/wood pillar.png.import diff --git a/Hiro/hiro_ai.tscn b/Hiro/hiro_ai.tscn index c9eaf86..fb3e5ab 100644 --- a/Hiro/hiro_ai.tscn +++ b/Hiro/hiro_ai.tscn @@ -283,12 +283,12 @@ collision_layer = 2 collision_mask = 10 [node name="Collider" type="CollisionShape2D" parent="Hitbox"] +visible = false position = Vector2(0, -14) shape = SubResource("CapsuleShape2D_vm050") debug_color = Color(1, 0.133333, 0.321569, 0.419608) [node name="MovementCollider" type="CollisionShape2D" parent="."] -visible = false position = Vector2(-0.5, -1) shape = SubResource("RectangleShape2D_bdqvd") diff --git a/Scripts/hiro_ai.gd b/Scripts/hiro_ai.gd index 4727c88..cc1ef7d 100644 --- a/Scripts/hiro_ai.gd +++ b/Scripts/hiro_ai.gd @@ -118,14 +118,22 @@ func _on_hurt_state_exited(): func _on_hurt_reposition_state_entered(): var facing_direction = attacked_from * -1 - $MovementCollider.set_deferred("disabled", true) + set_collision_layer_value(5, true) + set_collision_layer_value(1, false) + set_collision_mask_value(5, true) + set_collision_mask_value(1, false) + #$MovementCollider.set_deferred("disabled", true) set_animation_direction(facing_direction) anim_playback.travel("hurt") velocity = attacked_from * KNOCKBACK_REPOSITION_POWER * -1 func _on_hurt_reposition_state_exited(): velocity = Vector2.ZERO - $MovementCollider.set_deferred("disabled", false) + set_collision_layer_value(5, false) + set_collision_layer_value(1, true) + set_collision_mask_value(5, false) + set_collision_mask_value(1, true) + #$MovementCollider.set_deferred("disabled", false) hit_counter = 0 func _on_animation_tree_animation_finished(anim_name): diff --git a/world/long wood pillar .png b/world/long wood pillar .png new file mode 100644 index 0000000..82443cd --- /dev/null +++ b/world/long wood pillar .png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23b7bac7f4e77b1022e96eb71e1b2d897acef9790e6e7c64b98417b08a4b4b10 +size 3156 diff --git a/world/long wood pillar .png.import b/world/long wood pillar .png.import new file mode 100644 index 0000000..85e6a34 --- /dev/null +++ b/world/long wood pillar .png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dywy1nhojkpuq" +path="res://.godot/imported/long wood pillar .png-2ae92e566dd29779fff88b39b2055e5e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://world/long wood pillar .png" +dest_files=["res://.godot/imported/long wood pillar .png-2ae92e566dd29779fff88b39b2055e5e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/world/pillar.tscn b/world/pillar.tscn new file mode 100644 index 0000000..4b8ed10 --- /dev/null +++ b/world/pillar.tscn @@ -0,0 +1,32 @@ +[gd_scene load_steps=4 format=3 uid="uid://c503u0i421w34"] + +[ext_resource type="Texture2D" uid="uid://d0aw0q6fvgk1o" path="res://world/wood pillar.png" id="1_wjgo2"] +[ext_resource type="Texture2D" uid="uid://dywy1nhojkpuq" path="res://world/long wood pillar .png" id="2_q108x"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_nsmbw"] +size = Vector2(8, 24) + +[node name="Node2D" type="Node2D"] + +[node name="StaticBody2D" type="StaticBody2D" parent="."] +texture_filter = 1 +position = Vector2(0, -22) +collision_layer = 17 +collision_mask = 17 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] +texture_filter = 1 +position = Vector2(0, 10) +shape = SubResource("RectangleShape2D_nsmbw") + +[node name="WoodPillar" type="Sprite2D" parent="."] +visible = false +y_sort_enabled = true +texture_filter = 1 +position = Vector2(0, -22) +texture = ExtResource("1_wjgo2") + +[node name="LongWoodPillar" type="Sprite2D" parent="."] +texture_filter = 1 +position = Vector2(0, -32) +texture = ExtResource("2_q108x") diff --git a/world/walls.png b/world/walls.png new file mode 100644 index 0000000..a93051d --- /dev/null +++ b/world/walls.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4c48de5e73e57b79cf237076f3fa6a99a18f0ff0da202732ce576a8d9f557a8 +size 2043 diff --git a/world/walls.png.import b/world/walls.png.import new file mode 100644 index 0000000..941b858 --- /dev/null +++ b/world/walls.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dc12iaho4b8yl" +path="res://.godot/imported/walls.png-a96ddd85a7a29b3ff8651db1d6479999.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://world/walls.png" +dest_files=["res://.godot/imported/walls.png-a96ddd85a7a29b3ff8651db1d6479999.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/world/wood pillar.png b/world/wood pillar.png new file mode 100644 index 0000000..a8c76ca --- /dev/null +++ b/world/wood pillar.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84baf95923c09b0cf7957726efc874f304169135a3b0134c1c8d0b6354e60a55 +size 421 diff --git a/world/wood pillar.png.import b/world/wood pillar.png.import new file mode 100644 index 0000000..b3b5c88 --- /dev/null +++ b/world/wood pillar.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d0aw0q6fvgk1o" +path="res://.godot/imported/wood pillar.png-458c768add8f3021bafd77705155c1df.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://world/wood pillar.png" +dest_files=["res://.godot/imported/wood pillar.png-458c768add8f3021bafd77705155c1df.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/world/world.tscn b/world/world.tscn index 8e93564..1ae8a21 100644 --- a/world/world.tscn +++ b/world/world.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://bxuxjqxxqy7ce"] +[gd_scene load_steps=9 format=3 uid="uid://bxuxjqxxqy7ce"] [ext_resource type="PackedScene" uid="uid://di21xheryhp0k" path="res://Hiro/hiro_player.tscn" id="1_c1gpq"] [ext_resource type="PackedScene" uid="uid://b8sfype1vx5ad" path="res://Nem/nem_npc.tscn" id="1_sqt7d"] @@ -6,18 +6,63 @@ [ext_resource type="Texture2D" uid="uid://b40la2vyf4rn6" path="res://world/Fighting Dojo BG.png" id="4_elb6q"] [ext_resource type="PackedScene" uid="uid://dd2km6qhpdicx" path="res://Hiro/hiro_ai.tscn" id="5_r7nw4"] [ext_resource type="PackedScene" uid="uid://bakb5a7xe4qby" path="res://Reed/reed_player.tscn" id="6_cn8e2"] +[ext_resource type="Texture2D" uid="uid://dc12iaho4b8yl" path="res://world/walls.png" id="7_pp5dn"] +[ext_resource type="PackedScene" uid="uid://c503u0i421w34" path="res://world/pillar.tscn" id="8_mxq55"] [node name="Node2D" type="Node2D"] y_sort_enabled = true -[node name="FightingDojoBg" type="Sprite2D" parent="."] +[node name="MapElements" type="Node2D" parent="."] +y_sort_enabled = true + +[node name="FightingDojoBg" type="Sprite2D" parent="MapElements"] z_index = -5 texture_filter = 1 position = Vector2(136, 148) texture = ExtResource("4_elb6q") +metadata/_edit_lock_ = true + +[node name="LongWoodPillar" parent="MapElements" instance=ExtResource("8_mxq55")] +y_sort_enabled = true +position = Vector2(48, 239) + +[node name="LongWoodPillar2" parent="MapElements" instance=ExtResource("8_mxq55")] +y_sort_enabled = true +position = Vector2(48, 159) + +[node name="LongWoodPillar3" parent="MapElements" instance=ExtResource("8_mxq55")] +y_sort_enabled = true +position = Vector2(96, 120) + +[node name="LongWoodPillar4" parent="MapElements" instance=ExtResource("8_mxq55")] +y_sort_enabled = true +position = Vector2(224, 159) + +[node name="LongWoodPillar5" parent="MapElements" instance=ExtResource("8_mxq55")] +y_sort_enabled = true +position = Vector2(224, 239) + +[node name="LongWoodPillar6" parent="MapElements" instance=ExtResource("8_mxq55")] +y_sort_enabled = true +position = Vector2(176, 120) + +[node name="LongWoodPillar7" parent="MapElements" instance=ExtResource("8_mxq55")] +y_sort_enabled = true +position = Vector2(96, 280) + +[node name="LongWoodPillar8" parent="MapElements" instance=ExtResource("8_mxq55")] +y_sort_enabled = true +position = Vector2(176, 279) + +[node name="Walls" type="Sprite2D" parent="MapElements"] +z_index = 1 +texture_filter = 1 +position = Vector2(137, 199) +texture = ExtResource("7_pp5dn") [node name="HiroPlayer" parent="." instance=ExtResource("1_c1gpq")] position = Vector2(92, 178) +speed = 80 [node name="ReedPlayer" parent="." instance=ExtResource("6_cn8e2")] position = Vector2(176, 178) @@ -26,12 +71,14 @@ position = Vector2(176, 178) position = Vector2(138, 112) [node name="BG Collissions" type="StaticBody2D" parent="."] -y_sort_enabled = true +z_index = 2 +collision_layer = 17 +collision_mask = 17 [node name="Floor Collission" type="CollisionPolygon2D" parent="BG Collissions"] position = Vector2(-1341, -243) scale = Vector2(8.83789, 4.22585) -polygon = PackedVector2Array(157.843, 76.9076, 161.464, 75.961, 172.213, 75.7244, 176.513, 76.9076, 179.22, 82.4429, 180.012, 85.7558, 180.238, 91.9084, 180.012, 107.053, 178.549, 113.823, 176.739, 116.426, 175.042, 118.083, 169.497, 118.319, 169.497, 123.525, 164.745, 123.525, 164.858, 118.319, 158.975, 117.846, 157.504, 116.663, 155.806, 114.533, 154.109, 108.617, 154.109, 94.4188, 154.222, 83.2968, 152.186, 83.0602, 152.412, 80.9304, 146.181, 70.3743, 139.513, 85.4266, 135.779, 90.8692, 147.66, 124.945, 187.367, 125.038, 195.514, 91.4351, 192.232, 66.1148, 173.676, 53.3363, 157.382, 53.8096, 152.404, 63.2751, 153.317, 81.6403, 154.222, 83.7701, 155.92, 79.9839) +polygon = PackedVector2Array(157.843, 76.9076, 161.464, 75.961, 172.213, 75.7244, 176.513, 76.9076, 179.22, 82.4429, 180.012, 85.7558, 180.36, 93.9456, 180.247, 114.06, 179.341, 117.373, 177.871, 119.739, 174.929, 120.922, 169.497, 120.922, 169.497, 123.525, 164.745, 123.525, 164.632, 120.922, 159.201, 120.922, 156.372, 120.213, 154.901, 117.373, 154.109, 114.533, 153.883, 94.4189, 153.883, 84.0068, 152.186, 83.0602, 152.412, 80.9304, 146.181, 70.3743, 139.513, 85.4266, 135.779, 90.8692, 147.66, 124.945, 187.367, 125.038, 195.514, 91.4351, 192.232, 66.1148, 173.676, 53.3363, 157.382, 53.8096, 152.404, 63.2751, 153.317, 81.6403, 153.883, 84.0068, 155.92, 79.9839) [node name="StateChartDebugger" parent="." instance=ExtResource("2_o5str")] offset_left = 296.0 @@ -44,6 +91,7 @@ initial_node_to_watch = NodePath("../HiroAI") [node name="HiroAI" parent="." node_paths=PackedStringArray("player_character") instance=ExtResource("5_r7nw4")] position = Vector2(135, 215) player_character = NodePath("../HiroPlayer") +health = 400 attack_power = 5 [connection signal="attack_did_hit" from="HiroPlayer" to="HiroAI" method="_on_player_attack_did_hit"]