ID:264300
 
Code:
mob
var
Stats
Health
New()
..()
Health = new(100)

Stats
var
Value = 0
maxValue = 0
New(n)
if(n)
Value = n
maxValue = n
proc
Add(n)
Value = min(max(Value+n,1),maxValue)

obj/Jutsu/Sand_Manipulator
icon = 'Sand Manipulator Jutsu.dmi'
Sand_Tsunami
icon_state = "Sand Tsunami"
density = 1
Bump(atom/A)
var/mob/O = Owner
if(ismob(A))
var/mob/M = A
var/dmg = O.Ninjutsu.Value*O.sandTsun
M.Health.Add(-dmg)
O.Dmg_Text(M,dmg,"Sand Tsunami")


Problem description:
Okay I read the whole guide thing on datums and I came up with a system like that. I figured I could use the Add() datum proc for subtraction as well. However when the obj bumps into a mob, it gives me the following runtime error.

runtime error: Cannot execute null.Add().
proc name: Bump (/obj/Jutsu/Sand_Manipulator/Sand_Tsunami/Bump)
usr: 0
src: Sand Tsunami (/obj/Jutsu/Sand_Manipulator/Sand_Tsunami)
call stack:
Sand Tsunami (/obj/Jutsu/Sand_Manipulator/Sand_Tsunami): Bump(Sand Clone (/mob/Clones/Sand_Clone))
Sand Tsunami (/obj/Jutsu/Sand_Manipulator/Sand_Tsunami): Move(Grass1 (9,4,1) (/turf/Terrains/Grass1), 8)

How is it null when I have it M.Health.Add()?
Do you have Health as a new instance or is it still null?
Health = new
In response to GhostAnime
Yeah sorry. Forgot to add that snippet.
mob
New()
..()
Health = new(100)


Updated OP.
Still need help >_>
Since Health is being initialized, the problem must be that although it's not null when the mob is first created, it's becoming null at a later point.

One culprit to look at might be your savefiles. If you have an old savefile it may be trying to load health directly into a var, while the datum it loads is null. If that is the case, then here is the solution: In Read(), after the default load, make sure the Health var is still valid and if not adjust it accordingly.

If it's not a savefile issue, I'd take a look around other parts of your code that may be manipulating mob.Health and see if maybe something is nulling it out.

Lummox JR
In response to Lummox JR
I'm using this in a test world where there is no savefiles going on. So it's not the savefile system.

I'm using a verb that creates a clone of myself and sets the clone's attributes (e.g. Health, Chakra, etc). Could that not be working properly?

mob/Clones/Sand_Clone
density = 1
New(loc,owner,dir)
..()
name = "[owner]"
dir = dir
Owner = owner
var/mob/O = Owner
icon = O.icon
flick("Sand Clone",src)
Health = O.Health.Value/(8-O.sandClon/2)
var/mob/T = O.Target
Clone_AI(T,O)
In response to Mizukouken Ketsu
If Health is a datum, then why are you setting it to a number in New()?

This line:

Health = O.Health.Value/(8-O.sandClon/2)


Obviously results in a number, not a datum. Create the Health datum first, then set its Value variable to that instead?