ID:146795
 
Context:
Welcome back to the game!
You initiate an attack on the bear.
You did 4 damage to the bear!
the bear did 2 damage to you!
runtime error: Cannot read null.Doing
proc name: AttackTwo (/mob/proc/AttackTwo)
source file: Procedures.dm,21
usr: Marlier (/mob/Player)
src: null
call stack:
AttackTwo(Marlier (/mob/Player), null)
Marlier (/mob/Player): Attack(null)
You initiate an attack on the bear.
You did 4 damage to the bear!
You have slain the bear!
runtime error: Cannot read null.attackDelay
proc name: AttackTwo (/mob/proc/AttackTwo)
source file: Procedures.dm,30
usr: Marlier (/mob/Player)
src: null
call stack:
AttackTwo(null, Marlier (/mob/Player))
AttackTwo(Marlier (/mob/Player), null)
Marlier (/mob/Player): Attack(null)
runtime error: Cannot modify null.Doing.
proc name: AttackTwo (/mob/proc/AttackTwo)
source file: Procedures.dm,23
usr: Marlier (/mob/Player)
src: null
call stack:
AttackTwo(Marlier (/mob/Player), null)
Marlier (/mob/Player): Attack(null)

Code:
mob
proc

//BEGIN ATTACK PROCEDURE
AttackTwo(mob/A,mob/D)
set background=1
if(istype(D,/mob/Attackable)) //If enemy
if(A.attackDelay >= 1)
return
A << "You initiate an attack on [D.Name]."
var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
if(youHitOrNot > D.Evasion)
var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
var/youDamageDone2 = youDamageDone - D.Toughness
if(youDamageDone2 < 1) youDamageDone2 = 1
D.HP -= youDamageDone2
A << "You did [youDamageDone2] damage to [D.Name]!"
A.deathCheck(D)
else
A << "You miss [D.Name]!"
if(D.Doing == 0) //ERROR
call(/mob/proc/AttackTwo)(D,A)
D.Doing = 1 //ERROR
A.attackDelay = A.AttackDelay
else if(istype(D,/mob/Player)) //If player
while(A)
while(D)
if(!D in oview(1,A)) break
WAIT
if(A.attackDelay >= 1) //ERROR
goto WAIT
var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
if(youHitOrNot > D.Evasion)
var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
var/youDamageDone2 = youDamageDone - D.Toughness
if(youDamageDone2 < 1) youDamageDone2 = 1
D.HP -= youDamageDone2
D << "[A.Name] did [youDamageDone2] damage to you!"
A.deathCheck(D)
else
D << "[A.Name] misses you!"
A.attackDelay = A.AttackDelay
break
A.Doing = 0
//END ATTACK PROCEDURE

Verb Code:
mob
Player
verb

//BEGIN ATTACK VERB
Attack(mob/M in oview(1))
set category="Verbs"
if(!istype(M,/mob/Attackable)&&!istype(M,/mob/Player))
return 0
call(/mob/proc/AttackTwo)(usr,M)
//END ATTACK VERB


Problem description: Read the context for errors, they happen as soon as it dies....

Spire8989 wrote:
Context:
> Welcome back to the game!
> You initiate an attack on the bear.
> You did 4 damage to the bear!
> the bear did 2 damage to you!
> runtime error: Cannot read null.Doing
> proc name: AttackTwo (/mob/proc/AttackTwo)
> source file: Procedures.dm,21
> usr: Marlier (/mob/Player)
> src: null
> call stack:
> AttackTwo(Marlier (/mob/Player), null)
> Marlier (/mob/Player): Attack(null)
> You initiate an attack on the bear.
> You did 4 damage to the bear!
> You have slain the bear!
> runtime error: Cannot read null.attackDelay
> proc name: AttackTwo (/mob/proc/AttackTwo)
> source file: Procedures.dm,30
> usr: Marlier (/mob/Player)
> src: null
> call stack:
> AttackTwo(null, Marlier (/mob/Player))
> AttackTwo(Marlier (/mob/Player), null)
> Marlier (/mob/Player): Attack(null)
> runtime error: Cannot modify null.Doing.
> proc name: AttackTwo (/mob/proc/AttackTwo)
> source file: Procedures.dm,23
> usr: Marlier (/mob/Player)
> src: null
> call stack:
> AttackTwo(Marlier (/mob/Player), null)
> Marlier (/mob/Player): Attack(null)
>

