ID:263430
 
Code:
mob
verb
Attack(mob/M as mob in oview(1))
set hidden = 1
M.death_check()
usr.stamina()
usr.icon_state = "attack"
src.exp +=rand(2,1)
src.stamina -=rand(2,1)
sleep(4)
usr.icon_state = ""
src.Levelup()
sleep(15)
var/damage = M.strength
M.powerlevel -=damage
return

mob
verb
Rest()
set hidden = 1
usr.icon_state = "rest"
sleep(100)
usr.icon_state = ""
src.stamina = src.stamina_max
src.powerlevel=src.powerlevel_max
view() << "[src.name] has fully rested his strength"
return
client
command_text = ".alt "

mob/proc
KO()
if(src.powerlevel <= 5)
view() << "[src.name] has been knocked out!"
usr.icon_state = "KO"
src.KO = 1
mob
proc
Levelup()
if(src.exp>=src.tnl)//If your exp var equals, or passes your maxexp var
src.level++//Add to your level
src.exp=0//resets your exp to 0
src.tnl*=2//makes your maxexp double
src.strength+=rand(2,1)
src.defence+=rand(2,1)
src<<"You gained a level!"
world << "<small><font color = green><b>Level Info: <font color = blue>[src]/[key] has gained a level."
src.Statup()
else
..()

mob/proc/death_check(mob/M)
if(src.powerlevel <= 0)
usr. <<"You killed [src]!"
world << "<small><font color = red><b>Death Info: <font color = blue>[src]/[key] has been killed by [usr]."
if(src.client)
world << "<small><font color = red><b>Death Info: <font color = blue>[src]/[key] has been killed by [usr]."
src.loc = locate(23,1,2)
src.powerlevel = src.powerlevel_max
else
del(src)


Problem description:

i keep on getting runtime error when i kill someone ! the code above is the attack and the death check e/t/c i dont kno what that runritme error means can someone fix it for me please


