Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 863912a

Browse files
committed
More story progression
1 parent 8344daf commit 863912a

5 files changed

Lines changed: 141 additions & 72 deletions

File tree

scenes/levels/CaveTileset.tres

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ texture_region_size = Vector2i(32, 32)
559559
19:3/0 = 0
560560
19:1/0 = 0
561561
20:1/0 = 0
562-
20:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
562+
20:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-13.5, -13, -7.75, -16, 5, -16, 4.75, -7.75, 6, -2.75, -7, 4.25, -12.25, 0.5)
563563
20:0/0 = 0
564564

565565
[resource]

scenes/levels/ExampleScene.tscn

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=132 format=4 uid="uid://dfkwq6qwtxw25"]
1+
[gd_scene load_steps=133 format=4 uid="uid://dfkwq6qwtxw25"]
22

33
[ext_resource type="Script" path="res://scripts/EnemyManager.cs" id="1_bmkfv"]
44
[ext_resource type="Script" path="res://scripts/Map.cs" id="1_pa1ge"]
@@ -14990,14 +14990,18 @@ size = Vector2(190.043, 242.52)
1499014990
a = Vector2(-14, -120)
1499114991
b = Vector2(-14, 132)
1499214992

14993+
[sub_resource type="SegmentShape2D" id="SegmentShape2D_k0qre"]
14994+
a = Vector2(-11, -257)
14995+
b = Vector2(-11, -7)
14996+
1499314997
[node name="Node2D" type="Node2D"]
1499414998
position = Vector2(2595, 2509)
1499514999
script = ExtResource("1_pa1ge")
1499615000
_darknessCircleDamage = 1
1499715001
_allyHealthChangeIntervall = 5.0
1499815002

1499915003
[node name="Ally" parent="." node_paths=PackedStringArray("_responseField", "_nameLabel", "Chat", "_animPlayer") instance=ExtResource("6_l8h37")]
15000-
position = Vector2(923, 2052)
15004+
position = Vector2(5780, -4309)
1500115005
_responseField = NodePath("ResponseField")
1500215006
_nameLabel = NodePath("Label")
1500315007
_visionRadius = 200
@@ -15098,10 +15102,11 @@ shadow_filter_smooth = 2.3
1509815102
texture_scale = 14.0
1509915103

1510015104
[node name="Ally2" parent="." node_paths=PackedStringArray("_responseField", "_nameLabel", "Chat", "_animPlayer") groups=["navigation"] instance=ExtResource("6_l8h37")]
15101-
position = Vector2(289, 2015)
15105+
position = Vector2(7410, -6307)
1510215106
_responseField = NodePath("ResponseField")
1510315107
_nameLabel = NodePath("Label")
1510415108
_visionRadius = 200
15109+
_interactionRadius = 250
1510515110
Chat = NodePath("Ally2Cam/Ally2Chat")
1510615111
_animPlayer = NodePath("AnimationPlayer2")
1510715112

@@ -15355,16 +15360,17 @@ position = Vector2(8600, -2333)
1535515360
scale = Vector2(0.999999, 0.999999)
1535615361

1535715362
[node name="InsideBigHouse" type="Node2D" parent="Abandoned Village/Sprite2D"]
15363+
z_index = 2
1535815364
position = Vector2(-221, -475.001)
1535915365
script = ExtResource("25_0y114")
1536015366
SceneToShow = ExtResource("26_vmw0c")
1536115367
Radius = 500
15362-
NeedsToBeInInventoryName = 11
15368+
ItemActivationStatus = false
1536315369

1536415370
[node name="InsideBigHouse2" parent="Abandoned Village/Sprite2D" instance=ExtResource("26_vmw0c")]
1536515371
z_index = 30
1536615372
position = Vector2(-222, -200.001)
15367-
scale = Vector2(3.7, 3.7)
15373+
scale = Vector2(3.7, 6.5)
1536815374

1536915375
[node name="VisibleForAI" type="Node2D" parent="Abandoned Village/Sprite2D"]
1537015376
script = ExtResource("6_7bcmx")
@@ -15383,17 +15389,6 @@ WalkingObject = NodePath("../../../../Ally")
1538315389
WalkingObject2 = NodePath("../../../../Ally2")
1538415390
Sound = NodePath("../../../../AudioManager/door_sound")
1538515391

