[Exploit] - Guardian pigs attack each other after full moons


Arcita

Recommended Posts

Bug Submission:

Category: Exploit

Issue Title: Guardian pigs attack each other after full moons

Issue Description: Once Guardian pigs return to normal from their werepig form after full moons, they sometimes attack each other.

Some people hypothesize that they revert to Guardians at varying times, causing the Guardians to aggro the werepigs, and the aggro just persists through the transformation.

Please fix this. It's inconsistent behavior that messes pig torches up for those who want to utilize them, and it's just free resources and free access to the berries/grass for people who stumble upon it after full moons.

Steps to Reproduce: 1. Go around Guardians after they wake up from a full moon.

2. Sometimes they attack each other.

Link to comment
Share on other sites

I did a bit more investigating, and this bug is stranger than I thought. 

 

I stood in a location so that the pigs were unloaded during the entirety of the full moon. Once day broke, I went and checked on several pig torch camps, and all of them returned to normal and behaved properly. This is consistent over several tests: if you load the pigs after a full moon before the world is reset, then everything functions properly. 

 

I then unloaded the pigs during a full moon, but instead of checking on them right away, I did c_reset(true) once. I went to check on the pigs, and at each pig torch camp, around half were visually and behaviorally werepigs. I snapped a screenshot: 

 

zIqnhF0.png?1

Once I loaded the werepigs in this way, they never returned to being guard pigs. They were stuck like that even after a reset. This reminds me of that bug with werepigs persisting once haunted by a ghost.

Here's where it gets super strange on my third test:

I stood so that the pigs were unloaded during a full moon, and afterwards I reset the world twice (edit: I should also note that I waited a full day-night cycle in addition to two resets, however the wait alone didn't effect the pigs until after the second reset), and this time some of the pigs were visually guard pigs, but they behaved as if they were werepigs, breaking walls and fighting with other guards. This is consistent with my initial experiences while playing: all of the pigs are guards visually, but they'd fight each other as if some are werepigs. I'd also typically only notice them fighting if I hadn't been around their pig torch camp in a long while, so these results make some sense.

Anyway, I'll continue investigating whenever I have time since I'm sure you're all focusing on caves and skins.

Link to comment
Share on other sites

Guard Pigs are programmed to target anything within their circle of influence that isn't tagged as a "guard". In the current build, only Guard Pigs and the yet-unfinished Wildbore Guards are tagged as "guard". When transforming into werepigs, however, the "guard" tag is removed and the "werepig" tag is added, so when a Guard Pig transforms, any nearby un-transformed Guard Pigs will attack it. This can be seen in scripts/prefabs/pigman.lua, line 279:

local invader = FindEntity(defenseTarget or inst, SpringMod(TUNING.PIG_GUARD_TARGET_DIST), function(guy)    return guy:HasTag("character") and not guy:HasTag("guard")end)

"Character" in this context does not mean a player character specifically; just an actor. Otherwise they'd be attacking their torches or whatever. As long as the invader isn't tagged "guard", it's a prime target.

 

Line 377 begins what happens during the transformation to werepig:

local function SetWerePig(inst)    inst:AddTag("werepig")    inst:RemoveTag("guard")

I don't know what the original intent was when designing the "guard" mechanic, but since Guard Pigs are the only thing that makes use of it, one can safely remove or comment out that line to RemoveTag and Pig Guards will no longer attack their brethren turned Werepig, all without breaking anything else.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.