Jump to content

Custom Loot Table


Recommended Posts

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
Share on other sites

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} )end

Not working quite yet, though.

Edited by MattDoesnt
Link to comment
Share on other sites

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} )end

Not 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
Share on other sites

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 using

SetSharedLootTable( 'palehuman',{    {'houndfire',   1.0},    {'houndfire',   1.0},    {'houndfire',   1.0},})

and

inst: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 by MattDoesnt
Link to comment
Share on other sites

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)	end

In the character prefab, outside the master_postinit.

Link to comment
Share on other sites

@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 by MattDoesnt
Link to comment
Share on other sites

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)	end

trIn 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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...