ID:149897
 
Ok, Im trying to make it, when you kill a skeleton, it creates a certain amount of gold in place of the skeleton. This is the code i whipped up:
    proc
deathcheck()
if(src.hp <= 0)
if(src.client)
view() << "[src] has died."
usr.def += src.def / 2
usr.str += src.str / 2
src.Move(locate(1,1,1))
else
if(istype(src,/mob/Skeleton))
usr.def += 1
usr.str += 1
new/obj/Gold(src.loc)
for(var/obj/Gold/G in oview(1))
var/ramount = rand(10,25)
G.amount = ramount
del(src)


But that code would make it to where, if theres gold all around you, it would set all of thier amounts, equal ramount. How would i just change the amount of the one it just created? Since src is the skeleton, i couldn't do src.amount. Any help would be great.

Thanks

-Rcet
Give the Gold obj a New() proc that assigns it a random amount upon creation... And when you create it with the skeleton's death...the Gold will set its own value...

Or at least...I think that will work...lol
In response to SuperSaiyanGokuX
Oh man, am I an idiot. I should have thought of that. -_-;
Anyway, thanks!

-Very embarassed Rcet

If you are worried about the object you just created, why not store a reference to it when you create it? (Ex: var/obj/Gold/theReference = new(src.loc) ) Then you can set its amount to whatever you want. Is the problem something else?
Rcet wrote:
new/obj/Gold(src.loc)
for(var/obj/Gold/G in oview(1))
...

But that code would make it to where, if theres gold all around you, it would set all of thier amounts, equal ramount. How would i just change the amount of the one it just created? Since src is the skeleton, i couldn't do src.amount. Any help would be great.

If you want to do anything with the gold you just created, you need to keep track of it, like this:
var/obj/Gold/G=new(src.loc)
G.amount = rand(10,25)

What your code is basically doing is creating the object, then forgetting about it, then trying to find it again.

Lummox JR