var
helm = 0
shirt = 0
pants = 0
armorbonus = 0
attackbonus = 0
Health = 50
Maxhealth = 50
verb
Attack(M as mob in oview(1))
var/attack = rand(1,20)
var/defence = rand(1,20)
attack += usr.attackbonus
defence += M.armorbonus
if(attack >= defence)
M.Health -= attack
oview(6)<<"[usr] hits [M] for [attack] damage!"
else
oview(6)<<"[M] blocks [usr]'s attack!"
Problem description:
For some reason when i compile this i get error that say
error:M.armorbonus:undefined var
error:M.Health:undefined var
Why is this happening?
It's happening because the compiler doesn't know that M is a mob. "M as mob" tells DreamSeeker to give you a list of mobs only, but the compiler ignores it.
Instead, put "mob/M as mob". The mob/M part tells the compiler the M is a variable of type /mob (that has variables like Health), and the as mob part tells DreamSeeker to give you the list of mobs when you click the verb.