mob/verb
Attack(mob/M as mob in get_step(usr,usr.dir))
set category = ("Commands")
var/damage
flick("attack",usr)
flick(damage,usr)
usr.Deathcheck()
if(usr.level >=100)
damage = rand(1,350) + usr.str - M.def
else
if(usr.level >=75)
damage = rand(1,275) + usr.str - M.def
else
if(usr.level >=50)
damage = rand(1,200) + usr.str - M.def
else
if(usr.level >=25)
damage = rand(1,100) + usr.str - M.def
else
if(usr.level >=10)
damage = rand(1,50) + usr.str - M.def
else
if(usr.level >=5)
damage = rand(1,20) + usr.str - M.def
else
if(usr.level <=5)
damage = rand(1,10) + usr.str - M.def
if(usr.doing==0)
if(istype(M, /mob/npc))
usr<<"YOU CANT ATTACK A NPC"
return
if(istype(M, /mob/pet))
usr<<"YOU CANT ATTACK A NPC"
return
else
if(damage <= 0)
if(istype(M, /mob/anisters/))
M.Attack2()
else
usr.doing=1
usr<<"You start attacking [M]"
sleep(5)
M<<"[src] attacks you"
M << "You dodge [src]'s attack."
usr<<"[M] dodges your attack."
usr.doing=0
else
if(usr.doing==0)
usr.doing=1
usr<<"You start to attack [M]"
sleep(5)
M.hp -= damage
usr.doing=0
M<<"[src] attacks you!"
usr<< "[src] attacks [M] with [damage] damage!"
if(istype(M, /mob/anisters/))
M.Attack2()
M.Deathcheck()
usr.doing=0
usr.BarCheck()
M.BarCheck()
mob
proc
Attack2(mob/M as mob in get_step(usr,usr.dir))
var/damage2
if(usr.level >=100)
damage2 = rand(120,350) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=75)
damage2 = rand(75,275) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=50)
damage2 = rand(40,200) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=20)
damage2 = rand(25,100) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=10)
damage2 = rand(5,50) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=6)
damage2 = rand(5,20) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level <=5)
damage2 = rand(1,10) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
Problem description:
i keep getting the following error on DD
____
runtime error: Cannot modify null.doing.
proc name: Deathcheck (/mob/proc/Deathcheck)
source file: battle.dm,303
usr: null
src: Moungral (/mob/anisters/Moungral)
call stack:
Moungral (/mob/anisters/Moungral): Deathcheck()
Moungral (/mob/anisters/Moungral): Attack2(null)
Attack(Moungral (/mob/anisters/Moungral))
runtime error: Cannot modify null.doing.
proc name: Attack2 (/mob/proc/Attack2)
source file: battle.dm,183
usr: null
src: Moungral (/mob/anisters/Moungral)
call stack:
Moungral (/mob/anisters/Moungral): Attack2(null)
Attack(Moungral (/mob/anisters/Moungral))
______
it happens on more than one monster. please help
You always use src. I also recommend: using Boolean logic (there's a section in the DM guide devoted to it!), modular coding (I wrote an article on it for dream makers, as did Iain Peregrine), and you should use a formula instead of that long else if chain! Formulas are much more dynamic and offer much better, consistent damage calculation.