Code:
> mob
> proc
>
> //BEGIN ATTACK PROCEDURE
> AttackTwo(mob/A,mob/D)
> set background=1
> if(istype(D,/mob/Attackable)) //If enemy
> if(A.attackDelay >= 1)
> return
> A << "You initiate an attack on [D.Name]."
> var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
> if(youHitOrNot > D.Evasion)
> var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
> var/youDamageDone2 = youDamageDone - D.Toughness
> if(youDamageDone2 < 1) youDamageDone2 = 1
> D.HP -= youDamageDone2
> A << "You did [youDamageDone2] damage to [D.Name]!"
> A.deathCheck(D)
> else
> A << "You miss [D.Name]!"
> if(D.Doing == 0)
> call(/mob/proc/AttackTwo)(D,A)
> D.Doing = 1
> A.attackDelay = A.AttackDelay
> else if(istype(D,/mob/Player)) //If player
> while(A)
> while(D)
> if(!D in oview(1,A)) break
> WAIT
> if(A.attackDelay >= 1)
> goto WAIT
> var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
> if(youHitOrNot > D.Evasion)
> var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
> var/youDamageDone2 = youDamageDone - D.Toughness
> if(youDamageDone2 < 1) youDamageDone2 = 1
> D.HP -= youDamageDone2
> D << "[A.Name] did [youDamageDone2] damage to you!"
> A.deathCheck(D)
> else
> D << "[A.Name] misses you!"
> A.attackDelay = A.AttackDelay
> break
> A.Doing = 0
> //END ATTACK PROCEDURE
>

Verb Code:
> mob
> Player
> verb
>
> //BEGIN ATTACK VERB
> Attack(mob/M in oview(1))
> set category="Verbs"
> if(!istype(M,/mob/Attackable)&&!istype(M,/mob/Player))
> return 0
> call(/mob/proc/AttackTwo)(usr,M)
> //END ATTACK VERB
>

Problem description: Read the context for errors, they happen as soon as it dies....


Uhhh could you place in comments which lines in the code the errors took place on?
In response to Green Lime
I did, check now...
ok lets see now hmm according the the call stack.

call stack:
AttackTwo(Marlier (/mob/Player), null)
Marlier (/mob/Player): Attack(null)


Right so M = null cause it just said so its calling null as D for the AttackTwo() proc. Right? right.

Thats where those errors are coming from. As for your if statement to end your verb. Im not sure why thats not working O.o

Why not do this, get rid of the ! operators. Then just,
if(istype(M,/mob/Attackable)&&istype(M,/mob/Player))

Then just stick the call statement in the if.
In response to Green Lime
Green Lime wrote:
ok lets see now hmm according the the call stack.

call stack:
AttackTwo(Marlier (/mob/Player), null)
Marlier (/mob/Player): Attack(null)


Right so M = null cause it just said so its calling null as D for the AttackTwo() proc. Right? right.

Thats where those errors are coming from. As for your if statement to end your verb. Im not sure why thats not working O.o

Why not do this, get rid of the ! operators. Then just,
if(istype(M,/mob/Attackable)||istype(M,/mob/Player)) You mean this right?
if(istype(M,/mob/Attackable)&&istype(usr,/mob/Player)) Or this?

Then just stick the call statement in the if.
In response to Spire8989
Usr should not be in procs. Read Dream Tutor: usr Unfriendly by Lummox Jr.


Whoops, that is a verb. Still you are using usr as an arguement in call() and I don't think that is wise =P.
In response to N1ghtW1ng
I have had many many problems with usr in procs, Ive been programming in Byond for around a year. I know to take it out of procs. But I don't know about in call statements...
In response to Spire8989
When I change to this:

//BEGIN ATTACK PROCEDURE
AttackTwo(var/mob/A,var/mob/D)
set background=1
if(istype(D,/mob/Attackable)) //If enemy
if(A.attackDelay >= 1)
return
A << "You initiate an attack on [D.Name]."
var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
if(youHitOrNot > D.Evasion)
var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
var/youDamageDone2 = youDamageDone - D.Toughness
if(youDamageDone2 < 1) youDamageDone2 = 1
D.HP -= youDamageDone2
A << "You did [youDamageDone2] damage to [D.Name]!"
A.deathCheck(D)
else
A << "You miss [D.Name]!"
if(D.Doing == 0) //ERROR
call(/mob/proc/AttackTwo)(D,A)
D.Doing = 1 //ERROR
A.attackDelay = A.AttackDelay
else if(istype(D,/mob/Player)) //If player
while(A)
while(D)
usr << "HERE"
if(!D in oview(1,A)) break
usr << "HERE2"
WAIT
if(A.attackDelay >= 1) //ERROR
usr << "STUCK!!!!!"
goto WAIT
usr << "HERE3"
var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
if(youHitOrNot > D.Evasion)
var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
var/youDamageDone2 = youDamageDone - D.Toughness
if(youDamageDone2 < 1) youDamageDone2 = 1
D.HP -= youDamageDone2
D << "[A.Name] did [youDamageDone2] damage to you!"
A.deathCheck(D)
else
D << "[A.Name] misses you!"
A.attackDelay = A.AttackDelay
break
A.Doing = 0
//END ATTACK PROCEDURE


It just repeats STUCK!!! over and over and i have to CTRL + ALT + DEL. So here is my update attackdelay, is this bad?

world
name = "The Wilderness"
view = 6
hub="Spire8989.wilderness"
New()
while(1)
sleep(10)
UpdateDelays()
..()
proc
UpdateDelays()
for(var/mob/M in world)
if(M.attackDelay > 0)
M.attackDelay -= 1
if(M.attackDelay < 0)
M.attackDelay = 0
                    A << "You did [youDamageDone2] damage to [D.Name]!"
A.deathCheck(D)
else
A << "You miss [D.Name]!"
if(D.Doing == 0) //ERROR
call(/mob/proc/AttackTwo)(D,A)
D.Doing = 1 //ERROR


You're calling deathCheck() and then checking D.Doing, do you delete NPCs in deathCheck()?
In response to YMIHere
yes I do actually, if they have hp <= 0.....
In response to Spire8989
Well, that's why it's null. Just don't check it's variables if it's null. =)
In response to YMIHere
YMIHere wrote:
>                     
> A.deathCheck(D)
> else
> A << "You miss [D.Name]!"
> if(D.Doing == 0) //ERROR
> call(/mob/proc/AttackTwo)(D,A)
> D.Doing = 1 //ERROR
>

You're calling deathCheck() and then checking D.Doing, do you delete NPCs in deathCheck()?

So should i try this?

                    A.deathCheck(D)
else
A << "You miss [D.Name]!"
if(D)
if(D.Doing == 0)
call(/mob/proc/AttackTwo)(D,A)
D.Doing = 1 //ERROR
In response to YMIHere
Look up a little...
And down...
In response to Spire8989
Sure, as long as you indent the other two lines with it. You could also just check if(D && !D.Doing) in one if().
In response to YMIHere
Yeah, it looked odd to me. And i indented before you posted if you look again. I think that's fixed. But what about the delay error?
In response to Spire8989
                        WAIT
if(A.attackDelay >= 1) //ERROR
usr << "STUCK!!!!!"
goto WAIT


You're not sleep()ing at all here, which doesn't seem like a good idea, even with this proc in the background. You can use a while to make it more readable too. Also, that while(A) is pretty useless if you're going to break out of that loop after the first run. Just use if(A).

                        while(A.attackDelay >= 1) //ERROR
usr << "STUCK!!!!!"
sleep(10)


Now, where you change the attackDelay, are you aware that that proc doesn't loop? It only runs once to change your delay, and if that and this proc are the only places you change it then this loop will never quit.

