ID:155773
 
    orc
icon = 'icons.dmi'
icon_state = "orc"
health = 30
damage = 4
wealth = 10

        proc
deathcheck()
if (health <= 0)
if (src.wealth >= 1)
var/obj/gold/golddrop = src.wealth

world << "[src] dies!"
del(src)


Hi all, I appologise if this should be simple but Iv spent the last hour and a half trying to figure this out.

I want to make the deathcheck command initiate a gold drop according to the wealth of the specific npc. Please could someone help with this.
You've mostly got it down.

var/obj/gold/G = new(src.loc)

G.wealth = src.wealth
In response to LordAndrew
    proc
deathcheck()
if (health <= 0)
if (src.wealth >= 1)
var/obj/gold/golddrop = src.wealth
var/obj/gold/G = new(src.loc)
G.wealth = src.wealth
world << "[src] dies!"
del(src)


"player.dm:34:error: G.wealth: undefined type: G.wealth
player.dm:33:error: G: unknown variable type
player.dm:32:warning: golddrop: variable defined but not used

newworld.dmb - 2 errors, 1 warning (double-click on an error to jump to it)"

I keep getting these error messages. Is there something I'm missing?
In response to Saladon
proc
deathcheck()
if (health <= 0)
if (src.wealth >= 1)
var/obj/gold/golddrop = src.wealth
var/obj/gold/G = new(src.loc)
src.wealth = 0
world << "[src] dies!"
del(src)


Try that, probably not the best way but meh it should work i assume.

In response to Rickoshay
Ah but there is still an error saying that G is an unknown variable type. My mind is boggled.

player.dm:36:error: G: unknown variable type

Also has a warning:

"golddrop: variable defined but not used"
In response to Saladon
Saladon wrote:
Ah but there is still an error saying that G is an unknown variable type. My mind is boggled.

player.dm:36:error: G: unknown variable type

Also has a warning:

"golddrop: variable defined but not used"

proc
deathcheck()
if (health <= 0)
if (src.wealth >= 1)
var/obj/gold/golddrop = new(src.loc)
src.wealth = 0
world << "[src] dies!"
del(src)


Try that maybe and the warning was because golddrop wasn't in use. I'm not sure if what i've done will change anything. kinda rushing cause I'm at work.
In response to Rickoshay
Thanks that took 1 error away lol. Still one left
    obj

gold
icon = 'icons.dmi'
icon_state = "gold"
var
amount
verb
get()
set src in view(1)
usr << "You picked up [amount] Gold"
usr.wealth += amount
del(src)

    proc
deathcheck()
if (health <= 0)
if (src.wealth >= 1)
var/obj/gold/golddrop = new(src.loc)
src.wealth = 0
world << "[src] dies!"
del(src)

//error:
//player.dm:34:error: golddrop: unknown variable type


Is there a way I should be defining the golddrop variable? I assume that the "var/obj/gold/golddrop" code would define it automatically? and thanks for taking the time to help me. I appreciate it
In response to Saladon
Can i ask have you got gold as an obj?
In response to Saladon
obj

gold
icon = 'icons.dmi'
icon_state = "gold"
var
amount
verb
get()
set src in view(1)
usr << "You picked up [amount] Gold"
usr.wealth += amount
del(src)


Yep there it is :)
In response to Rickoshay
    obj

gold
icon = 'icons.dmi'
icon_state = "gold"
var
amount
verb
get()
set src in view(1)
usr << "You picked up [amount] Gold"
usr.wealth += amount
del(src)


Here it is
In response to Saladon
mob 
var/obj/gold/golddrop
proc
deathcheck()
if (health <= 0)
if (src.wealth >= 1)
golddrop = new(src.loc)
src.wealth = 0
world << "[src] dies!"
del(src)


Not sure on this either. But for some reason this is the only way i could get it to work *sad face*
In response to Rickoshay
It's ok, I figured it would be easier to just let you gain the gold straight away after the kill, instead of letting it drop and the player picking it up.

    proc
deathcheck()
if(src.health <= 0)
usr.wealth += src.wealth //Gold after Kill
usr << "You won [src.wealth] Gold"

usr.xppool += src.xpgive //XP after Kill
usr << "You gained [src.xpgive] XP"

world << "[src] dies!" //[src] Dies!
del(src)
In response to Saladon
Okies, also no usr in procs. I Can't quite remember how to define two mobs in a procedure but I'll reply in about five mins once i remember.
In response to Saladon
This is completely wrong. usr is not meant to be used in a proc like that.

obj
gold
var
amount = 0

New()
amount = rand(1, 100)

mob
proc
deathcheck(mob/attacker)
if(health <= 0)

if(client)
src << "You are killed by [attacker]."

Move(locate("spawnpointorsomething"))

else
attacker << "You kill [src]."

new /obj/gold(loc)

del src


Edit: ...hrm. I've been awake for a very long time so I may be mixing up my logic here. The goal is that when you call deathcheck(), you pass along the person who killed the thing.
In response to LordAndrew
That one works perfectly. Thank you so much. :)

But one more question... I keep seeing do not add usr into a proc. So what would I replace "attacker" with?

Edit: nevermind, waiting for Rickoshay. Only read his post now

    proc
deathcheck()
if(src.health <= 0)

usr << "You kill [src]."
new /obj/gold(loc)
del src
In response to Saladon
As Lord Andrew did it you can see how he used attacker. The attacker being the killer and you being the src. so like he did.

mob/proc/DeathCheck(mob/attacker)
src<<"You were killed by [attacker]" // So src being you attacker being them.