Jump to content

Random corpse mutation chance isn't accounted for with some of the new functionality


hoxi
  • Fixed

Or at least, in some cases it results in needing to succeed the same random check multiple times.

As an example, in componentutil.lua:

function TryEntityToCorpse(inst, corpseprefab)
    local can_corpse = CanEntityBecomeCorpse(inst)

    if can_corpse then
        local x, y, z = inst.Transform:GetWorldPosition()
        local rot = inst.Transform:GetRotation()
        local sx, sy, sz = inst.Transform:GetScale()

        local corpse = SpawnPrefab(corpseprefab)
        corpse.Transform:SetPosition(x, y, z)
        corpse.Transform:SetRotation(rot)
        corpse.Transform:SetScale(sx, sy, sz) -- Corpses will copy scale from the original mob. Mutated will NOT.
        corpse.AnimState:MakeFacingDirty()
        corpse.AnimState:SetBuild(inst.AnimState:GetBuild())
        corpse.AnimState:SetBank(inst.AnimState:GetBankHash())

        corpse.corpse_loot = inst:GetDeathLoot()

        local corpsedata = inst.SaveCorpseData ~= nil and inst:SaveCorpseData(corpse) or nil

        if corpsedata then
            corpse:SetCorpseData(corpsedata)
        end

        corpse.sg.mem.nolunarmutate = inst.sg.mem.nolunarmutate -- This is saved.

        if CanLunarRiftMutateFromCorpse(inst) then
            corpse:SetGestaltCorpse()
        elseif CanLunarPreRiftMutateFromCorpse(inst) then
            corpse:SetNonGestaltCorpse()
        end

        inst:Remove()

        return corpse
    end
end

CanLunarRiftMutateFromCorpse and CanLunarPreRiftMutateFromCorpse are both checked by CanEntityBecomeCorpse. Meaning this has to succeed twice for a corpse to lunar mutate, or rift mutate.

 

There's also this bit in components/health.lua:

        -- NOTES(JBK): Make sure to keep the events fired up to date with the explosive component.
        --Push world event first, because the entity event may invalidate itself
        --i.e. items that use .nofadeout and manually :Remove() on "death" event
        local is_corpsing = CanEntityBecomeCorpse(self.inst)
        TheWorld:PushEvent("entity_death", { inst = self.inst, cause = cause, afflicter = afflicter, corpsing = is_corpsing })
        self.inst:PushEvent("death", { cause = cause, afflicter = afflicter, corpsing = is_corpsing })
        self.is_corpsing = is_corpsing

CanEntityBecomeCorpse there might return false but the corpse might still mutate, or viceversa.

 

EDIT: could maybe evaluate once and set the result on the inst, and check that in subsequent calls of those functions?


Steps to Reproduce

I honestly haven't tested in-game as I'm going through all of the changes, but I'm sure this is worth looking into.

  • Like 1



User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...