attacking in Developer Help
|
|
I'm having trouble with my attack. it goes:
obj var mob/owner obj sword icon = 'spells.dmi' icon_state = "gemsword" New() for(var/mob/M in src.loc) var/damage = src.owner.damage M.HP -= damage world<<src.owner deathcheck(M,src.owner) flick("attack",src.owner) flick("hit",M) M << "[src.owner] attacks you for [damage] damage" src << "You do [damage] damage to [M]" spawn(5) del(src) spawn(4) del(src) mob/verb/sword() var/obj/sword/S = new/obj/sword(get_step(usr,usr.dir)) S.owner = usr S.dir = usr.dir
|
The runtime error I get only happens when I attack another mob, when I just attack at nothing, it works. The runtime is:
runtime error: Cannot read null.damage proc name: New (/obj/sword/New) source file: fight.dm,10 usr: Aleis (/mob) src: the sword (/obj/sword) call stack: the sword (/obj/sword): New(the path (22,20,1) (/turf/floor/path)) Aleis (/mob): sword() Aleis (/client): Northeast()
|
|
Your problem is that you never set the obj's owner variable. Therefore, src.owner is null.