MattDoesnt Posted January 13, 2015 Share Posted January 13, 2015 I'm trying to get a custom loot table going for a character mod I'm working on. I've been trying a few things from the lootdropper.lua, and hound.lua but can't seem to get anything to drop on death.SetSharedLootTable( 'palehuman',{ {'houndfire', 1.0}, {'houndfire', 1.0}, {'houndfire', 1.0},})The above is the only loot table code I've been able to keep in without crashing, but it doesn't activate on death. As you can also see, I'm specifically trying to make myself drop the houndfire that Fire Hounds drop when they die. Any help is appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/ Share on other sites More sharing options...
DarkXero Posted January 13, 2015 Share Posted January 13, 2015 Did you try havinginst:AddComponent("lootdropper")inst.components.lootdropper:SetChanceLootTable('palehuman')in your character prefab? Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-601406 Share on other sites More sharing options...
MattDoesnt Posted January 13, 2015 Author Share Posted January 13, 2015 (edited) Alright, I think I'm headed in the right direction. I've got:inst:AddComponent("lootdropper")inst.components.lootdropper:SetChanceLootTable('palehuman')in my master_postinit, and my current table looks like this:function LootDropper:AddChanceLoot( palehuman, { {'houndfire', 1.0}, {'houndfire', 1.0}, {'houndfire', 1.0},}) if not self.chanceloot then self.chanceloot = {} end table.insert(self.chanceloot, {prefab=prefab,chance=chance} )endNot working quite yet, though. Edited January 13, 2015 by MattDoesnt Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-601457 Share on other sites More sharing options...
Jjmarco Posted January 14, 2015 Share Posted January 14, 2015 Alright, I think I'm headed in the right direction. I've got:inst:AddComponent("lootdropper")inst.components.lootdropper:SetChanceLootTable('palehuman')in my master_postinit, and my current table looks like this:function LootDropper:AddChanceLoot( palehuman, { {'houndfire', 1.0}, {'houndfire', 1.0}, {'houndfire', 1.0},}) if not self.chanceloot then self.chanceloot = {} end table.insert(self.chanceloot, {prefab=prefab,chance=chance} )endNot working quite yet, though. Not quite sure what you are trying to do on that second code, but all you need to do is to create a loot table:SetSharedLootTable( 'palehuman',{ {'houndfire', 1.0}, {'houndfire', 1.0}, {'houndfire', 1.0},})This creates a loot table named palehuman, but it isn't assigned to anything yet. You then assign it to your character using these lines:inst:AddComponent("lootdropper")inst.components.lootdropper:SetChanceLootTable('palehuman') Hope it helped! Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-601664 Share on other sites More sharing options...
MattDoesnt Posted January 14, 2015 Author Share Posted January 14, 2015 (edited) Not quite sure what you are trying to do on that second code, but all you need to do is to create a loot table:SetSharedLootTable( 'palehuman',{ {'houndfire', 1.0}, {'houndfire', 1.0}, {'houndfire', 1.0},})This creates a loot table named palehuman, but it isn't assigned to anything yet. You then assign it to your character using these lines:inst:AddComponent("lootdropper")inst.components.lootdropper:SetChanceLootTable('palehuman') Hope it helped! I tried the new code for the actual table because I couldn't get what you posted to work, as that's what I tried first. However, now I've gone back to usingSetSharedLootTable( 'palehuman',{ {'houndfire', 1.0}, {'houndfire', 1.0}, {'houndfire', 1.0},})andinst:AddComponent("lootdropper")inst.components.lootdropper:SetChanceLootTable('palehuman')Is there anything else I'm supposed to do with them, or specific placing for them? Currently, the table is outside of any function as seen in hound.lua, and the component code is in my master_postinit. I've tried mixing and matching the code placement, but can't stop it from crashing right after applying the mod. Also, for the time being I've replaced houndfire with goldnugget, just in case there any problems with actually dropping houndfire it won't hinder my troubleshooting until loot dropping actually works. Edited January 14, 2015 by MattDoesnt Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-601703 Share on other sites More sharing options...
Jjmarco Posted January 14, 2015 Share Posted January 14, 2015 @MattDoesnt: Does it say anything when it crashes? Or does log.txt say something? It may well be that characters can't have custom loot, I actually don't know. Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-601717 Share on other sites More sharing options...
DarkXero Posted January 14, 2015 Share Posted January 14, 2015 Try the following. Add:inst:ListenForEvent("ms_becameghost", firedup)In your master_postinit. And add: local function firedup(inst) local pos = inst:GetPosition() local fire1 = SpawnPrefab("houndfire") local fire2 = SpawnPrefab("houndfire") local fire3 = SpawnPrefab("houndfire") local fire4 = SpawnPrefab("houndfire") local fire5 = SpawnPrefab("houndfire") fire1.Transform:SetPosition(pos.x, 0, pos.z) fire2.Transform:SetPosition(pos.x + 5, 0, pos.z) fire3.Transform:SetPosition(pos.x, 0, pos.z + 5) fire4.Transform:SetPosition(pos.x - 5, 0, pos.z) fire5.Transform:SetPosition(pos.x, 0, pos.z - 5) endIn the character prefab, outside the master_postinit. Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-601724 Share on other sites More sharing options...
MattDoesnt Posted January 14, 2015 Author Share Posted January 14, 2015 (edited) @MattDoesnt: Does it say anything when it crashes? Or does log.txt say something? It may well be that characters can't have custom loot, I actually don't know.No, the screen just freezes up when you start the game with it activated, or leave mods section ingame after activating. @DarkXero Trying this next chance I get thanks ahead of time for the input. Edited January 14, 2015 by MattDoesnt Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-601764 Share on other sites More sharing options...
MattDoesnt Posted January 14, 2015 Author Share Posted January 14, 2015 Try the following. Add:inst:ListenForEvent("ms_becameghost", firedup)In your master_postinit. And add: local function firedup(inst) local pos = inst:GetPosition() local fire1 = SpawnPrefab("houndfire") local fire2 = SpawnPrefab("houndfire") local fire3 = SpawnPrefab("houndfire") local fire4 = SpawnPrefab("houndfire") local fire5 = SpawnPrefab("houndfire") fire1.Transform:SetPosition(pos.x, 0, pos.z) fire2.Transform:SetPosition(pos.x + 5, 0, pos.z) fire3.Transform:SetPosition(pos.x, 0, pos.z + 5) fire4.Transform:SetPosition(pos.x - 5, 0, pos.z) fire5.Transform:SetPosition(pos.x, 0, pos.z - 5) endtrIn the character prefab, outside the master_postinit. Tried this, even added a speech prompt to test if it was working but nothing happened. It doesn't crash, but it doesn't activate either. Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-601800 Share on other sites More sharing options...
DarkXero Posted January 14, 2015 Share Posted January 14, 2015 SpawnPrefab = GLOBAL.SpawnPrefablocal function firedup(inst) local pos = inst:GetPosition() local fire1 = SpawnPrefab("houndfire") local fire2 = SpawnPrefab("houndfire") local fire3 = SpawnPrefab("houndfire") local fire4 = SpawnPrefab("houndfire") local fire5 = SpawnPrefab("houndfire") fire1.Transform:SetPosition(pos.x, 0, pos.z) fire2.Transform:SetPosition(pos.x + 5, 0, pos.z) fire3.Transform:SetPosition(pos.x, 0, pos.z + 5) fire4.Transform:SetPosition(pos.x - 5, 0, pos.z) fire5.Transform:SetPosition(pos.x, 0, pos.z - 5)endAddPlayerPostInit(function(inst) if inst.prefab == "MyCharacter" then inst:ListenForEvent("death", firedup) endend)Put all of this in the modmain and replace MyCharacter for palehuman or whatever your character prefab is. Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-601849 Share on other sites More sharing options...
MattDoesnt Posted January 14, 2015 Author Share Posted January 14, 2015 SpawnPrefab = GLOBAL.SpawnPrefablocal function firedup(inst) local pos = inst:GetPosition() local fire1 = SpawnPrefab("houndfire") local fire2 = SpawnPrefab("houndfire") local fire3 = SpawnPrefab("houndfire") local fire4 = SpawnPrefab("houndfire") local fire5 = SpawnPrefab("houndfire") fire1.Transform:SetPosition(pos.x, 0, pos.z) fire2.Transform:SetPosition(pos.x + 5, 0, pos.z) fire3.Transform:SetPosition(pos.x, 0, pos.z + 5) fire4.Transform:SetPosition(pos.x - 5, 0, pos.z) fire5.Transform:SetPosition(pos.x, 0, pos.z - 5)endAddPlayerPostInit(function(inst) if inst.prefab == "MyCharacter" then inst:ListenForEvent("death", firedup) endend)Put all of this in the modmain and replace MyCharacter for palehuman or whatever your character prefab is. This is the answer, for anyone looking to make a custom character drop table! Thanks to everyone for the help on this one, and special thanks to DarkXero and PeterA! Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-602008 Share on other sites More sharing options...
DarkXero Posted January 14, 2015 Share Posted January 14, 2015 It's not the best thing, you could integrate it into your character prefab but I saw you had problems in that area. Also, in order to create a custom drop table, it depends how you want to do it: for example, in order to drop human meat, when the character dies, the game gives him the prefabs and them makes him drop them. You can't do this with houndfire because you can't put it in the inventory. If you want to edit where the houndfires spawn, edit the setpositions, and if you want more fires, add more spawnprefabs. I'm glad this works for you! Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-602011 Share on other sites More sharing options...
MattDoesnt Posted January 14, 2015 Author Share Posted January 14, 2015 It's not the best thing, you could integrate it into your character prefab but I saw you had problems in that area. Also, in order to create a custom drop table, it depends how you want to do it: for example, in order to drop human meat, when the character dies, the game gives him the prefabs and them makes him drop them. You can't do this with houndfire because you can't put it in the inventory. If you want to edit where the houndfires spawn, edit the setpositions, and if you want more fires, add more spawnprefabs. I'm glad this works for you! Already tinkered with the positioning of the fire a bit, and it works great. Thanks again! Link to comment https://forums.kleientertainment.com/forums/topic/49063-custom-loot-table/#findComment-602015 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