ID:270902
 
Ok ive been wondering is there a way to set a list of contents on a monster and in a death check proc make it add the stuff in the mosters contents to my contents? ive never really messed with setting contents on something besides a playable mob, but i think there is could some one please provide a simple example or tell me how?
Yes a monster can have contents:

mob
Monster
New()
..()
src.contents += new /obj/Item//add the item to their contents as soon as created
//or you could just make some kind of proc that adds to their contents


I'm contemplating a way to auto add to the player's contents..
National Guardsmen wrote:
Ok ive been wondering is there a way to set a list of contents on a monster and in a death check proc make it add the stuff in the mosters contents to my contents? ive never really messed with setting contents on something besides a playable mob, but i think there is could some one please provide a simple example or tell me how?

If your monsters are descended from /atom (they're probably mobs, right? That means that they're descended from /mob, which is descended from /atom) then they also have a contents list. You can add or subtract items from your monsters' contents just like you would for your playable characters. In fact, your program can be made in such a way that you only have to program it once for players, monsters, and NPCs:
mob
character
proc
add_item(var/atom/movable/what)
if(!istype(what, /atom/movable))
return FALSE
contents.Add(what)
. = ..()
remove_item(var/atom/movable/what)
if(!istype(what, /atom/movable))
return FALSE
contents.Remove(what)
. = ..()
empty_contents(var/mob/character/receiver)
if(istype(receiver, /mob/character))
for(var/atom/movable/what in contents)
receiver.add_item(what)
else if(loc)
for(var/atom/what in contents)
loc.contents.Add(what)
else
for(var/atom/what in contents)
what.loc = null
. = ..()
die(var/mob/character/killer)
empty_contents(killer)
. = ..()
player
monster
NPC
In response to Mecha Destroyer JD
and in the death of the monster i belive you can do this:
usr.contents += M.contents

add that to your deathcheck

i got almost the same but for gold and exp, but i think usr.contents is supposed to be src.contents