15386-
[node name="InsideSmallHouse" parent="Abandoned Village/Sprite2D" instance=ExtResource("19_qd0ov")]
15387-
z_index = 30
15388-
position = Vector2(550.001, 1808)
15389-
scale = Vector2(4, 5)
15390-
15391-
[node name="ShowWhileInRadius" type="Node2D" parent="Abandoned Village/Sprite2D"]
15392-
position = Vector2(540, 1479)
15393-
script = ExtResource("25_0y114")
15394-
SceneToShow = ExtResource("19_qd0ov")
15395-
Radius = 500
15396-
1539715392
[node name="HauntedForestVillageAiNode" parent="Abandoned Village" instance=ExtResource("13_05imv")]
1539815393
position = Vector2(8649, -1315)
1539915394
scale = Vector2(3, 3)
@@ -15411,6 +15406,22 @@ script = ExtResource("24_sabha")
1541115406
MusicPlayer1 = NodePath("../../AudioManager/game_music")
1541215407
MusicPlayer2 = NodePath("../../AudioManager/creepy_music")
1541315408

15409+
[node name="Node2D" type="Node2D" parent="Abandoned Village"]
15410+
15411+
[node name="Sprite2D" type="Sprite2D" parent="Abandoned Village/Node2D"]
15412+
15413+
[node name="InsideSmallHouse" parent="Abandoned Village/Node2D/Sprite2D" instance=ExtResource("19_qd0ov")]
15414+
z_index = 30
15415+
position = Vector2(9150, -525.002)
15416+
scale = Vector2(4, 4.99999)
15417+
15418+
[node name="InsideSmallHouse2" type="Node2D" parent="Abandoned Village/Node2D/Sprite2D"]
15419+
position = Vector2(9140, -854.001)
15420+
scale = Vector2(0.999999, 0.999999)
15421+
script = ExtResource("25_0y114")
15422+
SceneToShow = ExtResource("19_qd0ov")
15423+
Radius = 500
15424+
1541415425
[node name="Spaceport" type="Node" parent="."]
1541515426