*Edit
There's definitely a better way to handle delays than a constant looping proc of course.
In response to YMIHere
you managed to confuse me....please try to rephrase :(

I did: Just use if(A).
In response to Spire8989
tyvm by the way, now the bear continues to fight back like it's supposed to...
Code:
mob
proc

//BEGIN ATTACK PROCEDURE
AttackTwo(mob/A,mob/D)
set background=1
if(istype(D,/mob/Attackable)) //If enemy
if(A.attackDelay >= 1)
return 0
A << "You initiate an attack on [D.Name]."
var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
if(youHitOrNot > D.Evasion)
var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
var/youDamageDone2 = youDamageDone - D.Toughness
if(youDamageDone2 < 1) youDamageDone2 = 1
D.HP -= youDamageDone2
A << "You did [youDamageDone2] damage to [D.Name]!"
A.deathCheck(D)
else
A << "You miss [D.Name]!"
if(D && D.Doing == 0)
call(/mob/proc/AttackTwo)(D,A)
D.Doing = 1 //ERROR
A.attackDelay = A.AttackDelay
else if(istype(D,/mob/Player)) //If player
if(A)
while(D)
usr << "HERE"
if(!D in oview(1,A)) break
usr << "HERE2"
while(A.attackDelay >= 1) //ERROR
sleep(10)
usr << "HERE3"
var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
if(youHitOrNot > D.Evasion)
var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
var/youDamageDone2 = youDamageDone - D.Toughness
if(youDamageDone2 < 1) youDamageDone2 = 1
D.HP -= youDamageDone2
D << "[A.Name] did [youDamageDone2] damage to you!"
A.deathCheck(D)
else
D << "[A.Name] misses you!"
A.attackDelay = A.AttackDelay
if(A) A.Doing = 0
//END ATTACK PROCEDURE


Errors:
runtime error: Cannot read null.attackDelay
proc name: AttackTwo (/mob/proc/AttackTwo)
source file: Procedures.dm,32
usr: TEST (/mob/Player)
src: null
call stack:
AttackTwo(null, TEST (/mob/Player))
AttackTwo(TEST (/mob/Player), null)
TEST (/mob/Player): Attack(null)
runtime error: Cannot modify null.Doing.
proc name: AttackTwo (/mob/proc/AttackTwo)
source file: Procedures.dm,23
usr: TEST (/mob/Player)
src: null
call stack:
AttackTwo(TEST (/mob/Player), null)
TEST (/mob/Player): Attack(null)
runtime error: Cannot read null.attackDelay
proc name: AttackTwo (/mob/proc/AttackTwo)
source file: Procedures.dm,32
usr: TEST (/mob/Player)
src: null
call stack:
AttackTwo(null, TEST (/mob/Player))
AttackTwo(TEST (/mob/Player), null)
TEST (/mob/Player): Attack(null)
runtime error: Cannot modify null.Doing.
proc name: AttackTwo (/mob/proc/AttackTwo)
source file: Procedures.dm,23
usr: TEST (/mob/Player)
src: null
call stack:
AttackTwo(TEST (/mob/Player), null)
TEST (/mob/Player): Attack(null)
In response to Spire8989
I fixed it all, thank god. Here is my code:

mob
proc

//BEGIN ATTACK PROCEDURE
AttackTwo(mob/A,mob/D)
set background=1
if(istype(D,/mob/Attackable)) //If enemy
if(A.attackDelay >= 1)
return 0
A.attackDelay = A.AttackDelay
A << "You initiate an attack on [D.Name]."
var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
if(youHitOrNot > D.Evasion)
var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
var/youDamageDone2 = youDamageDone - D.Toughness
if(youDamageDone2 < 1) youDamageDone2 = 1
D.HP -= youDamageDone2
A << "You did [youDamageDone2] damage to [D.Name]!"
A.deathCheck(D)
else
A << "You miss [D.Name]!"
if(D && D.Doing == 0)
D.Doing = 1
call(/mob/proc/AttackTwo)(D,A)
else if(istype(D,/mob/Player)) //If player
if(A)
while(D)
if(!D in oview(1,A)) break
while(A && A.attackDelay >= 1)
sleep(10)
if(!A) return
var/youHitOrNot = rand(A.Rogueness+2,D.Evasion-2)
if(youHitOrNot > D.Evasion)
var/youDamageDone = rand((A.Strength / A.Level) + 1,(A.Strength / A.Level) + 3)
var/youDamageDone2 = youDamageDone - D.Toughness
if(youDamageDone2 < 1) youDamageDone2 = 1
D.HP -= youDamageDone2
D << "[A.Name] did [youDamageDone2] damage to you!"
A.deathCheck(D)
else
D << "[A.Name] misses you!"
A.attackDelay = A.AttackDelay
if(A) A.Doing = 0
//END ATTACK PROCEDURE
Spire8989 wrote:
call(/mob/proc/AttackTwo)(usr,M)

This is a bogus use of call(). The point of call() is to use it when you don't exactly know which proc you're going to call. In this case, you should be calling it this way:
AttackTwo(usr, M)

That's it. Nothing fancy.

Lummox JR
Page: 1 2