//tbg-mobs.dm
mob
var
HP = 1
DMG = 0
//tbg-combat.dm
mob/verb/attack(M as mob in oview(1))
usr << "You attack [M]!"
var/damage = rand(0,src.cAttack)
usr << "You dealt [damage] damage!"
M.HP -= damage
Problem description:
So I'm following along with this tutorial and I'm running into a problem with a variable being used in combat.
When I try to compile, the compiler says:
"tbg-combat.dm:5:error: M.HP: undefined var"
How can I fix this?
(Note: cAttack is a different variable from a different file, but it's not throwing an error so I'm not focusing on it.)
(Note: If you're asking why they're in separate files, another tutorial I was following organized the code for all their different parts (areas, turfs, objects, mobs, procs, etc.) into different files for organization, so I did the same. If this is the problem I can change it.)
Keep in mind though, DM won't prevent you from passing things of the wrong type, so if you for instance, passed an object to attack() instead of a mob, you'd get a runtime error about the variable not existing instead of a compile-time error. That's where things like istype() come in handy.