proc
Battle(attacker,defender)
var/damage
var/otherhit
var/otherdamage
sleep(10)
var/hit = rand(1,(attacker:attack[1] - defender:agility))
if(hit <= 1)
if(defender:defence > attacker:strength[1])
var/chance = rand(0,4)
if(chance == 1)
damage = rand(1,attacker:strength[1])
usr << "[defender] did [otherdamage] to you"
usr << "Your strength is to little to breach the defence"
else
damage = rand(1,(attacker:strength[1] - defender:defence))
usr << "You do [damage] to [defender]"
defender:health -= damage
else
usr << "You have missed"
ChkHealth(attacker,defender)
if(ChkHealth())
return
sleep(10)
otherhit = rand(1,(defender:attack - attacker:agility[1]))
if(otherhit <= 1)
if(attacker:defence[1] > defender:strength)
var/chance = rand(0,4)
if(chance == 1)
otherdamage = rand(1,defender:strength)
usr << "[defender] did [otherdamage] to you"
else
usr << "The enemys strength is to little to breach your defence"
else
otherdamage = rand(1,(defender:attack - attacker:defence[1]))
usr << "[defender] did [otherdamage] to you"
attacker:health -= otherdamage
else
usr << "[defender] has missed"
ChkHealth(attacker,defender)
if(ChkHealth())
return
Battle(attacker,defender)
ChkHealth(var/A,var/D)
if(A:health <= 0)
A << "[A] has died at the hands of [D]"
A:health = A:maxhealth[1]
A:loc = locate(1,1,1)
return 1
if(D:health <= 0)
A << "You have killed [D]"
del(D)
return 1
I have already defined the varibles in there in another piece of code. When I run this each time I loop though the battle system it comes up with this error:
runtime error: Cannot read null.health
proc name: ChkHealth (/mob/proc/ChkHealth)
usr: ADT_CLONE (/mob/player)
src: Rat (/mob/Rat)
call stack:
Rat (/mob/Rat): ChkHealth(null, null)
Rat (/mob/Rat): Battle(ADT_CLONE (/mob/player), Rat (/mob/Rat))
Rat (/mob/Rat): Attack()
Could someone please help me.[EDIT] this is how I run the proc:
verb
Attack()
set src in oview(1)
usr << "[usr],[src]"
Battle(usr,src)