# ===input variables===
# seconds
# energy
# health
# hunger
# speed
# slope
# movement_mode: 0 = still, 1 = walking, 2 = running, 3 = fighting while not striking
# in_combat: 0 = no, 1 = yes
# avatar_is_carnivore: 0 = no, 1 = yes

# ===output variables===
# energy (will automatically clamp to the range 0-100)
# hunger (will automatically clamp to the range 0-100)
# health (will automatically clamp to the range 0-100)


# hunger has steady decay
if (avatar_is_carnivore==1) hunger = hunger - 0.35 * seconds endif
if (avatar_is_carnivore==0) hunger = hunger - 0.6 * seconds endif

if (movement_mode == 1 )
  energy = energy + 5 * seconds
endif

if (movement_mode == 2 )
    energy = energy - (4 * seconds)
endif

if (movement_mode == 3)
   energy = energy
endif

if (movement_mode == 0)
if (in_combat == 0)
    # charge energy when still, except when hunger is red
    if (hunger <= 10) energy = energy - 3 * seconds endif
    if (hunger > 10 and hunger <= 66) energy = energy + 10 * seconds endif
    if (hunger > 66) energy = energy + 10 * seconds endif  
endif  
endif

# creatures can starve to death
if (hunger <= 10) health = health - 1 * seconds endif