Jump to content

Having the player drop loot other than his inventory item? (i.e. like spiders drop silk)

Recommended Posts

My previous question that's related to this: http://forums.kleientertainment.com/topic/52436-spawning-a-specific-prefab-on-player-death/


I wanted to spawn a specific prefab, but all the methods that were suggest in the thread, I tried, and all failed.


I think the issue lies within me trying to spawn it from math based on the location of a player who's no longer there, so now I'm thinking it might be easier to just have it drop like mobs drop loot using "SetSharedLootTable" but that isn't working too well, as it crashes on start up.

SetSharedLootTable( 'stuff',{    {'rocks',     	1.00}})

would be at the top and this was at the bottom

AddPlayerPostInit(function(inst)    inst:AddComponent("lootdropper")	inst.components.lootdropper:SetChanceLootTable('stuff')end)

but nonetheless it crashed on start up calling the SetSharedLootTable a nil value.

Can anyone offer another solution? Perhaps something similar to how the skeleton is spawned on death? (I couldn't figure that out myself.)

Link to comment
Share on other sites

It's because the death event is handled differently in the Wilson stategraph.

Monsters have a common death, which uses the drop loot functionality.


What you are looking for is:

GLOBAL.SetSharedLootTable("stuff", {	{"meat", 1.00},	{"meat", 1.00},	{"meat", 0.33}})AddPlayerPostInit(function(inst)	inst:AddComponent("lootdropper")	inst.components.lootdropper:SetChanceLootTable("stuff")	inst:ListenForEvent("death", function()		inst.components.lootdropper:DropLoot(inst:GetPosition())	end)end)
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

  • Create New...