How would i make a monster drop an item when it dies?
I really need help on this, Thanks
NilFisk
ID:179249
![]() Jan 27 2002, 5:02 pm
|
|
ACWraith wrote:
There is a tutorial which drops gold when a mob dies: there is an even better method [edit] Well it might not be better, but ive found it to be efficient.(ie: monsters dont keep walking around after being deleted, which often happened to me when i tried using a Move() statement.) [/edit] mob/proc/DeathCheck() if(src.hp <= 0)//if their hp variable is below 0, they dead //determine differences between players and monsters if(src.client == null)//its a monster src.loc.contents += src.contents del(src) else//its a player //do whatever here now, the statement src.loc.contents += src.contents makes every item inside the monsters contents drop to the turf loc that he is standing on. This makes it easy for organizing what monsters have what. mob/monster/JackBlack contents = newlist(/obj/sword,/obj/gold) here we say that jackblack the monster's contents will start with a sword and some gold. When he dies, he will drop both of those items. Of course this method isnt that great if you have unique items, that are created from a template, because the statement contents = newlist(/obj/sword,/obj/gold) creates a new sword and a new gold inside of the monster's contents when the monster is created. If you had some really unique items created from templates, you would have ot use the New() statement for all monsters, but i dont recommend that. FIREking |
http://zilal.byond.com/zbt.html
Short answer: One method is to create the item with (or just move an existing item to) the monster's location as the monster is being deleted (inside the monster's Del() proc).
It is hard to give you an exact method because it depends on how you have implemented death and monsters. However, this method often works.