Jump to content

Abigail haunting a dirt pile should pass the Wendy she's linked to as the doer for investigating it


hoxi
  • Pending

This would prevent unexpected behavior (especially with mods) with the hunter component. Namely because Abigail currently gets set as the "active player" for the hunt.

This only has one side effect with vanilla, which is that that the Wendy player that the haunting Abigail belongs to, is technically not busy with a hunt, and another could start if walking far away enough (quite a bit of distance, but still, would lead to weird unexpected behavior).

This could get worse with mods like I said though, if they expect a player, since all that hunter.lua code only interacts with players normally.

 

Also, if the Wendy linked to the Abigail that haunts the dirt pile is passed, it means she'll talk like when investigating the pile by hand, pointing out when reaching the last one, if the track got dangerous, or if the track got lost, etc, which would also be nice to keep that working as usual.

The following bit in dirtpile.lua:

local function OnHaunted(inst, haunter)
    --if haunter.isplayer then
        inst:OnInvestigated(haunter)
   -- end
    return true
end

Could instead look like:

local function OnHaunted(inst, haunter)
    if haunter ~= nil and not haunter.isplayer then
        local follower = haunter.components.follower
        local leader = follower ~= nil and follower:GetLeader() or nil
        haunter = leader ~= nil and leader.isplayer and leader or nil
    end

    if haunter ~= nil then
        inst:OnInvestigated(haunter)

        return true
    end

    return false
end

Alternatively, the OnDirtInvestigated function from the hunter component could be modified to account for it similarly to this, but it might make more sense to account for it in the OnHaunted function.

 

 

Also, not related to this bug but something I noticed (and I'll explain why I'm mentioning this here further below*), is that in the hunter component, players that leave aren't removed as active players from a hunt. And not only those stale references are kept, events can be fired on them (like losing the track).

local function OnPlayerLeft(src, player)
    for i,v in ipairs(_activeplayers) do
        if v == player then
            table.remove(_activeplayers, i)
            return
        end
    end
end

Should be doing something like this:

local function OnPlayerLeft(src, player)
    for i,v in ipairs(_activeplayers) do
        if v == player then
            table.remove(_activeplayers, i)

            for i2,v2 in ipairs(_activehunts) do
                if player == v2.activeplayer then
                    v2.activeplayer = nil

                    break
                end
            end

            return
        end
    end
end

This will prevent the stale player reference from being kept, and will avoid pushing an event on the now invalid player (even if event listeners should be removed at this point, it's still not good).

*This also won't be compatible with Abigail being set as the active_player, meaning you'd have to use "onremove" listeners for the active player instead if she's still passed as the doer.


Steps to Reproduce
  • Have Abigail haunt a suspicious dirt pile.
  • Notice how Wendy won't comment on anything in regards to the hunt, like getting into a dangerous path, finding the creature, or losing the tracks.

 

For the issue native to hunter.lua, you'd have to verify with printing, debug, or console commands, but the issue should be there.

  • Have a player investigate a suspicious dirt pile and leave.
  • Wait until the track disappears.
  • Verify how hunt.active_player is a stale reference.
  • Like 1



User Feedback


There are no comments to display.



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...