ID:1746317
 
Keywords: chest, mimic, transform
(See the best response by Zecronious.)
Code:
name = "Chest"
icon = 'Mobs.dmi'
icon_state = "Chest"
density = 1
verb
Open()
set src in oview(1)
var/mimicchance = prob(15)
if(!mimicchance)
flick("Chest_Open", src)
else
new type(/mob/Mimic)
del(src)


Problem description:
When I start up the game, the Chest instantly becomes a mimic, even though it's supposed to be a 15% chance of happening WHEN you click the Open() verb next to it.
if(prob(15))
-- here is the 15% chance
else
-- normal chest.
Best response
There's a lot more wrong with this code than what you're pointing out. new type(/mob/Mimic) for example. Do you even know what that does?
In response to Zecronious
Zecronious wrote:
There's a lot more wrong with this code than what you're pointing out. new type(/mob/Mimic) for example. Do you even know what that does?

I address the basic issue. I dont program with BYOND anymore, so I'm just here as a minimal help junky.
In response to Lundex
Wasn't responding to you. Was responding to the main post.
@Lundex: Isn't that pretty much what I have, but inverted to having the normal chest in the if, and the Mimic in the else?

@Zecronious: No, not really, I read the page that was talking about it, and it seems to work how I want it too, but if there's a better way to actually spawn the mob then I would love that way.

Edit1:
So, I re-read the DM Guide and now have:
new /mob/Mimic(locate(src.x, src.y, src.z))


And I put Lundex's suggestion for the chance, but the chest still instantly becomes a Mimic upon starting the game instead of when someone uses the Open() verb on it.

Edit 2:
NVM, I was able to get it working, but thanks!
What did you do to make it start working? Was looking through the code, couldn't find the issue.
Seiryuu The Azure Dragon wrote:
 new /mob/Mimic(locate(src.x, src.y, src.z))


This can be simplified down to:

new /mob/Mimic(src.loc)

No need to use locate() at all!