Jump to content

Need help with a workaround for Trader component


Recommended Posts

I'm adding in an item that I want Pig King to accept and in turn, he'll drop a different item other than gold nuggets. I know how to implement this as I've already done something similar to Pigmen by adding in a PrefabPostInIt and just changing their ongetitem and accepttest functions. I wonder, however, if there is any other way for me to implement what I want to do other than changing those functions? I feel like with the way I've done things, my mod might clash with other Pig and PK mods that fiddle with their trader components. 

 

 

Link to comment
Share on other sites

you could probably do something like this
 

local old_targetfn = inst.components.combat.targetfn
local old_retargetperiod = inst.components.combat.retargetperiod
inst.components.combat:SetRetargetFunction(old_retargetperiod, function(...)
    local target = old_targetfn(...)
    if target and target:HasTag("your_tag_here") then
        return
    end

    return old_targetfn(...)
end)

not using this function or whatever but the same concept with the old_targetfn

Edited by TemporarySolutn
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
 Share

×
  • Create New...