Skip to content

Commit 06e2f07

Browse files
committed
improve reviving
1 parent 6912ad8 commit 06e2f07

5 files changed

Lines changed: 46 additions & 14 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ A savegame editor for "Sons of The Forest".
1818
- [Inventory](#inventory)
1919
- [Armor](#armor)
2020
- [Weather](#weather)
21+
- [Reviving](#reviving)
2122
- [Troubleshooting](#troubleshooting)
2223
- [Contributing](#contributing)
2324
- [Final Words](#final-words)
@@ -102,6 +103,15 @@ Here is a list of number of days per season per season length setting:
102103
- Long: 10 days
103104
- Realistic: 90 days
104105

106+
# Reviving
107+
108+
If you want to revive either or both followers, there are some things to consider:
109+
- If the body is completely missing, the follower will spawn at the players location
110+
- Make sure to be outside of buildings, else you might glitch into the building sometimes
111+
- The followers will be at maximum stats and should be friendly towards players
112+
- They will not have any items, but you can easily use the other Editors to change that after reviving
113+
- Virginia is shy as a lamb when she was revived. I haven't tested it thoroughly but to me it appears that you have to regain her trust, like in the beginning of a session. I'm still trying to figure out which setting determines her trust.
114+
105115
# Troubleshooting
106116

107117
One of the items in inventory is listed as "Unknown"?

SOTFEdit/Model/Savegame.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,18 @@ private static void CreateFollowerData(JObject vailWorldSim, JToken? npcItemInst
240240
}
241241

242242
var rnd = new Random();
243-
var spawnerId = rnd.Next();
244-
while (allSpawnerIds.Contains(spawnerId))
243+
int spawnerId;
244+
if (typeId == KelvinTypeId)
245+
{
246+
spawnerId = 0;
247+
}
248+
else
245249
{
246250
spawnerId = rnd.Next();
251+
while (allSpawnerIds.Contains(spawnerId))
252+
{
253+
spawnerId = rnd.Next();
254+
}
247255
}
248256

249257
var templatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data", "followerTemplate.txt");
@@ -259,7 +267,7 @@ private static void CreateFollowerData(JObject vailWorldSim, JToken? npcItemInst
259267
var playerPos = Ioc.Default.GetRequiredService<PlayerPageViewModel>().PlayerState.Pos;
260268
if (!playerPos.IsDefault())
261269
{
262-
actorTemplate["Position"]?.Replace(JToken.FromObject(playerPos with { Y = playerPos.Y + 2 }));
270+
actorTemplate["Position"]?.Replace(JToken.FromObject(playerPos));
263271
}
264272

265273
if (typeId == VirginiaTypeId)
@@ -275,15 +283,19 @@ private static void CreateFollowerData(JObject vailWorldSim, JToken? npcItemInst
275283
influenceMemory.Add(influenceTemplate);
276284
}
277285

278-
if (template["actorItems"] is not { } actorItemTemplate || npcItemInstancesToken?.ToObject<string>() is not
279-
{ } npcItemInstancesJson ||
280-
JsonConverter.DeserializeRaw(npcItemInstancesJson) is not JArray npcItemInstances)
286+
if (template["actorItems"] is { } actorItemTemplate && npcItemInstancesToken?.ToObject<string>() is
287+
{ } npcItemInstancesJson &&
288+
JsonConverter.DeserializeRaw(npcItemInstancesJson) is JArray npcItemInstances)
281289
{
282-
return;
290+
npcItemInstances.Add(actorItemTemplate);
291+
npcItemInstancesToken.Replace(JsonConverter.Serialize(npcItemInstances));
283292
}
284293

285-
npcItemInstances.Add(actorItemTemplate);
286-
npcItemInstancesToken.Replace(JsonConverter.Serialize(npcItemInstances));
294+
if (typeId == VirginiaTypeId && template["spawner"] is { } spawnerTemplate &&
295+
vailWorldSim["Spawners"] is JArray spawners)
296+
{
297+
spawners.Add(spawnerTemplate);
298+
}
287299
}
288300

289301
private static bool ModifyFollowerData(JToken vailWorldSim, int uniqueId)

SOTFEdit/View/FollowersPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
Move to Virginia
6262
</Button>
6363
<Button Style="{StaticResource ButtonStyle}" Command="{Binding ReviveCommand}"
64-
CommandParameter="{Binding KelvinState}">
64+
CommandParameter="{Binding KelvinState}" ToolTip="Make sure you do this outside of buildings when the body is missing, else you might glitch into the building">
6565
Revive
6666
</Button>
6767
</StackPanel>
@@ -189,7 +189,7 @@
189189
Move to Kelvin
190190
</Button>
191191
<Button Style="{StaticResource ButtonStyle}" Command="{Binding ReviveCommand}"
192-
CommandParameter="{Binding VirginiaState}">
192+
CommandParameter="{Binding VirginiaState}" ToolTip="Make sure you do this outside of buildings when the body is missing, else you might glitch into the building">
193193
Revive
194194
</Button>
195195
</StackPanel>

SOTFEdit/ViewModel/FollowerPageViewModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,11 @@ public bool Update(Savegame? savegame, bool createBackup)
275275

276276
if (npcItemInstances != null && actor["UniqueId"] is { } uniqueId)
277277
{
278-
npcItemInstances["ActorItems"] ??= new JArray();
279-
278+
if (npcItemInstances["ActorItems"] == null)
279+
{
280+
npcItemInstances["ActorItems"] = new JArray();
281+
hasChanges = true;
282+
}
280283

281284
var actorItemsForActor = (npcItemInstances["ActorItems"]
282285
?.Children() ?? Enumerable.Empty<JToken>()).FirstOrDefault(token =>
@@ -297,6 +300,7 @@ public bool Update(Savegame? savegame, bool createBackup)
297300
if (npcItemInstances["ActorItems"] is JArray actorItems)
298301
{
299302
actorItems.Add(actorItemsForActor);
303+
hasChanges = true;
300304
}
301305
}
302306

SOTFEdit/data/followerTemplate.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"Influences": [
3939
{
4040
"TypeId": "Player",
41-
"Sentiment": -100.0,
41+
"Sentiment": 100.0,
4242
"Anger": 0.0,
4343
"Fear": 0.0
4444
},
@@ -62,6 +62,12 @@
6262
"Version": "0.0.0",
6363
"ItemBlocks": []
6464
}
65+
},
66+
"spawner": {
67+
"UniqueId": {spawnerId},
68+
"Count": 1,
69+
"SpawnedCount": 1,
70+
"LastSpawnTime": 0.0
6571
}
6672
}
6773

0 commit comments

Comments
 (0)