Mods / Zippy's Fearless Foes

Tags: #Creatures #Other #Tweak
Author: ZippyWonderdust
Side: Server
Created: Mar 10th at 1:24 AM
Last modified: Mar 10th at 1:28 AM
Downloads: 142
Follow Unfollow 17

Latest file for v1.20.4:
ZippysFearlessFoes-VS1.20.4_1.0.0.zip 1-click install


NOTE: As of 1.20.5 this patch has been incorporated into the vanilla game. This mod is no longer needed.

TLDR summary

This mod fixes how mobs react to daylight during temporal storms.

With this mod loaded, mobs that "fear" the sun will not flee the player if they spawn during a temporal storm that is happening during the day. This is different from the current vanilla game behaviour of these mobs, which is that in a daytime temporal storm these mobs will flee the player, despite there being an active storm.  The affected mobs are surface and deep drifters, and surface and deep shivers (and the bowtorn variants from my Bashful Bowtorns mod).

I think the vanilla behaviour is actually a bug caused by a very small logic error in the game's AI task code.

This mod fixes that bug.

Long explanation follows

I was writing my Zippy's Bashful Bowtorns mod and I noticed a problem.  The Bashful Bowtorns mod is intended to correct the problem of players being pinned down by a mob of bowtorns that spawn during a temporal storm and then never go away, even in broad daylight.  Upon examining the AI tasks for bowtorns I noticed that the vanilla bowtorns, unlike drifters and shivers, don't have any task that causes them to retreat from the player when in daylight.  I figured that the solution would be simple; write a mod that adds a flee-in-daylight task to them.  Easy-peasy, problem solved.

Well, yes and no.

The task did what it was supposed to; it made them flee the player when in daylight.  That was the good news.  The bad news was that it worked too well.  They always fled from the player when in daylight -- even in the middle of a temporal storm.  If I set all bowtorn variants to flee, I could stand outside in a daytime temporal storm and watch them turn tail and run without so much as a grumble in my direction.

"Well this isn't right," I thought. "I must be doing something wrong.  Surely drifters and shivers don't behave like this."

So I tested it by spawning a few daytime temporal storms with only drifters and shivers.

And they turned tail and fled too!

So I went to GitHub and started reading through the Vintage Story source code.  I drilled down to the class that handles entity fleeing behaviour, to the method that decides if a particular entity should flee or not, and I found this comment in the code:

"This code section controls drifter behavior - they retreat (flee slowly) from the player in the daytime, this is "switched off" below ground or at night, also switched off in temporal storms"

Also switched off in temporal storms.

Well that obviously wasn't happening.

I read the code section in question, and I thought about it, and then I read it again.  And again.  And then I saw the problem -- a very simple mixup on a boolean test that meant that entities could never possibly ignore daylight during a storm.

So I made this mod, which uses the Harmony transpiler to alter that boolean test to what I think the devs intended it to be.  Subsequent testing shows that this mod does indeed alter the entity behaviour to match what is described in the code comments.

I will also be submitting a C# code patch to the devs.  If they accept my patch (or implement their own) I will retire this mod.  Until then, enjoy being assaulted by (more) fearless foes.

Version For Game version Downloads Release date Changelog Download 1-click mod install*
v1.0.0 142 Mar 10th at 1:28 AM Show ZippysFearlessFoes-VS1.20.4_1.0.0.zip Install now

3 Comments (oldest first | newest first)

💬 ZippyWonderdust , 1 day ago

Yup!  The devs accepted my patch, so this mod is no longer needed.

💬 Qooqey, 3 days ago

Broken in v1.20.5, but seems to be resolved in vanilla since rc.3, so mod is no longer needed?

[Error] [zippysfearlessfoes] An exception was thrown when trying to start the mod:
[Error] [zippysfearlessfoes] Exception: Patching exception in method virtual System.Boolean Vintagestory.GameContent.AiTaskFleeEntity::ShouldExecute()
at HarmonyLib.PatchClassProcessor.ReportException(Exception exception, MethodBase original)
at HarmonyLib.PatchClassProcessor.Patch()
at HarmonyLib.Harmony.<>c__DisplayClass14_0.b__1(Type type)
at HarmonyLib.CollectionExtensions.Do[T](IEnumerable`1 sequence, Action`1 action)
at HarmonyLib.Harmony.PatchCategory(Assembly assembly, String category)
at HarmonyLib.Harmony.PatchCategory(String category)
at ZippysFearlessFoes.ZippysFearlessFoesModSystem.Start(ICoreAPI api) in /home/rling/Documents/Projects/Vintagestory/ModDev/ZippysFearlessFoes/ZippysFearlessFoes/ZippysFearlessFoesModSystem.cs:line 17
at Vintagestory.Common.ModLoader.TryRunModPhase(Mod mod, ModSystem system, ICoreAPI api, ModRunPhase phase) in VintagestoryLib\Common\API\ModLoader.cs:line 626
18.3.2025 15:21:43 [Error] Failed to run mod phase Start for mod ZippysFearlessFoes.ZippysFearlessFoesModSystem

💬 Brick, Mar 10th at 2:57 PM

Thanks!

 (edit comment delete)