runtime error: Cannot read null.strength
proc name: Attack (/mob/verb/Attack)
usr: Gebsbo (/mob)
src: Gebsbo (/mob)
call stack:
Gebsbo (/mob): Attack(null)
runtime error: Cannot read null.strength
proc name: Attack (/mob/verb/Attack)
usr: Gebsbo (/mob)
src: Gebsbo (/mob)
call stack:
Gebsbo (/mob): Attack(null)
Add this (#define DEBUG) then repost error and the code
Your code is all [didn't mommy teach you not to use dirty words?] up why do u have mob/M in death_check but your still using src? and also the error is happening on var/damage = M.strength, and also in the attack verb you are using M,usr,src.dont do that jeez<.< go back and read more of the dm guide.
~Grand~
In response to KillerGrand
lol i sed help me fix it by fixing it and showing me the errors not writing a load of crap that i dont understand :/
In response to Tomf and Tails5
People cant always do stuff for you in the programming life u have to try and learn how to fix your errors not get people to do them for you.
mob
verb
Attack(mob/M as mob in oview(1))
set hidden = 1
M.death_check()
src.stamina()
src.icon_state = "attack"
src.exp +=rand(2,1)
src.stamina -=rand(2,1)
sleep(4)
src.icon_state = ""
src.Levelup()
sleep(15)
var/damage = M.strength
M.powerlevel -=damage
return

mob
verb
Rest()
set hidden = 1
src.icon_state = "rest"
sleep(100)
src.icon_state = ""
src.stamina = src.stamina_max
src.powerlevel=src.powerlevel_max
view() << "[src.name] has fully rested his strength"
return
client
command_text = ".alt "

mob/proc
KO()
if(src.powerlevel <= 5)
view() << "[src.name] has been knocked out!"
src.icon_state = "KO"
src.KO = 1
mob
proc
Levelup()
if(src.exp>=src.tnl)//If your exp var equals, or passes your maxexp var
src.level++//Add to your level
src.exp=0//resets your exp to 0
src.tnl*=2//makes your maxexp double
src.strength+=rand(2,1)
src.defence+=rand(2,1)
src<<"You gained a level!"
world << "<small><font color = green><b>Level Info: <font color = blue>[src]/[key] has gained a level."
src.Statup()
else
..()

mob/proc/death_check(mob/M)
if(M.powerlevel <= 0)
src<<"You killed [M.key]!"
world << "<small><font color = red><b>Death Info: <font color = blue>[M.key] has been killed by [src]."
if(M.client)
world << "<small><font color = red><b>Death Info: <font color = blue>[M.key] has been killed by [src]."
M.loc = locate(23,1,2)
M.powerlevel = src.powerlevel_max
else
del(M)

That should all work better then what it did im just not sure about the error.
~Grand~

In response to KillerGrand
None of your changes were any good, Killer. :(

Turns out the reason the Attack() verb wasn't working was because you were calling the death check proc before trying to access the victim mob.
The deathcheck proc was killing it so when it came to accessing it, it wasn't there anymore.

Ignore KillerGrand's changes to your code, they didn't fix anything (for example he reversed the death_check() proc, when it was right the first time).
In response to KillerGrand
thank you ^_^
In response to Elation
Can you fix it and show me code please
In response to Elation
Elation how was it right he was defining mob/M without even using M in his code <.<.
In response to KillerGrand
His proc wasn't right but it had the perspective correct. A death check proc should be checking (and then killing) the object it belongs to, not the other way round.
In response to Elation
Well sense you know more about coding then me are u gonna try and help him fix his code if not then let me try <.<.
In response to KillerGrand
Can one of you fix this code for me please!
In response to Tomf and Tails5
I think this is how elation is saying not sure tho.
mob/proc/death_check(mob/M)
if(M.client)
if(M.powerlevel <= 0)
src<<"You killed [M.key]!"
world << "<small><font color = red><b>Death Info: <font color = blue>[M.key] has been killed by [src]."
M.loc = locate(23,1,2)
M.powerlevel = src.powerlevel_max
else
del(M)

here.
~Grand~
In response to Tomf and Tails5
As I said before, you're calling the death_check() proc prematurely. Fix that problem first, then we'll move onto the other problems.

A section of your deathcheck proc:
mob/proc/death_check(mob/M)
if(src.powerlevel <= 0)
usr. <<"You killed [src]!"


Don't use usr in procs, as you cannot be sure what it is actually referring to.
Usr is evil :p

Anyway, what you need to be doing is making use of that mob you parsed into the proc as an argument. When you call death_check() you should make sure the attacker is sent through too.
victim.death_check(attacker)

Then you can use it properly- for example, send it messages.
M <<"You killed [src]!"


Oh, also this bit below is entirely redundant- delete the first message and <font color="red">close your tags! It's just lazy otherwise and it can cause problems later on. I'd find an example but my mind's gone blank...</font>
        world << "<small><font color = red><b>Death Info: <font color = blue>[src]/[key] has been killed by [usr]."
if(src.client)
world << "<small><font color = red><b>Death Info: <font color = blue>[src]/[key] has been killed by [usr]."



Also, judging from the way you've defined those three mob procedures in three different ways? Fairly obvious sign that you can't code, and every single line of code in your post was copy pasted from stuff other people have made.

Go learn!
In response to KillerGrand
Nope, you got it the wrong way round. The death_check should be from the perspective of the mob it belongs to- it should be checking src's health and deleting src. With all due respect Killer I don't think you really know enough to be giving people help just yet.

Sorry :(
In response to Elation
Well im still learning, also isnt (usr,src) the same thing.
if so then why would you be using [src]/[key] got killed by [usr].?
~Grand~
In response to Elation
ok i got all that but i still get the runtime error :(
In response to KillerGrand
src and key is showing the users name and the users key name/key next to each other
In response to Tomf and Tails5
Exactly the users name/key, usr = user <.<, so why should src = user also.
~Grand~
In response to KillerGrand
KillerGrand wrote:
Well im still learning, also isnt (usr,src) the same thing.

Nope.
What is usr?

if so then why would you be using [src]/[key] got killed by [usr].?

I don't- it's wrong. It should be "got killed by [M]." in this instance.
Page: 1 2 3