Rewrite Twinner and Triner code

Issue #8156 resolved
John Snail created an issue

I rewrote the Twinner and Triner parts to fix many bugs related to twinning/trining lampreys, one of the buggiest creatures in the game (and not in a fun way). These include:

  • #3822
  • #4109 (WONTFIX can be maintained but not fun at all)
  • #4720
  • #7652
  • #7951 (WONTFIX can be maintained but not as fun, see second change)
  • Unloading one of the twins causing duplication, many reports of which can be found on Steam and Reddit
  • Names and experience being lost, and other strange and unfun behaviour resulting from twins making entirely new creatures
  • Experience only being given by one of the twins, instead of the first killed

The first and biggest change is that a twin is created only once. If one dies, it's just removed from the zone instead of destroyed, and respawned by the other on their turn, with full health, negative effects cleared and reset temperature.

The second change is that they are identical when spawned (save for the removal of GivesRep). If one dies, ReplicaCreatedEvent is called on all of them to remove parts such as AbsorbablePsyche.

The third change is that they follow each other into other zones, preventing the aforementioned unloading bugs. A possible better method is adding some kind of context check to object pooling in FreezeZoneThread (GetContextEvent might be a big performance hit due to Physics) and giving the parts context instead of using EnteredCell, so a twin's object is only pooled if the other unloaded (it could also be used to fix bugs with unloading leaders and properly fix #5495).

I also slightly optimised Triner by only getting spawn locations and checking reality stabilisation in each location once. This lowers their overall chance of bypassing normality but makes more sense, and if need be, RealityStabilizationPenetration can be increased or GetSpawnCells can be made to continue instead of break at the first failure (is this intentional by the way?).

Of course, I have thoroughly tested these changes. I have also extensively tested this creature recycling approach with my Conjoined mutation mod; it works flawlessly after hours of play and I think it works better than duplication (which was my previous approach). It might be beneficial to apply it to things like phylacteries as well.

Comments (3)

  1. chaos

    Many elements implemented in next update, most notable exception being propagation of party leader. Attempt is being made to achieve related results using state copying and propagation of effects on spawn instead. Hopefully accomplishes most of the same things.

  2. Log in to comment