SenL Posted February 22, 2015 Share Posted February 22, 2015 I tried this but it doesn't work local function DropMore(inst) inst.components.lootdropper:SpawnLootPrefab("goldnugget") --testend AddPrefabPostInit("koalefant_summer",DropMore)AddPrefabPostInit("koalefant_winter",DropMore) What's the correct way of doing this? Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/ Share on other sites More sharing options...
Maris Posted February 22, 2015 Share Posted February 22, 2015 It depends on what prefab you are going to tweak.For koalefant:AddPrefabPostInit("koalefant_summer",function(inst) table.insert(inst.components.lootdropper.loot,"goldnugget")end) Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-615511 Share on other sites More sharing options...
SenL Posted February 22, 2015 Author Share Posted February 22, 2015 I will try but last time we tried this on tree, (adds a twigs everytime a tree is chopped) the tree yields 1 twigs and then next tree = 2 twigs, and next tree = 3 twigs etc. Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-615517 Share on other sites More sharing options...
Maris Posted February 22, 2015 Share Posted February 22, 2015 (edited) For tree it's not easy because trees changes their loot dynamically depending on stage. Edited February 22, 2015 by Maris Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-615518 Share on other sites More sharing options...
SenL Posted February 22, 2015 Author Share Posted February 22, 2015 Oh ok. It works but it gives 2 gold.I added prefab post init twice one for summer and one for winter.I spawned and killed a winter but got 2 gold instead of 1.(next kill = 2 gold, next kill after that = 2 gold so it's good) AddPrefabPostInit("koalefant_summer",function(inst)table.insert(inst.components.lootdropper.loot, "goldnugget")end) AddPrefabPostInit("koalefant_winter",function(inst)table.insert(inst.components.lootdropper.loot, "goldnugget")end) Hm... Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-615519 Share on other sites More sharing options...
Jjmarco Posted February 22, 2015 Share Posted February 22, 2015 @SenL, Try using AddChanceLoot:inst.components.lootdropper:AddChanceLoot("goldnugget", 1)You can also change the chance of loot. Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-615565 Share on other sites More sharing options...
Developer bizziboi Posted February 22, 2015 Developer Share Posted February 22, 2015 @SenL, I suspect there was two koalefants in your level when you tested this (or at least two had been spawned)? All koalefants_summer share the same loot table, so if you spawn two koalefants the loot table is modified twice. You'd have to keep track of whether you already modified it so you won't do it again for the next spawned koalefant (and the next and the next and.....by the time you get to your 10th koalefant it'd be dropping 10 gold) Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-615638 Share on other sites More sharing options...
SenL Posted February 23, 2015 Author Share Posted February 23, 2015 @Jjmarco That seems to work.@bizziboi I used c_spawn ... also thanks for suggestion. Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-615691 Share on other sites More sharing options...
SenL Posted March 10, 2015 Author Share Posted March 10, 2015 Hm, client gets a crash on 1st day of winter but not immediately.Crash on lootdropper being nil. Code:AddPrefabPostInit("koalefant_winter",function(inst) inst.components.lootdropper:AddChanceLoot("mycustomitem", 1)end I do have "Koalefant family" mod which adds baby koalefant.Should I change to: if not inst.components.lootdropper then inst.components.lootdropper:AddChanceLoot("mycustomitem", 1)end or is it safe to change it to: if not inst.components.lootdropper then inst:AddComponents("lootdropper")endinst.components.lootdropper:AddChanceLoot("mycustomitem", 1) ?Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-620506 Share on other sites More sharing options...
Kzisor Posted March 10, 2015 Share Posted March 10, 2015 @SenL, no...that crash means you are trying to add the lootdropper component or call lootdropper component on the client's machine. You need to not do that by using 'if not TheWorld.ismastersim then return inst end' code. Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-620521 Share on other sites More sharing options...
SenL Posted March 10, 2015 Author Share Posted March 10, 2015 Crap... does this apply to anything else or just AddPrefabPostInit in modmain? Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-620529 Share on other sites More sharing options...
Kzisor Posted March 10, 2015 Share Posted March 10, 2015 Crap... does this apply to anything else or just AddPrefabPostInit in modmain? I recommend you read the stickied topics at the top of this subforum. You'll learn a lot of the answers you're seeking. To answer your question, code which only needs to be ran on the server that code should be applied so it doesn't run on the client. Link to comment https://forums.kleientertainment.com/forums/topic/51328-want-prefab-to-drop-more-loot/#findComment-620533 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