#This formula is responsible for determining how many creatures are spawned or lost due to city happiness

Time_Since_Last_Creature_Created = Time_Since_Last_Creature_Created + Time_Since_Last_Execution_In_Seconds

Add_Creatures = 0

if (Average_Happiness >= 40)
if (Average_Happiness < 50)
  if (Time_Since_Last_Creature_Created > 125)
	Time_Since_Last_Creature_Created = 0
    Add_Creatures = 1
  endif
endif
endif


if (Average_Happiness >= 50)
if (Average_Happiness < 60)
  if (Time_Since_Last_Creature_Created > 75)
	Time_Since_Last_Creature_Created = 0
    Add_Creatures = 1
  endif
endif
endif


if (Average_Happiness >= 60)
if (Average_Happiness < 70)
  if (Time_Since_Last_Creature_Created > 50)
	Time_Since_Last_Creature_Created = 0
    Add_Creatures = 1
  endif
endif
endif



if (Average_Happiness >= 70)
if (Average_Happiness < 80)
  if (Time_Since_Last_Creature_Created > 25)
	Time_Since_Last_Creature_Created = 0
    Add_Creatures = 1
  endif
endif
endif




if (Average_Happiness >= 80)
if (Average_Happiness < 90)
  if (Time_Since_Last_Creature_Created > 10)
	Time_Since_Last_Creature_Created = 0
    Add_Creatures = 1
  endif
endif
endif




if (Average_Happiness >= 90)
  if (Time_Since_Last_Creature_Created > 5)
	Time_Since_Last_Creature_Created = 0
    Add_Creatures = 1
  endif
endif


#Creature_Population = Creature_Population

#defines how population effects by subtracting time from the birth rate
#MaxPopulationAffect = 8
#PopulationBirthEffect = (Creature_Population / 100) * MaxPopulationAffect

# This is how long it takes for a creature to be born when happiness is at or above threshold
#MinSecondsPerBirth = 18 - PopulationBirthEffect

# Creatures won't be born if average happiness is below this threshold
#HappinessThreshold = 45

# make happiness negative when it is below the threshold
#Average_Happiness = Average_Happiness + HappinessThreshold - 100

# birthrate is 1 when happiness is at or above the threshold
#Add_Creatures = (deltaT * Average_Happiness) / (MinSecondsPerBirth * HappinessThreshold )

