ID:168217
 
im not sure how to make monsters drop items at random with very small chance of getting one. Can anyone do a tiny demo to show me how to?
there are lots of video tutorials here and one covers this subject http://www.riddlersoft.com/ByondPage.htm
In response to The Riddler
thaks riddler but thats not exactly what i need and i liiked i cant find any at all anywere in forum libs or demos and i need random drop not drop everytime a monster dies and diffrent drops for different monsters.
In response to Fireweilder
mob/monster/Death()
var/gold = rand(1,100)
if(prob(50))
//drop 1 to 100 gold here.


That should help.
In response to Kalzar
thanks, that sorta helps but i need somthing to make my monster drop different items like... a slime and a lava slime droping different stuff
In response to Fireweilder
that's pretty easy here's what i use:

mob/monster/Del() //when the monster dies
if(prob(.5)) //if the probability to drop the item is .5%
new/obj/weapon/Dagger(loc) //create a new item where the monster dies
..() //call the parent


of course your DeathCheck() proc might be different, but this is similar to what mine looks like
In response to Fireweilder
I'm almost 100% sure I've read something about that in a tutorial on BYONDscape. Which means you haven't read all the tutorials, which you should.

Although if I were you, I'd just skip to the DM Guide, it's more useful on basic things.

But all that you have to do is to keep a variable for each monster storing how much gold it'll drop.
In response to Pyro_dragons
once again thanks but it still wont work... i have one death check for all my monsters. look

mob/proc/Death()
if(src.HP<=0)
if(src.client)
world << "[src] has died!"
usr<<"You were killed,robbed and left in the wilderness"
src.HP = src.maxHP
usr.Gold += round(src.Gold/2)
src.Gold -= round(src.Gold/2)
src.loc = locate(180,83,1)
LevelUp()
return
else
usr.Exp += src.expplus
usr.Gold += src.goldplus
usr<< "you gain [src.expplus] exp and [src.goldplus] Gold from killing[src]!!"
LevelUp()
del(src)


(indention errors dont exist)
i saw a forum on here that used a list to do what i want but when i try to do that i get errors everywhere and dont see anything wrong with code
In response to Fireweilder
Don't put usr in procs, basic lesson.
In response to Mysame
here is a simple DeathCheck() modify it how you please.

mob
proc
DeathCheck()
if(src.HP <= 0) //if the mob HP = 0
usr << "<font color = red>You have killed [src]!</font>" //tell the usr what they killed
del(src) //delete the dead body
if(usr.HP <= 0) //if the usrs HP = 0
usr << "<font color = red><I>You were killed by <b>[src]</b>!</font></I>" //tell the usr they died
world << "<font color = blue><b>Info:</b> [usr] was killed by[src]!</font>" //tell the world who died
usr.loc = locate(1,1,1) //relocate the usr. of course you could just delete them

it works fine, though sometimes the moster doesn't get deleted, so just make it so that when you atack, if it is already dead, the usr can't attack it again.
In response to Pyro_dragons
ok thanks but i have a death check all i need is to use a list procedure to make monsters drop different items at random but the ones i try from other forums give me like 7-15 errors and i dont know how to fix them.
In response to Fireweilder
ok i made my own... can someone help me with the runtime error though?



proc/Drop(J)
usr << "<font color = red>You just found a [J]!"

proc/itemdrop(mob/Monster/M)
if(M.Slime == 1)
var B = rand(1,2)
switch(B)
if (1)
var/obj/MPpot1/J
usr.contents += new/obj/MPpot1
Drop(J)
if (2)
var/obj/Healthpot1/J
usr.contents += new/obj/Healthpot1
Drop(J)
else
return
(indention errors dont exist)

runtime error: Cannot read null.Slime
proc name: itemdrop (/proc/itemdrop)
source file: Monster drops.dm,6
usr: Fireweilder (/mob/player)
src: null
call stack:
itemdrop(null)
Slime (/mob/Monster/Slime): Death()
Fireweilder (/mob/player): Attack()
In response to Fireweilder
here is what mines looks like. i have no idea what you're doing there so try this, it works perfectly. of course you need to change the name of the monster and its icon state. also change the prob. and put dm tags around your code. i also included making monsters drop random amounts of gold and picking up the gold.

mob
monster
Fire_Dragon_Weakling //monster name
icon= 'Monsters.dmi' //icon file
icon_state = "Fire Dragon Weakling"
var/HP = 100 //monsters //its stats
var/Defense = 5
var/Attack = 15
Del(mob/monster) //when the monster is deleted
if(prob(10)) //if the prob to drop the item is 10%
new/obj/item/armor/Robes(loc) //drop the item where the monster died
..()//cal the parent
if(prob(10))
new/obj/item/shield/Wood_Shield(loc)
..()
if(prob(15))
new/obj/item/weapon/Dagger(loc)
..()
if(prob(5))
new/obj/item/weapon/Blade(loc)
..()
if(prob(30))
var/obj/Gold/G = new(loc)
G.amount = rand(1,100)
..()
if(prob(30)) //in this case, the monster has a 30% chance to drop nothiing at all
..()

obj
Gold
icon = 'Gold.dmi'
var
amount //amount of gold
verb
Grab_Gold() //verb to get the gold
set src in view(1) //must be at least one space away to use the verb
usr << "You pick up [amount] gold." //tell the usr they picked up an amount of gold
usr.Gold += amount //add that amount to the gold stat
del(src)//delete the gold icon

this has no problems.
In response to Pyro_dragons
thanks, but i was just wandering if anyone could help me with the problems in my code...
In response to Pyro_dragons
Don't think of usr as the person playing your game in real life.

In a proper DeathCheck(), you should send an argument saying who did the killing (instead of using usr).

mob
proc
DeathCheck(mob/M) //in this case, M is the person who killed src.
if(src.HP <= 0) //if the mob HP = 0
M << "<font color = red>You have killed [src]!</font>" //tell the usr what they killed
del(src) //delete the dead body


The proper way of calling it would be to do:

mob/verb/KillAnyone(mob/M in world)
M.HP = 0
M.DeathCheck(usr) //Check if M is dead. usr is the one who killed M, so send DeathCheck() the argument
In response to Fireweilder
thanks to all that helped i found my prob... i just had to change M to src