ID:149129
 
ok heres the code to attack. i have 3 types of guns because you can buy 3 different types of guns.

mob/Guns
verb
Shoot_Pistol(mob/M as mob in oview(6))
usr << "You shoot [M] with your Pistol!"
oview(6)<<"[usr] shoots [M]with a Pistol"
var/damage = 5
M:Health -= damage
if(usr.Health<=0)
src.Health=src.MaxHealth
src.loc=locate(33,24,1)
M:DeathCheck()
DeathCheck()


Shoot_Shotgun(mob/M as mob in oview(6))
usr << "You shoot [M] with an Shotgun!"
oview(6)<<"[usr] shoots [M] with an Shotgun!"
var/damage = 30
M:Health -= damage
if(usr.Health<=0)
src.Health=src.MaxHealth
src.loc=locate(33,24,1)
M:DeathCheck()
DeathCheck()

Shoot_Uzi(mob/M as mob in oview(6))
usr << "You shoot [M] with a Uzi!"
oview(6)<<"[usr] shoots [M] with a Uzi"
var/damage = 20
M:Health -= damage
if(usr.Health<=0)
src.Health=src.MaxHealth
src.loc=locate(33,24,1)
M:DeathCheck()
DeathCheck()

proc
DeathCheck()
if (Health <= 0)
loc = locate(26,20,2)
Health = MaxHealth
usr << "[src] has died!"


Whats happening is the mobs go into negitive life. I don't get any errors with this thought. Any suggestions?
I know whats wrong. It dont know whether Health = 0 is for u or for something else so nothing happens so change it to this:

if(M.HP<=0)

but also at the top it should say:

DeathCheck(mob/M as mob)

Then it should work. On my game I have this for Deathcheck:


mob/proc/deathcheck(mob/M as mob)
if(M.HP<=0)
if(M.client)
M.loc = locate(3,3,1)
M.HP = M.MAXHP
M.exp/=2
M.wealth/=2
M<<"Sadly the [src] killed you!"
else
src<<"You killed [M]!"
usr.exp+=M.expreward
usr.wealth+=M.wealthreward
usr<<"You get [M.expreward] Exp and [M.wealthreward] gold!"
del M

and it works. You should change it to work for ur game of course but use this if it dont work k?

In response to Greater Ice Craymel
i get Runtime errors too

runtime error: undefined proc or verb /mob/Hooker/DeathCheck().

proc name: Shoot Pistol (/mob/Guns/verb/Shoot_Pistol)
usr: Dark Ray (/mob/Gray)
src: Dark Ray (/mob/Gray)
call stack:
Dark Ray (/mob/Gray): Shoot Pistol(Hooker (/mob/Hooker))
In response to Alienman22774
Seperate the different kinds of guns
In response to Greater Ice Craymel
i fixed the runtime errors. but the mobs stil don't die
A few different problems here:

Throughout, your usage of colons should be unnecessary. It looks ok, but it depends on where your vars are located. You should get rid of them though.

if(usr.Health<=0)
src.Health=src.MaxHealth
src.loc=locate(33,24,1)
M:DeathCheck()
DeathCheck()

I have no idea what you're doing here. This is what it looks like you're doing:

if the caller's health is <= 0:
Set the owner's health to maximum
Set the owner's location to 33,24,1
Call M's DeathCheck() proc
Call the owner's DeathCheck() proc

in the above, the owner is actually mob/Guns, because it owns Shoot_Pistol(mob/M as mob in oview(6)), I believe.

You probably want to use usr instead of src.

A good way to figure this stuff out is to add:

world << "src: [src] -- usr: [usr]"

To the top line of your verbs/procs when you aren't sure as to which one to use.

Also, you're using the : operator, so things aren't type-checked before-hand. this means that the DeathCheck() proc may not be called AT ALL.

I advise changing to the . operator, and adding some debugging messages such as:

world << "Calling DeathCheck() proc"
..
world << "In deathcheck proc with [src] as src and [usr] as usr"

they help a lot.