#How do I add chance to an item so 1/2 or 1/4 of getting the item

1 messages · Page 1 of 1 (latest)

peak prairie
#

on step on pressure plate:
if event-block is a iron pressure plate:
if block below event-location is iron block:
set {_number} to a random integer between 1 and 4
if {_number} is 1:
give player iron nugget named "&fIron Nugget" with lore "This is worth 25¢"
if {_number} is 2:
give player white dye named "&fIron Chunk" with lore "This is worth 5$"
if {_number} is 3:
give player iron ingot named "&fIron Ingot" with lore "This is worth 25$"
if {_number} is 4:
give player iron block named "&fIron Block" with lore "This is worth 500$"
wait 1 tick

vital coyote
#

by using random integers

peak prairie
#

wdum

#

i mean like u have a 1/2 chanse of getting 1 and a 1/4 on 2 and so on

vital coyote
#

i know

peak prairie
#

right now its 25% each

vital coyote
#

u can use random integers

#

use brain

peak prairie
#

o

vital coyote
#

u see now?

peak prairie
#

no

#

{_n} can only be set to one object, not more
on step on pressure plate: if event-block is a iron pressure plate: if block below event-location is iron block: set {_n} to a random integer between 1 and 2 and 3 if {_n} is 3: set {_n} to a random integer between 4 and 5 and 6 if {_n} is 6: set {_n} to a random integer between 7 and 8 and 9 if {_n} is 1 or 2: give player iron nugget named "&fIron Nugget" with lore "This is worth 25¢" if {_n} is 4 or 5: give player white dye named "&fIron Chunk" with lore "This is worth 5$" if {_n} is 7 or 8: give player iron ingot named "&fIron Ingot" with lore "This is worth 25$" if {_n} is 9: give player iron block named "&fIron Block" with lore "This is worth 500$"

#

im trying to do 2/3 to 1/3

#

says it can only be 1

#

@vital coyote

vital coyote
#

what the hell

peak prairie
#

?

vital coyote
#

is that

peak prairie
#

idk

#

it works

#

but not when i add

#

3rd number

vital coyote
#
on step on pressure plate:
    if event-block is a iron pressure plate:
        if block below event-location is iron block:
            set {_number} to a random integer between 1 and 5
            if {_number} is 1 or 2:
                give player iron nugget named "&fIron Nugget" with lore "This is worth 25¢"
            if {_number} is 3:
                give player white dye named "&fIron Chunk" with lore "This is worth 5$"
            if {_number} is 4:
                give player iron ingot named "&fIron Ingot" with lore "This is worth 25$"
            if {_number} is 5:
                give player iron block named "&fIron Block" with lore "This is worth 500$"
            wait 1 tick
#

this is what i mean

#

not the full code

#

but its an example

peak prairie
#

that is just 2/2 1/1

#

ok

peak prairie
#

i need 50 25 12.5 etc

vital coyote
#

so make it like that then

peak prairie
#

oh wait

#

i mean 33

#

and whatever is after

#

thats why i have it as 1 and 2 and 3

#

but it says {_n} can only be set to one object, not more

#

oh wait

#

im stupid

ionic shadow
#

Just 2^(-x) = (1/2)^x = 1/(2^x)

vital coyote
#

real

ionic shadow
#

Heres an exampleloop 5 times: chance of 2^(0 - (loop-number - 1)): broadcast “&aSUCCESS! There was a %2^(0 - (loop-number - 1))%%% chance of this succeeding” else: broadcast “&cFAILED! There was a %2^(0 - (loop-number - 1))%%% chance of this succeeding”

#

chance of 50% = chance of 0.5 = chance of 1/2