ID:147871
 
I have looked over the battling coding, looked at demo's, and still I receive this error. I am unsure as to why so I'm posting it here to see if anyone has any ideas.

runtime error: Cannot read null.defense
proc name: damage (/mob/proc/damage)
usr: Jackie (/mob/characters/Violet)
src: Jackie (/mob/characters/Violet)
call stack:
Jackie (/mob/characters/Violet): damage(null)
Jackie (/mob/characters/Violet): Attack(null)

Thanks
I think I know what the problem is, but I can't help you unless you provide the piece of code that has the error in it..

Trog
In response to Troglodyte
Ok here is the damage proc for the game.
damage(mob/M in world)
var/dam =rand(1,M.attack)

dam -= rand(1,M.defense)

if (dam > 0)
M.health -= dam
view(6) << "[usr] attacks [M] for [dam] HP!"
usr.fskill += rand(15,25)
fightinglevel(usr)
else
view(1) << "[usr] attacks [M] but misses!"

if (M.health <= 0)
die(M)

And here is the recent error I get cuz I had changed that coding a bit since last error.

runtime error: Cannot read null.attack
proc name: damage (/mob/proc/damage)
usr: Jackie Chun (/mob/characters/Violet)
src: Jackie Chun (/mob/characters/Violet)
call stack:
Jackie Chun (/mob/characters/Violet): damage(null)
Jackie Chun (/mob/characters/Violet): Attack(null)

And the reason this is a problem because whether its a porblem with null.attack / null.defense / or null.health it wont allow that stat to grow any longer cuz I continue to get the message. If you can help great.

Thanks

-Jackie Chun
In response to Jackiechun302
First of all you have usr in a proc, change those to source and I'll tell you why in a minute. I believe damage(mob/M in world) is your problem. This proc was designed to take and arguement as a mob(the person being damaged). damage(mob/M) is how you want to use it and make sure when you call the proc that you call it for the attacking mob and send the defendung mob as an arguement, like this:

attack.damage(defender)

Though usually your mobs will be defined more like this in an attack verb:

usr.damage(M)

Now to explain the first part, when you call a mob proc(damage) from a mob(usr in the above example) that mob becomes the src of the new proc. I hope this helps you sort out that problem. :)
In response to Jackiechun302
Alright... heres one problem, don't use usr in procs.
take a look here, its Lummox's usr-unfriendly tutor. I think more DM programmers should read, even memorize this, this is your DM bible, it teaches you when and where to use usr and where not to use usr which can help avoid many hard to find bugs in the long-run.
http://www.byondscape.com/ascape.dmb/LummoxJR.2002-1104/

there are problems with your damage proc,your arg for the damage proc mob/M in world sould be damage(mob/M), but i dont think thats the cause of the error, it's how your calling the damage proc.. what are you doing thats causing the errors to popup? Im guessing its attack, so it should be called like this: usr.attack(defender), usr representing the attacker
<edit>
damn, i was in the middle of posting and jnco posted, well now you'll see 2 peoples thoughts
</edit>
Trog
In response to Troglodyte
Ah, but you did include a link to Usr unfriendly. :)
In response to Jnco904
well i figured if i post the link to it whenever i see usr in procs, lazy programmers new and old will take the time to read it and hopefully the occurence of usr in procs will happen less often =)

Trog