ID:179114
 
OK im haveing more problems with my battle system. when someone walks up to the monster they are fighting, and click the Battle verb, it just makes it so they cant move, and doesnt do what its supposed to do. Here is the error i get.

runtime error: Cannot read null.defence.
proc name: Battle2 (/mob/proc/Battle2)
source file: NewBattleSystem.dm,24
usr: *Anti-dbz73 (/mob)
src: *Anti-dbz73 (/mob)
call stack:
*Anti-dbz73 (/mob): Battle2(null)
*Anti-dbz73 (/mob): Battle(the fly (/mob/fly))

Here is the fly's code

mob
fly
icon='fly.dmi'
HP = 50
attack=8
wealth = 20
defence=5
exp = 10
InBattle = 0
CanMove=1
var/tmp
next_walk_time // When is the next time for us to walk?
walking_delay = 10 // How long between movement?
movement_percent = 50 // What percentage of the time should it move?


base_EventCycle()
// This gets called once each tick.

if (next_walk_time <= world.time)
// It's time to walk if we want to.
// There is a movement_percent chance that we will walk.
if (prob(movement_percent))
if(src.CanMove==1)
step_rand(src)

// Set the next walk time.
next_walk_time = world.time + walking_delay
return


and here is the battle code.

mob
var
CanMove = 1
verb
Battle(mob/M as mob in oview(1))
if(M.client==null)
if(usr.InBattle==0)
if(M.InBattle==0)
usr.CanMove = 0
usr.InBattle = 1
M.CanMove = 0
M.InBattle = 1
usr:Battle2()
else
usr << "[M] is currently battling."
else
usr << "You is currently battling."
else
usr << "We currently dont allow Player Fighting Outside the Arena"

// Start the battle code

mob/proc/Battle2(mob/M as mob in oview(1))
var/damage = usr.attack-M.defence //assign a random # to a new variable
var/colour = "red"
if(damage>=1)
s_damage(damage,colour,M)
M.HP -= damage //take away the damage from M
M:DeathCheck() //check for death with a proc
usr:Battle3()
if(damage<=0)
usr << "You are to week to hurt [M]."
usr:Battle3()

mob/proc/Battle3(mob/M as mob in oview(1))
var/Mdamage = M.attack - usr.defence
var/colour = "red"
if(Mdamage>=1)
s_damage(Mdamage,colour,usr)
usr.HP -= Mdamage //take away the damage from M
usr:MonsterKill() //check for death with a proc
sleep(20)
usr:Battle2()
if(Mdamage<=0)
usr << "[M]'s hit bounces off harmlessly."
sleep(20)
usr:Battle2()

// making them not be able then able to move code
client
Move()
if(usr.CanMove == 1)
..()
else
return 0

Thanks!

~~dbz73~~
NOT a dbz game maker.