Pianobeats Posted January 6, 2015 Share Posted January 6, 2015 So this is my first time modding and I'm trying to make a mod that changes the loot chance that a mob will drop. So it's easy for people to farm pigskin, silk, electric milk, etc. Anyway, I'm having trouble. How do you distinguish a normal pig, guardpig, and werepig in the code? They're all under the same prefab (pigman) so I don't know how to separate them. If I try to modify the drop rates, only the normal pig is affected. The werepig still retains its original drop rate. Is there a way to separate them? Sorry, I'm really new to programming. Here's my code so far. function spiderpostinit(inst) inst.components.lootdropper:SetLoot(nil) inst.components.lootdropper:AddRandomLoot("monstermeat", .8) inst.components.lootdropper:AddRandomLoot("silk", 1) inst.components.lootdropper:AddRandomLoot("spidergland", 1) inst.components.lootdropper.numrandomloot = 2 --This changes the amount of items it will drop.endfunction spider_warriorpostinit(inst) inst.components.lootdropper:SetLoot(nil) inst.components.lootdropper:AddRandomLoot("monstermeat", .8) inst.components.lootdropper:AddRandomLoot("silk", 1) inst.components.lootdropper:AddRandomLoot("spidergland", 1) inst.components.lootdropper.numrandomloot = 3endfunction pigmanpostinit(inst) inst.components.lootdropper:SetLoot(nil) inst.components.lootdropper:AddRandomLoot("meat", 1) inst.components.lootdropper:AddRandomLoot("pigskin", 1) inst.components.lootdropper.numrandomloot = 4end--Add PrefabPostInitAddPrefabPostInit("pigman", pigmanpostinit)AddPrefabPostInit("spider_warrior", spider_warriorpostinit)AddPrefabPostInit("spider", spiderpostinit) Link to comment Share on other sites More sharing options...
Developer PeterA Posted January 6, 2015 Developer Share Posted January 6, 2015 The guardpig is it's own prefab "pigguard", and the werepig gets changed after the postinit when transition to and from it's were state. You'll want to take a look at this code inst.components.werebeast:SetOnNormalFn(SetNormalPig) --this gets run when transitioning back to a normal pigand inst.components.werebeast:SetOnWereFn(SetWerePig) --this gets run when transitioning to a werepigIn your postinit function you probably want to override what it set to werebeast:SetOnNormalFn and werebeast:SetOnWereFn so that the lootdropper component always gets the values you want. Link to comment Share on other sites More sharing options...
Pianobeats Posted January 6, 2015 Author Share Posted January 6, 2015 Thank you! Does this apply to Volt Goats too? Because normal Volt Goats don't drop Electric Milk, but Charged Volt Goats do drop Electric Milk. Link to comment Share on other sites More sharing options...
Developer PeterA Posted January 6, 2015 Developer Share Posted January 6, 2015 @Pianobeats, I assume they work the same way, but as far as I'm aware, they are not in DST yet. Link to comment 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