ID:148735
 
Ok, heres the fishing code for a new game i plan on making... water
icon = 'turfs.dmi'
icon_state = "water"
density = 1
verb
fish()
set category = "Fishing"
set src in view(1)
var/fish = rand(1,4)
if(fish == 1) usr << "You catch a fish!"
new/obj/fish(usr)
if(fish == 2) usr << "You Fail to catch anything!"
if(fish == 3) usr << "You Fail to catch anything!"
if(fish == 4) usr << "You Fail to catch anything!"
obj
fish
icon = 'turfs.dmi'
icon_state = "fish"
verb
get()
set category = "Inventory"
set src in oview(1)
src.Move(usr)
drop()
set category = "Inventory"
src.Move(usr.loc)
eat()
set category = "Inventory"
usr <<"[usr]: Mmmm Mmmm Good!"

heres the errors
loading AllYouNeedDemo.dme
fishing.dm:10:error:rand:undefined proc
fishing.dm:11:error::invalid expression
fishing.dm:10:fish :warning: variable defined but not used

AllYouNeedDemo.dmb - 2 errors, 1 warning (double-click on an error to jump to it)
how can i fix this? Or if you don't, is there a way around it that does the same thing?


change var/fish = rand(1,4) to switch(prob(25))

change if(fish == 1) to if(1)
change the other if(fish == whatever) to one if: if(0)
To expand on and clarify what Garthor said:

<code>verb fish() set category = "Fishing" set src in view(1) if(prob(25)) //25% chance (1 in 4) of catching a fish usr << "You catch a fish!" new/obj/fish(usr) else usr << "You fail to catch anything!"</code>