Jump to content

Parasite hosted Bunnymen still add naughtiness in rabbitkingmanager


hoxi
  • Fixed

Despite the beta adding a parasite hosted tag check shown below:

self.OnPlayerKilledOther = function(player, data)
    local victim = data and data.victim or nil
    if victim == nil then
        return
    end

    if victim:HasAnyTag("rabbit", "manrabbit") and not victim:HasTag("shadowthrall_parasite_hosted") then
        local naughtiness = FunctionOrValue(NAUGHTY_VALUE[victim.prefab] or 1, player, data)
        self:AddNaughtinessFromPlayer(player, naughtiness)
    end
end

It doesn't work because the tag is removed at that point in time.

The reason this happens is due to:

  • "death" event fires (before "killed" event, which is what rabbitkingmanager listens to from players).
  • The parasite mask has a death listener to unequip the mask (shown below).
  • Unequipping the mask removes the parasite hosted tag (shown below).
  • "killed" event eventually fires from combat component, and manages to go through the check due to the tag being missing, and adds naughtiness anyway.

 

-- when this event is fired, this also fires the event below
fns.shadowthrall_parasite_ondeath = function(owner, data)
    owner.components.inventory:Unequip(EQUIPSLOTS.HEAD)
end

fns.shadowthrall_parasite_onunequip = function(inst, owner)
    _onunequip(inst, owner)

    inst:RemoveEventCallback("death", fns.shadowthrall_parasite_ondeath, owner)
    inst:RemoveEventCallback("killed", fns.shadowthrall_parasite_onkilledsomething, owner)
       
    owner:RemoveTag("shadowthrall_parasite_hosted")

    -- rest of the function
end

 

Since you intend to fix this issue, could I bother you to look at this report I made a while ago too? It's also related to parasite Bunnymen (and Werepigs) having a small, but noticeable, inconsistency with non-parasite ones. It'd be really simple to address.


Steps to Reproduce
  • Kill a parasite hosted Bunnyman.
  • Notice how naughtiness to spawn the rabbit king still gets added.

I realize typing this, maybe you should make sure that naughtiness in general isn't added with parasite hosted kills. It's clearly not intended with the Rabbit King, but wouldn't that mean that it also shouldn't be the case with Krampus?

  • Like 3
  • Thanks 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.

The issue has been fixed (as well as the targeting issue mentioned in the other report)! And I'm happy about it, I thought I'd bump this just to double check on this.

Quote

I realize typing this, maybe you should make sure that naughtiness in general isn't added with parasite hosted kills. It's clearly not intended with the Rabbit King, but wouldn't that mean that it also shouldn't be the case with Krampus?

Killing parasite hosted Bunnymen or Pigmen will still result in naughtiness for Krampus to spawn, which I doubt is intentional if it got addressed for the Bunnymen and the Rabbit King.

 

In kramped.lua:

local function OnKilledOther(player, data)
    if data ~= nil and data.victim ~= nil and data.victim.prefab ~= nil then
        local naughtiness = NAUGHTY_VALUE[data.victim.prefab]
        if naughtiness ~= nil then
            local playerdata = _activeplayers[player]
            if not (data.victim.prefab == "pigman" and
                    data.victim.components.werebeast ~= nil and
                    data.victim.components.werebeast:IsInWereState()) then
                local naughty_val = FunctionOrValue(naughtiness, player, data)
                OnNaughtyAction(naughty_val * (data.stackmult or 1), playerdata)
            end
        end
    end
end

Given that this already makes use of FunctionOrValue, wouldn't it make sense to put a function in the NAUGHTY_VALUE global to check for the werebeast state and other similar things? You could check if the returned value is nil or 0, and not do anything if so.

 

It could look something like this:

local function OnKilledOther(player, data)
    if data ~= nil and data.victim ~= nil and data.victim.prefab ~= nil then
        local naughtiness = NAUGHTY_VALUE[data.victim.prefab]
        if naughtiness ~= nil then
            local playerdata = _activeplayers[player]
            local naughty_val = FunctionOrValue(naughtiness, player, data)

            if naughty_val ~= nil and naughty_val > 0 then -- could do ~= 0 too but, allowing negatives would be weird
                OnNaughtyAction(naughty_val * (data.stackmult or 1), playerdata)
            end
        end
    end
end

 

rabbitkingmanager would need to be slightly changed as well:

self.OnPlayerKilledOther = function(player, data)
    local victim = data and data.victim or nil
    if victim == nil then
        return
    end

    if victim:HasAnyTag("rabbit", "manrabbit") then
        -- keep the "or 1" bit for other potential rabbit entities without a defined naughtiness value
        local naughtiness = FunctionOrValue(NAUGHTY_VALUE[victim.prefab] or 1, player, data)

        if naughtiness ~= nil and naughtiness > 0 then -- could do ~= 0 too but, allowing negatives would be weird
            self:AddNaughtinessFromPlayer(player, naughtiness)
        end
    end
end

 

And in constants.lua:

NAUGHTY_VALUE =
{
	["pigman"] = function(player, data)
		if data.victim.was_shadowthrall_parasited or data.victim:HasTag("shadowthrall_parasite_hosted") then
			return 0
		end

		if data.victim.components.werebeast ~= nil and data.victim.components.werebeast:IsInWereState() then
			return 0
		end

		return 3
	end,
	["bunnyman"] = function(player, data)
		if data.victim.was_shadowthrall_parasited or data.victim:HasTag("shadowthrall_parasite_hosted") then
			return 0
		end

		return 3
	end,
	-- rest of the values
}

You can also alternatively just add a parasite check to kramped.lua like rabbitkingmanager.lua, to catch any cases like that (but still move the pig werestate check to the table as that's a specific edge case).

Though regardless, something that could be changed is that 0 naughtiness can still result in triggering some logic and warning sounds, when ideally that shouldn't be triggering anything.

Edited by hoxi

Share this comment


Link to comment
Share on other sites



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