# incoming variables
#########
# tree_cover = 1 or 0
# movement_mode: 0 = still, 1 = walking, 2 = running
#
# the following variables relate to the creature's current interaction
# they are 1 if the creature is in that interaction, and 0 otherwise
# creature_is_eating
# creature_is_scaring
# creature_is_grooming
# creature_is_mating
# creature_is_nesting - is the creature nesting?
# creature_is_building_nest - is the creature building a nest?
#
# group_size: the size of the group the creature is travelling with.
# For the avatar, and creatures in the avatar's possee, it is the size of 
# the avatar's possee.  For every other creature it is 1, since we don't 
# have a rigorous definition of group for those creatures.

####
#Visibility moderates the size of other creatures' vision perception rings 
#(visibility output multiplied by the perception distance)
##note: assumption is that perception radii in ini apply to walk. 
#'s further modded here for run and still.
#and all are modded by tree coverage and avatar stealth pts.
#####


#local var: stealth_factor takes in to account stealth points and tree cover

# if you're under a tree or have spent points on stealth, you're always quieter.
stealth_factor = 1 - ( 0.2 * stealth + 0.5 * tree_cover )
if (stealth_factor < 0) stealth_factor = 0 endif

# run is full strength
if (movement_mode == 2)
interaction_noise = 1.33
  endif

# walking is base level
  if( movement_mode == 1 )
interaction_noise = 1
  endif


# still, doing nothing
if (movement_mode == 0 )
interaction_noise = 0.666
   endif


if (creature_is_eating == 1)
interaction_noise = 1
endif

if (creature_is_scaring == 1)
interaction_noise = 2
endif

if (creature_is_grooming == 1)
interaction_noise = 1
endif

if (creature_is_mating == 1)
interaction_noise = 1.5
endif

if (creature_is_nesting == 1)
interaction_noise = 0.666
endif

if (creature_is_building_nest == 1)
interaction_noise = 1.5
endif

# Make each creature in the avatar's group slightly more 
# visible than if they were doing the same interaction alone.
  visibility = interaction_noise * stealth_factor * ((1+group_size)^0.5)
  

# a test to demonstrate the effects of having visibiltiy > 1
# visibility = visibility * 1.5

#####

# loudness impacts hearing circles (not vision)
loudness = 1/(1+0.5*stealth)