1541615427
[node name="Tilemap Layers" type="Node" parent="Spaceport"]
@@ -15838,37 +15849,35 @@ tile_map_data = PackedByteArray("AAASACMAAAAFAAQAAAATACcAAAAFAAQAAAAWACgAAAAGAAU
1583815849
tile_set = SubResource("TileSet_tur7q")
1583915850

1584015851
[node name="Big Tree" parent="." instance=ExtResource("13_05imv")]
15841-
unique_name_in_owner = true
15842-
position = Vector2(5562, -7925)
15852+
position = Vector2(5567, -7879)
1584315853
ObjectName = "Big Tree"
1584415854
ObjectDescription = "A massive tree that is surrounded by scrub and looks damaged"
15845-
CustomOverrideMessage = "You've successfully removed the scrub from the tree and are now able to reach it"
15855+
CustomOverrideMessage = "You've successfully removed the scrub from the tree and a big hideous scar appears underneath it"
1584615856
ShowWhileInRadius = true
1584715857

1584815858
[node name="StaticBody2D" type="StaticBody2D" parent="Big Tree"]
1584915859

1585015860
[node name="CollisionShape2D" type="CollisionShape2D" parent="Big Tree/StaticBody2D"]
1585115861
z_index = 50
15852-
position = Vector2(100, -141)
15862+
position = Vector2(95, -200)
1585315863
rotation = -1.56722
1585415864
shape = SubResource("RectangleShape2D_g520r")
1585515865

15856-
[node name="CaveEntrance" parent="." instance=ExtResource("13_05imv")]
15866+
[node name="CaveEntranceTerminal" parent="." instance=ExtResource("13_05imv")]
1585715867
unique_name_in_owner = true
15858-
position = Vector2(2025, -8275)
15859-
ObjectName = "Cave entrance"
15868+
position = Vector2(2086, -8391)
15869+
ObjectName = "Cave entrance terminal"
1586015870
ObjectDescription = "Seems like a locked entracne with a small terminal next to it. Maybe there is some nfc device needed to enter."
15861-
Interactable = false
1586215871
CustomOverrideMessage = "The door opens slowly and a big dark cave apperas behind it"
1586315872

15864-
[node name="StaticBody2D" type="StaticBody2D" parent="CaveEntrance"]
15873+
[node name="StaticBody2D" type="StaticBody2D" parent="CaveEntranceTerminal"]
1586515874

15866-
[node name="CollisionShape2D" type="CollisionShape2D" parent="CaveEntrance/StaticBody2D"]
15875+
[node name="CollisionShape2D" type="CollisionShape2D" parent="CaveEntranceTerminal/StaticBody2D"]
1586715876
z_index = 1
15877+
position = Vector2(-60, 114)
1586815878
shape = SubResource("SegmentShape2D_i54bb")
1586915879

1587015880
[node name="Scar" parent="." instance=ExtResource("13_05imv")]
15871-
unique_name_in_owner = true
1587215881
position = Vector2(5613, -8059)
1587315882
ObjectName = "Scar"
1587415883
ObjectDescription = "A big scar on the tree which could be the reason for the tree looking dead. It is not reachable because of the scrub"
@@ -15883,17 +15892,39 @@ ObjectDescription = "can be used to fill an empty bucket with water"
1588315892
RemovedAfter = false
1588415893
CustomOverrideMessage = "the ally now has a water bucket"
1588515894

15886-
[node name="InsideBigTree" type="Node2D" parent="."]
15895+
[node name="DoorOpener" parent="." instance=ExtResource("13_05imv")]
15896+
position = Vector2(-1917, -7812)
15897+
ObjectName = "Door opener"
15898+
ObjectDescription = "Seems like a door can be opened through interacting. There is a timer that starts when the door opens, so there is only a limited amount of time to pass it."
15899+
RemovedAfter = false
15900+
CustomOverrideMessage = "Door is now open for 5 seconds"
15901+
15902+
[node name="StaticBody2D" type="StaticBody2D" parent="DoorOpener"]
15903+
15904+
[node name="CaveEntrance1" type="CollisionShape2D" parent="DoorOpener/StaticBody2D"]
15905+
z_index = 2
15906+
position = Vector2(-25, -835)
15907+
shape = SubResource("SegmentShape2D_k0qre")
15908+
15909+
[node name="StaticBody2D2" type="StaticBody2D" parent="DoorOpener"]
15910+
15911+
[node name="CaveEntrance2" type="CollisionShape2D" parent="DoorOpener/StaticBody2D2"]
15912+
z_index = 2
15913+
position = Vector2(-541, -834)
15914+
shape = SubResource("SegmentShape2D_k0qre")
15915+
15916+
[node name="Node2D" type="Node2D" parent="."]
15917+
15918+
[node name="Sprite2D" type="Sprite2D" parent="Node2D"]
1588715919
position = Vector2(5613, -8059)
1588815920

15889-
[node name="InsideBigTree" parent="InsideBigTree" instance=ExtResource("58_llp75")]
15921+
[node name="InsideBigTree" parent="Node2D/Sprite2D" instance=ExtResource("58_llp75")]
1589015922
z_index = 30
1589115923
position = Vector2(114, 58)
1589215924
scale = Vector2(2.5, 2.5)
1589315925

15894-
[node name="ShowWhileInRadius" type="Node2D" parent="InsideBigTree"]
15926+
[node name="ShowWhileInRadius" type="Node2D" parent="Node2D/Sprite2D"]
1589515927
scale = Vector2(2.5, 2.5)
1589615928
script = ExtResource("25_0y114")
1589715929
SceneToShow = ExtResource("58_llp75")
15898-
Radius = 100
15899-
ItemActivationStatus = false
15930+
Radius = 500

scripts/Ally.cs

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public partial class Ally : CharacterBody2D
2525
protected Game.Scripts.Core _core = null!;
2626
public Inventory SsInventory = new Inventory(12);
2727
private AudioOutput _audioOutput = null!;
28-
private AiNode _caveEntrance = null!;
29-
private AiNode _scar = null!;
3028

3129

3230
private RichTextLabel _ally1ResponseField = null!, _ally2ResponseField = null!;
@@ -36,6 +34,7 @@ public partial class Ally : CharacterBody2D
3634
private bool _interactOnArrival, _busy, _reached, _harvest, _returning;
3735
public bool IsTextBoxReady = true, Lit;
3836

37+
public bool AnimationIsAlreadyPlaying = false;
3938

4039
[Export] public Chat Chat = null!;
4140
public Map? Map;
@@ -76,9 +75,6 @@ public override void _Ready()
7675
// SsInventory.AddItem(new Itemstack(Items.Material.Copper, 1));
7776
SsInventory.AddItem(new Itemstack(Items.Material.BucketWater, 1));
7877
_torch = GetNode<PointLight2D>("AllyTorch");
79-
_caveEntrance = GetNode<AiNode>("%CaveEntrance");
80-
_scar = GetNode<AiNode>("%Scar");
81-
8278
_ally1ResponseField = GetNode<RichTextLabel>("ResponseField");
8379
_ally2ResponseField = GetNode<RichTextLabel>("ResponseField");
8480
_audioOutput = Chat.GetNode<AudioOutput>("Speech");
@@ -178,6 +174,22 @@ public void SetAllyInDarkness()
178174

179175
}
180176

