yanecc Posted September 10, 2024 Share Posted September 10, 2024 I'm quite confused with the following code. Only daywalker2 can drop the item. for i, v in pairs({ "daywalker", "daywalker2", "sharkboi" }) do AddPrefabPostInit(v, function(inst) if inst.components.lootdropper == nil then inst:AddComponent("lootdropper") end inst.components.lootdropper:AddChanceLoot("ancient_soul", 1) end) end Link to comment https://forums.kleientertainment.com/forums/topic/159615-help-how-to-add-some-loot-for-the-nightmare-werepig-and-the-frostjaw/ Share on other sites More sharing options...
ClumsyPenny Posted September 10, 2024 Share Posted September 10, 2024 daywalker uses SetLootSetupFn to determine the exact loot to generate, called when the loot is about to drop. In the function daywalker uses, it calls SetLoot, which resets your chanceloot, so it gets lost. For a solution, I'd hook into the lootsetup function. sharkboi doesn't call the function to drop loot. Like, anywhere. It doesn't drop anything on death normally. For a solution, hook into its stategraph somewhere to drop the loot or maybe more simply ListenForEvent "minhealth" which handles its death. 1 Link to comment https://forums.kleientertainment.com/forums/topic/159615-help-how-to-add-some-loot-for-the-nightmare-werepig-and-the-frostjaw/#findComment-1747009 Share on other sites More sharing options...
yanecc Posted September 11, 2024 Author Share Posted September 11, 2024 8 hours ago, ClumsyPenny said: daywalker uses SetLootSetupFn to determine the exact loot to generate, called when the loot is about to drop. In the function daywalker uses, it calls SetLoot, which resets your chanceloot, so it gets lost. For a solution, I'd hook into the lootsetup function. sharkboi doesn't call the function to drop loot. Like, anywhere. It doesn't drop anything on death normally. For a solution, hook into its stategraph somewhere to drop the loot or maybe more simply ListenForEvent "minhealth" which handles its death. Alright, I will implement it by listening for the minhealth event. It looks good, thank you very much. local function OnMinHealth(inst, data) if data.afflicter and data.afflicter.prefab == "fhl" and not inst:HasTag("defeated") then inst.components.lootdropper:SpawnLootPrefab("ancient_soul") inst:AddTag("defeated") end end for i, v in pairs({ "daywalker", "daywalker2", "sharkboi" }) do AddPrefabPostInit(v, function(inst) if inst.components.lootdropper == nil then inst:AddComponent("lootdropper") end inst:ListenForEvent("minhealth", OnMinHealth) end) end 1 Link to comment https://forums.kleientertainment.com/forums/topic/159615-help-how-to-add-some-loot-for-the-nightmare-werepig-and-the-frostjaw/#findComment-1747072 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