Item duplication and other bugs with lampreys

Issue #8174 resolved
John Snail created an issue

A change made to #8156 to deep copy the twin on respawn causes item duplication, in addition to overriding the despawned object and still requiring you to kill the hostile twin if the other is proselytized or beguiled.

I also realized item duplication is possible with my code too, on the turn a clone spawns or if a twin is somehow deleted.

There are also a few other issues, like StripContents removing their psychic bite (if it weren't for the overriding), the relocation of ReplicaCreatedEvent only allowing you to absorb the psyche of one of the twins instead of the first killed, and RestorePristineHealth being slightly excessive with its thirst resetting and full limb restoration (let the lampreys use their Regeneration!).

If this was done to stay accurate to the description of the lampreys, I'd argue that letting the twins diverge is no less accurate; it could be interpreted as a smudge on the mirrored planes of reality, or something. Gameplay comes first as well.

Attached is my updated code with the following changes:

  • Both EnteredCellEvent: Added a flag for twin initialization, meaning lampreys initialize their twins the moment they spawn instead of when spawning their twin, preventing item duplication via giving them items before the twin spawns or the twin somehow being deleted entirely (which should be impossible anyway). This also happens to clean up Triner's spawn code substantially.
  • Both BeforeDestroyEvent: Reverted ReplicaCreatedEvent relocation and added WasReplicatedEvent.
  • FireEvent: Added back BecomeCompanion. Propagation of the party leader is needed to prevent having to kill a hostile twin.
  • Spawn, Twinner Act, Triner TrySpawn: Cleaned up the entire methods. Removed the now redundant RestorePristineHealth call. Act and TrySpawn now return if a twin is null, as it will not be created again, though this should be impossible anyway.
  • Despawn: Reverted RestorePristineHealth, though this is up to you. Removed StripContents as there are no sources of item duplication that it stops; twins are stripped of their items and/or made temporary by proxy.

Comments (3)

  1. chaos

    Item duplication bug fixed in next update. Rest is wontfix.

    ReplicaCreatedEvent and WasReplicatedEvent are tied to specific things happening aren't things that should just be sent out from arbitrary locations because that happens to achieve a nominally desired result in some circumstance. Having to kill the original lamprey of a psychic hunter pair/trine in order to absorb its psyche = not a bug.

    BecomeCompanion propagating leader guarantees inappropriate player control persistence bugs with love tonics/proselytize/cloning etc. Getting control of one lamprey and having to kill its twin/trines = not a bug.

    StripContents called on despawn to get objects destroyed and ready for cleanup sooner. RestorePristineHealth isn't hurting anything.

  2. Log in to comment