177+
private void playPlayerAnimation(){
178+
if (PathFindingMovement.CurrentDirection == PathFindingMovement.WalkingState.Left)
179+
{
180+
_animPlayer.Play("Walk-Left");
181+
}
182+
else if (PathFindingMovement.CurrentDirection == PathFindingMovement.WalkingState.Right)
183+
{
184+
_animPlayer.Play("Walk-Right");
185+
}
186+
else if (PathFindingMovement.CurrentDirection == PathFindingMovement.WalkingState.IdleLeft)
187+
{
188+
_animPlayer.Play("Idle-Left");
189+
}
190+
else { _animPlayer.Play("Idle-Right"); }
191+
}
192+
181193
private bool _hasSeenOtherAlly = false;
182194
public override void _PhysicsProcess(double delta)
183195
{
@@ -213,19 +225,12 @@ public override void _PhysicsProcess(double delta)
213225

214226
UpdateTarget();
215227

216-
if (PathFindingMovement.CurrentDirection == PathFindingMovement.WalkingState.Left)
217-
{
218-
_animPlayer.Play("Walk-Left");
219-
}
220-
else if (PathFindingMovement.CurrentDirection == PathFindingMovement.WalkingState.Right)
221-
{
222-
_animPlayer.Play("Walk-Right");
228+
if(!AnimationIsAlreadyPlaying){
229+
playPlayerAnimation();
223230
}
224-
else if (PathFindingMovement.CurrentDirection == PathFindingMovement.WalkingState.IdleLeft)
225-
{
226-
_animPlayer.Play("Idle-Left");
231+
else if(!_animPlayer.IsPlaying()){
232+
AnimationIsAlreadyPlaying = false;
227233
}
228-
else { _animPlayer.Play("Idle-Right"); }
229234

230235
_reached = GlobalPosition.DistanceTo(PathFindingMovement.TargetPosition) < 150;
231236

@@ -253,18 +258,6 @@ public override void _PhysicsProcess(double delta)
253258
*/
254259
}
255260

256-
//Cave entrance logic:
257-
if (this.SsInventory.ContainsMaterial(Items.Material.Chipcard) && this.GlobalPosition.DistanceTo(_caveEntrance.GlobalPosition) < 300)
258-
{
259-
_caveEntrance.Interactable = true;
260-
}
261-
//Well logic:
262-
if (GlobalPosition.DistanceTo(_well.GlobalPosition) < 300 &&
263-
SsInventory.ContainsMaterial(Game.Scripts.Items.Material.BucketEmpty))
264-
{
265-
_well.Interactable = true;
266-
}
267-
268261
}//Node2D/Abandoned Village/HauntedForestVillage/Big House/Sprite2D/InsideBigHouse2/InsideBigHouse/Sprite2D/ChestInsideHouse
269262

270263
private void UpdateTarget()

scripts/Interaction/Interactable.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Game.Scripts;
2+
using Game.Scripts.AI;
23
using Game.Scripts.Items;
34

45
using Godot;
@@ -12,10 +13,20 @@ public partial class Interactable : Node2D
1213
[Signal] public delegate void InteractEventHandler();
1314

1415
public string? SystemMessageForAlly;
16+
private CollisionShape2D _caveEntrance1 = null!;
17+
private CollisionShape2D _caveEntrance2 = null!;
18+
private float _doorDuration = 5.0f;
19+
private AiNode _scar = null!;
1520

1621
public override void _Ready()
1722
{
1823
AddToGroup(GroupName);
24+
_caveEntrance1 = GetTree().Root.GetNode<CollisionShape2D>("Node2D/DoorOpener/StaticBody2D/CaveEntrance1");
25+
_caveEntrance2 = GetTree().Root.GetNode<CollisionShape2D>("Node2D/DoorOpener/StaticBody2D2/CaveEntrance2");
26+
_scar = GetTree().Root.GetNode<AiNode>("Node2D/Scar");
27+
if(GetParent().Equals(_scar)) {
28+
_scar.GetNode<VisibleForAI>("VisibleForAI").QueueFree();
29+
}
1930
}
2031

2132
public void Trigger(Node caller)
@@ -31,10 +42,16 @@ public void Trigger(Node caller)
3142
if(this.GetParent<AiNode>().Name.Equals("Well") && caller.Name.ToString().Contains("Ally")) {
3243
Ally ally = (caller as Ally)!;
3344
ally.SsInventory.HardSwapItems(Game.Scripts.Items.Material.BucketEmpty, Game.Scripts.Items.Material.BucketWater);
45+
ally.AnimationIsAlreadyPlaying = true;
3446
ally._animPlayer.Play("Fill-Bucket");
3547
}
3648
//Remove scrub with Jones
3749
if(this.GetParent<AiNode>().Name.Equals("Big Tree") && caller.Name.ToString().Contains("Ally2")) {
50+
VisibleForAI scarVisibileForAI = new VisibleForAI();
51+
scarVisibileForAI.NameForAi = "Scar";
52+
scarVisibileForAI.DescriptionForAi = "A big scar on the tree which could be the reason for the tree looking dead. It is not reachable because of the scrub";
53+
_scar.AddChild(scarVisibileForAI, true, InternalMode.Disabled);
54+
GD.Print("Scar VFAI added");
3855
EmitSignal(SignalName.Interact);
3956
EmitSignal(SignalName.InteractFromNode, caller);
4057
}
@@ -44,10 +61,28 @@ public void Trigger(Node caller)
4461
if(!ally.SsInventory.ContainsMaterial(Game.Scripts.Items.Material.BucketWater)) {
4562
return;
4663
}
64+
ally.AnimationIsAlreadyPlaying = true;
4765
ally._animPlayer.Play("Empty-Bucket");
66+
ally.SsInventory.HardSwapItems(Game.Scripts.Items.Material.BucketWater, Game.Scripts.Items.Material.BucketEmpty);
4867
//Tree is now cured (for story progression)
68+
GD.Print("Tree cured");
4969
TreeCured = true;
5070
}
71+
//Cave entrance
72+
if(this.GetParent<AiNode>().Name.Equals("CaveEntranceTerminal") && caller.Name.ToString().Contains("Ally")) {
73+
Ally ally = (caller as Ally)!;
74+
if(!ally.SsInventory.ContainsMaterial(Game.Scripts.Items.Material.Chipcard)) {
75+
return;
76+
}
77+
}
78+
//Door opener
79+
if(this.GetParent<AiNode>().Name.Equals("DoorOpener") && caller.Name.ToString().Contains("Ally")) {
80+
Ally ally = (caller as Ally)!;
81+
if(!ally.SsInventory.ContainsMaterial(Game.Scripts.Items.Material.Chipcard)) {
82+
return;
83+
}
84+
TemporarilyDisable();
85+
}
5186

5287
if(this.GetParent<AiNode>().Name.Equals("EmptyBucket") && caller.Name.ToString().Contains("Ally2")) {
5388
GD.Print("Jones already has his machine gun, so he can't carry the bucket");
@@ -58,4 +93,16 @@ public void Trigger(Node caller)
5893
EmitSignal(SignalName.Interact);
5994
EmitSignal(SignalName.InteractFromNode, caller);
6095
}
96+
97+
public async void TemporarilyDisable() {
98+
_caveEntrance1.SetDeferred("disabled", true);
99+
_caveEntrance2.SetDeferred("disabled", true);
100+
GD.Print("Door is open!");
101+
102+
await ToSignal(GetTree().CreateTimer(_doorDuration), "timeout");
103+
104+
_caveEntrance1.SetDeferred("disabled", false);
105+
_caveEntrance2.SetDeferred("disabled", false);
106+
GD.Print("Door is closed");
107+
}
61108
}

0 commit comments

Comments
 (0)