Twitchy_Girl Posted November 15, 2021 Share Posted November 15, 2021 So I have been toiling around with an idea as a small QoL for people that can't help but put things in their backpack. The scenario is simple: Leaving a life giving amulet in a backpack is far from unusual, the issue arises where if a player dies and the amulet is in the backpack it is useless to them. I want to make it so when a player haunts the backpack it can drop the amulet from the backpack. I am unaware if there is a way to define this behavior over all items with the container component, so any help would be greatly appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/135300-general-use-haunt-behavior-question/ Share on other sites More sharing options...
Twitchy_Girl Posted November 20, 2021 Author Share Posted November 20, 2021 Hate to bump this but I am still seeking an answer to this. Link to comment https://forums.kleientertainment.com/forums/topic/135300-general-use-haunt-behavior-question/#findComment-1515203 Share on other sites More sharing options...
-LukaS- Posted November 20, 2021 Share Posted November 20, 2021 For that you need to override the 'onhaunt' function from the hauntable component: AddPrefabPostInit("backpack", function(inst) if not GLOBAL.TheWorld.ismastersim then return end if inst.components.hauntable then inst:RemoveComponent("hauntable") -- Remove it first to add it properly later end AddNewOnHaunt(inst) -- Set up new hauntable end) The AddNewOnHaunt: local function AddNewOnHaunt(inst) inst:AddComponent("hauntable") -- Add the hauntable component inst.components.hauntable.onhaunt = DropRevivers -- Set up new 'onhaunt' end The DropRevivers: local function DropRevivers(inst, doer) inst.components.container:DropEverythingWithTag("resurrector") -- Drop everything that has the 'resurrector' tag, so the Life Giving Amulet end Put all of this in modmain.lua and it should work. Link to comment https://forums.kleientertainment.com/forums/topic/135300-general-use-haunt-behavior-question/#findComment-1515331 Share on other sites More sharing options...
Recommended Posts
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