ID:261770
 
Ok I got a problem i got a bump attack system and it always seems to attack dense turfs also and i get a run error like cannot find nulls health and such heres my code.
mob
Bump(mob/M)//This will be used to make the demo challenging
Damage = rand(MinimumDamage,MaximumDamage)
M<<"[src] attacked you for [Damage] damage!"
if(src.client)
src<<"You attacked [M] for [Damage] damage!"
M.Health-=Damage
src.DeathCheck(M)

mob/proc/Attack(mob/M)
Damage = rand(MinimumDamage,MaximumDamage)
M<<"[usr] attacked you for [Damage] damage!"
if(src.client)
src<<"You attacked [M] for [Damage] damage!"
M.Health-=Damage
M.DeathCheck(M)


mob/proc/DeathCheck(mob/M as mob)
if(M.Health<=0)
if(src.client)
M.loc = locate(1,1,1)
M.Health = M.Maxhealth
M<<"[src] killed you!"

else
src<<"You killed [M]!"
usr.MobExp+=rand(M.Exp,M.MaxExp)
del M

Morte Warrior wrote:
mob
Bump(mob/M)

You're assuming that because you specify the argument as a mob, then it will only be called with mob arguments. It's a common mistake. =)

You need to add an istype() check as the first line of the Bump() proc:

<code>if (!istype(M)) return ..() //If M is not the type it's supposed to be (in this case a mob), just do whatever Bump() normally does instead of all the stuff below</code>