mob
proc
ItemChance(mob/player/P,mob/monsters/M)
var/chance1 = rand(1.20)
var/chance2 = rand(5,5)
var/continues = 1
if(chance2 == 5)
var/obj/O
if(M.drop2)
O = new M.drop2
else
return
if(istype(O,/obj/keys))
world << "Here"
if(!(O.type in P.keys))
AddInfo(P,"An item drops from the monster!","It's a [O]!")
sleep(12)
O.Hloc = P.keys
continues = 0
else
AddInfo(P,"An item drops from the monster!","It is a [O]!")
sleep(12)
O.loc = P.contents
continues = 0
else if(chance1 == 10 && continues == 1)
var/obj/O
if(M.drop1)
O = new M.drop1
else
return
AddInfo(P,"An item drops from the monster!","It is a [O]!")
sleep(12)
O.loc = P.contents
Problem description:
The code is simple. The mob (monster) has one or two drop items defined by drop1 and drop2 variables in it's specs. What this code does is that it checks the two chance variables chance1 and chance2, basically a percentage thing. if chance2 is good, they get drop2, and if chance1 is good, they get drop1. The problem is that drop2 can be a key to progress into the game, and as such I want the key to enter a special Key inventory (P.keys). ALL of this code works except for the fact that the keys do not enter the key inventory, or any inventory for that matter. At least, as far as I know, they do not. How do I know? I have a statpanel named Keys that is P.keys, that's it, much like an Inventory statpanel where you make it P.contents (I'm saying this as if P is the player, so the Player's inventory/keys/whatever) Nothing ever shows up in the Keys statpanel AND the code continues to give me more of the key, so nothing ever enters P.keys.
Before anyone tries to tell me about my rands and such, chance2 is rand(5,5) FOR A REASON. SO I CAN TEST IT. PLEASE DO NOT TELL ME ABOUT IT I KNOW.
That's a much more robust solution. The specific problem I believe you were having was that the location of an atom can't be a list. A list can only contain references to objects, not the objects themselves.