ID:178683
 
This is my deathcheck proc

    proc
Death(mob/M)
if(src.type == /mob/PC)
PCDeath()
else
if(src.health <= 0)
del(src)
How would i make it where there a 50% chance of creating 1 item and a 50% chance of creating a differnt item when it dies?
switch(rand(1,2))
if(1)
blah blah
if(2)
blah blah

pretty simple :)
In response to Jon Snow
Or

if(prob(50))//50% chance
//something
else
//something else
SuperGoku15 wrote:
How would i make it where there a 50% chance of creating 1 item and a 50% chance of creating a differnt item when it dies?

Question: Do you mean that the 50% chance of creating each is independent, so that there's a 25% chance of creating both and a 25% chance of creating none? Or do you mean that you want to creat something no matter what, but as an either/or choice? (That is, you're basically flipping a coin to create something. Do you want to flip two coins, one for each different thing, or do you want to flip just one coin?)

If the chances are independent, you'd do something like this:
if(prob(50)) new /obj/thing1(src.loc)
if(prob(50)) new /obj/thing2(src.loc)

If you want to create either one item or the other, I suggest a different approach from either of the ones you've seen:
var/list/dropitems=list(/obj/thing1,/obj/thing2)
var/which=pick(dropitems)
new which(src.loc)

The beauty of this system is that it's extensible: You can add new types to the list.

Lummox JR