ID:2126974
 
(See the best response by Kaiochao.)
I know there is a cleaner way of doing what i want but im having issues just figuring out how to make this work:

so i want to add items to a NPC's contents so when it dies death() will have it dump its contents as loot

was planning for boolean arguements to list loot for each mob, If someone knows a better way i would greatly appreciate a nudge towards a better design or help me with adding objects to a npc content
You can literally just use the contents list and a list of objects, or even your own hand-rolled list.

mob
npc
gold_guy
contents = newlist(/obj/item/gold,/obj/item/moregold)


Then just dump said items on the ground when the mob dies and be done with it. If you want to get into things like drop rates and the sort you'd obviously have to expand on things.
Best response
I would give NPCs a proc that returns a lazy-initialized list of item instances to drop. It's best to lazy-initialize it so it's not generated as soon as the NPC is created, which you don't want if a lot of NPCs are created simultaneously (e.g. at world startup, if there are lots of NPCs on the map).
mob/npc
// This is what you call whenever you want a list of an NPC's loot.
// For example, call it in death(), or when you want to take a
// peek at the loot an NPC is carrying before you kill it.
proc/GetLoot()
// This returns a list of /obj instances that the NPC will drop.
// Implementation below, but it's not important.

// This is called only once, the first time loot is asked for.
// It does nothing by default, and is purely for overriding.
proc/GenerateLoot()
// Override this to return one of:
// * a list of new item instances
// * an obj instance or obj prototype.

// A list to store the generated loot so we
// don't generate it every time GetLoot() is called.
// The underscore means you should avoid reading the variable.
// If you want to get the loot of an NPC, call NPC.GetLoot().
var _loot[]

GetLoot()
if(!_loot)
// If _loot isn't initialize, initialize it.
_loot = GenerateLoot()

// _loot needs to be a list of zero or more items,
// so turn int into one somehow:

// If GenerateLoot() didn't return anything,
// _loot is an empty list().
if(!_loot)
_loot = list()

// If GenerateLoot() returned something other than a list,
// try to convert that into a list of items.
else if(!istype(_loot, /list))
// If GenerateLoot() returned an obj,
// return a list containing that obj.
if(isobj(_loot))
_loot = list(_loot)

// If GenerateLoot() returned a path to an obj,
// return a list containing a new instance of that obj.
else if(ispath(_loot, /obj))
_loot = newlist(_loot)

// Return a copy of _loot so that it can't be touched by gnomes.
return _loot.Copy()

mob/npc
// Example NPC type: a slime that has a 50% chance to drop gel.
slime
GenerateLoot()
if(prob(50))
return /obj/item/gel

// Another example: a special slime that may drop multiple things.
golden_slime
GenerateLoot()
var loot[0]

// 25% chance to drop gel
if(prob(25))
loot += new /obj/item/gel

// 75% chance to drop a bag of between 5 and 10 gold.
if(prob(75))
loot += new /obj/item/bag_of_gold (rand(5, 10))

return loot
Thanks Nadrew no idea why i drew such a blank,

Kaiochao That is so much cleaner than that i was planning to do, I greatly appreciate the commenting on it! thanks for taking the time.