Give item to npc

This commit is contained in:
2025-06-28 18:12:04 -07:00
parent 0880b74695
commit 54d9bcf52d
14 changed files with 69 additions and 43 deletions

View File

@@ -8,4 +8,8 @@ I haven't had a script added yet.
~ hit
Yep, hitting me does work though.
=> END
~ get_item
ooo yum
=> END

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=254 format=4 uid="uid://dvnc26rebk6o0"]
[gd_scene load_steps=257 format=4 uid="uid://dvnc26rebk6o0"]
[ext_resource type="Script" uid="uid://cuhfkyh3d7noa" path="res://src/map/dungeon/code/Overworld.cs" id="1_5hmt3"]
[ext_resource type="Texture2D" uid="uid://co6h8vyi11sl2" path="res://src/map/overworld/Models/Overworld_CLOUD_RINGS_INNER_63.png" id="2_g6b7b"]
@@ -68,6 +68,9 @@
[ext_resource type="Texture2D" uid="uid://wqbflec631rm" path="res://src/map/overworld/Models/Overworld_optimized_Pass 1_BANYAN_LEAVES.png" id="66_plu1v"]
[ext_resource type="Texture2D" uid="uid://ck2milaawr3ef" path="res://src/map/overworld/Models/Overworld_optimized_Pass 1_BANYAN_LEAVES2.png" id="67_shdaj"]
[ext_resource type="Texture2D" uid="uid://c5jloiaiy7iug" path="res://src/map/overworld/Models/Overworld_optimized_Pass 1_BANYAN_LEAVES_3.png" id="68_8o0x4"]
[ext_resource type="PackedScene" uid="uid://jds3hr41coal" path="res://src/npc/Ran/Ran.tscn" id="69_g6b7b"]
[ext_resource type="PackedScene" uid="uid://db206brufi83s" path="res://src/items/weapons/Weapon.tscn" id="70_r8r3k"]
[ext_resource type="Resource" uid="uid://cfhwlpa0d7wb4" path="res://src/items/weapons/resources/MysteryRod.tres" id="71_t71yg"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_peugn"]
resource_name = "CLOUDS1"
@@ -8264,10 +8267,6 @@ skeleton = NodePath("")
unique_name_in_owner = true
transform = Transform3D(-0.0104718, 0, 0.999945, 0, 1, 0, -0.999945, 0, -0.0104718, -241.939, 2.09173, 42.6114)
[node name="ExitSpawnPoint" type="Marker3D" parent="Spawn Points"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -222.479, 0.9708, 17.5532)
[node name="Exit" type="Area3D" parent="Spawn Points"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -99.0174, 4.81592, 93.6446)
@@ -8277,3 +8276,10 @@ collision_mask = 256
[node name="CollisionShape3D" type="CollisionShape3D" parent="Spawn Points/Exit"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -13.5815, -2.1779, -3.80354)
shape = SubResource("BoxShape3D_b53dq")
[node name="Ran" parent="." instance=ExtResource("69_g6b7b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -230.292, 4.34026, 49.3324)
[node name="Weapon" parent="Ran" instance=ExtResource("70_r8r3k")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.451996, -1.48021, -8.76553)
Stats = ExtResource("71_t71yg")

View File

@@ -27,8 +27,8 @@ texture = ExtResource("2_rop5q")
[node name="DialogueZone" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 2
collision_mask = 2
collision_layer = 0
collision_mask = 2068
[node name="CollisionShape3D" type="CollisionShape3D" parent="DialogueZone"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00131226, 0, -0.00723076)

View File

@@ -49,8 +49,8 @@ shape = SubResource("CapsuleShape3D_kg3qv")
[node name="Hitbox" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 16
collision_mask = 16
collision_layer = 0
collision_mask = 2068
[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"]
shape = SubResource("CylinderShape3D_nwuwj")

View File

@@ -50,8 +50,8 @@ shape = SubResource("CapsuleShape3D_kg3qv")
[node name="Hitbox" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 16
collision_mask = 16
collision_layer = 0
collision_mask = 2068
[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"]
shape = SubResource("CylinderShape3D_nwuwj")

View File

@@ -20,45 +20,53 @@ public partial class Npc : Node3D
public void OnReady()
{
SetPhysicsProcess(true);
DialogueZone.BodyEntered += DialogueZone_BodyEntered;
DialogueZone.BodyExited += DialogueZone_BodyExited;
Hitbox.AreaEntered += Hitbox_AreaEntered;
SetPhysicsProcess(true);
DialogueZone.BodyEntered += DialogueZone_BodyEntered;
DialogueZone.BodyExited += DialogueZone_BodyExited;
Hitbox.AreaEntered += Hitbox_AreaEntered;
}
private void Hitbox_AreaEntered(Area3D area)
{
DialogueController.ShowDialogue(Dialogue, "hit");
if (area.GetOwner() is ThrownItem thrownItem)
{
DialogueController.ShowDialogue(Dialogue, "get_item");
thrownItem.QueueFree();
}
else
{
DialogueController.ShowDialogue(Dialogue, "hit");
}
}
private void Hitbox_BodyEntered(Node body)
{
DialogueController.ShowDialogue(Dialogue, "hit");
DialogueController.ShowDialogue(Dialogue, "hit");
}
private void DialogueZone_BodyExited(Node3D body)
{
_isInDialogueZone = false;
DialogueController.Interrupt();
_isInDialogueZone = false;
DialogueController.Interrupt();
}
private void DialogueZone_BodyEntered(Node3D body)
{
_isInDialogueZone = true;
_isInDialogueZone = true;
}
public override void _UnhandledInput(InputEvent @event)
{
if (@event.IsActionPressed(GameInputs.Interact) && _isInDialogueZone)
{
if (_isIntroductionComplete)
DialogueController.ShowDialogue(Dialogue, "general");
else
{
DialogueController.ShowDialogue(Dialogue, "introduction");
_isIntroductionComplete = true;
}
}
if (@event.IsActionPressed(GameInputs.Interact) && _isInDialogueZone)
{
if (_isIntroductionComplete)
DialogueController.ShowDialogue(Dialogue, "general");
else
{
DialogueController.ShowDialogue(Dialogue, "introduction");
_isIntroductionComplete = true;
}
}
}
}

View File

@@ -46,8 +46,8 @@ shape = SubResource("CapsuleShape3D_kg3qv")
[node name="Hitbox" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 16
collision_mask = 16
collision_layer = 0
collision_mask = 2068
[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"]
shape = SubResource("CylinderShape3D_nwuwj")

View File

@@ -48,8 +48,8 @@ shape = SubResource("CapsuleShape3D_kg3qv")
[node name="Hitbox" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 16
collision_mask = 16
collision_layer = 0
collision_mask = 2068
[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"]
shape = SubResource("CylinderShape3D_nwuwj")

View File

@@ -277,7 +277,7 @@ animation = &"idle"
[node name="DialogueZone" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 2
collision_layer = 0
collision_mask = 2
[node name="CollisionShape3D" type="CollisionShape3D" parent="DialogueZone"]
@@ -295,8 +295,8 @@ shape = SubResource("CapsuleShape3D_kg3qv")
[node name="Hitbox" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 16
collision_mask = 16
collision_layer = 0
collision_mask = 2068
[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"]
shape = SubResource("CylinderShape3D_nwuwj")

View File

@@ -10,3 +10,7 @@ Rӑn: okay......
Rӑn: hey ow
=> END
~ get_item
Rӑn: ooo yum
=> END

View File

@@ -47,8 +47,8 @@ shape = SubResource("CapsuleShape3D_kg3qv")
[node name="Hitbox" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 16
collision_mask = 16
collision_layer = 0
collision_mask = 2068
[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"]
shape = SubResource("CylinderShape3D_nwuwj")

View File

@@ -46,3 +46,7 @@ Royal Rat Princep, Tekohcyo: The walls of the Tower may deceive you.
Royal Rat Princep, Tekohcyo: I suppose in the end, any end is, relievingly, an end.
=> END
~ get_item
Royal Rat Princep, Tekohcyo: ooo yum
=> END

View File

@@ -50,8 +50,8 @@ shape = SubResource("CapsuleShape3D_kg3qv")
[node name="Hitbox" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 16
collision_mask = 16
collision_layer = 0
collision_mask = 2068
[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"]
shape = SubResource("CylinderShape3D_nwuwj")

View File

@@ -486,7 +486,7 @@ size = Vector3(1.94531, 3.38623, 1.50671)
height = 1.6909
[node name="Player" type="CharacterBody3D"]
collision_layer = 806
collision_layer = 802
collision_mask = 775
script = ExtResource("1_xcol5")
_playerStatResource = SubResource("Resource_bj1ma")
@@ -587,7 +587,7 @@ disabled = true
[node name="CollisionDetector" type="Area3D" parent="Collision"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.126903, 0)
collision_layer = 452
collision_layer = 448
collision_mask = 452
[node name="CollisionShape3D" type="CollisionShape3D" parent="Collision/CollisionDetector"]