ID:170789
 
ok i made this custom move where you can absorb a race and you get moves i tested on players its 100% complete but when i get to monsters heres the error
runtime error: Cannot read null.race
proc name: Body Copy (/mob/swap/verb/Finalpash)
source file: skills.dm,3377
usr: the white tee (/mob/player/bebi)
src: the white tee (/mob/player/bebi)
call stack:
the white tee (/mob/player/bebi): Body Copy(null)

now heres the coding
mob
swap
verb
Finalpash(mob/M in oview(6))
set name = "Body Copy"
set category = "Fighting"
if(M.PowerLevel <= 0)
if(usr.ki >= 19)
if(usr.stamina >= 50)
if(usr.swapping == 0)
var/dam = usr.maxPowerLevel
if(dam == usr.maxPowerLevel)
if(M)//Sanity Check, it checks to see if M is still active
view(6) << "<font size = 1><B>[usr] creeps under [M] skin and steals [M] body"
usr.loc = M.loc
sleep(35)
usr.swapping = 1
usr.icon = M.icon
usr.icon_state = M.icon_state
M.PowerLevel -= dam
M.DeathCheck()
usr.firing = 0
usr.stamina -= 50
usr.ki -= 20
if(M.race == "Sayain"||M.race == null)
if(usr.maxPowerLevel >= 25000)
usr.verbs += new /mob/kame/verb/sbomb
usr.verbs += new /mob/Furry/verb/Finalpash
usr.verbs += new /mob/galicz/verb/finalflash
if(usr.maxPowerLevel >= 500000)
usr.verbs += new /mob/ITkame/verb/finalflagg
usr.verbs += new /mob/fflash/verb/finalflash
usr.verbs += new /mob/meteor/verb/finalflash
if(usr.maxPowerLevel >= 1000000)
usr.verbs += new /mob/spiritbomb/verb/sbomb
usr.verbs += new /mob/bbang/verb/finalflash
if(M.race == "Monster")
usr.PowerLevel += 0
del(M)
if(M.race == "Namekian"||M.race == null)
if(usr.maxPowerLevel >= 25000)
usr.verbs += new /mob/scatterz/verb/finalflash
if(usr.maxPowerLevel >= 500000)
usr.verbs += new /mob/masenkos/verb/finalflash
usr.verbs += new /mob/arm/verb/sbomb
if(usr.maxPowerLevel >= 1000000)
usr.verbs += new /mob/hellzone/verb/finalhell
else
usr << "Chill [usr] you already stolen a body"
else
usr << "You need to rest"
else
usr << "Your out of ki"
else
usr << "[M] powerlevel must be below 0"

the white tee was just my character.
^bumping^
In response to Jiamind
bump
In response to Jiamind
Only bump every 24 hours IF it's off of the front page, that's just outrageous bumping there, lad.
In response to Hell Ramen
oh ight im still new to these forums but this is my last piece of coding to my game and im done and its my first game so im ready to stop coding.
There's no need to bump this much, people will get to your post when they're able to.

Anyways, your problem is where you have "del(M)". M gets deleted, but the code continues, and then does "if(M.race == "Namekian"||M.race == null)". It can't read M.race because M doesn't exist anymore - you deleted M.
In response to Jiamind
Woah, don't stop coding. @_@
Keep on going.
Just don't forum spam, as of it wastes bandwith.
In response to Hell Ramen
lol ok no problem ima just delete those extra messages
In response to Cinnom
no not the del(M) its been like the even before i added that.
In response to Jiamind
Also, just a guess, what is "the white tee"'s race?
In response to Hell Ramen
alien
In response to Jiamind
Dur, I just noticed, which line is 3377?
In response to Jiamind
My best guess is that M.DeathCheck() is deleting M. Can you point out where line 3377 is? Hit Ctrl+G and type in 3377, and it will highlight the line for you.
One problem that I see (but I can't be sure that this is the current one, without having you mark the line that's having problems) is that if M is of race "Monster", then it's deleted before the "Namekian" race check is made. If you want the QUICK fix then just move the "Monster" race check down below the "Namekian" race check. If you want a bit better fix, use else if's for the race checks (players can't be more than one race at a time, right?). Then, have a catch-all else statement at the end, in case the race of the victim isn't set, or whatever else could possibly go wrong.
In response to Hell Ramen
i dont really get the line number but this is the last coding on the skills page.But its then null.race line where all the M.races are.
Instead of
if(M.race=="MyRace"||M.race==null)

Put
if(!M.race||M.race=="MyRace")


You're putting "if(!M.race)" in place of "if(M.race=null)", because it checks for null, 0, and "", which, in DM, count as seperate values. It's much more robust/bullet-proof/watertight.

The reason we put "if(!M.race)" first, was because DM short-circuits things. That means that with "if(A||B), for example, DM won't check B if A returns true, because it just needs one to be true. If M.race really is null, and it trys to check for if(M.race=="Saiyan"), then it will return a runtime.
In response to Wizkidd0123
Not quite - it won't give a runtime if you check M.race and M.race happens to be null. It will, however, give a runtime if you try to check M.race if M is null.
In response to Cinnom
Cinnom wrote:
Not quite - it won't give a runtime if you check M.race and M.race happens to be null. It will, however, give a runtime if you try to check M.race if M is null.

Oops; that's what I meant <_<
In response to Cinnom
none of them did not work but the mob will die
You know, you really shouldn't be using such huge files. I mean, I saw that you'er already up to line 3337. I think it would be much easier for you in the long run if you were to seperate that out into smaller, more organized files.