The TL;DR
If a sleeping mob you can trade with is not a Merm, they don't wake up to accept or refuse items the player is trying to trade, despite their attempts in the code to try to.
I don't know if these are the causes, all I know is that these are the differences that exist between Merms and the other mobs.
OnRefuseItem:
The following traders have the following OnRefuseItem function where if they are sleeping, they should wake up and refuse the item yet don't do that:
- Pigmen
- Bunnyman
- Spiders
- Rock Lobsters
- Beefalos
- Gnarwail
- Catcoon
The OnRefuseItem function ONLY works for Merms.
What I've noticed is that there is a check for the sleeper component for the Merm's OnRefuseItem function.
Birdcages don't have a sleep check at all for this function, which will be relevant later.
Code here with the relevant parts:
What Merms Have:
local function OnRefuseItem(inst, item) inst.sg:GoToState("refuse") if inst.components.sleeper and inst.components.sleeper:IsAsleep() then --has check for sleeper component inst.components.sleeper:WakeUp() end end
What Mobs 1-7 Have:
local function OnRefuseItem(inst, item) inst.sg:GoToState("refuse") if inst.components.sleeper:IsAsleep() then --missing check for sleeper component inst.components.sleeper:WakeUp() end end
Birdcages:
local function OnRefuseItem(inst, item) --no sleep check at all. Is relevant later for accepting items end
OnGetItemFromPlayer
Unfortunately, this one is the complicated because the function varies greatly between the mobs.
The following traders have the following OnGetItemFromPlayer function where if they are sleeping, they should wake up and accept the item yet don't do that:
- Pigmen
- Bunnyman
- Spiders
- Rock Lobsters
- Gnarwail
- Catcoon
- Birdcages
I've noticed three differences b/w the listed mobs and with Merms.
- Merms have their sleep check is in ShouldAcceptItem function instead of their GetItemFromPlayer function.
-
The ShouldAcceptItem for Merms has an extra parameter giver while the other mobs don't have that parameter.
- Spiders and Gnarwails are an exception and have the giver parameter in said function.
- For a lot of the mobs, if a giver check is present in OnGetItemFromPlayer(), they are in different orders (inst,item,giver) vs (inst,giver,item). Don't know if that has any impact.
- Merms have an extra check for their sleeper component
Birdcages have the same sleep check as Merms surprisingly, but it doesn't work for reason 1 (and has the same difference from merms in reason 2).
Beefalos are a little different as don't take sleeping into account at all. Idk what's Klei's intentions are for beefalos and sleeping due to past changes [1] [2] [3].
Code here with the relevant parts:
What Merms Have:
local function ShouldAcceptItem(inst, item, giver) --(1) uses ShouldAcceptItem() + (2) has giver parameter if inst.components.sleeper and inst.components.sleeper:IsAsleep() then --(3) sleeper component check inst.components.sleeper:WakeUp() end end local function OnGetItemFromPlayer(inst, giver, item) -- (1) NOT using OnGetItemFromPlayer for the sleep check --nothing of relevance to sleeping and accepting items end
What Mobs 1-6 Have:
local function ShouldAcceptItem(inst, item) --(2) no giver check --- (3) nothing of relevance to sleeping and accepting items, should be here based on merm.lua end local function OnGetItemFromPlayer(inst, item) if inst.components.sleeper:IsAsleep() then --(3) Missing sleep component check + (1) is in different function than Merms inst.components.sleeper:WakeUp() end
What Birdcages Have:
local function ShouldAcceptItem(inst, item) --(2) no giver parameter --- (3) nothing of relevance to sleeping and accepting items, should be here based on merm.lua end local function OnGetItem(inst, giver, item) --If you're sleeping, wake up. <- The dev comment that started this bug report if inst.components.sleeper and inst.components.sleeper:IsAsleep() then -- (1) is in different function than Merms; has same sleeper check as Merms though inst.components.sleeper:WakeUp() end end
What Beefalo Lack:
local function ShouldAcceptItem(inst, item) --(2) No giver parameter --(3) No Sleep check at all, should be here if added based on merm.lua end local function OnGetItemFromPlayer(inst, giver, item) --(3) No sleep check at all and shouldn't be here based on merm.lua if added end
See the dev comment in birdcage.lua that suggests that trader mobs should wake up when getting an item.
Try to give sleeping mobs an item where applicable (aka do they have a trader component).
See that only Merms will wake up to accept or refuse items.
Go down the rabbit hole and find the above.
-
3
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 accountSign in
Already have an account? Sign in here.
Sign In Now