// this script was compiled with wurst 1.7.0.0-jenkins-Wurst-597
globals
integer AI_STATE_AGGRESSIVE=0
integer AI_STATE_RETREAT=0
integer AI_BEAST_ID=0
integer AI_THUNDER_CD=0
player AI_tempPlayer=null
unit AI_tempUnit=null
group AI_grp=null
unit AI_hunterLeader=null
real AI_CLOCK_PERIOD=0.
player array AI_players
integer AI_count=0
timer AI_clock=null
real Basics_ANIMATION_PERIOD=0.
string BeastAttack_FX=null
string BeastAttack_BLOOD_FX=null
string BeastAttack_THUNDER_FX_BIG=null
string BeastAttack_THUNDER_FX=null
integer BeastAttack_DOT_EXCLUSIVITY=0
integer BeastAttack_THUNDER_EXCLUSIVITY=0
integer BeastAttack_STUDDED_LEATHER_ID=0
real BeastAttack_BASE_DAMAGE=0.
real BeastAttack_LEATHER_DAMAGE_REDUCTION=0.
real BeastAttack_DAMAGE_PER_SECOND=0.
real BeastAttack_DOT_DURATION=0.
real BeastAttack_THUNDER_DURATION=0.
real BeastAttack_THUNDER_BONUS_MULTIPLIER=0.
real BinocularVision_CLOCK_PERIOD=0.
real BinocularVision_OFFSET=0.
real BinocularVision_RADIUS=0.
fogmodifier array BinocularVision_lSight
integer Blink_BLINK_ID=0
string CameraControl_FILTER_MASK=null
timer CameraControl_hunterFadeContinueTimer=null
timer CameraControl_hunterFadeFinishTimer=null
timer CameraControl_beastFadeContinueTimer=null
timer CameraControl_beastFadeFinishTimer=null
string Cinematic_TIP_SOUND=null
string Cinematic_START_SOUND=null
string Cinematic_TITLE_ONE=null
string Cinematic_TITLE_TWO=null
string Cinematic_TITLE_THREE=null
string Cinematic_TITLE_BEAST_ONE=null
string Cinematic_TITLE_BEAST_TWO=null
string Cinematic_TITLE_BEAST_THREE=null
string Cinematic_HUMAN_INTRO_TEXT=null
string Cinematic_FORTRESS_EXPOSITION=null
string Cinematic_TOWNS_EXPOSITION=null
string Cinematic_CLASS_DIVIDE_EXPOSITION=null
string Cinematic_EXPOSITION_BEAST_SITUATION=null
string Cinematic_HUNTERS_HALL_EXPOSITION=null
string Cinematic_HUNTER_COMPARISON=null
string Cinematic_RUNE_LOCATION_EXPOSITION=null
string Cinematic_ROUND_OBJECTIVE_EXPLANATION=null
string Cinematic_HUMAN_PROPERTIES=null
string Cinematic_BEAST_TELEPATHY=null
string Cinematic_HOW_TO_SHOOT=null
real Cinematic_MINIMAP_X=0.
real Cinematic_MINIMAP_Y=0.
real Cinematic_MINIMAP_AOA=0.
real Cinematic_MINIMAP_DISTANCE=0.
real Cinematic_FARM_X=0.
real Cinematic_FARM_Y=0.
real Cinematic_FARM_AOA=0.
real Cinematic_FARM_DISTANCE=0.
real Cinematic_FARM_ROTATION=0.
real Cinematic_FOREST_X=0.
real Cinematic_FOREST_Y=0.
real Cinematic_FOREST_AOA=0.
real Cinematic_FOREST_DISTANCE=0.
real Cinematic_CASTLE_X=0.
real Cinematic_CASTLE_Y=0.
real Cinematic_NORTH_X=0.
real Cinematic_NORTH_Y=0.
real Cinematic_SOUTH_X=0.
real Cinematic_SOUTH_Y=0.
real Cinematic_MTN_X=0.
real Cinematic_MTN_Y=0.
real Cinematic_HALL_X=0.
real Cinematic_HALL_Y=0.
real Cinematic_RED_X=0.
real Cinematic_RED_Y=0.
sound Cinematic_tipSound=null
sound Cinematic_startSound=null
timer Cinematic_humanClock=null
timer Cinematic_beastClock=null
unit Cinematic_farmer=null
unit Cinematic_farmer2=null
unit Cinematic_primative=null
unit Cinematic_attackTarget=null
unit Cinematic_hunter=null
unit Cinematic_hunter2=null
unit Cinematic_corpse=null
unit Cinematic_beast=null
item Cinematic_dummyItem=null
unit Cinematic_gatherer=null
unit Cinematic_gatherer2=null
unit Cinematic_gatherer3=null
destructable Cinematic_gatherTarget=null
unit Cinematic_robed=null
unit Cinematic_robed2=null
unit Cinematic_deer=null
unit Cinematic_coolBeast=null
unit Cinematic_coolBeast2=null
unit Cinematic_coolBeast3=null
unit Cinematic_demoHunter=null
unit Cinematic_demoHunter2=null
integer Cinematic_stopwatch=0
integer Cinematic_stopwatch2=0
weathereffect Cinematic_wfx=null
fogmodifier array Cinematic_fm
boolean Cinematic_enabled=false
boolean Cinematic_over=false
integer Colors_decs=0
real DamageOverTime_CLOCK_PERIOD=0.
integer DamageOverTime_FX_FLAG_ATTACH=0
integer DamageOverTime_FX_FLAG_COORDS=0
integer array DamageOverTime_dotDB
integer DamageOverTime_dbIndex=0
timer DamageOverTime_time=null
unit array DotData_source
unit array DotData_target
real array DotData_dps
real array DotData_duration
string array DotData_fx
integer array DotData_fxFlag
integer array DotData_exFlag
boolean DamageType_USE_BONUS_CALCULATOR=false
integer DamageType_DAMAGE_TYPE_CHECK_ID=0
integer DamageType_NULLED=0
integer DamageType_ATTACK=0
integer DamageType_SPELL=0
integer DamageType_CODE=0
attacktype DamageType_ATTACK_TYPE_UNIVERSAL=null
real DamageType_DELAY_AMOUNT=0.
integer DamageType_lastDamageType=0
unit array DelayDat_target
unit array DelayDat_source
real array DelayDat_damage
integer DummyUnitStack_DUMMY_UNIT_ID=0
integer DummyUnitStack_MIN_PRELOAD_BLOCK_SIZE=0
integer DummyUnitStack_PRELOAD_INIT_COUNT=0
boolean DummyUnitStack_DO_PIC=false
integer DummyUnitStack_DYNAMIC_DEFERRED_PRELOAD_COUNT=0
boolean DummyUnitStack_DO_DDPC=false
integer DummyUnitStack_INITIAL_DEFERRED_PRELOAD_COUNT=0
boolean DummyUnitStack_DO_IDPC=false
integer DummyUnitStack_MAX_PRELOADED_UNITS=0
boolean DummyUnitStack_DO_MPU=false
real DummyUnitStack_SAFE_LOC_X=0.
real DummyUnitStack_SAFE_LOC_Y=0.
real DummyUnitStack_CLOCK_PERIOD=0.
unit array DummyUnitStack_dummyStack
integer DummyUnitStack_stackIndex=0
integer DummyUnitStack_deferredTodoCount=0
timer DummyUnitStack_clock=null
unit array UnitAlloc_u
integer ErrorHandling_MUTE_ERROR_DURATION=0
integer ErrorHandling_PRIMARY_ERROR_KEY=0
timer GameTimer_gameTimer=null
real GameTimer_currentTime=0.
string Game_WIN_SOUND=null
string Game_DEF_SOUND=null
string Game_BEAST_VICTORY=null
string Game_HUNTER_VICTORY=null
real Game_BEAST_PLACE_OFFSET=0.
real Game_VICTORY_SOUND_DELAY=0.
integer Game_TEAM_HUNTERS=0
integer Game_TEAM_BEASTS=0
real Game_POST_ROUND_DELAY=0.
real Game_POST_GAME_DELAY=0.
real Game_START_DELAY=0.
integer Game_ROUND_DURATION=0
timer Game_postRoundTimer=null
integer Game_roundsToWin=0
boolean array Game_escapesPressed
boolean Game_singlePlayer=false
boolean Game_roundEnabled=false
integer HeroDeath_CONTRACT_ID=0
integer HeroDeath_GOLD_BONUS=0
integer HeroDeath_GOLD_BONUS_LESSER=0
integer HeroDeath_MAJOR_CONTRACT_BONUS=0
integer HeroDeath_MINOR_CONTRACT_BONUS=0
real HunterAttack_SPREAD_ARC=0.
real HunterAttack_JITTER=0.
real HunterAttack_SEPARATION_ARC=0.
real HunterAttack_SEPARATION_RADIUS=0.
real HunterAttack_AUTO_RATE=0.
real HunterAttack_POST_BURST_DELAY=0.
integer HunterAttack_BURST_ID=0
integer HunterAttack_logicalClock=0
unit array attacker
real array AutoDat_uX
real array AutoDat_uY
real array AutoDat_tX
real array AutoDat_tY
unit array AutoDat_attacker
integer array AutoDat_logicalSecret
real HunterCamera_CLOCK_PERIOD=0.
real HunterCamera_OFFSET_STATIC=0.
real HunterCamera_OFFSET_JITTER=0.
real HunterCamera_OFFSET_DYNAMIC=0.
real HunterCamera_JITTER_THRESHOLD=0.
integer HunterCamera_KERNEL_SIZE=0
real array HunterCamera_kernel
integer array HunterCamera_kernelIndex
string HunterToggle_TOGGLE_SOUND=null
integer HunterToggle_TOGGLE_ID=0
integer HunterToggle_BURST_ID=0
integer HunterToggle_AUTO_ID=0
string Initialization_ORB_FX=null
boolean Initialization_SINGLEPLAYER_ADD_AI=false
integer Initialization_PILLAR_GROUP_COUNT=0
integer Initialization_PILLAR_GROUP_COUNT_BEAST_SPAWN=0
integer Initialization_PILLARS_PER_GROUP=0
integer Initialization_OBELISK_ID=0
integer Initialization_HUNTER_STARTING_GOLD=0
real Initialization_PHASE=0.
real Initialization_OBELISK_FACING_PHASE=0.
real Initialization_GROUP_SEPARATION_ANGLE=0.
real Initialization_RADIUS=0.
real Initialization_RADIUS2=0.
real Initialization_OBELISK_PATH_RADIUS=0.
real Initialization_PATH_ITERATE_SIZE=0.
real Initialization_ORB_HEIGHT=0.
group Initialization_grp=null
real Initialization_tempX=0.
real Initialization_tempY=0.
trigger Initialization_diaClick=null
dialog Initialization_dialo=null
button array Initialization_btns
timer Initialization_voteTimer=null
integer Initialization_votesCounted=0
integer ItemFieldConditioningKit_DUST_ID=0
integer ItemFieldConditioningKit_COMBAT_TIME=0
integer ItemFieldConditioningKit_damageTimings=0
integer Knife_KNIFE_ID=0
string Knife_FX=null
string Knife_FX_PROC=null
string Knife_FX_EXPLODED=null
string Knife_FX_PROC_ATTACH_POINT=null
real Knife_OFFSET=0.
real Knife_EFFECT_HEIGHT=0.
real Knife_FX_DURATION=0.
real Knife_RADIUS=0.
real Knife_EXECUTE_MAX_HEALTH=0.
real Knife_BASE_DAMAGE=0.
real Knife_SHORT_COOLDOWN=0.
group Knife_grp=null
unit array DummyAlloc_u
boolean MagicFunctions_compiletime=false
real Math_DELTA=0.
real Maths_PI=0.
real MinimapVisionHints_CLOCK_PERIOD=0.
real MinimapVisionHints_RADIUS=0.
real MinimapVisionHints_CHECK_RADIUS=0.
fogmodifier array MinimapVisionHints_hints
multiboard MultiboardControl_mb=null
timer MultiboardControl_time=null
integer array Chord_first
integer array Chord_last
integer array Chord_next
integer Muscii_dbIndex=0
integer array Muscii_first
integer array Muscii_last
integer array Muscii_iterator
real array Muscii_tempo
timer array Muscii_clock
integer array Muscii_count
integer array Muscii_queueCount
integer array Muscii_cbf
integer array Muscii_queued
string array Note_path
integer array Note_volume
real array Note_pitch
integer array Note_next
string Music_HI_HAT_HIT_CLOSED=null
string Music_TOM_1_HIT=null
string Music_TOM_4_HIT=null
integer Music_m=0
integer Music_v=0
string Net_NET_FX=null
string Net_NET_MODEL=null
integer Net_NET_ID=0
integer Net_NET_SLOW_ID=0
integer Net_EXCLUSIVITY_NET=0
real Net_RADIUS=0.
real Net_CLOCK_PERIOD=0.
real Net_NET_VELOCITY=0.
real Net_COLLISION_RADIUS=0.
real Net_MAX_DISTANCE=0.
group Net_grp=null
timer Net_clock=null
integer array Net_dataDb
integer Net_dbIndex=0
real array NetData_delX
real array NetData_delY
real array NetData_distance
unit array NetData_dummy
effect array NetData_attached
player array NetData_caster
string OrganicConcatenation_IMAGE_SOUND=null
integer OrganicConcatenation_CONCATENATION_ID=0
integer OrganicConcatenation_BEAST_ILLUSION_ID=0
real OrganicConcatenation_DURATION=0.
real OrganicConcatenation_RANGE=0.
real OrganicConcatenation_PHASE_OFFSET=0.
real OrganicConcatenation_CLOCK_PERIOD=0.
integer array OrganicConcatenation_ddStack
integer OrganicConcatenation_ddIndex=0
timer OrganicConcatenation_clock=null
real array DuplicateDat_uX
real array DuplicateDat_uY
real array DuplicateDat_face
real array DuplicateDat_f0
real array DuplicateDat_f1
real array DuplicateDat_timeLeft
real array DuplicateDat_axis
real array DuplicateDat_dist
unit array DuplicateDat_image0
unit array DuplicateDat_image1
unit array DuplicateDat_image2
unit array DuplicateDat_image3
unit array DuplicateDat_tU
unit array DuplicateDat_friend
string OrganicHemisection_IMAGE_SOUND=null
integer OrganicHemisection_HEMISECTION_ID=0
integer OrganicHemisection_BEAST_ILLUSION_ID=0
real OrganicHemisection_DURATION=0.
real OrganicHemisection_OFFSET=0.
real OrganicHemisection_PHASE_OFF=0.
real OrganicHemisection_CLOCK_PERIOD=0.
real OrganicHemisection_PHASE_MULTIPLIER=0.
integer array OrganicHemisection_ddStack
integer OrganicHemisection_ddIndex=0
timer OrganicHemisection_clock=null
real array DuplicateDat_uX_2
real array DuplicateDat_uY_2
real array DuplicateDat_face_2
real array DuplicateDat_timeLeft_2
unit array DuplicateDat_image0_2
unit array DuplicateDat_image1_2
unit array DuplicateDat_image2_2
unit array DuplicateDat_tU_2
string PedestalReceive_DUMMY_MODEL=null
string PedestalReceive_EFFECT_MODEL=null
string PedestalReceive_RUNE_SECURED=null
integer PedestalReceive_SPAWN_COUNT=0
real PedestalReceive_ENUM_EPSILON=0.
real PedestalReceive_TARGET_PILLAR_LEFT_x=0.
real PedestalReceive_TARGET_PILLAR_LEFT_y=0.
real PedestalReceive_TARGET_PILLAR_LEFT_z=0.
real PedestalReceive_TARGET_PILLAR_RIGHT_x=0.
real PedestalReceive_TARGET_PILLAR_RIGHT_y=0.
real PedestalReceive_TARGET_PILLAR_RIGHT_z=0.
real PedestalReceive_ITEM_DROP_OFFS=0.
real PedestalReceive_ITEM_SPAWN_HEIGHT=0.
real PedestalReceive_SPAWN_PERIOD=0.
real PedestalReceive_INITIAL_PITCH=0.
real PedestalReceive_INITIAL_VELOCITY=0.
real PedestalReceive_ACCELERATION=0.
real PedestalReceive_CLOCK_PERIOD=0.
real PedestalReceive_AIR_FRICTION=0.
timer PedestalReceive_time=null
timer PedestalReceive_time2=null
group PedestalReceive_grp=null
rect PedestalReceive_rctEpsilon=null
item PedestalReceive_fakeRune=null
integer PedestalReceive_spawnCount=0
integer PedestalReceive_effectIndex=0
integer array PedestalReceive_fxDb
real array Effect_velocity
real array Effect_velocity_2
real array Effect_velocity_3
real array Effect_target
real array Effect_target_2
real array Effect_target_3
unit array Effect_dummy
effect array Effect_attached
integer Players_COUNT=0
integer Players_FIRST_HUNTER=0
integer Players_LAST_BEAST=0
integer Players_MARKERS=0
integer Players_PASSIVE=0
integer Players_FIRST_BEAST=0
player Players_locl=null
boolean array Players_playing
boolean array Players_aiControlled
player array Players_fromId
integer Players_aliveCount=0
integer Players_aiCount=0
integer Players_humanCount=0
integer Players_playingCount=0
integer Players_escapePressedCount=0
boolean array PrintingHelper_wantDebug
real PrintingHelper_DEBUG_MSG_DURATION=0.
unit array ProjectileDat_projectile
unit array ProjectileDat_damageSource
real array ProjectileDat_speed
real array ProjectileDat_dx
real array ProjectileDat_dy
real array ProjectileDat_damage
real array ProjectileDat_rangeLeft
string ProjectileStack_DUST_FX=null
string ProjectileStack_ERROR_NO_PROJECTILE=null
string ProjectileStack_ERROR_NO_SPEED=null
string ProjectileStack_ERROR_NO_DAMAGE=null
real ProjectileStack_PROJECTILE_OFFSET=0.
real ProjectileStack_DEFAULT_VELOCITY=0.
real ProjectileStack_BULLET_ENUM_RADIUS=0.
real ProjectileStack_PROJECTILE_VELOCITY=0.
real ProjectileStack_PROJECTILE_DAMAGE=0.
real ProjectileStack_DEFAULT_DAMAGE=0.
real ProjectileStack_CLOCK_PERIOD=0.
real ProjectileStack_FLY_HEIGHT=0.
real ProjectileStack_RANGE=0.
timer ProjectileStack_time=null
integer array ProjectileStack_projectileDB
integer ProjectileStack_dbIndex=0
group ProjectileStack_g=null
string Quests_CREDITS_DESC=null
string Quests_CREDITS_ICONPATH=null
string Quests_CREDITS_TITLE=null
string Quests_MODEL_CREDITS_DESC=null
string Quests_MODEL_CREDITS_ICONPATH=null
string Quests_MODEL_CREDITS_TITLE=null
string Quests_HOWTO_HUNTER_DESC=null
string Quests_HOWTO_BEAST_DESC=null
string Quests_HOWTO_ICONPATH=null
string Quests_HOWTO_TITLE=null
string Quests_ABOUT_DESC=null
string Quests_ABOUT_ICONPATH=null
string Quests_ABOUT_TITLE=null
trigger array RegisterPlayerUnitEvent_t
sound SimError_error=null
string array Slop_snd
integer Statistics_roundEndTime=0
integer Statistics_secondsElapsed=0
integer Statistics_hunterWins=0
integer Statistics_beastWins=0
integer Statistics_huntersAlive=0
integer Statistics_beastsAlive=0
integer Statistics_hunterKills=0
integer Statistics_beastKills=0
string String_charset=null
string String_numberset=null
boolean StructuredDD_ADD_ALL_UNITS=false
integer StructuredDD_BUCKET_SIZE=0
real StructuredDD_PER_CLEANUP_TIMEOUT=0.
integer array Bucket_bucketIndex
trigger array Bucket_trig
boolexpr array StructuredDD_conditions
integer array StructuredDD_bucketDB
integer StructuredDD_conditionsIndex=0
integer StructuredDD_dbIndex=0
integer StructuredDD_maxDBIndex=0
hashtable Table_ht=null
real TerrainData_HUNTER_SPAWN_X=0.
real TerrainData_HUNTER_SPAWN_Y=0.
real TerrainData_BEAST_SPAWN_X=0.
real TerrainData_BEAST_SPAWN_Y=0.
real TerrainData_HALL_MIN_X=0.
real TerrainData_HALL_MAX_X=0.
real TerrainData_HALL_MIN_Y=0.
real TerrainData_HALL_MAX_Y=0.
real TerrainData_RUNE_1_X=0.
real TerrainData_RUNE_1_Y=0.
real TerrainData_RUNE_2_X=0.
real TerrainData_RUNE_2_Y=0.
real TerrainData_RUNE_RETURN_X=0.
real TerrainData_RUNE_RETURN_Y=0.
real TerrainData_MIN_X=0.
real TerrainData_MAX_X=0.
real TerrainData_MIN_Y=0.
real TerrainData_MAX_Y=0.
real TerrainData_SAFE_X=0.
real TerrainData_SAFE_Y=0.
location TerrainData_loc=null
integer Terrain_DUMMY_ITEM_ID=0
item Terrain_dItem=null
texttag array TextTag_minimapLabels
integer TextTag_labelIndex=0
integer Thunder_THUNDER_ID=0
string TimerUp_TIME_LIMIT_REACHED=null
timer array TimerUtils_freeTimers
integer TimerUtils_freeTimersCount=0
integer TimerUtils_timerData=0
integer TimerUtils_HELD=0
unit array BeastLightningDat_u
integer array BeastLightningDat_ticksUntilNextCheck
integer array BeastLightningDat_balls
real array BeastLightningDat_phase
integer array BeastLightningDat_ballHead
integer array BeastLightningDat_typ
integer array BeastLightningDat_prev
integer array BeastLightningDat_next
unit array LightningBallDat_u
effect array LightningBallDat_fx
integer array LightningBallDat_next
string Units_LIGHTNING_BALL_FX=null
real Units_CLOCK_PERIOD=0.
real Units_LIGHTNING_CHECK_PERIOD=0.
real Units_BALL_OFF=0.
real Units_PHASE_ANGULAR_VELOCITY=0.
real Units_EFFECT_SCALE=0.
real Units_EFFECT_HEIGHT=0.
integer Units_BLINK_PASSIVE_ID=0
integer Units_BLINK_ID=0
integer Units_HEMISECT_PASSIVE_ID=0
integer Units_HEMISECT_ID=0
integer Units_CONCAT_PASSIVE_ID=0
integer Units_CONCAT_ID=0
integer Units_HUNTER_ID=0
integer Units_BEAST_ID=0
integer Units_LESSER_BEAST_ID=0
integer Units_HUNTER_PROJECTILE_ID=0
integer Units_ARTIFACT_ID=0
integer Units_GAS_ACTION=0
integer Units_INITIAL_BALLS=0
integer Units_MAX_BALLS=0
integer Units_MAX_BALLS_LESSER=0
group Units_grp=null
timer Units_clock=null
integer Units_beastHead=0
integer Units_fromBeast=0
unit array Units_hero
unit array Units_subHero
integer Units_thunderCd=0
integer Units_thunderClock=0
integer Units_beastState=0
integer Units_sitePref=0
item Units_artifact=null
item Units_artifact2=null
integer array CallbackSingle_nextFree
integer CallbackSingle_firstFree=0
integer CallbackSingle_maxIndex=0
integer array CallbackSingle_typeId
integer array DotData_nextFree
integer DotData_firstFree=0
integer DotData_maxIndex=0
integer array DotData_typeId
integer array DelayDat_nextFree
integer DelayDat_firstFree=0
integer DelayDat_maxIndex=0
integer array DelayDat_typeId
integer array UnitAlloc_nextFree
integer UnitAlloc_firstFree=0
integer UnitAlloc_maxIndex=0
integer array UnitAlloc_typeId
integer array AutoDat_nextFree
integer AutoDat_firstFree=0
integer AutoDat_maxIndex=0
integer array AutoDat_typeId
integer array DummyAlloc_nextFree
integer DummyAlloc_firstFree=0
integer DummyAlloc_maxIndex=0
integer array DummyAlloc_typeId
integer array Chord_nextFree
integer Chord_firstFree=0
integer Chord_maxIndex=0
integer array Chord_typeId
integer array Muscii_nextFree
integer Muscii_firstFree=0
integer Muscii_maxIndex=0
integer array Muscii_typeId
integer array MyCallBackFunc_nextFree
integer MyCallBackFunc_firstFree=0
integer MyCallBackFunc_maxIndex=0
integer array MyCallBackFunc_typeId
integer array Note_nextFree
integer Note_firstFree=0
integer Note_maxIndex=0
integer array Note_typeId
integer array NetData_nextFree
integer NetData_firstFree=0
integer NetData_maxIndex=0
integer array IdGenerator_nextFree
integer IdGenerator_firstFree=0
integer IdGenerator_maxIndex=0
integer array DuplicateDat_nextFree
integer DuplicateDat_firstFree=0
integer DuplicateDat_maxIndex=0
integer array DuplicateDat_typeId
integer array DuplicateDat_nextFree_2
integer DuplicateDat_firstFree_2=0
integer DuplicateDat_maxIndex_2=0
integer array DuplicateDat_typeId_2
integer array Effect_nextFree
integer Effect_firstFree=0
integer Effect_maxIndex=0
integer array Effect_typeId
integer array ProjectileDat_nextFree
integer ProjectileDat_firstFree=0
integer ProjectileDat_maxIndex=0
integer array ProjectileDat_typeId
integer array Slop_nextFree
integer Slop_firstFree=0
integer Slop_maxIndex=0
integer array Slop_typeId
integer array Bucket_nextFree
integer Bucket_firstFree=0
integer Bucket_maxIndex=0
integer array Bucket_typeId
integer array Table_nextFree
integer Table_firstFree=0
integer Table_maxIndex=0
integer array Table_typeId
integer array BeastLightningDat_nextFree
integer BeastLightningDat_firstFree=0
integer BeastLightningDat_maxIndex=0
integer array BeastLightningDat_typeId
integer array LightningBallDat_nextFree
integer LightningBallDat_firstFree=0
integer LightningBallDat_maxIndex=0
integer array LightningBallDat_typeId
unit array Bucket_members_0
unit array Bucket_members_1
unit array Bucket_members_2
unit array Bucket_members_3
unit array Bucket_members_4
real vec3_op_minus_return_x=0.
real vec3_op_minus_return_y=0.
real vec3_op_minus_return_z=0.
real vec3_norm_return_x=0.
real vec3_norm_return_y=0.
real vec3_norm_return_z=0.
real real_op_mult_return_x=0.
real real_op_mult_return_y=0.
real real_op_mult_return_z=0.
real vec3_op_plus_return_x=0.
real vec3_op_plus_return_y=0.
real vec3_op_plus_return_z=0.
real vec3_op_mult_return_x=0.
real vec3_op_mult_return_y=0.
real vec3_op_mult_return_z=0.
code ref_function_init_String=null
code ref_function_init_Table=null
code ref_function_init_Trigger=null
code ref_function_init_Player=null
code ref_function_init_PrintingHelper=null
code ref_function_init_MagicFunctions=null
code ref_function_init_Basics=null
code ref_function_init_GameTimer=null
code ref_function_init_ErrorHandling=null
code ref_function_init_TimerUtils=null
code ref_function_init_Maths=null
code ref_function_init_Vectors=null
code ref_function_init_TempGroups=null
code ref_function_init_Colors=null
code ref_function_init_Rect=null
code ref_function_init_Terrain=null
code ref_function_init_TypeCasting=null
code ref_function_init_ObjectIds=null
code ref_function_init_ObjectIdGenerator=null
code ref_function_init_TerrainData=null
code ref_function_init_Players=null
code ref_function_init_DummyUnitStack=null
code ref_function_init_Units=null
code ref_function_init_Statistics=null
code ref_function_init_AI=null
code ref_function_init_AttackTeammate=null
code ref_function_init_StructuredDD=null
code ref_function_init_DamageType=null
code ref_function_init_MultiboardControl=null
code ref_function_init_CameraControl=null
code ref_function_init_Game=null
code ref_function_init_DamageOverTime=null
code ref_function_init_TextTag=null
code ref_function_init_ItemFieldConditioningKit=null
code ref_function_init_BeastAttack=null
code ref_function_init_Cinematic=null
code ref_function_init_BinocularVision=null
code ref_function_init_Blink=null
code ref_function_init_Castle=null
code ref_function_init_CastleSmall=null
code ref_function_init_EscapeKey=null
code ref_function_init_HeroDeath=null
code ref_function_init_ProjectileStack=null
code ref_function_init_HunterAttack=null
code ref_function_init_Math=null
code ref_function_init_HunterCamera=null
code ref_function_init_HunterToggle=null
code ref_function_init_HuntersHall=null
code ref_function_init_Initialization=null
code ref_function_init_KeepSmall=null
code ref_function_init_Knife=null
code ref_function_init_Marketplace=null
code ref_function_init_MinimapVisionHints=null
code ref_function_init_Muscii=null
code ref_function_init_Music=null
code ref_function_init_Net=null
code ref_function_init_SimError=null
code ref_function_init_NoItemDuplicates=null
code ref_function_init_OrganicConcatenation=null
code ref_function_init_OrganicHemisection=null
code ref_function_init_Pedestal=null
code ref_function_init_PedestalReceive=null
code ref_function_init_PlayerLeaves=null
code ref_function_init_Quests=null
code ref_function_init_ScoutTower=null
code ref_function_init_Thunder=null
code ref_function_init_TimerUp=null
code ref_function_AI_periodic=null
code ref_function_act=null
code ref_function_hand=null
code ref_function_act_2=null
code ref_function_act_3=null
code ref_function_CameraControl_endFadeHunter=null
code ref_function_CameraControl_endFadeBeast=null
code ref_function_Cinematic_cleanup=null
code ref_function_Cinematic_endCinematic=null
code ref_function_Cinematic_human24=null
code ref_function_Cinematic_human23=null
code ref_function_Cinematic_human22=null
code ref_function_Cinematic_human21=null
code ref_function_Cinematic_human20=null
code ref_function_Cinematic_human19=null
code ref_function_Cinematic_human18=null
code ref_function_Cinematic_human17=null
code ref_function_Cinematic_human16=null
code ref_function_Cinematic_human15=null
code ref_function_Cinematic_human14c=null
code ref_function_Cinematic_human14b=null
code ref_function_Cinematic_human14a=null
code ref_function_Cinematic_human14=null
code ref_function_Cinematic_human13=null
code ref_function_Cinematic_human12a=null
code ref_function_Cinematic_human12=null
code ref_function_Cinematic_human11=null
code ref_function_Cinematic_human10=null
code ref_function_Cinematic_human9=null
code ref_function_Cinematic_human8b=null
code ref_function_Cinematic_human8=null
code ref_function_Cinematic_human7=null
code ref_function_Cinematic_human6=null
code ref_function_Cinematic_human5=null
code ref_function_Cinematic_human4=null
code ref_function_Cinematic_human3=null
code ref_function_Cinematic_human2=null
code ref_function_Cinematic_human1=null
code ref_function_Cinematic_beast35=null
code ref_function_Cinematic_beast34=null
code ref_function_Cinematic_beast33b=null
code ref_function_Cinematic_beast33a=null
code ref_function_Cinematic_beast33=null
code ref_function_Cinematic_beast32=null
code ref_function_Cinematic_beast31b=null
code ref_function_Cinematic_beast31a=null
code ref_function_Cinematic_beast31=null
code ref_function_Cinematic_beast30=null
code ref_function_Cinematic_beast28=null
code ref_function_Cinematic_beast29=null
code ref_function_Cinematic_beast26=null
code ref_function_Cinematic_beast25=null
code ref_function_Cinematic_beast23=null
code ref_function_Cinematic_beast23b=null
code ref_function_Cinematic_beast24=null
code ref_function_Cinematic_beast22=null
code ref_function_Cinematic_beast21=null
code ref_function_Cinematic_beast20=null
code ref_function_Cinematic_beast19=null
code ref_function_Cinematic_beast18=null
code ref_function_Cinematic_beast17=null
code ref_function_Cinematic_beast16=null
code ref_function_Cinematic_beast15=null
code ref_function_Cinematic_beast14=null
code ref_function_Cinematic_beast13=null
code ref_function_Cinematic_beast12=null
code ref_function_Cinematic_beast11b=null
code ref_function_Cinematic_beast11a=null
code ref_function_Cinematic_beast11=null
code ref_function_Cinematic_beast10=null
code ref_function_Cinematic_beast9=null
code ref_function_Cinematic_beast8=null
code ref_function_Cinematic_beast7=null
code ref_function_Cinematic_beast6=null
code ref_function_Cinematic_beast5=null
code ref_function_Cinematic_beast4=null
code ref_function_Cinematic_beast3=null
code ref_function_Cinematic_beast2=null
code ref_function_Cinematic_beast1=null
code ref_function_Cinematic_human0=null
code ref_function_Cinematic_beast0=null
code ref_function_Cinematic_neutral2=null
code ref_function_Cinematic_neutral1=null
code ref_function_CallbackSingle_staticCallback=null
code ref_function_DamageOverTime_damageTick=null
code ref_function_DamageType_c=null
code ref_function_DamageType_handler=null
code ref_function_DamageType_after=null
code ref_function_DummyUnitStack_deferredPreloader=null
code ref_function_DummyUnitStack_afterDelay=null
code ref_function_c=null
code ref_function_GameTimer_closure_impl=null
code ref_function_Game_countSeconds=null
code ref_function_Game_gameOver2=null
code ref_function_Game_hunterVictorySound=null
code ref_function_Game_gameOver=null
code ref_function_Game_roundStart=null
code ref_function_Game_beastVictorySound=null
code ref_function_a=null
code ref_function_autoTick=null
code ref_function_act_4=null
code ref_function_act_5=null
code ref_function_act_6=null
code ref_function_startC=null
code ref_function_endVotes=null
code ref_function_diaA=null
code ref_function_afterDelay=null
code ref_function_checkCombatDuration=null
code ref_function_releaseDummy=null
code ref_function_resetCooldown=null
code ref_function_act_7=null
code ref_function_update=null
code ref_function_periodic=null
code ref_function_act_8=null
code ref_function_Muscii_p=null
code ref_function_pauseForGameMusic=null
code ref_function_periodic_2=null
code ref_function_act_9=null
code ref_function_act_10=null
code ref_function_ddPeriodic=null
code ref_function_act_11=null
code ref_function_ddPeriodic_2=null
code ref_function_act_12=null
code ref_function_fxSpawn3=null
code ref_function_fxSpawn2=null
code ref_function_act_13=null
code ref_function_cond=null
code ref_function_switchDebug=null
code ref_function_ProjectileStack_bulletTick=null
code ref_function_SoundControl_preloadAfter=null
code ref_function_StructuredDD_autoAddC=null
code ref_function_StructuredDD_perCleanup=null
code ref_function_act_14=null
code ref_function_checkRoundSeconds=null
code ref_function_Units_beastLightningTick=null
code ref_function_Units_filterItems=null
unit DummyUnitStack_gettempReturn=null
unit ProjectileStack_getUnitProjectiletempReturn=null
unit ProjectileStack_getUnitProjectiletempReturn_2=null
quest addQuesttempReturn=null
texttag TextTag_minimapLabeltempReturn=null
timer getTimertempReturn=null
unit Bucket_members_gettempReturn=null
endglobals
native UnitAlive takes unit id returns boolean
function TerrainData_distanceBetweenXY takes real x1, real x2, real y1, real y2 returns real
	return SquareRoot((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
endfunction

function TerrainData_radiansBetweenXY takes real x1, real x2, real y1, real y2 returns real
	return Atan2(y2 - y1, x2 - x1)
endfunction

function hashtable_hasInt takes hashtable this, integer parentKey, integer childKey returns boolean
	return HaveSavedInteger(this, parentKey, childKey)
endfunction

function Table_hasInt takes integer this, integer parentKey returns boolean
	return hashtable_hasInt(Table_ht, this, parentKey)
endfunction

function hashtable_hasBoolean takes hashtable this, integer parentKey, integer childKey returns boolean
	return HaveSavedBoolean(this, parentKey, childKey)
endfunction

function hashtable_loadBoolean takes hashtable this, integer parentKey, integer childKey returns boolean
	return LoadBoolean(this, parentKey, childKey)
endfunction

function hashtable_loadInt takes hashtable this, integer parentKey, integer childKey returns integer
	return LoadInteger(this, parentKey, childKey)
endfunction

function hashtable_saveBoolean takes hashtable this, integer parentKey, integer childKey, boolean value returns nothing
	call SaveBoolean(this, parentKey, childKey, value)
endfunction

function hashtable_saveInt takes hashtable this, integer parentKey, integer childKey, integer value returns nothing
	call SaveInteger(this, parentKey, childKey, value)
endfunction

function print takes string msg returns nothing
	call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., PrintingHelper_DEBUG_MSG_DURATION, msg)
endfunction

function real_toInt takes real this returns integer
	return R2I(this)
endfunction

function error takes string msg returns nothing
	local integer hash = StringHash(msg)
	if hashtable_hasInt(Table_ht, ErrorHandling_PRIMARY_ERROR_KEY, hash) then
		if hashtable_loadInt(Table_ht, ErrorHandling_PRIMARY_ERROR_KEY, hash) + ErrorHandling_MUTE_ERROR_DURATION < GameTimer_currentTime then
			call print("|cffFF3A29Error:|r " + msg + "")
			call hashtable_saveInt(Table_ht, ErrorHandling_PRIMARY_ERROR_KEY, hash, real_toInt(GameTimer_currentTime))
			call hashtable_saveBoolean(Table_ht, ErrorHandling_PRIMARY_ERROR_KEY, hash, false)
		elseif hashtable_hasBoolean(Table_ht, ErrorHandling_PRIMARY_ERROR_KEY, hash) then
			if  not hashtable_loadBoolean(Table_ht, ErrorHandling_PRIMARY_ERROR_KEY, hash) then
				call print("|cffFF3A29Excessive repeating errors are being omitted")
				call hashtable_saveBoolean(Table_ht, ErrorHandling_PRIMARY_ERROR_KEY, hash, true)
			endif
		else
			call print("|cffFF3A29Excessive repeating errors are being omitted")
			call hashtable_saveBoolean(Table_ht, ErrorHandling_PRIMARY_ERROR_KEY, hash, true)
		endif
	else
		call hashtable_saveInt(Table_ht, ErrorHandling_PRIMARY_ERROR_KEY, hash, real_toInt(GameTimer_currentTime))
		call print("|cffFF3A29Error:|r " + msg + "")
	endif
	call I2S(1 / 0)
endfunction

function dispatch_Table_Table_Table_hasInt takes integer this, integer parentKey returns boolean
	local boolean Table_Table_hasInt_result
	if Table_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Table.Table_Table_hasInt")
		else
			call error("Called Table.Table_Table_hasInt on invalid object.")
		endif
	endif
	set Table_Table_hasInt_result = Table_hasInt(this, parentKey)
	return Table_Table_hasInt_result
endfunction

function Table_loadInt takes integer this, integer parentKey returns integer
	return hashtable_loadInt(Table_ht, this, parentKey)
endfunction

function dispatch_Table_Table_Table_loadInt takes integer this, integer parentKey returns integer
	local integer Table_Table_loadInt_result
	if Table_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Table.Table_Table_loadInt")
		else
			call error("Called Table.Table_Table_loadInt on invalid object.")
		endif
	endif
	set Table_Table_loadInt_result = Table_loadInt(this, parentKey)
	return Table_Table_loadInt_result
endfunction

function handle_getHandleId takes handle this returns integer
	return GetHandleId(this)
endfunction

function Units_countBalls takes unit u returns integer
	local integer ua
	if dispatch_Table_Table_Table_hasInt(Units_fromBeast, handle_getHandleId(u)) then
		set ua = dispatch_Table_Table_Table_loadInt(Units_fromBeast, handle_getHandleId(u))
		return BeastLightningDat_balls[ua]
	endif
	call BJDebugMsg("Units.countBalls: Tried to count balls on unindexed unit")
	return -1
endfunction

function Table_saveInt takes integer this, integer parentKey, integer value returns nothing
	call hashtable_saveInt(Table_ht, this, parentKey, value)
endfunction

function dispatch_Table_Table_Table_saveInt takes integer this, integer parentKey, integer value returns nothing
	if Table_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Table.Table_Table_saveInt")
		else
			call error("Called Table.Table_Table_saveInt on invalid object.")
		endif
	endif
	call Table_saveInt(this, parentKey, value)
endfunction

function parseBeast takes nothing returns nothing
	local real d = 99999999.
	local unit selected = null
	local unit iter
	local real safeX
	local real safeY
	local real ang
	call GroupEnumUnitsInRect(AI_grp, bj_mapInitialPlayableArea, null)
	loop
		set iter = FirstOfGroup(AI_grp)
		exitwhen iter == null
		if IsUnitEnemy(iter, AI_tempPlayer) and UnitAlive(iter) and IsUnitInRangeXY(iter, GetUnitX(AI_tempUnit), GetUnitY(AI_tempUnit), d) and GetUnitAbilityLevel(iter, 1114205814) < 1 then
			set selected = iter
			set d = TerrainData_distanceBetweenXY(GetUnitX(iter), GetUnitX(AI_tempUnit), GetUnitY(iter), GetUnitY(AI_tempUnit))
		endif
		call GroupRemoveUnit(AI_grp, iter)
	endloop
	if dispatch_Table_Table_Table_loadInt(Units_beastState, handle_getHandleId(AI_tempUnit)) == AI_STATE_AGGRESSIVE then
		if GetWidgetLife(AI_tempUnit) < GetUnitState(AI_tempUnit, UNIT_STATE_MAX_LIFE) * .5 then
			call dispatch_Table_Table_Table_saveInt(Units_beastState, handle_getHandleId(AI_tempUnit), AI_STATE_RETREAT)
		endif
		if Units_countBalls(AI_tempUnit) < 2 and IsUnitInRange(AI_tempUnit, selected, 1200.) then
			call dispatch_Table_Table_Table_saveInt(Units_beastState, handle_getHandleId(AI_tempUnit), AI_STATE_RETREAT)
		endif
		if selected != null and GetUnitCurrentOrder(AI_tempUnit) != OrderId("attack") then
			if IsUnitInRange(AI_tempUnit, selected, 140.) and Statistics_secondsElapsed - dispatch_Table_Table_Table_loadInt(Units_thunderCd, handle_getHandleId(AI_tempUnit)) > AI_THUNDER_CD then
				call IssueImmediateOrder(AI_tempUnit, "berserk")
				call dispatch_Table_Table_Table_saveInt(Units_thunderCd, handle_getHandleId(AI_tempUnit), Statistics_secondsElapsed)
			else
				call IssueTargetOrder(AI_tempUnit, "attack", selected)
			endif
		endif
	else
		if GetWidgetLife(AI_tempUnit) > GetUnitState(AI_tempUnit, UNIT_STATE_MAX_LIFE) * .8 then
			call dispatch_Table_Table_Table_saveInt(Units_beastState, handle_getHandleId(AI_tempUnit), AI_STATE_AGGRESSIVE)
		endif
		if GetItemX(Units_artifact) > 0. and GetItemY(Units_artifact) < 0. then
			set safeX = 3350.
			set safeY =  - 3700.
		else
			set safeX =  - 2150.
			set safeY = 3180.
		endif
		if selected != null and IsUnitInRange(AI_tempUnit, selected, 1200.) then
			set ang = TerrainData_radiansBetweenXY(GetUnitX(selected), safeX, GetUnitY(selected), safeY)
			call IssuePointOrder(AI_tempUnit, "move", GetUnitX(selected) + 1400. * Cos(ang), GetUnitY(selected) + 1400. * Sin(ang))
		else
			call SetUnitFacingTimed(AI_tempUnit, GetUnitFacing(AI_tempUnit) + 90., 1.)
		endif
	endif
	set iter = null
	set selected = null
endfunction

function hunterElection takes nothing returns nothing
	local integer index = 0
	loop
		exitwhen index >= Players_FIRST_BEAST
		if UnitAlive(Units_hero[index]) and ( not Players_aiControlled[index]) then
			set AI_hunterLeader = Units_hero[index]
			return
		endif
		set index = index + 1
	endloop
	set index = 0
	loop
		exitwhen index >= Players_FIRST_BEAST
		if UnitAlive(Units_hero[index]) then
			set AI_hunterLeader = Units_hero[index]
			return
		endif
		set index = index + 1
	endloop
endfunction

function player_getId takes player this returns integer
	return GetPlayerId(this)
endfunction

function item_getX takes item this returns real
	return GetItemX(this)
endfunction

function item_getY takes item this returns real
	return GetItemY(this)
endfunction

function unit_getOwner takes unit this returns player
	return GetOwningPlayer(this)
endfunction

function proceedObjective takes nothing returns nothing
	local item artifact
	local integer objective
	if UnitHasItem(AI_tempUnit, Units_artifact) then
		call IssuePointOrder(AI_tempUnit, "move", TerrainData_RUNE_RETURN_X, TerrainData_RUNE_RETURN_Y)
	else
		set objective = dispatch_Table_Table_Table_loadInt(Units_sitePref, handle_getHandleId(Units_hero[player_getId(unit_getOwner(AI_tempUnit))]))
		if objective == 0 then
			set artifact = Units_artifact
		else
			set artifact = Units_artifact2
		endif
		if IsUnitInRangeXY(AI_tempUnit, GetItemX(artifact), GetItemY(artifact), 200.) then
			call IssueTargetOrder(AI_tempUnit, "smart", artifact)
		else
			call IssuePointOrder(AI_tempUnit, "move", item_getX(artifact), item_getY(artifact))
		endif
	endif
	set artifact = null
endfunction

function unit_issuePointOrder takes unit this, string order, real target_x, real target_y returns nothing
	call IssuePointOrder(this, order, target_x, target_y)
endfunction

function parseHunter takes nothing returns nothing
	local real d = 1200.
	local unit selected = null
	local player owner = GetOwningPlayer(AI_tempUnit)
	local unit iter
	local real hunterX
	local real hunterY
	local real tempD
	local real ang
	if  not UnitAlive(AI_hunterLeader) then
		call hunterElection()
	endif
	set hunterX = GetUnitX(AI_tempUnit)
	set hunterY = GetUnitY(AI_tempUnit)
	call GroupEnumUnitsInRange(AI_grp, GetUnitX(AI_tempUnit), GetUnitY(AI_tempUnit), d, null)
	loop
		set iter = FirstOfGroup(AI_grp)
		exitwhen iter == null
		if UnitAlive(iter) and IsUnitInRange(iter, AI_tempUnit, d) and IsUnitEnemy(iter, owner) and IsUnitVisible(iter, owner) then
			set selected = iter
			set d = TerrainData_distanceBetweenXY(GetUnitX(iter), hunterX, GetUnitY(iter), hunterY)
		endif
		call GroupRemoveUnit(AI_grp, iter)
	endloop
	if selected != null then
		if IsUnitInRange(AI_tempUnit, selected, 900.) then
			call unit_issuePointOrder(AI_tempUnit, "channel", GetUnitX(selected), GetUnitY(selected))
		else
			call IssuePointOrder(AI_tempUnit, "move", GetUnitX(selected), GetUnitY(selected))
		endif
	elseif AI_tempUnit == AI_hunterLeader then
		call GroupEnumUnitsInRange(AI_grp, GetUnitX(AI_tempUnit), GetUnitY(AI_tempUnit), 1400., null)
		set d = 0.
		loop
			set iter = FirstOfGroup(AI_grp)
			exitwhen iter == null
			set tempD = TerrainData_distanceBetweenXY(GetUnitX(iter), hunterX, GetUnitY(iter), hunterY)
			if UnitAlive(iter) and player_getId(unit_getOwner(iter)) < Players_FIRST_BEAST and tempD > d then
				set d = tempD
			endif
			call GroupRemoveUnit(AI_grp, iter)
		endloop
		if d > 1000. then
			call IssueImmediateOrder(AI_tempUnit, "stop")
			call SetUnitFacingTimed(AI_tempUnit, GetUnitFacing(AI_tempUnit) - 90., 1.25)
		else
			call ExecuteFunc("proceedObjective")
		endif
	else
		set ang = TerrainData_radiansBetweenXY(hunterX, GetUnitX(AI_hunterLeader), hunterY, GetUnitY(AI_hunterLeader)) + bj_PI
		call IssuePointOrder(AI_tempUnit, "move", GetUnitX(AI_hunterLeader) + 200. * Cos(ang), GetUnitY(AI_hunterLeader) + 200. * Sin(ang))
	endif
	set iter = null
	set selected = null
	set owner = null
endfunction

function parsePlayer takes nothing returns nothing
	local unit hero = Units_hero[GetPlayerId(AI_tempPlayer)]
	set AI_tempUnit = hero
	if  not UnitAlive(hero) then
		set hero = null
		return
	endif
	if GetUnitTypeId(hero) == AI_BEAST_ID then
		call ExecuteFunc("parseBeast")
	else
		call ExecuteFunc("parseHunter")
	endif
	set hero = null
endfunction

function AI_periodic takes nothing returns nothing
	local integer index = 0
	loop
		exitwhen index > AI_count
		set AI_tempPlayer = AI_players[index]
		call ExecuteFunc("parsePlayer")
		set index = index + 1
	endloop
endfunction

function HunterAttack_closure_impl takes integer this returns nothing
	call IssueImmediateOrder(attacker[this], "stop")
endfunction

function dispatch_CallbackSingle_ClosureTimers_CallbackSingle_call takes integer this returns nothing
	if CallbackSingle_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling CallbackSingle.ClosureTimers_CallbackSingle_call")
		else
			call error("Called CallbackSingle.ClosureTimers_CallbackSingle_call on invalid object.")
		endif
	endif
	call HunterAttack_closure_impl(this)
endfunction

function CallbackSingle_onDestroy takes integer this returns nothing
endfunction

function dealloc_CallbackSingle takes integer obj returns nothing
	if CallbackSingle_typeId[obj] == 0 then
		call error("Double free: object of type CallbackSingle")
	else
		set CallbackSingle_nextFree[CallbackSingle_firstFree] = obj
		set CallbackSingle_firstFree = CallbackSingle_firstFree + 1
		set CallbackSingle_typeId[obj] = 0
	endif
endfunction

function destroyCallbackSingle takes integer this returns nothing
	call CallbackSingle_onDestroy(this)
	call dealloc_CallbackSingle(this)
endfunction

function dispatch_CallbackSingle_destroyCallbackSingle takes integer this returns nothing
	if CallbackSingle_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling CallbackSingle.destroyCallbackSingle")
		else
			call error("Called CallbackSingle.destroyCallbackSingle on invalid object.")
		endif
	endif
	call destroyCallbackSingle(this)
endfunction

function timer_getData takes timer this returns integer
	return dispatch_Table_Table_Table_loadInt(TimerUtils_timerData, GetHandleId(this))
endfunction

function timer_pause takes timer this returns nothing
	call PauseTimer(this)
endfunction

function timer_setData takes timer this, integer data returns nothing
	call dispatch_Table_Table_Table_saveInt(TimerUtils_timerData, GetHandleId(this), data)
endfunction

function timer_release takes timer this returns nothing
	if this == null then
		call error("Trying to release a null timer")
		return
	endif
	if timer_getData(this) == TimerUtils_HELD then
		call error("ReleaseTimer: Double free!")
		return
	endif
	call timer_setData(this, TimerUtils_HELD)
	call timer_pause(this)
	set TimerUtils_freeTimers[TimerUtils_freeTimersCount] = this
	set TimerUtils_freeTimersCount = TimerUtils_freeTimersCount + 1
endfunction

function CallbackSingle_staticCallback takes nothing returns nothing
	local timer t = GetExpiredTimer()
	local integer cb = timer_getData(t)
	call dispatch_CallbackSingle_ClosureTimers_CallbackSingle_call(cb)
	call dispatch_CallbackSingle_destroyCallbackSingle(cb)
	call timer_release(t)
	set t = null
endfunction

function CameraControl_endFadeBeast takes nothing returns nothing
	call DestroyTimer(CameraControl_beastFadeFinishTimer)
	set CameraControl_beastFadeFinishTimer = null
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call DisplayCineFilter(false)
		call EnableUserUI(true)
	endif
endfunction

function CameraControl_endFadeHunter takes nothing returns nothing
	call DestroyTimer(CameraControl_hunterFadeFinishTimer)
	set CameraControl_hunterFadeFinishTimer = null
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call DisplayCineFilter(false)
		call EnableUserUI(true)
	endif
endfunction

function CameraControl_fadeInBeast takes real duration returns nothing
	if CameraControl_beastFadeContinueTimer != null then
		call DestroyTimer(CameraControl_beastFadeContinueTimer)
	endif
	if CameraControl_beastFadeFinishTimer != null then
		call DestroyTimer(CameraControl_beastFadeFinishTimer)
	endif
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call EnableUserUI(false)
		call SetCineFilterTexture(CameraControl_FILTER_MASK)
		call SetCineFilterBlendMode(BLEND_MODE_BLEND)
		call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
		call SetCineFilterStartUV(0., 0., 1., 1.)
		call SetCineFilterEndUV(0., 0., 1., 1.)
		call SetCineFilterStartColor(0, 0, 0, 255)
		call SetCineFilterEndColor(0, 0, 0, 0)
		call SetCineFilterDuration(duration)
		call DisplayCineFilter(true)
	endif
	set CameraControl_beastFadeFinishTimer = CreateTimer()
	call TimerStart(CameraControl_beastFadeFinishTimer, duration, false, ref_function_CameraControl_endFadeBeast)
endfunction

function CameraControl_panAoaBeast takes real aoa, real duration returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, aoa, duration)
	endif
endfunction

function CameraControl_panBeast takes real x, real y, real duration returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call PanCameraToTimed(x, y, duration)
	endif
endfunction

function CameraControl_panDistanceBeast takes real dist, real duration returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, dist, duration)
	endif
endfunction

function CameraControl_snapAoaBeast takes real aoa returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, aoa, 0.)
	endif
endfunction

function CameraControl_snapBeast takes real x, real y returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call PanCameraToTimed(x, y, 0.)
	endif
endfunction

function CameraControl_snapDistanceBeast takes real d returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, d, 0.)
	endif
endfunction

function Cinematic_clearTextBeast takes nothing returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call ClearTextMessages()
	endif
endfunction

function Cinematic_conditionalScene takes real sleep, code next returns nothing
	if Players_escapePressedCount < Players_humanCount then
		call TimerStart(Cinematic_beastClock, sleep, false, next)
	endif
endfunction

function DummyUnitStack_add takes boolean preloading returns unit
	set bj_lastCreatedUnit = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DummyUnitStack_DUMMY_UNIT_ID, DummyUnitStack_SAFE_LOC_X, DummyUnitStack_SAFE_LOC_Y, 0.)
	call UnitAddAbility(bj_lastCreatedUnit, 1097625443)
	call UnitAddAbility(bj_lastCreatedUnit, 1098015094)
	if preloading then
		set DummyUnitStack_stackIndex = DummyUnitStack_stackIndex + 1
		set DummyUnitStack_dummyStack[DummyUnitStack_stackIndex] = bj_lastCreatedUnit
	else
		return bj_lastCreatedUnit
	endif
	return null
endfunction

function DummyUnitStack_get takes nothing returns unit
	local unit result
	if DummyUnitStack_stackIndex != -1 then
		set DummyUnitStack_stackIndex = DummyUnitStack_stackIndex - 1
		set result = DummyUnitStack_dummyStack[DummyUnitStack_stackIndex + 1]
	else
		set result = DummyUnitStack_add(false)
	endif
	if DummyUnitStack_DO_DDPC then
		if DummyUnitStack_stackIndex < DummyUnitStack_DYNAMIC_DEFERRED_PRELOAD_COUNT - 1 and DummyUnitStack_deferredTodoCount < 1 then
			set DummyUnitStack_deferredTodoCount = DummyUnitStack_MIN_PRELOAD_BLOCK_SIZE
			call TimerStart(DummyUnitStack_clock, DummyUnitStack_CLOCK_PERIOD, true, ref_function_DummyUnitStack_deferredPreloader)
		endif
	endif
	set DummyUnitStack_gettempReturn = result
	set result = null
	return DummyUnitStack_gettempReturn
endfunction

function alloc_LightningBallDat takes nothing returns integer
	local integer this
	if LightningBallDat_firstFree == 0 then
		if LightningBallDat_maxIndex < 8191 then
			set LightningBallDat_maxIndex = LightningBallDat_maxIndex + 1
			set this = LightningBallDat_maxIndex
			set LightningBallDat_typeId[this] = 56
		else
			call error("Out of memory: Could not create LightningBallDat.")
			set this = 0
		endif
	else
		set LightningBallDat_firstFree = LightningBallDat_firstFree - 1
		set this = LightningBallDat_nextFree[LightningBallDat_firstFree]
		set LightningBallDat_typeId[this] = 56
	endif
	return this
endfunction

function construct_LightningBallDat takes integer this returns nothing
	set LightningBallDat_next[this] = 0
endfunction

function new_LightningBallDat takes nothing returns integer
	local integer this = alloc_LightningBallDat()
	call construct_LightningBallDat(this)
	return this
endfunction

function Units_pushBall takes unit u returns nothing
	local string fxString = Units_LIGHTNING_BALL_FX
	local integer ua = dispatch_Table_Table_Table_loadInt(Units_fromBeast, handle_getHandleId(u))
	local integer lbd = new_LightningBallDat()
	local integer swap
	set LightningBallDat_u[lbd] = DummyUnitStack_get()
	call SetUnitFlyHeight(LightningBallDat_u[lbd], Units_EFFECT_HEIGHT, 0.)
	call SetUnitScale(LightningBallDat_u[lbd], Units_EFFECT_SCALE, Units_EFFECT_SCALE, Units_EFFECT_SCALE)
	if Players_locl != GetOwningPlayer(u) then
		set fxString = ""
	endif
	set LightningBallDat_fx[lbd] = AddSpecialEffectTarget(fxString, LightningBallDat_u[lbd], "origin")
	set BeastLightningDat_balls[ua] = BeastLightningDat_balls[ua] + 1
	if BeastLightningDat_balls[ua] == 1 then
		call UnitRemoveAbility(BeastLightningDat_u[ua], Units_BLINK_PASSIVE_ID)
		call UnitAddAbility(BeastLightningDat_u[ua], Units_BLINK_ID)
	elseif BeastLightningDat_balls[ua] == 3 and BeastLightningDat_typ[ua] == Units_BEAST_ID then
		call UnitRemoveAbility(BeastLightningDat_u[ua], Units_HEMISECT_PASSIVE_ID)
		call UnitAddAbility(BeastLightningDat_u[ua], Units_HEMISECT_ID)
	elseif BeastLightningDat_balls[ua] == 3 and BeastLightningDat_typ[ua] == Units_LESSER_BEAST_ID then
		call UnitRemoveAbility(BeastLightningDat_u[ua], Units_CONCAT_PASSIVE_ID)
		call UnitAddAbility(BeastLightningDat_u[ua], Units_CONCAT_ID)
	endif
	if BeastLightningDat_ballHead[ua] == 0 then
		set BeastLightningDat_ballHead[ua] = lbd
	else
		set swap = BeastLightningDat_ballHead[ua]
		set LightningBallDat_next[lbd] = swap
		set BeastLightningDat_ballHead[ua] = lbd
	endif
endfunction

function alloc_BeastLightningDat takes nothing returns integer
	local integer this
	if BeastLightningDat_firstFree == 0 then
		if BeastLightningDat_maxIndex < 8191 then
			set BeastLightningDat_maxIndex = BeastLightningDat_maxIndex + 1
			set this = BeastLightningDat_maxIndex
			set BeastLightningDat_typeId[this] = 55
		else
			call error("Out of memory: Could not create BeastLightningDat.")
			set this = 0
		endif
	else
		set BeastLightningDat_firstFree = BeastLightningDat_firstFree - 1
		set this = BeastLightningDat_nextFree[BeastLightningDat_firstFree]
		set BeastLightningDat_typeId[this] = 55
	endif
	return this
endfunction

function construct_BeastLightningDat takes integer this returns nothing
	set BeastLightningDat_phase[this] = 0.
	set BeastLightningDat_ballHead[this] = 0
	set BeastLightningDat_prev[this] = 0
	set BeastLightningDat_next[this] = 0
endfunction

function new_BeastLightningDat takes nothing returns integer
	local integer this = alloc_BeastLightningDat()
	call construct_BeastLightningDat(this)
	return this
endfunction

function Units_initializeBeast takes unit u returns nothing
	local integer ua = new_BeastLightningDat()
	local integer index = 0
	local integer id = GetUnitTypeId(u)
	local integer swap
	set BeastLightningDat_typ[ua] = id
	set BeastLightningDat_u[ua] = u
	set BeastLightningDat_ticksUntilNextCheck[ua] = R2I(Units_LIGHTNING_CHECK_PERIOD / Units_CLOCK_PERIOD)
	set BeastLightningDat_balls[ua] = 0
	loop
		exitwhen index >= Units_INITIAL_BALLS
		call Units_pushBall(u)
		set index = index + 1
	endloop
	call dispatch_Table_Table_Table_saveInt(Units_fromBeast, handle_getHandleId(u), ua)
	if Units_beastHead == 0 then
		set Units_beastHead = ua
		call TimerStart(Units_clock, Units_CLOCK_PERIOD, true, ref_function_Units_beastLightningTick)
	else
		set swap = Units_beastHead
		set BeastLightningDat_prev[swap] = ua
		set BeastLightningDat_next[ua] = swap
		set Units_beastHead = ua
	endif
endfunction

function Cinematic_beast0 takes nothing returns nothing
	call Cinematic_clearTextBeast()
	set Cinematic_demoHunter = CreateUnit(Players_fromId[0], Units_HUNTER_ID, 2650.,  - 3290., 30.)
	set Cinematic_coolBeast = CreateUnit(Players_fromId[Players_FIRST_BEAST], Units_BEAST_ID, 3237.,  - 3220., 30. + 90.)
	set Cinematic_coolBeast2 = CreateUnit(Players_fromId[Players_FIRST_BEAST + 1], Units_BEAST_ID, 3237. + 128. * Cos(bj_PI / 6.), ( - 3220.) + 128. * Sin(bj_PI / 6.), 30. + 90.)
	set Cinematic_coolBeast3 = CreateUnit(Players_fromId[Players_FIRST_BEAST + 2], Units_BEAST_ID, 3237. - 128. * Cos(bj_PI / 6.), ( - 3220.) - 128. * Sin(bj_PI / 6.), 30. + 90.)
	call UnitRemoveAbility(Cinematic_coolBeast, 1096905835)
	call UnitRemoveAbility(Cinematic_coolBeast2, 1096905835)
	call UnitRemoveAbility(Cinematic_coolBeast3, 1096905835)
	call Units_initializeBeast(Cinematic_coolBeast)
	call Units_initializeBeast(Cinematic_coolBeast2)
	call Units_initializeBeast(Cinematic_coolBeast3)
	call CameraControl_snapBeast(2964.77, 635.94)
	call CameraControl_snapAoaBeast(291.17)
	call CameraControl_snapDistanceBeast(1126.97)
	call CameraControl_panBeast(2964.77 + 64., 635.94 - 64., 7.)
	call CameraControl_panAoaBeast(291.17 + 10., 8.)
	call CameraControl_panDistanceBeast(1126.97 - 100., 7.)
	call CameraControl_fadeInBeast(.5)
	call Cinematic_conditionalScene(1.5, ref_function_Cinematic_beast1)
endfunction

function Cinematic_titleTextBeast takes string text returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call DisplayTimedTextToPlayer(Players_locl, .1, 0., 3., text)
	endif
endfunction

function Cinematic_beast1 takes nothing returns nothing
	call Cinematic_titleTextBeast(Cinematic_TITLE_BEAST_ONE)
	call Cinematic_conditionalScene(5., ref_function_Cinematic_beast2)
endfunction

function Cinematic_beast10 takes nothing returns nothing
	call RemoveDestructable(Cinematic_gatherTarget)
	call IssueImmediateOrder(Cinematic_gatherer, "stop")
	call SetUnitX(Cinematic_gatherer, ( - 4235.) - 64.)
	call SetUnitY(Cinematic_gatherer, ( - 5180.) + 64.)
	call SetUnitFacing(Cinematic_gatherer, 180.)
	call SetUnitPathing(Cinematic_gatherer, false)
	call IssueImmediateOrder(Cinematic_gatherer2, "stop")
	call SetUnitX(Cinematic_gatherer2, ( - 4235.) + 32.)
	call SetUnitY(Cinematic_gatherer2, ( - 5180.) + 64.)
	call SetUnitFacing(Cinematic_gatherer2, 180.)
	call SetUnitPathing(Cinematic_gatherer2, false)
	call IssueImmediateOrder(Cinematic_gatherer3, "stop")
	call SetUnitX(Cinematic_gatherer3, ( - 4235.) + 128.)
	call SetUnitY(Cinematic_gatherer3, ( - 5180.) + 64.)
	call SetUnitFacing(Cinematic_gatherer3, 180.)
	call SetUnitPathing(Cinematic_gatherer3, false)
	call Cinematic_conditionalScene(2., ref_function_Cinematic_beast11)
endfunction

function Cinematic_beast11 takes nothing returns nothing
	call IssuePointOrder(Cinematic_gatherer, "move",  - 5317.,  - 5101.)
	call IssuePointOrder(Cinematic_gatherer2, "move", ( - 5317.) + 64.,  - 5101.)
	call IssuePointOrder(Cinematic_gatherer3, "move", ( - 5317.) + 128.,  - 5101.)
	call Cinematic_conditionalScene(4., ref_function_Cinematic_beast11a)
endfunction

function Cinematic_beast11a takes nothing returns nothing
	call SetUnitFacingTimed(Cinematic_robed2, 45. + 180. - 30., 2.)
	call SetUnitPosition(Cinematic_gatherer, GetUnitX(Cinematic_gatherer), GetUnitY(Cinematic_gatherer))
	call SetUnitPosition(Cinematic_gatherer2, GetUnitX(Cinematic_gatherer2), GetUnitY(Cinematic_gatherer2))
	call SetUnitPosition(Cinematic_gatherer3, GetUnitX(Cinematic_gatherer3), GetUnitY(Cinematic_gatherer3))
	call IssuePointOrder(Cinematic_gatherer, "move",  - 5317.,  - 5101.)
	call IssuePointOrder(Cinematic_gatherer2, "move", ( - 5317.) + 64.,  - 5101.)
	call IssuePointOrder(Cinematic_gatherer3, "move", ( - 5317.) + 128.,  - 5101.)
	call Cinematic_conditionalScene(4., ref_function_Cinematic_beast11b)
endfunction

function Cinematic_beast11b takes nothing returns nothing
	call SetUnitFacingTimed(Cinematic_robed, 45. - 15., 2.1)
	call SetUnitPosition(Cinematic_gatherer, GetUnitX(Cinematic_gatherer), GetUnitY(Cinematic_gatherer))
	call SetUnitPosition(Cinematic_gatherer2, GetUnitX(Cinematic_gatherer2), GetUnitY(Cinematic_gatherer2))
	call SetUnitPosition(Cinematic_gatherer3, GetUnitX(Cinematic_gatherer3), GetUnitY(Cinematic_gatherer3))
	call IssuePointOrder(Cinematic_gatherer, "move",  - 5317.,  - 5101.)
	call IssuePointOrder(Cinematic_gatherer2, "move", ( - 5317.) + 64.,  - 5101.)
	call IssuePointOrder(Cinematic_gatherer3, "move", ( - 5317.) + 128.,  - 5101.)
	call Cinematic_conditionalScene(4., ref_function_Cinematic_beast12)
endfunction

function CameraControl_fadeOutBeast takes real duration returns nothing
	if CameraControl_beastFadeContinueTimer != null then
		call DestroyTimer(CameraControl_beastFadeContinueTimer)
	endif
	if CameraControl_beastFadeFinishTimer != null then
		call DestroyTimer(CameraControl_beastFadeFinishTimer)
	endif
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call EnableUserUI(false)
		call SetCineFilterTexture(CameraControl_FILTER_MASK)
		call SetCineFilterBlendMode(BLEND_MODE_BLEND)
		call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
		call SetCineFilterStartUV(0., 0., 1., 1.)
		call SetCineFilterEndUV(0., 0., 1., 1.)
		call SetCineFilterStartColor(0, 0, 0, 0)
		call SetCineFilterEndColor(0, 0, 0, 255)
		call SetCineFilterDuration(duration)
		call DisplayCineFilter(true)
	endif
endfunction

function Cinematic_beast12 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast13)
endfunction

function Cinematic_transmissionBeast takes real duration, string text returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call SetCinematicScene(0, PLAYER_COLOR_LIGHT_BLUE, "", text, duration, duration)
	endif
endfunction

function Cinematic_beast13 takes nothing returns nothing
	call RemoveUnit(Cinematic_gatherer)
	call RemoveUnit(Cinematic_gatherer2)
	call RemoveUnit(Cinematic_gatherer3)
	call RemoveUnit(Cinematic_robed)
	call RemoveUnit(Cinematic_robed2)
	call SetUnitTimeScale(Cinematic_coolBeast, .91)
	call SetUnitTimeScale(Cinematic_coolBeast2, .87)
	call SetUnitTimeScale(Cinematic_coolBeast3, .94)
	call CameraControl_fadeInBeast(.5)
	call CameraControl_snapBeast(3230.75,  - 3202.29)
	call CameraControl_snapDistanceBeast(931.38)
	call CameraControl_snapAoaBeast(304.)
	call CameraControl_panBeast(3146.62,  - 3045.61, 13.)
	call CameraControl_panAoaBeast(310., 13.)
	call CameraControl_panDistanceBeast(1024.52, 13.)
	call Cinematic_transmissionBeast(13., "Thus, the source of |cffffcc00Beasts|r power " + "is revealed. Humans, tolerant of the energy, evolved very slowly, but Beasts, having acquired the rune, are sensitive. " + "The effects make Beasts hyperperceptive of their environment, and " + "generate |cffffcc00lightning charge|r as an ability resource.")
	call Cinematic_conditionalScene(8., ref_function_Cinematic_beast14)
endfunction

function Cinematic_beast14 takes nothing returns nothing
	call IssuePointOrder(Cinematic_demoHunter, "channel", 3220.,  - 3220.)
	call Cinematic_conditionalScene(.35, ref_function_Cinematic_beast15)
endfunction

function Cinematic_beast15 takes nothing returns nothing
	call IssuePointOrder(Cinematic_coolBeast3, "blink", GetUnitX(Cinematic_coolBeast3) + 208. * Cos(bj_PI * 2. / 3.), GetUnitY(Cinematic_coolBeast3) + 208. * Sin(bj_PI * 2. / 3.))
	call Cinematic_conditionalScene(.1, ref_function_Cinematic_beast16)
endfunction

function Cinematic_beast16 takes nothing returns nothing
	call IssuePointOrder(Cinematic_coolBeast, "blink", GetUnitX(Cinematic_coolBeast) + 178. * Cos(bj_PI * 2. / 3.), GetUnitY(Cinematic_coolBeast) + 178. * Sin(bj_PI * 2. / 3.))
	call Cinematic_conditionalScene(.12, ref_function_Cinematic_beast17)
endfunction

function Cinematic_beast17 takes nothing returns nothing
	call IssuePointOrder(Cinematic_coolBeast2, "blink", GetUnitX(Cinematic_coolBeast2) + 298. * Cos(bj_PI * 2. / 3.), GetUnitY(Cinematic_coolBeast2) + 298. * Sin(bj_PI * 2. / 3.))
	call Cinematic_conditionalScene(4.8, ref_function_Cinematic_beast18)
endfunction

function Cinematic_beast18 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast19)
endfunction

function Cinematic_beast19 takes nothing returns nothing
	call RemoveUnit(Cinematic_coolBeast)
	call RemoveUnit(Cinematic_coolBeast3)
	call RemoveUnit(Cinematic_coolBeast2)
	call RemoveUnit(Cinematic_demoHunter)
	call Cinematic_titleTextBeast(Cinematic_TITLE_BEAST_TWO)
	call Cinematic_conditionalScene(1., ref_function_Cinematic_beast20)
endfunction

function Cinematic_beast2 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast3)
endfunction

function CameraControl_snapRotationBeast takes real r returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_ROTATION, r, 0.)
	endif
endfunction

function Cinematic_beast20 takes nothing returns nothing
	set Cinematic_demoHunter = CreateUnit(Players_fromId[0], Units_HUNTER_ID,  - 3235.,  - 3652., 270.)
	call SetUnitMoveSpeed(Cinematic_demoHunter, 160.)
	set Cinematic_coolBeast = CreateUnit(Players_fromId[Players_FIRST_BEAST], Units_BEAST_ID,  - 2810.,  - 5070., 90.)
	call Units_initializeBeast(Cinematic_coolBeast)
	call CameraControl_snapBeast( - 2489.45,  - 4247.05)
	call CameraControl_snapAoaBeast(319.76)
	call CameraControl_snapDistanceBeast(1650.)
	call CameraControl_snapRotationBeast(97.14)
	call Cinematic_conditionalScene(4., ref_function_Cinematic_beast21)
endfunction

function Cinematic_beast21 takes nothing returns nothing
	call IssuePointOrder(Cinematic_demoHunter, "move", 3575.,  - 4185.)
	call CameraControl_fadeInBeast(.5)
	call CameraControl_panBeast(( - 2489.45) - 256., ( - 4247.05) + 256., 13.)
	set Cinematic_stopwatch = Statistics_secondsElapsed
	call Cinematic_transmissionBeast(12., "A group of |cffffcc00Hunters|r have located the " + "rune, and are trying to retrieve it. Use guerilla warfare to harass them and " + "slow their pace. Beasts regenerate health continuously.")
	call Cinematic_conditionalScene(4., ref_function_Cinematic_beast22)
endfunction

function Cinematic_beast22 takes nothing returns nothing
	local real x
	local real y
	local real ang
	if GetWidgetLife(Cinematic_demoHunter) > .9 * GetUnitState(Cinematic_demoHunter, UNIT_STATE_MAX_LIFE) then
		if IsUnitInRange(Cinematic_demoHunter, Cinematic_coolBeast, 200.) then
			call IssueTargetOrder(Cinematic_coolBeast, "attack", Cinematic_demoHunter)
		elseif IsUnitInRange(Cinematic_demoHunter, Cinematic_coolBeast, 625.) then
			set ang = TerrainData_radiansBetweenXY(GetUnitX(Cinematic_demoHunter), GetUnitX(Cinematic_coolBeast), GetUnitY(Cinematic_demoHunter), GetUnitY(Cinematic_coolBeast))
			set x = GetUnitX(Cinematic_demoHunter) + 100. * Cos(ang)
			set y = GetUnitY(Cinematic_demoHunter) + 100. * Sin(ang)
			call IssuePointOrder(Cinematic_coolBeast, "blink", x, y)
		else
			call IssueTargetOrder(Cinematic_coolBeast, "attack", Cinematic_demoHunter)
		endif
		call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast22)
	else
		set Cinematic_stopwatch2 = Statistics_secondsElapsed
		call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast23)
	endif
endfunction

function Cinematic_beast23 takes nothing returns nothing
	call IssuePointOrder(Cinematic_coolBeast, "move",  - 2150., 3180.)
	if Statistics_secondsElapsed - Cinematic_stopwatch < 12 then
		if Statistics_secondsElapsed - Cinematic_stopwatch2 < 3 then
			call IssuePointOrder(Cinematic_demoHunter, "move",  - 2150., 3180.)
			call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast23)
		else
			call IssueTargetOrder(Cinematic_demoHunter, "channel", Cinematic_coolBeast)
			set Cinematic_stopwatch2 = Statistics_secondsElapsed
			call Cinematic_conditionalScene(.4, ref_function_Cinematic_beast23b)
		endif
	else
		call Cinematic_conditionalScene(.1, ref_function_Cinematic_beast24)
	endif
endfunction

function Cinematic_beast23b takes nothing returns nothing
	local real ang = GetUnitFacing(Cinematic_coolBeast) * bj_DEGTORAD + bj_PI / 6.
	local real x = GetUnitX(Cinematic_coolBeast) + 400. * Cos(ang)
	local real y = GetUnitY(Cinematic_coolBeast) + 400. * Sin(ang)
	call IssuePointOrder(Cinematic_coolBeast, "blink", x, y)
	call Cinematic_conditionalScene(.7, ref_function_Cinematic_beast23)
endfunction

function Cinematic_beast24 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast25)
endfunction

function Cinematic_beast25 takes nothing returns nothing
	local item ite
	call RemoveUnit(Cinematic_coolBeast)
	call RemoveUnit(Cinematic_demoHunter)
	call CameraControl_snapBeast( - 348.54, 2149.71)
	call CameraControl_snapAoaBeast(311.61)
	call CameraControl_snapDistanceBeast(1239.67)
	call CameraControl_fadeInBeast(.5)
	set Cinematic_coolBeast = CreateUnit(Players_fromId[Players_FIRST_BEAST], Units_BEAST_ID,  - 952., 3080., 0.)
	set Cinematic_demoHunter = CreateUnit(Players_fromId[0], Units_HUNTER_ID,  - 203., 1440., 90.)
	set ite = CreateItem(Units_GAS_ACTION,  - 203., 1440.)
	call UnitAddItem(Cinematic_demoHunter, ite)
	call UnitAddAbility(Cinematic_demoHunter, 1093677134)
	call SetUnitMoveSpeed(Cinematic_demoHunter, 180.)
	call SetUnitMoveSpeed(Cinematic_coolBeast, 160.)
	call SetWidgetLife(Cinematic_coolBeast, 100.)
	call IssueTargetOrder(Cinematic_coolBeast, "attack", Cinematic_demoHunter)
	set Cinematic_stopwatch = Statistics_secondsElapsed
	call Cinematic_transmissionBeast(12., "The round is won if you prevent the Hunters from " + "returning with the rune, or simply killing them all. But be warned, if care is " + "not taken, Hunters will usually win an outright fight.")
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast26)
	set ite = null
endfunction

function Cinematic_beast26 takes nothing returns nothing
	if IsUnitInRange(Cinematic_coolBeast, Cinematic_demoHunter, 900.) then
		call IssueTargetOrder(Cinematic_demoHunter, "channel", Cinematic_coolBeast)
		call Cinematic_conditionalScene(.75, ref_function_Cinematic_beast28)
	else
		call IssuePointOrder(Cinematic_demoHunter, "move",  - 1715., 3570.)
		call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast26)
	endif
endfunction

function Cinematic_beast28 takes nothing returns nothing
	if UnitAlive(Cinematic_coolBeast) then
		call IssueTargetOrder(Cinematic_demoHunter, "channel", Cinematic_coolBeast)
		call Cinematic_conditionalScene(.75, ref_function_Cinematic_beast28)
	elseif Statistics_secondsElapsed - Cinematic_stopwatch < 13 then
		call IssuePointOrder(Cinematic_demoHunter, "move",  - 1715., 3570.)
		call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast28)
	else
		call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast29)
	endif
endfunction

function Cinematic_beast29 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast30)
endfunction

function Cinematic_beast3 takes nothing returns nothing
	call CameraControl_snapBeast(939.02,  - 2310.99)
	call CameraControl_snapAoaBeast(314.43)
	call CameraControl_snapDistanceBeast(1363.64)
	call CameraControl_snapRotationBeast(56.42)
	set Cinematic_deer = CreateUnit(Players_fromId[Players_PASSIVE], 1852073330, 967.,  - 2540., 140.)
	call UnitRemoveAbility(Cinematic_deer, 1098342766)
	call SetUnitTimeScale(Cinematic_deer, .77)
	call CameraControl_fadeInBeast(.5)
	call Cinematic_transmissionBeast(8., "This wilderness was once a utopia. There " + "was a perfect symbiotic relationship between plants and animals.")
	call Cinematic_conditionalScene(9., ref_function_Cinematic_beast4)
endfunction

function Cinematic_beast30 takes nothing returns nothing
	call RemoveUnit(Cinematic_coolBeast)
	call RemoveUnit(Cinematic_demoHunter)
	set Cinematic_coolBeast = CreateUnit(Players_fromId[Players_FIRST_BEAST], Units_BEAST_ID,  - 3620.,  - 1430., 260.)
	set Cinematic_coolBeast2 = CreateUnit(Players_fromId[Players_FIRST_BEAST + 1], Units_BEAST_ID,  - 3400.,  - 1675., 180.)
	call PauseUnit(Cinematic_coolBeast, true)
	call PauseUnit(Cinematic_coolBeast2, true)
	set Cinematic_demoHunter = CreateUnit(Players_fromId[0], Units_HUNTER_ID,  - 3660.,  - 1660., 180. + 45.)
	set Cinematic_demoHunter2 = CreateUnit(Players_fromId[1], Units_HUNTER_ID,  - 4032.,  - 1000., 180.)
	call SetUnitInvulnerable(Cinematic_demoHunter2, true)
	call Cinematic_titleTextBeast(Cinematic_TITLE_BEAST_THREE)
	call Cinematic_conditionalScene(5., ref_function_Cinematic_beast31)
endfunction

function CameraControl_snapFovBeast takes real aoa returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, aoa, 0.)
	endif
endfunction

function Cinematic_beast31 takes nothing returns nothing
	call CameraControl_snapBeast( - 3562.51,  - 1391.11)
	call CameraControl_snapAoaBeast(270.)
	call CameraControl_snapDistanceBeast(3300.)
	call CameraControl_snapFovBeast(30.)
	call CameraControl_snapRotationBeast(90.)
	call CameraControl_fadeInBeast(.5)
	call Cinematic_transmissionBeast(12., "Humans have much poorer vision than Beasts. " + "They can't see well other than in the forwards direction, and can easily " + "lose track of their allies. Track your enemy and engage stragglers as a group.")
	call Cinematic_conditionalScene(13., ref_function_Cinematic_beast31a)
endfunction

function Cinematic_beast31a takes nothing returns nothing
	call Cinematic_transmissionBeast(12., "Your |cffffcc00Basic Attack|r deals " + "|cffffcc0050|r damage, and an additional |cffffcc0010|r " + "damage over |cffffcc005|r seconds. The damage-over-time component does not stack. " + "Use these values to help assess when to " + "fight and when to wait.")
	call Cinematic_conditionalScene(7.5, ref_function_Cinematic_beast31b)
endfunction

function Cinematic_beast31b takes nothing returns nothing
	call PauseUnit(Cinematic_coolBeast, false)
	call PauseUnit(Cinematic_coolBeast2, false)
	call Cinematic_conditionalScene(5.5, ref_function_Cinematic_beast32)
endfunction

function Cinematic_beast32 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast33)
endfunction

function CameraControl_resetBeast takes nothing returns nothing
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call ResetToGameCamera(0.)
	endif
endfunction

function Units_initializeBeastEx takes unit u, integer balls returns nothing
	local integer ua = new_BeastLightningDat()
	local integer index = 0
	local integer id = GetUnitTypeId(u)
	local integer swap
	set BeastLightningDat_typ[ua] = id
	set BeastLightningDat_u[ua] = u
	set BeastLightningDat_ticksUntilNextCheck[ua] = R2I(Units_LIGHTNING_CHECK_PERIOD / Units_CLOCK_PERIOD)
	set BeastLightningDat_balls[ua] = 0
	call dispatch_Table_Table_Table_saveInt(Units_fromBeast, handle_getHandleId(u), ua)
	if Units_beastHead == 0 then
		set Units_beastHead = ua
		call TimerStart(Units_clock, Units_CLOCK_PERIOD, true, ref_function_Units_beastLightningTick)
	else
		set swap = Units_beastHead
		set BeastLightningDat_prev[swap] = ua
		set BeastLightningDat_next[ua] = swap
		set Units_beastHead = ua
	endif
	loop
		exitwhen index >= balls
		call Units_pushBall(u)
		set index = index + 1
	endloop
endfunction

function Cinematic_beast33 takes nothing returns nothing
	call CameraControl_resetBeast()
	call RemoveUnit(Cinematic_demoHunter)
	call RemoveUnit(Cinematic_demoHunter2)
	call RemoveUnit(Cinematic_coolBeast)
	call RemoveUnit(Cinematic_coolBeast2)
	set Cinematic_coolBeast = CreateUnit(Players_fromId[Players_FIRST_BEAST], Units_BEAST_ID, 3890.,  - 4278., 90.)
	call Units_initializeBeastEx(Cinematic_coolBeast, 5)
	call CameraControl_snapBeast(3637.79,  - 4278.92)
	call CameraControl_panBeast(3596.14,  - 3751.21, 13.)
	call CameraControl_panAoaBeast(309.43, 13.)
	call CameraControl_panDistanceBeast(2196.15, 13.)
	call CameraControl_fadeInBeast(.5)
	call Cinematic_transmissionBeast(12., "Use |cffffcc00Organic Hemisection|r to scout " + "the map and monitor the hunters before planning an engagement.")
	call Cinematic_conditionalScene(5., ref_function_Cinematic_beast33a)
endfunction

function Cinematic_beast33a takes nothing returns nothing
	call IssueImmediateOrder(Cinematic_coolBeast, "channel")
	call Cinematic_conditionalScene(1., ref_function_Cinematic_beast33b)
endfunction

function Cinematic_beast33b takes nothing returns nothing
	set Cinematic_coolBeast2 = Units_hero[Players_FIRST_BEAST]
	set Cinematic_coolBeast = Units_subHero[Players_FIRST_BEAST]
	call SetUnitMoveSpeed(Cinematic_coolBeast, 270. * .8)
	call IssuePointOrder(Cinematic_coolBeast, "move", 2867.,  - 2940.)
	call IssuePointOrder(Cinematic_coolBeast2, "move", 4200.,  - 2940.)
	call Cinematic_conditionalScene(7., ref_function_Cinematic_beast34)
endfunction

function Cinematic_beast34 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast35)
endfunction

function Cinematic_beast35 takes nothing returns nothing
	call CameraControl_resetBeast()
	call RemoveUnit(Cinematic_coolBeast)
	call RemoveUnit(Cinematic_coolBeast2)
	if GetPlayerId(Players_locl) >= Players_FIRST_BEAST then
		call DisplayTimedTextToPlayer(Players_locl, .1, 0., 1., "|cffffcc00Good Luck|r")
	endif
endfunction

function Cinematic_beast4 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast5)
endfunction

function Cinematic_beast5 takes nothing returns nothing
	call RemoveUnit(Cinematic_deer)
	call CameraControl_fadeInBeast(.5)
	call CameraControl_snapBeast( - 838.9,  - 177.35)
	call CameraControl_snapRotationBeast(244.8)
	call CameraControl_snapAoaBeast(307.59)
	call CameraControl_snapDistanceBeast(1363.64)
	call Cinematic_transmissionBeast(8., "A |cffffcc00Rune|r was buried beneath these " + "mountains - it emanated power. The soil itself lent this life to its " + "surroundings.")
	call Cinematic_conditionalScene(9., ref_function_Cinematic_beast6)
endfunction

function Cinematic_beast6 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast7)
endfunction

function Cinematic_beast7 takes nothing returns nothing
	set Cinematic_primative = CreateUnit(Players_fromId[Players_FIRST_BEAST], 1747988553, 4732., 2748., 100.)
	set Cinematic_attackTarget = CreateUnit(Players_fromId[0], 1747988554, 4722., 2770., 0.)
	call SetUnitTimeScale(Cinematic_primative, .8)
	call IssueTargetOrder(Cinematic_primative, "attack", Cinematic_attackTarget)
	call CameraControl_snapBeast(4734.42, 2744.56)
	call CameraControl_snapRotationBeast(90.)
	call CameraControl_snapAoaBeast(304.)
	call CameraControl_snapDistanceBeast(636.15)
	call CameraControl_fadeInBeast(.5)
	call Cinematic_transmissionBeast(10., "Primative humans unearthed the rune by chance, and " + "received great intellectual growth, hence imperializing the region. They " + "worshipped the rune as their source of science, economics, and creativity.")
	call Cinematic_conditionalScene(11., ref_function_Cinematic_beast8)
endfunction

function Cinematic_beast8 takes nothing returns nothing
	call CameraControl_fadeOutBeast(.5)
	call Cinematic_conditionalScene(.5, ref_function_Cinematic_beast9)
endfunction

function Cinematic_beast9 takes nothing returns nothing
	call RemoveUnit(Cinematic_primative)
	call RemoveUnit(Cinematic_attackTarget)
	set Cinematic_robed = CreateUnit(Players_fromId[Players_PASSIVE], 1747988555,  - 5039.,  - 4895., 45.)
	set Cinematic_robed2 = CreateUnit(Players_fromId[Players_PASSIVE], 1747988555,  - 4993.,  - 4800., 45. + 180. + 25.)
	call SetUnitTimeScale(Cinematic_robed, .5)
	call SetUnitTimeScale(Cinematic_robed2, .61)
	set Cinematic_gatherTarget = CreateDestructable(1096053874, ( - 4235.) + 2000.,  - 5180., 270., 1., 0)
	set Cinematic_gatherer = CreateUnit(Players_fromId[Players_PASSIVE], 1752196449, ( - 4235.) + 2000. - 64.,  - 5180., 0.)
	set Cinematic_gatherer2 = CreateUnit(Players_fromId[Players_PASSIVE], 1752196449, ( - 4235.) + 2000., ( - 5180.) + 64., 270.)
	set Cinematic_gatherer3 = CreateUnit(Players_fromId[Players_PASSIVE], 1752196449, ( - 4235.) + 2000. + 64.,  - 5180., 180.)
	call IssueTargetOrder(Cinematic_gatherer, "smart", Cinematic_gatherTarget)
	call IssueTargetOrder(Cinematic_gatherer2, "smart", Cinematic_gatherTarget)
	call IssueTargetOrder(Cinematic_gatherer3, "smart", Cinematic_gatherTarget)
	call SetUnitMoveSpeed(Cinematic_gatherer, 90.)
	call SetUnitMoveSpeed(Cinematic_gatherer2, 83.)
	call SetUnitMoveSpeed(Cinematic_gatherer3, 80.)
	call CameraControl_snapBeast( - 4825.27,  - 4901.36)
	call CameraControl_snapDistanceBeast(846.71)
	call CameraControl_snapAoaBeast(304.00)
	call CameraControl_fadeInBeast(.5)
	call Cinematic_transmissionBeast(14., "As the kingdom grew, a class divide became more " + "pronounced, and eventually a number of rebel groups banded together and rose " + "against imperialization. The rune was stolen, and the rebels were subsequently " + "annhialated, but the rune was never found.")
	call Cinematic_conditionalScene(1., ref_function_Cinematic_beast10)
endfunction

function Cinematic_cleanup takes nothing returns nothing
	local integer index = 0
	call RemoveUnit(Cinematic_farmer)
	call RemoveUnit(Cinematic_farmer2)
	call RemoveUnit(Cinematic_primative)
	call RemoveUnit(Cinematic_attackTarget)
	call RemoveUnit(Cinematic_corpse)
	call RemoveItem(Cinematic_dummyItem)
	call RemoveUnit(Cinematic_deer)
	call RemoveUnit(Cinematic_gatherer)
	call RemoveUnit(Cinematic_gatherer2)
	call RemoveUnit(Cinematic_gatherer3)
	call RemoveUnit(Cinematic_robed)
	call RemoveUnit(Cinematic_robed2)
	call RemoveDestructable(Cinematic_gatherTarget)
	call RemoveUnit(Cinematic_coolBeast)
	call RemoveUnit(Cinematic_coolBeast2)
	call RemoveUnit(Cinematic_coolBeast3)
	call RemoveUnit(Cinematic_demoHunter)
	loop
		exitwhen index > 7
		call FogModifierStop(Cinematic_fm[index])
		call DestroyFogModifier(Cinematic_fm[index])
		set index = index + 1
	endloop
	call RemoveUnit(Cinematic_hunter)
	call RemoveUnit(Cinematic_hunter2)
	call RemoveUnit(Cinematic_beast)
	call RemoveUnit(Cinematic_demoHunter2)
endfunction

function CameraControl_fadeInHunter takes real duration returns nothing
	if CameraControl_hunterFadeContinueTimer != null then
		call DestroyTimer(CameraControl_hunterFadeContinueTimer)
	endif
	if CameraControl_hunterFadeFinishTimer != null then
		call DestroyTimer(CameraControl_hunterFadeFinishTimer)
	endif
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call EnableUserUI(false)
		call SetCineFilterTexture(CameraControl_FILTER_MASK)
		call SetCineFilterBlendMode(BLEND_MODE_BLEND)
		call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
		call SetCineFilterStartUV(0., 0., 1., 1.)
		call SetCineFilterEndUV(0., 0., 1., 1.)
		call SetCineFilterStartColor(0, 0, 0, 255)
		call SetCineFilterEndColor(0, 0, 0, 0)
		call SetCineFilterDuration(duration)
		call DisplayCineFilter(true)
	endif
	set CameraControl_hunterFadeFinishTimer = CreateTimer()
	call TimerStart(CameraControl_hunterFadeFinishTimer, duration, false, ref_function_CameraControl_endFadeHunter)
endfunction

function Cinematic_clearTextHuman takes nothing returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call ClearTextMessages()
	endif
endfunction

function randomizeSitePreferences takes nothing returns nothing
	local integer index = 0
	loop
		exitwhen index >= Players_FIRST_BEAST
		call dispatch_Table_Table_Table_saveInt(Units_sitePref, handle_getHandleId(Units_hero[index]), GetRandomInt(0, 1))
		set index = index + 1
	endloop
endfunction

function AI_resetState takes nothing returns nothing
	local integer index = Players_FIRST_BEAST
	call hunterElection()
	call randomizeSitePreferences()
	loop
		exitwhen index > Players_LAST_BEAST
		call dispatch_Table_Table_Table_saveInt(Units_beastState, handle_getHandleId(Units_hero[index]), AI_STATE_AGGRESSIVE)
		call dispatch_Table_Table_Table_saveInt(Units_thunderCd, handle_getHandleId(Units_hero[index]), 0)
		set index = index + 1
	endloop
endfunction

function Units_clearExtraItems takes nothing returns nothing
	call EnumItemsInRect(bj_mapInitialPlayableArea, null, ref_function_Units_filterItems)
endfunction

function Units_clearNonHunters takes nothing returns nothing
	local integer index = 0
	local unit iter
	loop
		exitwhen index > Players_LAST_BEAST
		call GroupEnumUnitsOfPlayer(Units_grp, Players_fromId[index], null)
		loop
			set iter = FirstOfGroup(Units_grp)
			exitwhen iter == null
			call GroupRemoveUnit(Units_grp, iter)
			if GetUnitTypeId(iter) != Units_HUNTER_ID or ( not UnitAlive(iter)) then
				call RemoveUnit(iter)
			endif
		endloop
		set index = index + 1
	endloop
	set iter = null
endfunction

function showBoard takes nothing returns nothing
	call MultiboardDisplay(MultiboardControl_mb, true)
endfunction

function unit_addXp takes unit this, integer toAdd, boolean showEyeCandy returns nothing
	call AddHeroXP(this, toAdd, showEyeCandy)
endfunction

function unit_getState takes unit this, unitstate state returns real
	return GetUnitState(this, state)
endfunction

function unit_setX takes unit this, real x returns nothing
	call SetUnitX(this, x)
endfunction

function unit_setY takes unit this, real y returns nothing
	call SetUnitY(this, y)
endfunction

function unit_unpause takes unit this returns nothing
	call PauseUnit(this, false)
endfunction

function Game_roundStart takes nothing returns nothing
	local integer index = 0
	local real offsX
	local real offsY
	local unit receiver
	local unit receiver_2
	local unit receiver_3
	call Units_clearNonHunters()
	call Units_clearExtraItems()
	set Statistics_roundEndTime = Statistics_secondsElapsed + Game_ROUND_DURATION
	set Game_roundEnabled = true
	set Statistics_huntersAlive = 0
	set Statistics_beastsAlive = 0
	call SetItemPosition(Units_artifact, TerrainData_RUNE_1_X, TerrainData_RUNE_1_Y)
	call SetItemPosition(Units_artifact2, TerrainData_RUNE_2_X, TerrainData_RUNE_2_Y)
	call ResetToGameCamera(0.)
	call FogEnable(true)
	loop
		exitwhen index >= Players_COUNT
		if index < Players_FIRST_BEAST then
			if Players_playing[index] then
				if UnitAlive(Units_hero[index]) then
					set receiver = Units_hero[index]
					call unit_setX(receiver, TerrainData_HUNTER_SPAWN_X)
					set receiver_2 = receiver
					call unit_setY(receiver_2, TerrainData_HUNTER_SPAWN_Y)
					set receiver_3 = receiver_2
					call unit_unpause(receiver_3)
					call SetWidgetLife(Units_hero[index], unit_getState(Units_hero[index], UNIT_STATE_MAX_LIFE))
					call SetUnitInvulnerable(Units_hero[index], false)
				else
					set Units_hero[index] = CreateUnit(Players_fromId[index], Units_HUNTER_ID, TerrainData_HUNTER_SPAWN_X, TerrainData_HUNTER_SPAWN_Y, 270.)
				endif
				set Statistics_huntersAlive = Statistics_huntersAlive + 1
			endif
			if Players_locl == Players_fromId[index] then
				call PanCameraToTimed(TerrainData_HUNTER_SPAWN_X, TerrainData_HUNTER_SPAWN_Y, 0.)
				call SelectUnit(Units_hero[index], true)
			endif
		else
			if Players_playing[index] then
				set offsX = Game_BEAST_PLACE_OFFSET * Cos(index * 2. * bj_PI / (Players_COUNT * 1. / 2))
				set offsY = Game_BEAST_PLACE_OFFSET * Sin(index * 2. * bj_PI / (Players_COUNT * 1. / 2))
				set Units_hero[index] = CreateUnit(Players_fromId[index], Units_BEAST_ID, TerrainData_BEAST_SPAWN_X + offsX, TerrainData_BEAST_SPAWN_Y + offsY, 270.)
				call Units_initializeBeast(Units_hero[index])
				call UnitAddAbility(Units_hero[index], 1098015094)
				call UnitRemoveAbility(Units_hero[index], 1098015094)
				set Statistics_beastsAlive = Statistics_beastsAlive + 1
			endif
			if Players_locl == Players_fromId[index] then
				call PanCameraToTimed(TerrainData_BEAST_SPAWN_X, TerrainData_BEAST_SPAWN_Y, 0.)
				call SelectUnit(Units_hero[index], true)
			endif
		endif
		set Players_aliveCount = Players_aliveCount + 1
		call unit_addXp(Units_hero[index], 1000, false)
		call IssueImmediateOrder(Units_hero[index], "stop")
		set index = index + 1
	endloop
	call AI_resetState()
	call showBoard()
	set receiver = null
	set receiver_2 = null
	set receiver_3 = null
endfunction

function TextTag_resetMinimapLabels takes nothing returns nothing
	local integer index = 0
	loop
		exitwhen index > TextTag_labelIndex
		call DestroyTextTag(TextTag_minimapLabels[index])
		set index = index + 1
	endloop
	set TextTag_labelIndex = -1
endfunction

function Cinematic_endCinematic takes nothing returns nothing
	call TimerStart(Cinematic_humanClock, 0., false, ref_function_Cinematic_cleanup)
	call CameraControl_fadeInBeast(.5)
	call CameraControl_fadeInHunter(.5)
	call ShowInterface(true, .5)
	call StartSound(Cinematic_tipSound)
	call EnableUserUI(true)
	call EnableUserControl(true)
	set Cinematic_enabled = false
	set Cinematic_over = true
	call FogEnable(true)
	call FogMaskEnable(false)
	call ResetToGameCamera(0.)
	call TextTag_resetMinimapLabels()
	call Cinematic_clearTextHuman()
	call Cinematic_clearTextBeast()
	set Cinematic_wfx = AddWeatherEffect(bj_mapInitialPlayableArea, 1280470369)
	call EnableWeatherEffect(Cinematic_wfx, true)
	call Game_roundStart()
endfunction

function CameraControl_snapAoaHuman takes real aoa returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, aoa, 0.)
	endif
endfunction

function CameraControl_snapDistanceHuman takes real d returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, d, 0.)
	endif
endfunction

function CameraControl_snapHuman takes real x, real y returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call PanCameraToTimed(x, y, 0.)
	endif
endfunction

function Cinematic_biconditionalScene takes real sleep, code next returns nothing
	if Players_escapePressedCount >= Players_humanCount then
		call Cinematic_endCinematic()
	else
		call TimerStart(Cinematic_humanClock, sleep, false, next)
	endif
endfunction

function Cinematic_human0 takes nothing returns nothing
	call Cinematic_clearTextHuman()
	call CameraControl_snapHuman(Cinematic_MINIMAP_X, Cinematic_MINIMAP_Y)
	call CameraControl_snapAoaHuman(Cinematic_MINIMAP_AOA)
	call CameraControl_snapDistanceHuman(Cinematic_MINIMAP_DISTANCE)
	call CameraControl_fadeInHunter(.5)
	call Cinematic_biconditionalScene(1.5, ref_function_Cinematic_human1)
endfunction

function Cinematic_titleTextHuman takes string text returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call DisplayTimedTextToPlayer(Players_locl, .1, 0., 3., text)
	endif
endfunction

function Cinematic_human1 takes nothing returns nothing
	call Cinematic_titleTextHuman(Cinematic_TITLE_ONE)
	call Cinematic_biconditionalScene(5., ref_function_Cinematic_human2)
endfunction

function CameraControl_panDistanceHuman takes real dist, real duration returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, dist, duration)
	endif
endfunction

function CameraControl_panHuman takes real x, real y, real duration returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call PanCameraToTimed(x, y, duration)
	endif
endfunction

function Cinematic_human10 takes nothing returns nothing
	call CameraControl_snapHuman(Cinematic_FOREST_X, Cinematic_FOREST_Y)
	call CameraControl_snapAoaHuman(Cinematic_FOREST_AOA)
	call CameraControl_snapDistanceHuman(Cinematic_FOREST_DISTANCE)
	call CameraControl_panHuman(Cinematic_FOREST_X + 128., Cinematic_FOREST_Y + 128., 7.)
	call CameraControl_panDistanceHuman(Cinematic_FOREST_DISTANCE * 1.1, 7.)
	call RemoveUnit(Cinematic_farmer)
	call RemoveUnit(Cinematic_farmer2)
	call SetUnitTimeScale(Cinematic_hunter, .5)
	call SetUnitTimeScale(Cinematic_hunter2, .44)
	call CameraControl_fadeInHunter(.5)
	call Cinematic_biconditionalScene(7., ref_function_Cinematic_human11)
endfunction

function CameraControl_fadeOutHunter takes real duration returns nothing
	if CameraControl_hunterFadeContinueTimer != null then
		call DestroyTimer(CameraControl_hunterFadeContinueTimer)
	endif
	if CameraControl_hunterFadeFinishTimer != null then
		call DestroyTimer(CameraControl_hunterFadeFinishTimer)
	endif
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call EnableUserUI(false)
		call SetCineFilterTexture(CameraControl_FILTER_MASK)
		call SetCineFilterBlendMode(BLEND_MODE_BLEND)
		call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
		call SetCineFilterStartUV(0., 0., 1., 1.)
		call SetCineFilterEndUV(0., 0., 1., 1.)
		call SetCineFilterStartColor(0, 0, 0, 0)
		call SetCineFilterEndColor(0, 0, 0, 255)
		call SetCineFilterDuration(duration)
		call DisplayCineFilter(true)
	endif
endfunction

function Cinematic_human11 takes nothing returns nothing
	call CameraControl_fadeOutHunter(.5)
	call Cinematic_biconditionalScene(.5, ref_function_Cinematic_human12)
endfunction

function CameraControl_resetHuman takes nothing returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call ResetToGameCamera(0.)
	endif
endfunction

function Cinematic_transmissionHuman takes real duration, string text returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call SetCinematicScene(0, PLAYER_COLOR_LIGHT_BLUE, "", text, duration, duration)
	endif
endfunction

function Cinematic_human12 takes nothing returns nothing
	call RemoveUnit(Cinematic_hunter)
	call RemoveUnit(Cinematic_hunter2)
	call RemoveUnit(Cinematic_corpse)
	call CameraControl_resetHuman()
	call CameraControl_snapHuman( - 528.62, 3954.2)
	call CameraControl_snapDistanceHuman(1239.67)
	set Cinematic_hunter = CreateUnit(Players_fromId[Players_PASSIVE], 1752196449, 209., 3900., 180.)
	call SetUnitMoveSpeed(Cinematic_hunter, 130.)
	call IssuePointOrder(Cinematic_hunter, "move",  - 1200., 3830.)
	call CameraControl_fadeInHunter(.5)
	call Cinematic_transmissionHuman(8., Cinematic_HUNTER_COMPARISON)
	call Cinematic_biconditionalScene(9., ref_function_Cinematic_human12a)
endfunction

function Cinematic_human12a takes nothing returns nothing
	call CameraControl_fadeOutHunter(.5)
	call Cinematic_biconditionalScene(.5, ref_function_Cinematic_human13)
endfunction

function Cinematic_human13 takes nothing returns nothing
	call RemoveUnit(Cinematic_hunter)
	set Cinematic_hunter = CreateUnit(Players_fromId[0], Units_HUNTER_ID, 256.,  - 3196., 270.)
	call CameraControl_resetHuman()
	call CameraControl_snapHuman(TerrainData_RUNE_2_X, TerrainData_RUNE_2_Y)
	call Cinematic_titleTextHuman(Cinematic_TITLE_TWO)
	call Cinematic_biconditionalScene(5., ref_function_Cinematic_human14)
endfunction

function Cinematic_human14 takes nothing returns nothing
	call CameraControl_fadeInHunter(.5)
	call Cinematic_transmissionHuman(9., Cinematic_RUNE_LOCATION_EXPOSITION)
	call Cinematic_biconditionalScene(4., ref_function_Cinematic_human14a)
endfunction

function Cinematic_human14a takes nothing returns nothing
	call IssueTargetOrder(Cinematic_hunter, "smart", Units_artifact2)
	call Cinematic_biconditionalScene(4., ref_function_Cinematic_human14b)
endfunction

function Cinematic_human14b takes nothing returns nothing
	call CameraControl_fadeOutHunter(.5)
	call Cinematic_biconditionalScene(.5, ref_function_Cinematic_human14c)
endfunction

function Cinematic_human14c takes nothing returns nothing
	call SetItemPosition(Units_artifact2, 0., 0.)
	set Cinematic_dummyItem = CreateItem(1227894832, TerrainData_RUNE_2_X, TerrainData_RUNE_2_Y)
	call UnitAddItem(Cinematic_hunter, Cinematic_dummyItem)
	call SetUnitX(Cinematic_hunter,  - 2150.)
	call SetUnitY(Cinematic_hunter, 3180.)
	call CameraControl_snapHuman( - 1715., 3630.)
	call CameraControl_snapAoaHuman(304.)
	call CameraControl_snapDistanceHuman(1127.)
	call CameraControl_fadeInHunter(.5)
	call UnitDropItemPoint(Cinematic_hunter, Cinematic_dummyItem,  - 1622., 3660.)
	call Cinematic_biconditionalScene(2.5, ref_function_Cinematic_human15)
endfunction

function Cinematic_human15 takes nothing returns nothing
	call Cinematic_transmissionHuman(8., Cinematic_ROUND_OBJECTIVE_EXPLANATION)
	call Cinematic_biconditionalScene(9., ref_function_Cinematic_human16)
endfunction

function Cinematic_human16 takes nothing returns nothing
	call CameraControl_fadeOutHunter(.5)
	call Cinematic_biconditionalScene(1.5, ref_function_Cinematic_human17)
endfunction

function unit_getX takes unit this returns real
	return GetUnitX(this)
endfunction

function unit_getY takes unit this returns real
	return GetUnitY(this)
endfunction

function Cinematic_human17 takes nothing returns nothing
	local item ite
	call RemoveUnit(Cinematic_hunter)
	call RemoveItem(Cinematic_dummyItem)
	set Cinematic_hunter = CreateUnit(Players_fromId[0], Units_HUNTER_ID,  - 5032., 5032., 90.)
	set Cinematic_hunter2 = CreateUnit(Players_fromId[Players_PASSIVE], Units_HUNTER_ID, ( - 647.) + 512. + 256. + 128. + 64., ( - 1559.) + 128., 90.)
	set ite = CreateItem(Units_GAS_ACTION, unit_getX(Cinematic_hunter), unit_getY(Cinematic_hunter))
	call UnitAddItem(Cinematic_hunter, ite)
	call CameraControl_resetHuman()
	call Cinematic_titleTextHuman(Cinematic_TITLE_THREE)
	call Cinematic_biconditionalScene(5., ref_function_Cinematic_human18)
	set ite = null
endfunction

function Cinematic_human18 takes nothing returns nothing
	local integer index = 0
	call FogEnable(true)
	call FogMaskEnable(true)
	call SetUnitX(Cinematic_hunter,  - 647.)
	call SetUnitY(Cinematic_hunter,  - 1559.)
	set Cinematic_beast = CreateUnit(Players_fromId[Players_FIRST_BEAST], Units_BEAST_ID,  - 647., ( - 1559.) + 512., 90.)
	call PauseUnit(Cinematic_beast, true)
	call SetPlayerAlliance(Players_fromId[Players_PASSIVE], Players_fromId[Players_FIRST_BEAST], ALLIANCE_PASSIVE, false)
	call SetPlayerAlliance(Players_fromId[Players_FIRST_BEAST], Players_fromId[Players_PASSIVE], ALLIANCE_PASSIVE, false)
	set Cinematic_fm[0] = CreateFogModifierRadius(Players_fromId[1], FOG_OF_WAR_VISIBLE,  - 647.,  - 1559., 500., false, false)
	set Cinematic_fm[1] = CreateFogModifierRadius(Players_fromId[2], FOG_OF_WAR_VISIBLE,  - 647.,  - 1559., 500., false, false)
	set Cinematic_fm[2] = CreateFogModifierRadius(Players_fromId[0], FOG_OF_WAR_VISIBLE,  - 647., ( - 1559.) + 500., 600., false, false)
	set Cinematic_fm[3] = CreateFogModifierRadius(Players_fromId[1], FOG_OF_WAR_VISIBLE,  - 647., ( - 1559.) + 500., 600., false, false)
	set Cinematic_fm[4] = CreateFogModifierRadius(Players_fromId[2], FOG_OF_WAR_VISIBLE,  - 647., ( - 1559.) + 500., 600., false, false)
	set Cinematic_fm[5] = CreateFogModifierRadius(Players_fromId[0], FOG_OF_WAR_VISIBLE, ( - 647.) + 512. + 256. + 128. + 64., ( - 1559.) + 128., 350., false, false)
	set Cinematic_fm[6] = CreateFogModifierRadius(Players_fromId[1], FOG_OF_WAR_VISIBLE, ( - 647.) + 512. + 256. + 128. + 64., ( - 1559.) + 128., 350., false, false)
	set Cinematic_fm[7] = CreateFogModifierRadius(Players_fromId[2], FOG_OF_WAR_VISIBLE, ( - 647.) + 512. + 256. + 128. + 64., ( - 1559.) + 128., 350., false, false)
	loop
		exitwhen index > 7
		call FogModifierStart(Cinematic_fm[index])
		set index = index + 1
	endloop
	call CameraControl_snapHuman( - 179.14,  - 1337.26)
	call CameraControl_snapDistanceHuman(1996.5)
	call CameraControl_fadeInHunter(.5)
	call Cinematic_transmissionHuman(8., Cinematic_HUMAN_PROPERTIES)
	call Cinematic_biconditionalScene(10., ref_function_Cinematic_human19)
endfunction

function Cinematic_human19 takes nothing returns nothing
	call Cinematic_transmissionHuman(8., Cinematic_BEAST_TELEPATHY)
	call Cinematic_biconditionalScene(3., ref_function_Cinematic_human20)
endfunction

function Cinematic_human2 takes nothing returns nothing
	call Cinematic_transmissionHuman(12., Cinematic_HUMAN_INTRO_TEXT)
	call Cinematic_biconditionalScene(13., ref_function_Cinematic_human3)
endfunction

function Cinematic_human20 takes nothing returns nothing
	call IssuePointOrder(Cinematic_hunter, "move", GetUnitX(Cinematic_hunter), GetUnitY(Cinematic_hunter) + 128. + 64.)
	call SetUnitFacingTimed(Cinematic_beast, 270., 1.)
	call Cinematic_biconditionalScene(7., ref_function_Cinematic_human21)
endfunction

function Cinematic_human21 takes nothing returns nothing
	call Cinematic_transmissionHuman(8., Cinematic_HOW_TO_SHOOT)
	call Cinematic_biconditionalScene(3., ref_function_Cinematic_human22)
endfunction

function Cinematic_human22 takes nothing returns nothing
	call IssuePointOrder(Cinematic_hunter, "channel", GetUnitX(Cinematic_beast), GetUnitY(Cinematic_beast))
	call IssuePointOrder(Cinematic_hunter2, "channel", GetUnitX(Cinematic_beast) + 100., GetUnitY(Cinematic_beast) - 100.)
	call Cinematic_biconditionalScene(5., ref_function_Cinematic_human23)
endfunction

function Cinematic_human23 takes nothing returns nothing
	local integer index = 0
	call CameraControl_fadeOutHunter(.5)
	call RemoveUnit(Cinematic_hunter)
	call RemoveUnit(Cinematic_hunter2)
	call RemoveUnit(Cinematic_beast)
	loop
		exitwhen index > 7
		call FogModifierStop(Cinematic_fm[index])
		call DestroyFogModifier(Cinematic_fm[index])
		set index = index + 1
	endloop
	call Cinematic_biconditionalScene(.5, ref_function_Cinematic_human24)
endfunction

function Cinematic_human24 takes nothing returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call DisplayTimedTextToPlayer(Players_locl, .1, 0., 1., "|cffffcc00Good Luck|r")
	endif
	call Cinematic_biconditionalScene(3., ref_function_Cinematic_endCinematic)
endfunction

function TextTag_minimapLabel takes string s, real x, real y returns texttag
	local texttag tt = CreateTextTag()
	call SetTextTagPermanent(tt, true)
	call SetTextTagPos(tt, x - 10. * StringLength(s), y, 0.)
	call SetTextTagText(tt, s, 12. * .00225)
	call SetTextTagVisibility(tt, true)
	set TextTag_labelIndex = TextTag_labelIndex + 1
	set TextTag_minimapLabels[TextTag_labelIndex] = tt
	set TextTag_minimapLabeltempReturn = tt
	set tt = null
	return TextTag_minimapLabeltempReturn
endfunction

function Cinematic_human3 takes nothing returns nothing
	local texttag tt = TextTag_minimapLabel("Uzapils", Cinematic_CASTLE_X, Cinematic_CASTLE_Y)
	call SetTextTagColor(tt, 255, 200, 0, 255)
	call Cinematic_transmissionHuman(8., Cinematic_FORTRESS_EXPOSITION)
	call Cinematic_biconditionalScene(9., ref_function_Cinematic_human4)
	set tt = null
endfunction

function Cinematic_human4 takes nothing returns nothing
	call TextTag_minimapLabel("Ziematerre", Cinematic_NORTH_X, Cinematic_NORTH_Y)
	call TextTag_minimapLabel("Forresthill", Cinematic_SOUTH_X, Cinematic_SOUTH_Y)
	call TextTag_minimapLabel("Cascade Peaks", Cinematic_MTN_X, Cinematic_MTN_Y)
	call TextTag_minimapLabel("Hunter's Hall", Cinematic_HALL_X, Cinematic_HALL_Y)
	call Cinematic_transmissionHuman(8., Cinematic_TOWNS_EXPOSITION)
	call Cinematic_biconditionalScene(9., ref_function_Cinematic_human5)
endfunction

function Cinematic_human5 takes nothing returns nothing
	local texttag tt = TextTag_minimapLabel("x", Cinematic_RED_X, Cinematic_RED_Y)
	call SetTextTagColor(tt, 255, 100, 100, 255)
	call Cinematic_transmissionHuman(13., Cinematic_CLASS_DIVIDE_EXPOSITION)
	call Cinematic_biconditionalScene(14., ref_function_Cinematic_human6)
	set tt = null
endfunction

function Cinematic_human6 takes nothing returns nothing
	local texttag tt
	call TextTag_resetMinimapLabels()
	call TextTag_minimapLabel("Hunter's Hall", Cinematic_HALL_X, Cinematic_HALL_Y)
	set tt = TextTag_minimapLabel("x", Cinematic_RED_X, Cinematic_RED_Y)
	call SetTextTagColor(tt, 255, 100, 100, 255)
	call Cinematic_transmissionHuman(9., Cinematic_EXPOSITION_BEAST_SITUATION)
	call Cinematic_biconditionalScene(10., ref_function_Cinematic_human7)
	set tt = null
endfunction

function Cinematic_human7 takes nothing returns nothing
	call CameraControl_fadeOutHunter(.5)
	call Cinematic_biconditionalScene(.5, ref_function_Cinematic_human8)
endfunction

function CameraControl_snapRotationHuman takes real r returns nothing
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call SetCameraField(CAMERA_FIELD_ROTATION, r, 0.)
	endif
endfunction

function Cinematic_human8 takes nothing returns nothing
	set Cinematic_farmer = CreateUnit(Players_fromId[Players_PASSIVE], 1752196449, Cinematic_FARM_X, Cinematic_FARM_Y, 360. * 7. / 8.)
	set Cinematic_farmer2 = CreateUnit(Players_fromId[Players_PASSIVE], 1752196449, Cinematic_FARM_X - 196., Cinematic_FARM_Y + 48., 360. * 3. / 8.)
	call TextTag_resetMinimapLabels()
	call SetUnitAnimation(Cinematic_farmer, "stand work")
	call SetUnitTimeScale(Cinematic_farmer, .5)
	call SetUnitAnimation(Cinematic_farmer2, "stand work")
	call SetUnitTimeScale(Cinematic_farmer2, .42)
	call SetUnitScale(Cinematic_farmer2, 1.1, 1.1, 1.1)
	call CameraControl_snapHuman(Cinematic_FARM_X, Cinematic_FARM_Y)
	call CameraControl_snapAoaHuman(Cinematic_FARM_AOA)
	call CameraControl_snapDistanceHuman(Cinematic_FARM_DISTANCE)
	call CameraControl_snapRotationHuman(Cinematic_FARM_ROTATION)
	call CameraControl_fadeInHunter(.5)
	call Cinematic_transmissionHuman(12.5, Cinematic_HUNTERS_HALL_EXPOSITION)
	call Cinematic_biconditionalScene(3., ref_function_Cinematic_human8b)
endfunction

function Cinematic_human8b takes nothing returns nothing
	call SetUnitTimeScale(Cinematic_farmer, .6)
	call SetUnitTimeScale(Cinematic_farmer2, .38)
	call Cinematic_biconditionalScene(3., ref_function_Cinematic_human9)
endfunction

function Cinematic_human9 takes nothing returns nothing
	set Cinematic_hunter = CreateUnit(Players_fromId[0], 1747988552, 4000.,  - 50., 45.)
	set Cinematic_hunter2 = CreateUnit(Players_fromId[1], Units_HUNTER_ID, 3980., 22., 45.)
	set Cinematic_corpse = CreateCorpse(Players_fromId[Players_PASSIVE], 1852073330, 4320., 350., 200.)
	call CameraControl_fadeOutHunter(.5)
	call Cinematic_biconditionalScene(.5, ref_function_Cinematic_human10)
endfunction

function Cinematic_neutral1 takes nothing returns nothing
	call ClearTextMessages()
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 2.5, "    |cffffcc00Hunter's Hall|r")
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 2.5, "|cff999999A map by Cokemonkey11|r")
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 2.5, " ")
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 2.5, " ")
	call Cinematic_biconditionalScene(4.5, ref_function_Cinematic_neutral2)
endfunction

function Cinematic_neutral2 takes nothing returns nothing
	call ClearTextMessages()
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 5., " ")
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 5., " ")
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 5., "|cffeaeaea\"When in doubt, use brute force.\"|r")
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 5., "    |cffc9c9c9-Ken Thompson|r")
	call StartSound(Cinematic_startSound)
	call Cinematic_biconditionalScene(7., ref_function_Cinematic_human0)
	call Cinematic_conditionalScene(7., ref_function_Cinematic_beast0)
endfunction

function DamageType_dealCodeDamage takes unit who, unit target, real damage returns nothing
	local integer prevType = DamageType_lastDamageType
	local real hp = GetWidgetLife(target) - .405
	local real d = damage
	set DamageType_lastDamageType = DamageType_CODE
	if hp > d then
		call SetWidgetLife(target, hp - d + .405)
		call UnitDamageTarget(who, target, 0., true, false, DamageType_ATTACK_TYPE_UNIVERSAL, DAMAGE_TYPE_UNIVERSAL, null)
	else
		call UnitDamageTarget(who, target, 1000000. + d, true, false, DamageType_ATTACK_TYPE_UNIVERSAL, DAMAGE_TYPE_UNIVERSAL, null)
		call UnitDamageTarget(who, target, 1000000. + d, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_UNIVERSAL, null)
	endif
	set DamageType_lastDamageType = prevType
endfunction

function DotData_onDestroy takes integer this returns nothing
endfunction

function dealloc_DotData takes integer obj returns nothing
	if DotData_typeId[obj] == 0 then
		call error("Double free: object of type DotData")
	else
		set DotData_nextFree[DotData_firstFree] = obj
		set DotData_firstFree = DotData_firstFree + 1
		set DotData_typeId[obj] = 0
	endif
endfunction

function destroyDotData takes integer this returns nothing
	call DotData_onDestroy(this)
	call dealloc_DotData(this)
endfunction

function dispatch_DotData_destroyDotData takes integer this returns nothing
	if DotData_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling DotData.destroyDotData")
		else
			call error("Called DotData.destroyDotData on invalid object.")
		endif
	endif
	call destroyDotData(this)
endfunction

function DamageOverTime_damageTick takes nothing returns nothing
	local integer index = 0
	local integer tempDat
	loop
		exitwhen index > DamageOverTime_dbIndex
		set tempDat = DamageOverTime_dotDB[index]
		if DotData_fxFlag[tempDat] == DamageOverTime_FX_FLAG_COORDS then
			call DestroyEffect(AddSpecialEffect(DotData_fx[tempDat], GetUnitX(DotData_target[tempDat]), GetUnitY(DotData_target[tempDat])))
		elseif DotData_fxFlag[tempDat] == DamageOverTime_FX_FLAG_ATTACH then
			call DestroyEffect(AddSpecialEffectTarget(DotData_fx[tempDat], DotData_target[tempDat], "origin"))
		else
			call BJDebugMsg("DamageOverTime.damageTick: Unrecognized fx flag received")
		endif
		call DamageType_dealCodeDamage(DotData_source[tempDat], DotData_target[tempDat], DotData_dps[tempDat] * DamageOverTime_CLOCK_PERIOD)
		set DotData_duration[tempDat] = DotData_duration[tempDat] - DamageOverTime_CLOCK_PERIOD
		if DotData_duration[tempDat] <= 0. or ( not UnitAlive(DotData_target[tempDat])) or ( not Game_roundEnabled) then
			call dispatch_DotData_destroyDotData(tempDat)
			set DamageOverTime_dotDB[index] = DamageOverTime_dotDB[DamageOverTime_dbIndex]
			set DamageOverTime_dbIndex = DamageOverTime_dbIndex - 1
			set index = index - 1
			if DamageOverTime_dbIndex == -1 then
				call PauseTimer(DamageOverTime_time)
			endif
		endif
		set index = index + 1
	endloop
endfunction

function DelayDat_onDestroy takes integer this returns nothing
endfunction

function dealloc_DelayDat takes integer obj returns nothing
	if DelayDat_typeId[obj] == 0 then
		call error("Double free: object of type DelayDat")
	else
		set DelayDat_nextFree[DelayDat_firstFree] = obj
		set DelayDat_firstFree = DelayDat_firstFree + 1
		set DelayDat_typeId[obj] = 0
	endif
endfunction

function destroyDelayDat takes integer this returns nothing
	call DelayDat_onDestroy(this)
	call dealloc_DelayDat(this)
endfunction

function dispatch_DelayDat_destroyDelayDat takes integer this returns nothing
	if DelayDat_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling DelayDat.destroyDelayDat")
		else
			call error("Called DelayDat.destroyDelayDat on invalid object.")
		endif
	endif
	call destroyDelayDat(this)
endfunction

function DamageType_after takes nothing returns nothing
	local timer time = GetExpiredTimer()
	local integer tempDat = timer_getData(time)
	call DamageType_dealCodeDamage(DelayDat_source[tempDat], DelayDat_target[tempDat], DelayDat_damage[tempDat])
	call dispatch_DelayDat_destroyDelayDat(tempDat)
	call DestroyTimer(time)
	set time = null
endfunction

function DamageType_c takes nothing returns boolean
	local unit tU = GetTriggerUnit()
	call UnitAddAbility(tU, DamageType_DAMAGE_TYPE_CHECK_ID)
	call UnitMakeAbilityPermanent(tU, true, DamageType_DAMAGE_TYPE_CHECK_ID)
	set tU = null
	return false
endfunction

function DamageType_get takes nothing returns integer
	local real sourceDamage = GetEventDamage()
	if DamageType_lastDamageType == DamageType_CODE then
		return DamageType_CODE
	elseif sourceDamage > 0. then
		return DamageType_ATTACK
	elseif sourceDamage < 0. then
		return DamageType_SPELL
	endif
	return DamageType_NULLED
endfunction

function DamageType_getUnitBonusSpellResistance takes unit u returns real
	local integer prevType = DamageType_lastDamageType
	local real life = GetWidgetLife(u)
	local real scale = GetUnitState(u, UNIT_STATE_MAX_LIFE)
	call SetWidgetLife(u, scale)
	set DamageType_lastDamageType = DamageType_CODE
	call UnitDamageTarget(u, u,  - (scale / 2.), false, false, null, DAMAGE_TYPE_UNIVERSAL, null)
	set scale = 2. * (scale - GetWidgetLife(u)) / scale
	call SetWidgetLife(u, life)
	set DamageType_lastDamageType = prevType
	return scale
endfunction

function alloc_DelayDat takes nothing returns integer
	local integer this
	if DelayDat_firstFree == 0 then
		if DelayDat_maxIndex < 8191 then
			set DelayDat_maxIndex = DelayDat_maxIndex + 1
			set this = DelayDat_maxIndex
			set DelayDat_typeId[this] = 11
		else
			call error("Out of memory: Could not create DelayDat.")
			set this = 0
		endif
	else
		set DelayDat_firstFree = DelayDat_firstFree - 1
		set this = DelayDat_nextFree[DelayDat_firstFree]
		set DelayDat_typeId[this] = 11
	endif
	return this
endfunction

function construct_DelayDat takes integer this returns nothing
endfunction

function new_DelayDat takes nothing returns integer
	local integer this = alloc_DelayDat()
	call construct_DelayDat(this)
	return this
endfunction

function DamageType_handler takes nothing returns boolean
	local real attemptedDamage =  - GetEventDamage()
	local timer time
	local integer tempDat
	local unit tU
	local real sampledLife
	local real scale
	if DamageType_get() == DamageType_SPELL then
		set tU = GetTriggerUnit()
		if DamageType_USE_BONUS_CALCULATOR then
			set scale = DamageType_getUnitBonusSpellResistance(tU)
			if scale > 1. then
				set attemptedDamage = attemptedDamage * (scale + 1.) / 2.
			endif
		endif
		set sampledLife = GetWidgetLife(tU) - .405
		if sampledLife >= attemptedDamage and sampledLife <= 2. * attemptedDamage then
			call SetWidgetLife(tU, sampledLife - attemptedDamage)
			set time = CreateTimer()
			set tempDat = new_DelayDat()
			set DelayDat_target[tempDat] = tU
			set DelayDat_source[tempDat] = GetEventDamageSource()
			set DelayDat_damage[tempDat] = attemptedDamage
			call timer_setData(time, tempDat)
			call TimerStart(time, DamageType_DELAY_AMOUNT, false, ref_function_DamageType_after)
		else
			call DamageType_dealCodeDamage(GetEventDamageSource(), tU, 2. * attemptedDamage)
		endif
	endif
	set time = null
	set tU = null
	return false
endfunction

function DummyUnitStack_release takes unit u returns nothing
	if DummyUnitStack_DO_MPU then
		if DummyUnitStack_stackIndex >= DummyUnitStack_MAX_PRELOADED_UNITS then
			call RemoveUnit(u)
			return
		endif
	endif
	call SetUnitFlyHeight(u, 0., 0.)
	call SetUnitScale(u, 1., 1., 1.)
	call SetUnitOwner(u, Player(PLAYER_NEUTRAL_PASSIVE), true)
	call SetUnitX(u, DummyUnitStack_SAFE_LOC_X)
	call SetUnitY(u, DummyUnitStack_SAFE_LOC_Y)
	set DummyUnitStack_stackIndex = DummyUnitStack_stackIndex + 1
	set DummyUnitStack_dummyStack[DummyUnitStack_stackIndex] = u
endfunction

function UnitAlloc_onDestroy takes integer this returns nothing
endfunction

function dealloc_UnitAlloc takes integer obj returns nothing
	if UnitAlloc_typeId[obj] == 0 then
		call error("Double free: object of type UnitAlloc")
	else
		set UnitAlloc_nextFree[UnitAlloc_firstFree] = obj
		set UnitAlloc_firstFree = UnitAlloc_firstFree + 1
		set UnitAlloc_typeId[obj] = 0
	endif
endfunction

function destroyUnitAlloc takes integer this returns nothing
	call UnitAlloc_onDestroy(this)
	call dealloc_UnitAlloc(this)
endfunction

function dispatch_UnitAlloc_destroyUnitAlloc takes integer this returns nothing
	if UnitAlloc_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling UnitAlloc.destroyUnitAlloc")
		else
			call error("Called UnitAlloc.destroyUnitAlloc on invalid object.")
		endif
	endif
	call destroyUnitAlloc(this)
endfunction

function DummyUnitStack_afterDelay takes nothing returns nothing
	local timer tim = GetExpiredTimer()
	local integer u = timer_getData(tim)
	call DummyUnitStack_release(UnitAlloc_u[u])
	call dispatch_UnitAlloc_destroyUnitAlloc(u)
	call DestroyTimer(tim)
	set tim = null
endfunction

function DummyUnitStack_deferredPreloader takes nothing returns nothing
	set DummyUnitStack_deferredTodoCount = DummyUnitStack_deferredTodoCount - 1
	call DummyUnitStack_add(true)
	if DummyUnitStack_deferredTodoCount < 1 then
		call PauseTimer(DummyUnitStack_clock)
	endif
endfunction

function GameTimer_closure_impl takes nothing returns nothing
	set GameTimer_currentTime = GameTimer_currentTime + Basics_ANIMATION_PERIOD
endfunction

function SoundControl_play takes string str, real pitch, integer vol returns nothing
	local sound s = CreateSound(str, false, false, false, 12700, 12700, "")
	call SetSoundVolume(s, vol)
	call SetSoundPitch(s, pitch)
	call StartSound(s)
	call KillSoundWhenDone(s)
	set s = null
endfunction

function Game_beastVictorySound takes nothing returns nothing
	call DestroyTimer(GetExpiredTimer())
	call SoundControl_play(Game_BEAST_VICTORY, 1., 127)
endfunction

function Game_countSeconds takes nothing returns nothing
	set Statistics_secondsElapsed = Statistics_secondsElapsed + 1
endfunction

function Game_gameOver takes nothing returns nothing
	call EndGame(true)
	call TimerStart(Game_postRoundTimer, 1., true, ref_function_Game_gameOver2)
endfunction

function Game_gameOver2 takes nothing returns nothing
	call EndGame(true)
endfunction

function Game_hunterVictorySound takes nothing returns nothing
	call DestroyTimer(GetExpiredTimer())
	call SoundControl_play(Game_HUNTER_VICTORY, 1., 127)
endfunction

function Note_play takes integer this returns nothing
	call SoundControl_play(Note_path[this], Note_pitch[this], Note_volume[this])
endfunction

function dispatch_Note_Muscii_Note_play takes integer this returns nothing
	if Note_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Note.Muscii_Note_play")
		else
			call error("Called Note.Muscii_Note_play on invalid object.")
		endif
	endif
	call Note_play(this)
endfunction

function Chord_play takes integer this returns nothing
	local integer iterator = Chord_first[this]
	loop
		exitwhen iterator == 0
		call dispatch_Note_Muscii_Note_play(iterator)
		set iterator = Note_next[iterator]
	endloop
endfunction

function dispatch_Chord_Muscii_Chord_play takes integer this returns nothing
	if Chord_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Chord.Muscii_Chord_play")
		else
			call error("Called Chord.Muscii_Chord_play on invalid object.")
		endif
	endif
	call Chord_play(this)
endfunction

function Muscii_playCounted takes integer this, integer count returns integer
	set Muscii_count[this] = count
	call TimerStart(Muscii_clock[this], 1. / (Muscii_tempo[this] / 60.), true, ref_function_Muscii_p)
	return this
endfunction

function dispatch_Muscii_Muscii_Muscii_playCounted takes integer this, integer count returns integer
	local integer Muscii_Muscii_playCounted_result
	if Muscii_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Muscii.Muscii_Muscii_playCounted")
		else
			call error("Called Muscii.Muscii_Muscii_playCounted on invalid object.")
		endif
	endif
	set Muscii_Muscii_playCounted_result = Muscii_playCounted(this, count)
	return Muscii_Muscii_playCounted_result
endfunction

function Muscii_stop takes integer this returns integer
	call PauseTimer(Muscii_clock[this])
	set Muscii_iterator[this] = Muscii_first[this]
	return this
endfunction

function dispatch_Muscii_Muscii_Muscii_stop takes integer this returns integer
	local integer Muscii_Muscii_stop_result
	if Muscii_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Muscii.Muscii_Muscii_stop")
		else
			call error("Called Muscii.Muscii_Muscii_stop on invalid object.")
		endif
	endif
	set Muscii_Muscii_stop_result = Muscii_stop(this)
	return Muscii_Muscii_stop_result
endfunction

function alloc_Closure takes nothing returns integer
	local integer this
	if MyCallBackFunc_firstFree == 0 then
		if MyCallBackFunc_maxIndex < 8191 then
			set MyCallBackFunc_maxIndex = MyCallBackFunc_maxIndex + 1
			set this = MyCallBackFunc_maxIndex
			set MyCallBackFunc_typeId[this] = 23
		else
			call error("Out of memory: Could not create Closure.")
			set this = 0
		endif
	else
		set MyCallBackFunc_firstFree = MyCallBackFunc_firstFree - 1
		set this = MyCallBackFunc_nextFree[MyCallBackFunc_firstFree]
		set MyCallBackFunc_typeId[this] = 23
	endif
	return this
endfunction

function Muscii_callback takes integer this, integer func returns integer
	set Muscii_cbf[this] = func
	return this
endfunction

function dispatch_Muscii_Muscii_Muscii_callback takes integer this, integer func returns integer
	local integer Muscii_Muscii_callback_result
	if Muscii_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Muscii.Muscii_Muscii_callback")
		else
			call error("Called Muscii.Muscii_Muscii_callback on invalid object.")
		endif
	endif
	set Muscii_Muscii_callback_result = Muscii_callback(this, func)
	return Muscii_Muscii_callback_result
endfunction

function playVoteMusic takes nothing returns nothing
	local integer clVar
	local integer temp
	if  not Cinematic_over then
		set temp = dispatch_Muscii_Muscii_Muscii_playCounted(Music_v, 1)
		set clVar = alloc_Closure()
		call dispatch_Muscii_Muscii_Muscii_callback(temp, clVar)
	else
		call TimerStart(CreateTimer(), 0., false, ref_function_pauseForGameMusic)
	endif
endfunction

function Music_closure_impl takes integer this returns nothing
	call playVoteMusic()
endfunction

function alloc_Closure_2 takes nothing returns integer
	local integer this
	if MyCallBackFunc_firstFree == 0 then
		if MyCallBackFunc_maxIndex < 8191 then
			set MyCallBackFunc_maxIndex = MyCallBackFunc_maxIndex + 1
			set this = MyCallBackFunc_maxIndex
			set MyCallBackFunc_typeId[this] = 24
		else
			call error("Out of memory: Could not create Closure.")
			set this = 0
		endif
	else
		set MyCallBackFunc_firstFree = MyCallBackFunc_firstFree - 1
		set this = MyCallBackFunc_nextFree[MyCallBackFunc_firstFree]
		set MyCallBackFunc_typeId[this] = 24
	endif
	return this
endfunction

function playGameMusic takes nothing returns nothing
	local integer temp = dispatch_Muscii_Muscii_Muscii_playCounted(Music_m, 8)
	local integer clVar = alloc_Closure_2()
	call dispatch_Muscii_Muscii_Muscii_callback(temp, clVar)
endfunction

function Music_closure_impl_2 takes integer this returns nothing
	call playGameMusic()
endfunction

function dispatch_MyCallBackFunc_Muscii_MyCallBackFunc_doCallback takes integer this returns nothing
	if MyCallBackFunc_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling MyCallBackFunc.Muscii_MyCallBackFunc_doCallback")
		else
			call error("Called MyCallBackFunc.Muscii_MyCallBackFunc_doCallback on invalid object.")
		endif
	endif
	if MyCallBackFunc_typeId[this] <= 23 then
		call Music_closure_impl(this)
	else
		call Music_closure_impl_2(this)
	endif
endfunction

function Muscii_p takes nothing returns nothing
	local integer m = timer_getData(GetExpiredTimer())
	local integer now = Muscii_iterator[m]
	local integer next
	call dispatch_Chord_Muscii_Chord_play(now)
	if Chord_next[now] != 0 then
		set Muscii_iterator[m] = Chord_next[now]
	else
		set Muscii_iterator[m] = Muscii_first[m]
		if Muscii_count[m] > -1 then
			set Muscii_count[m] = Muscii_count[m] - 1
			if Muscii_count[m] == -1 then
				call dispatch_Muscii_Muscii_Muscii_stop(m)
				set next = Muscii_queued[m]
				if next != 0 then
					call dispatch_Muscii_Muscii_Muscii_playCounted(next, Muscii_queueCount[m])
				endif
				set Muscii_queued[m] = 0
				if Muscii_cbf[m] != 0 then
					call dispatch_MyCallBackFunc_Muscii_MyCallBackFunc_doCallback(Muscii_cbf[m])
					set Muscii_cbf[m] = 0
				endif
			endif
		endif
	endif
endfunction

function TerrainData_getZ takes real x, real y returns real
	call MoveLocation(TerrainData_loc, x, y)
	return GetLocationZ(TerrainData_loc)
endfunction

function ProjectileDat_onDestroy takes integer this returns nothing
endfunction

function dealloc_ProjectileDat takes integer obj returns nothing
	if ProjectileDat_typeId[obj] == 0 then
		call error("Double free: object of type ProjectileDat")
	else
		set ProjectileDat_nextFree[ProjectileDat_firstFree] = obj
		set ProjectileDat_firstFree = ProjectileDat_firstFree + 1
		set ProjectileDat_typeId[obj] = 0
	endif
endfunction

function destroyProjectileDat takes integer this returns nothing
	call ProjectileDat_onDestroy(this)
	call dealloc_ProjectileDat(this)
endfunction

function dispatch_ProjectileDat_destroyProjectileDat takes integer this returns nothing
	if ProjectileDat_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling ProjectileDat.destroyProjectileDat")
		else
			call error("Called ProjectileDat.destroyProjectileDat on invalid object.")
		endif
	endif
	call destroyProjectileDat(this)
endfunction

function ProjectileStack_bulletTick takes nothing returns nothing
	local integer index = 0
	local boolean killBullet = false
	local integer tempDat
	local real x
	local real y
	local real cz
	local real nz
	local unit iter
	loop
		exitwhen index > ProjectileStack_dbIndex
		set tempDat = ProjectileStack_projectileDB[index]
		set x = GetUnitX(ProjectileDat_projectile[tempDat]) + ProjectileDat_dx[tempDat]
		set y = GetUnitY(ProjectileDat_projectile[tempDat]) + ProjectileDat_dy[tempDat]
		set nz = TerrainData_getZ(x, y)
		set cz = TerrainData_getZ(GetUnitX(ProjectileDat_projectile[tempDat]), GetUnitY(ProjectileDat_projectile[tempDat]))
		set nz = nz - cz
		call SetUnitFlyHeight(ProjectileDat_projectile[tempDat], GetUnitFlyHeight(ProjectileDat_projectile[tempDat]) - nz, 0.)
		call SetUnitX(ProjectileDat_projectile[tempDat], x)
		call SetUnitY(ProjectileDat_projectile[tempDat], y)
		set ProjectileDat_rangeLeft[tempDat] = ProjectileDat_rangeLeft[tempDat] - ProjectileDat_speed[tempDat]
		if ProjectileDat_rangeLeft[tempDat] <= 0. then
			set killBullet = true
		endif
		call GroupEnumUnitsInRange(ProjectileStack_g, x, y, ProjectileStack_BULLET_ENUM_RADIUS, null)
		loop
			set iter = FirstOfGroup(ProjectileStack_g)
			exitwhen iter == null
			if IsUnitEnemy(ProjectileDat_projectile[tempDat], GetOwningPlayer(iter)) and UnitAlive(iter) then
				call DamageType_dealCodeDamage(ProjectileDat_damageSource[tempDat], iter, ProjectileDat_damage[tempDat])
				set killBullet = true
			endif
			call GroupRemoveUnit(ProjectileStack_g, iter)
		endloop
		if GetUnitX(ProjectileDat_projectile[tempDat]) > TerrainData_MAX_X or GetUnitX(ProjectileDat_projectile[tempDat]) < TerrainData_MIN_X or GetUnitY(ProjectileDat_projectile[tempDat]) > TerrainData_MAX_Y or GetUnitY(ProjectileDat_projectile[tempDat]) < TerrainData_MIN_Y then
			set killBullet = true
		endif
		if GetUnitFlyHeight(ProjectileDat_projectile[tempDat]) < 1. then
			call DestroyEffect(AddSpecialEffect(ProjectileStack_DUST_FX, x, y))
			set killBullet = true
		endif
		if killBullet then
			call KillUnit(ProjectileDat_projectile[tempDat])
			call dispatch_ProjectileDat_destroyProjectileDat(tempDat)
			set ProjectileStack_projectileDB[index] = ProjectileStack_projectileDB[ProjectileStack_dbIndex]
			set ProjectileStack_dbIndex = ProjectileStack_dbIndex - 1
			if ProjectileStack_dbIndex == -1 then
				call PauseTimer(ProjectileStack_time)
			endif
			set killBullet = false
			set index = index - 1
		endif
		set index = index + 1
	endloop
	set iter = null
endfunction

function Slop_onDestroy takes integer this returns nothing
endfunction

function dealloc_Slop takes integer obj returns nothing
	if Slop_typeId[obj] == 0 then
		call error("Double free: object of type Slop")
	else
		set Slop_nextFree[Slop_firstFree] = obj
		set Slop_firstFree = Slop_firstFree + 1
		set Slop_typeId[obj] = 0
	endif
endfunction

function destroySlop takes integer this returns nothing
	call Slop_onDestroy(this)
	call dealloc_Slop(this)
endfunction

function dispatch_Slop_destroySlop takes integer this returns nothing
	if Slop_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Slop.destroySlop")
		else
			call error("Called Slop.destroySlop on invalid object.")
		endif
	endif
	call destroySlop(this)
endfunction

function SoundControl_preloadAfter takes nothing returns nothing
	local timer time = GetExpiredTimer()
	local integer s = timer_getData(time)
	local sound sd = CreateSound(Slop_snd[s], false, false, false, 12700, 12700, "")
	call SetSoundVolume(sd, 1)
	call StartSound(sd)
	call KillSoundWhenDone(sd)
	call dispatch_Slop_destroySlop(s)
	call DestroyTimer(time)
	set time = null
	set sd = null
endfunction

function Bucket_members_set takes integer instanceId, integer arrayIndex, unit value returns nothing
	if arrayIndex < 0 or arrayIndex >= 5 then
		call error("Index out of Bounds")
	elseif arrayIndex <= 2 then
		if arrayIndex <= 1 then
			if arrayIndex <= 0 then
				set Bucket_members_0[instanceId] = value
			else
				set Bucket_members_1[instanceId] = value
			endif
		else
			set Bucket_members_2[instanceId] = value
		endif
	elseif arrayIndex <= 3 then
		set Bucket_members_3[instanceId] = value
	else
		set Bucket_members_4[instanceId] = value
	endif
endfunction

function alloc_Bucket takes nothing returns integer
	local integer this
	if Bucket_firstFree == 0 then
		if Bucket_maxIndex < 8191 then
			set Bucket_maxIndex = Bucket_maxIndex + 1
			set this = Bucket_maxIndex
			set Bucket_typeId[this] = 43
		else
			call error("Out of memory: Could not create Bucket.")
			set this = 0
		endif
	else
		set Bucket_firstFree = Bucket_firstFree - 1
		set this = Bucket_nextFree[Bucket_firstFree]
		set Bucket_typeId[this] = 43
	endif
	return this
endfunction

function construct_Bucket takes integer this returns nothing
	set Bucket_bucketIndex[this] = 0
	set Bucket_trig[this] = CreateTrigger()
endfunction

function new_Bucket takes nothing returns integer
	local integer this = alloc_Bucket()
	call construct_Bucket(this)
	return this
endfunction

function StructuredDD_getBucket takes nothing returns integer
	local integer index = 0
	local integer tempDat
	if StructuredDD_dbIndex != -1 and Bucket_bucketIndex[StructuredDD_bucketDB[StructuredDD_dbIndex]] < StructuredDD_BUCKET_SIZE then
		return StructuredDD_dbIndex
	else
		set StructuredDD_maxDBIndex = StructuredDD_maxDBIndex + 1
		set StructuredDD_dbIndex = StructuredDD_maxDBIndex
		set tempDat = new_Bucket()
		set StructuredDD_bucketDB[StructuredDD_maxDBIndex] = tempDat
		loop
			exitwhen index > StructuredDD_conditionsIndex
			call TriggerAddCondition(Bucket_trig[tempDat], StructuredDD_conditions[index])
			set index = index + 1
		endloop
		return StructuredDD_dbIndex
	endif
endfunction

function StructuredDD_add takes unit member returns nothing
	local integer whichBucket = StructuredDD_getBucket()
	local integer tempDat = StructuredDD_bucketDB[whichBucket]
	call Bucket_members_set(tempDat, Bucket_bucketIndex[tempDat], member)
	set Bucket_bucketIndex[tempDat] = Bucket_bucketIndex[tempDat] + 1
	call TriggerRegisterUnitEvent(Bucket_trig[tempDat], member, EVENT_UNIT_DAMAGED)
endfunction

function StructuredDD_autoAddC takes nothing returns boolean
	call StructuredDD_add(GetTriggerUnit())
	return false
endfunction

function Bucket_members_get takes integer index1, integer index2 returns unit
	local unit returnVal
	if index2 < 0 or index2 >= 5 then
		call error("Index out of Bounds")
	elseif index2 <= 2 then
		if index2 <= 1 then
			if index2 <= 0 then
				set returnVal = Bucket_members_0[index1]
			else
				set returnVal = Bucket_members_1[index1]
			endif
		else
			set returnVal = Bucket_members_2[index1]
		endif
	elseif index2 <= 3 then
		set returnVal = Bucket_members_3[index1]
	else
		set returnVal = Bucket_members_4[index1]
	endif
	set Bucket_members_gettempReturn = returnVal
	set returnVal = null
	return Bucket_members_gettempReturn
endfunction

function StructuredDD_bucketIsEmpty takes integer which returns boolean
	local integer tempDat = StructuredDD_bucketDB[which]
	local integer index = 0
	loop
		exitwhen index == StructuredDD_BUCKET_SIZE
		if GetUnitTypeId(Bucket_members_get(tempDat, index)) != 0 then
			return false
		endif
		set index = index + 1
	endloop
	return true
endfunction

function Bucket_onDestroy takes integer this returns nothing
endfunction

function dealloc_Bucket takes integer obj returns nothing
	if Bucket_typeId[obj] == 0 then
		call error("Double free: object of type Bucket")
	else
		set Bucket_nextFree[Bucket_firstFree] = obj
		set Bucket_firstFree = Bucket_firstFree + 1
		set Bucket_typeId[obj] = 0
	endif
endfunction

function destroyBucket takes integer this returns nothing
	call Bucket_onDestroy(this)
	call dealloc_Bucket(this)
endfunction

function dispatch_Bucket_destroyBucket takes integer this returns nothing
	if Bucket_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Bucket.destroyBucket")
		else
			call error("Called Bucket.destroyBucket on invalid object.")
		endif
	endif
	call destroyBucket(this)
endfunction

function StructuredDD_perCleanup takes nothing returns nothing
	local integer index = 0
	loop
		exitwhen index > StructuredDD_maxDBIndex
		if index != StructuredDD_dbIndex and StructuredDD_bucketIsEmpty(index) then
			call DestroyTrigger(Bucket_trig[StructuredDD_bucketDB[index]])
			call dispatch_Bucket_destroyBucket(StructuredDD_bucketDB[index])
			set StructuredDD_bucketDB[index] = StructuredDD_bucketDB[StructuredDD_maxDBIndex]
			set StructuredDD_maxDBIndex = StructuredDD_maxDBIndex - 1
			if StructuredDD_maxDBIndex == StructuredDD_dbIndex then
				set StructuredDD_dbIndex = index
			endif
			set index = index - 1
		endif
		set index = index + 1
	endloop
endfunction

function BeastLightningDat_onDestroy takes integer this returns nothing
endfunction

function dealloc_BeastLightningDat takes integer obj returns nothing
	if BeastLightningDat_typeId[obj] == 0 then
		call error("Double free: object of type BeastLightningDat")
	else
		set BeastLightningDat_nextFree[BeastLightningDat_firstFree] = obj
		set BeastLightningDat_firstFree = BeastLightningDat_firstFree + 1
		set BeastLightningDat_typeId[obj] = 0
	endif
endfunction

function destroyBeastLightningDat takes integer this returns nothing
	call BeastLightningDat_onDestroy(this)
	call dealloc_BeastLightningDat(this)
endfunction

function dispatch_BeastLightningDat_destroyBeastLightningDat takes integer this returns nothing
	if BeastLightningDat_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling BeastLightningDat.destroyBeastLightningDat")
		else
			call error("Called BeastLightningDat.destroyBeastLightningDat on invalid object.")
		endif
	endif
	call destroyBeastLightningDat(this)
endfunction

function LightningBallDat_onDestroy takes integer this returns nothing
endfunction

function dealloc_LightningBallDat takes integer obj returns nothing
	if LightningBallDat_typeId[obj] == 0 then
		call error("Double free: object of type LightningBallDat")
	else
		set LightningBallDat_nextFree[LightningBallDat_firstFree] = obj
		set LightningBallDat_firstFree = LightningBallDat_firstFree + 1
		set LightningBallDat_typeId[obj] = 0
	endif
endfunction

function destroyLightningBallDat takes integer this returns nothing
	call LightningBallDat_onDestroy(this)
	call dealloc_LightningBallDat(this)
endfunction

function dispatch_LightningBallDat_destroyLightningBallDat takes integer this returns nothing
	if LightningBallDat_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling LightningBallDat.destroyLightningBallDat")
		else
			call error("Called LightningBallDat.destroyLightningBallDat on invalid object.")
		endif
	endif
	call destroyLightningBallDat(this)
endfunction

function Units_beastLightningTick takes nothing returns nothing
	local integer ua = Units_beastHead
	local integer uaSwap
	local integer lbd
	local integer swap
	local integer index
	local real facing
	loop
		exitwhen ua == 0
		set BeastLightningDat_ticksUntilNextCheck[ua] = BeastLightningDat_ticksUntilNextCheck[ua] - 1
		set facing = GetUnitFacing(BeastLightningDat_u[ua]) * bj_DEGTORAD
		set BeastLightningDat_phase[ua] = BeastLightningDat_phase[ua] + Units_PHASE_ANGULAR_VELOCITY
		if BeastLightningDat_ticksUntilNextCheck[ua] <= 0 then
			if BeastLightningDat_balls[ua] < Units_MAX_BALLS and BeastLightningDat_typ[ua] == Units_BEAST_ID then
				call Units_pushBall(BeastLightningDat_u[ua])
			elseif BeastLightningDat_balls[ua] < Units_MAX_BALLS_LESSER and BeastLightningDat_typ[ua] == Units_LESSER_BEAST_ID then
				call Units_pushBall(BeastLightningDat_u[ua])
			endif
			set BeastLightningDat_ticksUntilNextCheck[ua] = R2I(Units_LIGHTNING_CHECK_PERIOD / Units_CLOCK_PERIOD)
		endif
		set index = 0
		set lbd = BeastLightningDat_ballHead[ua]
		loop
			exitwhen index >= BeastLightningDat_balls[ua]
			call SetUnitX(LightningBallDat_u[lbd], GetUnitX(BeastLightningDat_u[ua]) + Units_BALL_OFF * Cos(facing + BeastLightningDat_phase[ua] + index * 2. * bj_PI / BeastLightningDat_balls[ua]))
			call SetUnitY(LightningBallDat_u[lbd], GetUnitY(BeastLightningDat_u[ua]) + Units_BALL_OFF * Sin(facing + BeastLightningDat_phase[ua] + index * 2. * bj_PI / BeastLightningDat_balls[ua]))
			set lbd = LightningBallDat_next[lbd]
			set index = index + 1
		endloop
		if  not (UnitAlive(BeastLightningDat_u[ua]) and GetUnitTypeId(BeastLightningDat_u[ua]) > 0) then
			set lbd = BeastLightningDat_ballHead[ua]
			loop
				exitwhen lbd == 0
				set swap = LightningBallDat_next[lbd]
				call DestroyEffect(LightningBallDat_fx[lbd])
				call DummyUnitStack_release(LightningBallDat_u[lbd])
				call dispatch_LightningBallDat_destroyLightningBallDat(lbd)
				set lbd = swap
			endloop
			if BeastLightningDat_prev[ua] != 0 then
				set uaSwap = BeastLightningDat_prev[ua]
				set BeastLightningDat_next[uaSwap] = BeastLightningDat_next[ua]
			else
				set Units_beastHead = BeastLightningDat_next[ua]
				if BeastLightningDat_next[ua] == 0 then
					call PauseTimer(Units_clock)
				endif
			endif
			if BeastLightningDat_next[ua] != 0 then
				set uaSwap = BeastLightningDat_next[ua]
				set BeastLightningDat_prev[uaSwap] = BeastLightningDat_prev[ua]
			endif
			call dispatch_BeastLightningDat_destroyBeastLightningDat(ua)
		endif
		set ua = BeastLightningDat_next[ua]
	endloop
endfunction

function Units_filterItems takes nothing returns nothing
	local item f = GetEnumItem()
	if GetItemTypeId(f) != Units_ARTIFACT_ID then
		call RemoveItem(f)
	endif
	set f = null
endfunction

function SoundControl_playForPlayer takes string str, real pitch, player who returns nothing
	local sound s = CreateSound(str, false, false, false, 12700, 12700, "")
	if GetLocalPlayer() == who then
		call SetSoundVolume(s, 127)
	else
		call SetSoundVolume(s, 0)
	endif
	call SetSoundPitch(s, pitch)
	call StartSound(s)
	call KillSoundWhenDone(s)
	set s = null
endfunction

function Game_defeatTeam takes integer team returns nothing
	if team == Game_TEAM_BEASTS then
		call RemovePlayer(Players_fromId[0], PLAYER_GAME_RESULT_VICTORY)
		call RemovePlayer(Players_fromId[1], PLAYER_GAME_RESULT_VICTORY)
		call RemovePlayer(Players_fromId[2], PLAYER_GAME_RESULT_VICTORY)
		call RemovePlayer(Players_fromId[3], PLAYER_GAME_RESULT_DEFEAT)
		call RemovePlayer(Players_fromId[4], PLAYER_GAME_RESULT_DEFEAT)
		call RemovePlayer(Players_fromId[5], PLAYER_GAME_RESULT_DEFEAT)
		call SoundControl_playForPlayer(Game_WIN_SOUND, 1., Players_fromId[0])
		call SoundControl_playForPlayer(Game_WIN_SOUND, 1., Players_fromId[1])
		call SoundControl_playForPlayer(Game_WIN_SOUND, 1., Players_fromId[2])
		call SoundControl_playForPlayer(Game_DEF_SOUND, 1., Players_fromId[3])
		call SoundControl_playForPlayer(Game_DEF_SOUND, 1., Players_fromId[4])
		call SoundControl_playForPlayer(Game_DEF_SOUND, 1., Players_fromId[5])
	else
		call RemovePlayer(Players_fromId[0], PLAYER_GAME_RESULT_DEFEAT)
		call RemovePlayer(Players_fromId[1], PLAYER_GAME_RESULT_DEFEAT)
		call RemovePlayer(Players_fromId[2], PLAYER_GAME_RESULT_DEFEAT)
		call RemovePlayer(Players_fromId[3], PLAYER_GAME_RESULT_VICTORY)
		call RemovePlayer(Players_fromId[4], PLAYER_GAME_RESULT_VICTORY)
		call RemovePlayer(Players_fromId[5], PLAYER_GAME_RESULT_VICTORY)
		call SoundControl_playForPlayer(Game_DEF_SOUND, 1., Players_fromId[0])
		call SoundControl_playForPlayer(Game_DEF_SOUND, 1., Players_fromId[1])
		call SoundControl_playForPlayer(Game_DEF_SOUND, 1., Players_fromId[2])
		call SoundControl_playForPlayer(Game_WIN_SOUND, 1., Players_fromId[3])
		call SoundControl_playForPlayer(Game_WIN_SOUND, 1., Players_fromId[4])
		call SoundControl_playForPlayer(Game_WIN_SOUND, 1., Players_fromId[5])
	endif
endfunction

function Units_endRoundVfx takes nothing returns nothing
	local unit iter
	call GroupEnumUnitsInRect(Units_grp, bj_mapInitialPlayableArea, null)
	loop
		set iter = FirstOfGroup(Units_grp)
		exitwhen iter == null
		if GetPlayerId(GetOwningPlayer(iter)) <= Players_LAST_BEAST then
			call PauseUnit(iter, true)
			call SetUnitInvulnerable(iter, true)
		endif
		call GroupRemoveUnit(Units_grp, iter)
	endloop
	set iter = null
endfunction

function Game_beastWin takes nothing returns nothing
	set Statistics_beastWins = Statistics_beastWins + 1
	set Game_roundEnabled = false
	call Units_endRoundVfx()
	call TimerStart(CreateTimer(), Game_VICTORY_SOUND_DELAY, false, ref_function_Game_beastVictorySound)
	if Statistics_beastWins >= Game_roundsToWin then
		call Game_defeatTeam(Game_TEAM_HUNTERS)
		call DisplayTextToPlayer(Players_locl, 0., 0., "The |cff411d0aBeasts|r have won the round and the |cffffcc00best of " + I2S(Game_roundsToWin * 2 - 1) + "|r!")
		call DisplayTextToPlayer(Players_locl, 0., 0., "|cff999999The game will end momentarily.|r")
		call CameraControl_fadeOutHunter(Game_POST_GAME_DELAY)
		call CameraControl_fadeOutBeast(Game_POST_GAME_DELAY)
		call TimerStart(Game_postRoundTimer, Game_POST_GAME_DELAY, false, ref_function_Game_gameOver)
	else
		call DisplayTextToPlayer(Players_locl, 0., 0., "The |cff411d0aBeasts|r won the round. Round |cffffcc00" + I2S(Statistics_hunterWins + Statistics_beastWins + 1) + "|r will begin soon!")
		call TimerStart(Game_postRoundTimer, Game_POST_ROUND_DELAY, false, ref_function_Game_roundStart)
	endif
endfunction

function Game_hunterWin takes nothing returns nothing
	set Statistics_hunterWins = Statistics_hunterWins + 1
	set Game_roundEnabled = false
	call Units_endRoundVfx()
	call TimerStart(CreateTimer(), Game_VICTORY_SOUND_DELAY, false, ref_function_Game_hunterVictorySound)
	if Statistics_hunterWins >= Game_roundsToWin then
		call Game_defeatTeam(Game_TEAM_BEASTS)
		call DisplayTextToPlayer(Players_locl, 0., 0., "The |cff999999Hunters|r have won the round and the |cffffcc00best of " + I2S(Game_roundsToWin * 2 - 1) + "|r!")
		call DisplayTextToPlayer(Players_locl, 0., 0., "|cff999999The game will end momentarily.|r")
		call CameraControl_fadeOutHunter(Game_POST_GAME_DELAY)
		call CameraControl_fadeOutBeast(Game_POST_GAME_DELAY)
		call TimerStart(Game_postRoundTimer, Game_POST_GAME_DELAY, false, ref_function_Game_gameOver)
	else
		call DisplayTextToPlayer(Players_locl, 0., 0., "The |cff999999Hunters|r won the round. Round |cffffcc00" + I2S(Statistics_hunterWins + Statistics_beastWins + 1) + "|r will begin soon!")
		call TimerStart(Game_postRoundTimer, Game_POST_ROUND_DELAY, false, ref_function_Game_roundStart)
	endif
endfunction

function TextTag_bounty takes real x, real y, integer val, player whom returns nothing
	local texttag t = CreateTextTag()
	call SetTextTagColor(t, 255, R2I(255 * 12 * 1. / 15), 0, 255)
	call SetTextTagLifespan(t, 2.)
	call SetTextTagFadepoint(t, 1.)
	call SetTextTagPermanent(t, false)
	call SetTextTagPos(t, x, y, 25.)
	call SetTextTagText(t, "+" + I2S(val), 12. * .0023)
	call SetTextTagVelocity(t, 100. * Cos(Maths_PI / 2.) * .071 / 128., 100. * Sin(Maths_PI / 2.) * .071 / 128.)
	call SetTextTagVisibility(t, false)
	if Players_locl == whom then
		call SetTextTagVisibility(t, true)
	endif
	set t = null
endfunction

function noMoreUnits takes integer id returns boolean
	return  not (UnitAlive(Units_hero[id]) or UnitAlive(Units_subHero[id]))
endfunction

function a takes nothing returns nothing
	local unit u = GetTriggerUnit()
	local player p = GetOwningPlayer(u)
	local integer id = GetPlayerId(p)
	local unit k
	local player o
	local integer t
	local integer bounty
	if ( not Cinematic_enabled) and u == Units_hero[id] or u == Units_subHero[id] and Game_roundEnabled then
		if id >= Players_FIRST_BEAST then
			set Statistics_hunterKills = Statistics_hunterKills + 1
			set Statistics_beastsAlive = Statistics_beastsAlive - 1
			set k = GetKillingUnit()
			set o = unit_getOwner(k)
			set t = GetUnitTypeId(u)
			set bounty = 0
			if t == Units_BEAST_ID then
				set bounty = bounty + HeroDeath_GOLD_BONUS
				if UnitHasItemOfTypeBJ(k, HeroDeath_CONTRACT_ID) then
					set bounty = bounty + HeroDeath_MAJOR_CONTRACT_BONUS
				endif
			elseif t == Units_LESSER_BEAST_ID then
				set bounty = bounty + HeroDeath_GOLD_BONUS_LESSER
				if UnitHasItemOfTypeBJ(k, HeroDeath_CONTRACT_ID) then
					set bounty = bounty + HeroDeath_MINOR_CONTRACT_BONUS
				endif
			endif
			call SetPlayerState(o, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(o, PLAYER_STATE_RESOURCE_GOLD) + bounty)
			call TextTag_bounty(unit_getX(u), unit_getY(u), bounty, o)
			if Statistics_beastsAlive < 1 then
				call PanCameraToTimed(GetUnitX(u), GetUnitY(u), 0.)
				call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 1024., 0.)
				call Game_hunterWin()
			elseif noMoreUnits(id) then
				call DisplayTextToPlayer(p, 0., 0., "|cffffcc00[Game]|r You have been slain! You will revive in the next round.")
			endif
		else
			set Statistics_beastKills = Statistics_beastKills + 1
			set Statistics_huntersAlive = Statistics_huntersAlive - 1
			if Statistics_huntersAlive < 1 then
				call PanCameraToTimed(GetUnitX(u), GetUnitY(u), 0.)
				call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 1024., 0.)
				call Game_beastWin()
			else
				call DisplayTextToPlayer(p, 0., 0., "|cffffcc00[Game]|r You have been slain! You will revive in the next round.")
			endif
		endif
	endif
	set u = null
	set p = null
	set k = null
	set o = null
endfunction

function Units_dischargeBall takes unit u returns nothing
	local integer ua = dispatch_Table_Table_Table_loadInt(Units_fromBeast, handle_getHandleId(u))
	local integer lbd = BeastLightningDat_ballHead[ua]
	local integer swap
	call DestroyEffect(LightningBallDat_fx[lbd])
	call DummyUnitStack_release(LightningBallDat_u[lbd])
	set swap = LightningBallDat_next[lbd]
	call dispatch_LightningBallDat_destroyLightningBallDat(lbd)
	set BeastLightningDat_ballHead[ua] = swap
	set BeastLightningDat_balls[ua] = BeastLightningDat_balls[ua] - 1
	if BeastLightningDat_balls[ua] == 2 and BeastLightningDat_typ[ua] == Units_BEAST_ID then
		call UnitRemoveAbility(BeastLightningDat_u[ua], Units_HEMISECT_ID)
		call UnitAddAbility(BeastLightningDat_u[ua], Units_HEMISECT_PASSIVE_ID)
	elseif BeastLightningDat_balls[ua] == 2 and BeastLightningDat_typ[ua] == Units_LESSER_BEAST_ID then
		call UnitRemoveAbility(BeastLightningDat_u[ua], Units_CONCAT_ID)
		call UnitAddAbility(BeastLightningDat_u[ua], Units_CONCAT_PASSIVE_ID)
	endif
	if swap == 0 then
		call UnitRemoveAbility(BeastLightningDat_u[ua], Units_BLINK_ID)
		call UnitAddAbility(BeastLightningDat_u[ua], Units_BLINK_PASSIVE_ID)
	endif
endfunction

function act takes nothing returns nothing
	if GetSpellAbilityId() == Blink_BLINK_ID then
		call Units_dischargeBall(GetTriggerUnit())
	endif
endfunction

function alloc_NetData takes nothing returns integer
	local integer this
	if NetData_firstFree == 0 then
		if NetData_maxIndex < 8191 then
			set NetData_maxIndex = NetData_maxIndex + 1
			set this = NetData_maxIndex
		else
			call error("Out of memory: Could not create NetData.")
			set this = 0
		endif
	else
		set NetData_firstFree = NetData_firstFree - 1
		set this = NetData_nextFree[NetData_firstFree]
	endif
	return this
endfunction

function construct_NetData takes integer this returns nothing
endfunction

function new_NetData takes nothing returns integer
	local integer this = alloc_NetData()
	call construct_NetData(this)
	return this
endfunction

function unit_setOwner takes unit this, player p, boolean changeColor returns nothing
	call SetUnitOwner(this, p, changeColor)
endfunction

function act_2 takes nothing returns nothing
	local integer nd
	local unit tU
	local real uX
	local real uY
	local real ang
	local unit receiver
	local unit receiver_2
	local unit receiver_3
	if GetSpellAbilityId() == Net_NET_ID then
		set tU = GetTriggerUnit()
		set uX = GetUnitX(tU)
		set uY = GetUnitY(tU)
		set ang = Atan2(GetSpellTargetY() - uY, GetSpellTargetX() - uX)
		set nd = new_NetData()
		set NetData_delX[nd] = Net_NET_VELOCITY * Cos(ang) * Net_CLOCK_PERIOD
		set NetData_delY[nd] = Net_NET_VELOCITY * Sin(ang) * Net_CLOCK_PERIOD
		set NetData_caster[nd] = GetOwningPlayer(tU)
		set NetData_distance[nd] = Net_MAX_DISTANCE
		set NetData_dummy[nd] = DummyUnitStack_get()
		set NetData_attached[nd] = AddSpecialEffectTarget(Net_NET_MODEL, NetData_dummy[nd], "origin")
		set receiver = NetData_dummy[nd]
		call unit_setX(receiver, uX)
		set receiver_2 = receiver
		call unit_setY(receiver_2, uY)
		set receiver_3 = receiver_2
		call unit_setOwner(receiver_3, NetData_caster[nd], true)
		set Net_dbIndex = Net_dbIndex + 1
		set Net_dataDb[Net_dbIndex] = nd
		if Net_dbIndex == 0 then
			call TimerStart(Net_clock, Net_CLOCK_PERIOD, true, ref_function_periodic_2)
		endif
	endif
	set tU = null
	set receiver = null
	set receiver_2 = null
	set receiver_3 = null
endfunction

function Math_maxReal takes real a_2, real b returns real
	return RMaxBJ(a_2, b)
endfunction

function Math_minReal takes real a_2, real b returns real
	return RMinBJ(a_2, b)
endfunction

function Math_radiansNormalizeHalfModulo takes real n returns real
	return ModuloReal(n, 2. * bj_PI - Math_DELTA)
endfunction

function Math_radiansNormalizeHalf takes real n returns real
	set n = Math_radiansNormalizeHalfModulo(n)
	if n > bj_PI then
		return n - 2. * bj_PI
	endif
	return n
endfunction

function kernelApply takes integer index, real facing returns real
	local real min = bj_PI
	local real max =  - (1. * bj_PI)
	local integer i = 0
	set facing = Math_radiansNormalizeHalf(facing)
	set HunterCamera_kernel[index * HunterCamera_KERNEL_SIZE + HunterCamera_kernelIndex[index]] = facing
	loop
		exitwhen i >= HunterCamera_KERNEL_SIZE
		if i != index then
			set min = Math_minReal(min, Math_radiansNormalizeHalf(facing - HunterCamera_kernel[index * HunterCamera_KERNEL_SIZE + i]))
			set max = Math_maxReal(max, Math_radiansNormalizeHalf(facing - HunterCamera_kernel[index * HunterCamera_KERNEL_SIZE + i]))
		endif
		set i = i + 1
	endloop
	set HunterCamera_kernelIndex[index] = HunterCamera_kernelIndex[index] + 1
	set HunterCamera_kernelIndex[index] = ModuloInteger(HunterCamera_kernelIndex[index], HunterCamera_KERNEL_SIZE)
	return Math_radiansNormalizeHalfModulo(max - min)
endfunction

function act_3 takes nothing returns nothing
	local integer index = 0
	local real offset = HunterCamera_OFFSET_STATIC
	local real facing
	local real minimax
	if Game_roundEnabled then
		loop
			exitwhen index >= Players_FIRST_BEAST
			if UnitAlive(Units_hero[index]) then
				set facing = GetUnitFacing(Units_hero[index]) * bj_DEGTORAD
				set minimax = kernelApply(index, facing)
				if minimax > HunterCamera_JITTER_THRESHOLD then
					set offset = HunterCamera_OFFSET_JITTER
				elseif GetUnitCurrentOrder(Units_hero[index]) == OrderId("smart") then
					set offset = HunterCamera_OFFSET_DYNAMIC
				endif
				if Players_locl == Players_fromId[index] then
					call PanCameraToTimed(GetUnitX(Units_hero[index]) + offset * Cos(facing), GetUnitY(Units_hero[index]) + offset * Sin(facing), HunterCamera_CLOCK_PERIOD * 2.)
				endif
			endif
			set index = index + 1
		endloop
	endif
endfunction

function SoundControl_play3D takes string str, real pitch, real x, real y, real z returns nothing
	local sound s = CreateSound(str, false, true, true, 12700, 12700, "")
	call SetSoundPosition(s, x, y, z)
	call SetSoundVolume(s, 127)
	call SetSoundPitch(s, pitch)
	call StartSound(s)
	call KillSoundWhenDone(s)
	set s = null
endfunction

function act_4 takes nothing returns nothing
	local unit tU
	if GetSpellAbilityId() == HunterToggle_TOGGLE_ID then
		set tU = GetTriggerUnit()
		call SoundControl_play3D(HunterToggle_TOGGLE_SOUND, 2., GetUnitX(tU), GetUnitY(tU), 0.)
		if GetUnitAbilityLevel(tU, HunterToggle_BURST_ID) > 0 then
			call UnitRemoveAbility(tU, HunterToggle_BURST_ID)
			call UnitAddAbility(tU, HunterToggle_AUTO_ID)
		else
			call UnitRemoveAbility(tU, HunterToggle_AUTO_ID)
			call UnitAddAbility(tU, HunterToggle_BURST_ID)
		endif
	endif
	set tU = null
endfunction

function act_5 takes nothing returns nothing
	local unit tU
	if GetSpellAbilityId() == Thunder_THUNDER_ID then
		set tU = GetTriggerUnit()
		call dispatch_Table_Table_Table_saveInt(Units_thunderClock, handle_getHandleId(tU), Statistics_secondsElapsed)
	endif
	set tU = null
endfunction

function ProjectileStack_getProjectileSpeed takes unit u returns real
	local integer uType = GetUnitTypeId(u)
	if uType == Units_HUNTER_PROJECTILE_ID then
		return ProjectileStack_PROJECTILE_VELOCITY
	endif
	call DisplayTextToPlayer(Players_locl, 0., 0., ProjectileStack_ERROR_NO_SPEED)
	return ProjectileStack_DEFAULT_VELOCITY
endfunction

function ProjectileStack_getUnitDamage takes unit u returns real
	local integer uType = GetUnitTypeId(u)
	if uType == Units_HUNTER_ID then
		return ProjectileStack_PROJECTILE_DAMAGE
	endif
	call DisplayTextToPlayer(Players_locl, 0., 0., ProjectileStack_ERROR_NO_DAMAGE)
	return ProjectileStack_DEFAULT_DAMAGE
endfunction

function ProjectileStack_getUnitProjectile takes unit u, real sX, real sY, real tX, real tY returns unit
	local integer uType = GetUnitTypeId(u)
	local real facing = TerrainData_radiansBetweenXY(sX, tX, sY, tY)
	local real x = sX + ProjectileStack_PROJECTILE_OFFSET * Cos(facing)
	local real y = sY + ProjectileStack_PROJECTILE_OFFSET * Sin(facing)
	local unit returnedUnit
	if uType == Units_HUNTER_ID then
		set returnedUnit = CreateUnit(GetOwningPlayer(u), Units_HUNTER_PROJECTILE_ID, 0., 0., facing * bj_RADTODEG)
		call SetUnitX(returnedUnit, x)
		call SetUnitY(returnedUnit, y)
		set ProjectileStack_getUnitProjectiletempReturn = returnedUnit
		set returnedUnit = null
		return ProjectileStack_getUnitProjectiletempReturn
	endif
	call DisplayTextToPlayer(Players_locl, 0., 0., ProjectileStack_ERROR_NO_PROJECTILE)
	set returnedUnit = CreateUnit(GetOwningPlayer(u), Units_HUNTER_PROJECTILE_ID, 0., 0., GetUnitFacing(u))
	call SetUnitX(returnedUnit, x)
	call SetUnitY(returnedUnit, y)
	set ProjectileStack_getUnitProjectiletempReturn_2 = returnedUnit
	set returnedUnit = null
	return ProjectileStack_getUnitProjectiletempReturn_2
endfunction

function alloc_ProjectileDat takes nothing returns integer
	local integer this
	if ProjectileDat_firstFree == 0 then
		if ProjectileDat_maxIndex < 8191 then
			set ProjectileDat_maxIndex = ProjectileDat_maxIndex + 1
			set this = ProjectileDat_maxIndex
			set ProjectileDat_typeId[this] = 36
		else
			call error("Out of memory: Could not create ProjectileDat.")
			set this = 0
		endif
	else
		set ProjectileDat_firstFree = ProjectileDat_firstFree - 1
		set this = ProjectileDat_nextFree[ProjectileDat_firstFree]
		set ProjectileDat_typeId[this] = 36
	endif
	return this
endfunction

function construct_ProjectileDat takes integer this returns nothing
endfunction

function new_ProjectileDat takes nothing returns integer
	local integer this = alloc_ProjectileDat()
	call construct_ProjectileDat(this)
	return this
endfunction

function ProjectileStack_add takes unit u, real sX, real sY, real tX, real tY, real offset returns nothing
	local integer tempDat = new_ProjectileDat()
	local real rad
	set ProjectileDat_projectile[tempDat] = ProjectileStack_getUnitProjectile(u, sX, sY, tX, tY)
	set ProjectileDat_damageSource[tempDat] = u
	set ProjectileDat_speed[tempDat] = ProjectileStack_getProjectileSpeed(ProjectileDat_projectile[tempDat])
	set rad = TerrainData_radiansBetweenXY(sX, tX, sY, tY) + offset
	set ProjectileDat_dx[tempDat] = ProjectileDat_speed[tempDat] * Cos(rad)
	set ProjectileDat_dy[tempDat] = ProjectileDat_speed[tempDat] * Sin(rad)
	set ProjectileDat_damage[tempDat] = ProjectileStack_getUnitDamage(u)
	set ProjectileDat_rangeLeft[tempDat] = ProjectileStack_RANGE
	call SetUnitFlyHeight(ProjectileDat_projectile[tempDat], ProjectileStack_FLY_HEIGHT, 0.)
	set ProjectileStack_dbIndex = ProjectileStack_dbIndex + 1
	set ProjectileStack_projectileDB[ProjectileStack_dbIndex] = tempDat
	if ProjectileStack_dbIndex == 0 then
		call TimerStart(ProjectileStack_time, ProjectileStack_CLOCK_PERIOD, true, ref_function_ProjectileStack_bulletTick)
	endif
endfunction

function alloc_Closure_3 takes nothing returns integer
	local integer this
	if CallbackSingle_firstFree == 0 then
		if CallbackSingle_maxIndex < 8191 then
			set CallbackSingle_maxIndex = CallbackSingle_maxIndex + 1
			set this = CallbackSingle_maxIndex
			set CallbackSingle_typeId[this] = 7
		else
			call error("Out of memory: Could not create Closure.")
			set this = 0
		endif
	else
		set CallbackSingle_firstFree = CallbackSingle_firstFree - 1
		set this = CallbackSingle_nextFree[CallbackSingle_firstFree]
		set CallbackSingle_typeId[this] = 7
	endif
	return this
endfunction

function construct_CallbackSingle takes integer this returns nothing
endfunction

function getTimer takes nothing returns timer
	local timer receiver
	if TimerUtils_freeTimersCount > 0 then
		set TimerUtils_freeTimersCount = TimerUtils_freeTimersCount - 1
		call timer_setData(TimerUtils_freeTimers[TimerUtils_freeTimersCount], 0)
		set receiver = null
		return TimerUtils_freeTimers[TimerUtils_freeTimersCount]
	else
		set receiver = CreateTimer()
		call timer_setData(receiver, 0)
		set getTimertempReturn = receiver
		set receiver = null
		return getTimertempReturn
	endif
endfunction

function timer_start takes timer this, real time, code timerCallBack returns nothing
	call TimerStart(this, time, false, timerCallBack)
endfunction

function CallbackSingle_start takes integer this, real time returns nothing
	local timer receiver = getTimer()
	local timer receiver_2
	call timer_setData(receiver, this)
	set receiver_2 = receiver
	call timer_start(receiver_2, time, ref_function_CallbackSingle_staticCallback)
	set receiver = null
	set receiver_2 = null
endfunction

function dispatch_CallbackSingle_ClosureTimers_CallbackSingle_start takes integer this, real time returns nothing
	if CallbackSingle_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling CallbackSingle.ClosureTimers_CallbackSingle_start")
		else
			call error("Called CallbackSingle.ClosureTimers_CallbackSingle_start on invalid object.")
		endif
	endif
	call CallbackSingle_start(this, time)
endfunction

function doAfter takes real timeToWait, integer cb returns nothing
	call dispatch_CallbackSingle_ClosureTimers_CallbackSingle_start(cb, timeToWait)
endfunction

function alloc_AutoDat takes nothing returns integer
	local integer this
	if AutoDat_firstFree == 0 then
		if AutoDat_maxIndex < 8191 then
			set AutoDat_maxIndex = AutoDat_maxIndex + 1
			set this = AutoDat_maxIndex
			set AutoDat_typeId[this] = 16
		else
			call error("Out of memory: Could not create AutoDat.")
			set this = 0
		endif
	else
		set AutoDat_firstFree = AutoDat_firstFree - 1
		set this = AutoDat_nextFree[AutoDat_firstFree]
		set AutoDat_typeId[this] = 16
	endif
	return this
endfunction

function construct_AutoDat takes integer this returns nothing
endfunction

function new_AutoDat takes nothing returns integer
	local integer this = alloc_AutoDat()
	call construct_AutoDat(this)
	return this
endfunction

function act_6 takes nothing returns nothing
	local integer id = GetSpellAbilityId()
	local unit attacker_2
	local real jitter
	local real tX
	local real tY
	local real uX
	local real uY
	local real sepAngle
	local real offsetX
	local real offsetY
	local real angle
	local integer ad
	local timer clock
	local boolean haveAuto
	local integer clVar
	local real temp
	if id == HunterAttack_BURST_ID then
		set attacker_2 = GetTriggerUnit()
		set uX = GetUnitX(attacker_2)
		set uY = GetUnitY(attacker_2)
		set tX = GetSpellTargetX()
		set tY = GetSpellTargetY()
		set haveAuto = UnitHasItemOfTypeBJ(attacker_2, Units_GAS_ACTION)
		if  not haveAuto then
			set jitter = GetRandomReal(0., HunterAttack_JITTER) - HunterAttack_JITTER / 2.
			set sepAngle = GetRandomReal(0., HunterAttack_SEPARATION_ARC) - HunterAttack_SEPARATION_ARC / 2.
			set angle = TerrainData_radiansBetweenXY(uX, tX, uY, tY)
			if sepAngle < 0. then
				set offsetX = HunterAttack_SEPARATION_RADIUS * Cos(angle + sepAngle)
				set offsetY = HunterAttack_SEPARATION_RADIUS * Sin(angle + sepAngle)
				call ProjectileStack_add(attacker_2, uX + offsetX, uY + offsetY, tX + offsetX, tY + offsetY, jitter - HunterAttack_SPREAD_ARC)
				set offsetX = HunterAttack_SEPARATION_RADIUS * Cos(angle + sepAngle + bj_PI)
				set offsetY = HunterAttack_SEPARATION_RADIUS * Sin(angle + sepAngle + bj_PI)
				call ProjectileStack_add(attacker_2, uX + offsetX, uY + offsetY, tX + offsetX, tY + offsetY, jitter + HunterAttack_SPREAD_ARC)
			else
				set offsetX = HunterAttack_SEPARATION_RADIUS * Cos(angle + sepAngle)
				set offsetY = HunterAttack_SEPARATION_RADIUS * Sin(angle + sepAngle)
				call ProjectileStack_add(attacker_2, uX + offsetX, uY + offsetY, tX + offsetX, tY + offsetY, jitter + HunterAttack_SPREAD_ARC)
				set offsetX = HunterAttack_SEPARATION_RADIUS * Cos(angle + sepAngle + bj_PI)
				set offsetY = HunterAttack_SEPARATION_RADIUS * Sin(angle + sepAngle + bj_PI)
				call ProjectileStack_add(attacker_2, uX + offsetX, uY + offsetY, tX + offsetX, tY + offsetY, jitter - HunterAttack_SPREAD_ARC)
			endif
			call ProjectileStack_add(attacker_2, uX, uY, tX, tY, jitter)
			set temp = HunterAttack_POST_BURST_DELAY
			set clVar = alloc_Closure_3()
			call construct_CallbackSingle(clVar)
			set attacker[clVar] = attacker_2
			call doAfter(temp, clVar)
		else
			set jitter = GetRandomReal(HunterAttack_JITTER * ( - (1. / 2.)), HunterAttack_JITTER / 2.)
			call ProjectileStack_add(attacker_2, uX, uY, tX, tY, jitter)
			if dispatch_Table_Table_Table_hasInt(HunterAttack_logicalClock, handle_getHandleId(attacker_2)) then
				call dispatch_Table_Table_Table_saveInt(HunterAttack_logicalClock, handle_getHandleId(attacker_2), dispatch_Table_Table_Table_loadInt(HunterAttack_logicalClock, handle_getHandleId(attacker_2)) + 1)
			else
				call dispatch_Table_Table_Table_saveInt(HunterAttack_logicalClock, handle_getHandleId(attacker_2), 0)
			endif
			set ad = new_AutoDat()
			set AutoDat_attacker[ad] = attacker_2
			set AutoDat_logicalSecret[ad] = dispatch_Table_Table_Table_loadInt(HunterAttack_logicalClock, handle_getHandleId(attacker_2))
			set AutoDat_uX[ad] = uX
			set AutoDat_uY[ad] = uY
			set AutoDat_tX[ad] = tX
			set AutoDat_tY[ad] = tY
			set clock = CreateTimer()
			call timer_setData(clock, ad)
			call TimerStart(clock, HunterAttack_AUTO_RATE, true, ref_function_autoTick)
		endif
	endif
	set attacker_2 = null
	set clock = null
endfunction

function alloc_DuplicateDat takes nothing returns integer
	local integer this
	if DuplicateDat_firstFree == 0 then
		if DuplicateDat_maxIndex < 8191 then
			set DuplicateDat_maxIndex = DuplicateDat_maxIndex + 1
			set this = DuplicateDat_maxIndex
			set DuplicateDat_typeId[this] = 32
		else
			call error("Out of memory: Could not create DuplicateDat.")
			set this = 0
		endif
	else
		set DuplicateDat_firstFree = DuplicateDat_firstFree - 1
		set this = DuplicateDat_nextFree[DuplicateDat_firstFree]
		set DuplicateDat_typeId[this] = 32
	endif
	return this
endfunction

function construct_DuplicateDat takes integer this returns nothing
endfunction

function new_DuplicateDat takes nothing returns integer
	local integer this = alloc_DuplicateDat()
	call construct_DuplicateDat(this)
	return this
endfunction

function simError takes player forPlayer, string msg returns nothing
	set msg = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00" + msg + "|r"
	if GetLocalPlayer() == forPlayer then
		call ClearTextMessages()
		call DisplayTimedTextToPlayer(forPlayer, 0.52, 0.96, 2.00, msg)
		call StartSound(SimError_error)
	endif
endfunction

function act_7 takes nothing returns nothing
	local integer dd
	local player owner
	local integer id
	local real x1
	local real y1
	local real x2
	local real y2
	local real fDiff
	if GetSpellAbilityId() == OrganicConcatenation_CONCATENATION_ID then
		set id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
		if  not (IsUnitInRange(Units_hero[id], Units_subHero[id], OrganicConcatenation_RANGE) and UnitAlive(Units_hero[id]) and UnitAlive(Units_subHero[id]) and Units_countBalls(Units_hero[id]) > 2 and Units_countBalls(Units_subHero[id]) > 2) then
			call simError(Players_fromId[id], "No suitable unit in range for concatenation")
			set owner = null
			return
		endif
		set dd = new_DuplicateDat()
		set DuplicateDat_tU[dd] = Units_hero[id]
		set DuplicateDat_friend[dd] = Units_subHero[id]
		set DuplicateDat_timeLeft[dd] = OrganicConcatenation_DURATION
		set owner = GetOwningPlayer(DuplicateDat_tU[dd])
		set x1 = GetUnitX(DuplicateDat_tU[dd])
		set x2 = GetUnitX(DuplicateDat_friend[dd])
		set y1 = GetUnitY(DuplicateDat_tU[dd])
		set y2 = GetUnitY(DuplicateDat_friend[dd])
		set DuplicateDat_dist[dd] = TerrainData_distanceBetweenXY(x1, x2, y1, y2)
		set DuplicateDat_uX[dd] = (x1 + x2) / 2.
		set DuplicateDat_uY[dd] = (y1 + y2) / 2.
		set DuplicateDat_f0[dd] = GetUnitFacing(DuplicateDat_tU[dd]) * bj_DEGTORAD
		set DuplicateDat_f1[dd] = GetUnitFacing(DuplicateDat_friend[dd]) * bj_DEGTORAD
		set fDiff = Math_radiansNormalizeHalf(DuplicateDat_f1[dd] - DuplicateDat_f0[dd])
		set DuplicateDat_face[dd] = Math_radiansNormalizeHalfModulo(DuplicateDat_f0[dd] - fDiff / 2.)
		set DuplicateDat_axis[dd] = TerrainData_radiansBetweenXY(x1, x2, y1, y2)
		set DuplicateDat_image0[dd] = CreateUnit(owner, OrganicConcatenation_BEAST_ILLUSION_ID, DuplicateDat_uX[dd] + 2. * DuplicateDat_dist[dd] / 6. * Cos(DuplicateDat_axis[dd]), DuplicateDat_uY[dd] + 2. * DuplicateDat_dist[dd] / 6. * Sin(DuplicateDat_axis[dd]), DuplicateDat_f0[dd] + 4. * fDiff / 5.)
		set DuplicateDat_image1[dd] = CreateUnit(owner, OrganicConcatenation_BEAST_ILLUSION_ID, DuplicateDat_uX[dd] + 1. * DuplicateDat_dist[dd] / 6. * Cos(DuplicateDat_axis[dd]), DuplicateDat_uY[dd] + 1. * DuplicateDat_dist[dd] / 6. * Sin(DuplicateDat_axis[dd]), DuplicateDat_f0[dd] + 3. * fDiff / 5.)
		set DuplicateDat_image2[dd] = CreateUnit(owner, OrganicConcatenation_BEAST_ILLUSION_ID, DuplicateDat_uX[dd] - 1. * DuplicateDat_dist[dd] / 6. * Cos(DuplicateDat_axis[dd]), DuplicateDat_uY[dd] - 1. * DuplicateDat_dist[dd] / 6. * Sin(DuplicateDat_axis[dd]), DuplicateDat_f0[dd] + 2. * fDiff / 5.)
		set DuplicateDat_image3[dd] = CreateUnit(owner, OrganicConcatenation_BEAST_ILLUSION_ID, DuplicateDat_uX[dd] - 2. * DuplicateDat_dist[dd] / 6. * Cos(DuplicateDat_axis[dd]), DuplicateDat_uY[dd] - 2. * DuplicateDat_dist[dd] / 6. * Sin(DuplicateDat_axis[dd]), DuplicateDat_f0[dd] + 1. * fDiff / 5.)
		call SoundControl_play3D(OrganicConcatenation_IMAGE_SOUND, 1., DuplicateDat_uX[dd], DuplicateDat_uY[dd], 0.)
		call SetUnitVertexColor(DuplicateDat_image0[dd], 255, 255, 255, 128)
		call SetUnitVertexColor(DuplicateDat_image1[dd], 255, 255, 255, 128)
		call SetUnitVertexColor(DuplicateDat_image2[dd], 255, 255, 255, 128)
		call SetUnitVertexColor(DuplicateDat_image3[dd], 255, 255, 255, 128)
		call SetUnitTimeScale(DuplicateDat_image0[dd], 0.)
		call SetUnitTimeScale(DuplicateDat_image1[dd], 0.)
		call SetUnitTimeScale(DuplicateDat_image2[dd], 0.)
		call SetUnitTimeScale(DuplicateDat_image3[dd], 0.)
		call Units_dischargeBall(DuplicateDat_tU[dd])
		call Units_dischargeBall(DuplicateDat_tU[dd])
		call Units_dischargeBall(DuplicateDat_tU[dd])
		call Units_dischargeBall(DuplicateDat_friend[dd])
		call Units_dischargeBall(DuplicateDat_friend[dd])
		call Units_dischargeBall(DuplicateDat_friend[dd])
		call SetUnitFlyHeight(DuplicateDat_tU[dd], 1000., 0.)
		call SetUnitVertexColor(DuplicateDat_tU[dd], 0, 0, 0, 0)
		call PauseUnit(DuplicateDat_tU[dd], true)
		call SetUnitFlyHeight(DuplicateDat_friend[dd], 1000., 0.)
		call SetUnitVertexColor(DuplicateDat_friend[dd], 0, 0, 0, 0)
		call PauseUnit(DuplicateDat_friend[dd], true)
		set OrganicConcatenation_ddIndex = OrganicConcatenation_ddIndex + 1
		set OrganicConcatenation_ddStack[OrganicConcatenation_ddIndex] = dd
		if OrganicConcatenation_ddIndex == 0 then
			call TimerStart(OrganicConcatenation_clock, OrganicConcatenation_CLOCK_PERIOD, true, ref_function_ddPeriodic)
		endif
	endif
	set owner = null
endfunction

function act_8 takes nothing returns nothing
	call DestroyTimer(GetExpiredTimer())
	set MultiboardControl_mb = CreateMultiboard()
	call MultiboardSetColumnCount(MultiboardControl_mb, 2)
	call MultiboardSetRowCount(MultiboardControl_mb, 1)
	call MultiboardSetItemsStyle(MultiboardControl_mb, true, false)
	call MultiboardSetItemWidth(MultiboardGetItem(MultiboardControl_mb, 0, 0), .09)
	call MultiboardSetItemWidth(MultiboardGetItem(MultiboardControl_mb, 0, 1), .04)
	call MultiboardSetTitleText(MultiboardControl_mb, "|cff999999Hunters|r  0 - 0  |cff411d0aBeasts|r")
	call MultiboardSetItemValue(MultiboardGetItem(MultiboardControl_mb, 0, 0), "|cffffcc00Round Time:|r")
	call MultiboardSetItemValue(MultiboardGetItem(MultiboardControl_mb, 0, 1), "0:00")
	call TimerStart(MultiboardControl_time, 1., true, ref_function_periodic)
endfunction

function act_9 takes nothing returns nothing
	local integer index = 0
	local real face
	if  not Cinematic_enabled then
		loop
			exitwhen index > Players_FIRST_BEAST
			call FogModifierStop(BinocularVision_lSight[index])
			call DestroyFogModifier(BinocularVision_lSight[index])
			if GetUnitTypeId(Units_hero[index]) == Units_HUNTER_ID and UnitAlive(Units_hero[index]) then
				set face = GetUnitFacing(Units_hero[index]) * bj_DEGTORAD
				set BinocularVision_lSight[index] = CreateFogModifierRadius(Players_fromId[index], FOG_OF_WAR_VISIBLE, GetUnitX(Units_hero[index]) + BinocularVision_OFFSET * Cos(face), GetUnitY(Units_hero[index]) + BinocularVision_OFFSET * Sin(face), BinocularVision_RADIUS, false, true)
				call FogModifierStart(BinocularVision_lSight[index])
			endif
			set index = index + 1
		endloop
	endif
endfunction

function alloc_DummyAlloc takes nothing returns integer
	local integer this
	if DummyAlloc_firstFree == 0 then
		if DummyAlloc_maxIndex < 8191 then
			set DummyAlloc_maxIndex = DummyAlloc_maxIndex + 1
			set this = DummyAlloc_maxIndex
			set DummyAlloc_typeId[this] = 18
		else
			call error("Out of memory: Could not create DummyAlloc.")
			set this = 0
		endif
	else
		set DummyAlloc_firstFree = DummyAlloc_firstFree - 1
		set this = DummyAlloc_nextFree[DummyAlloc_firstFree]
		set DummyAlloc_typeId[this] = 18
	endif
	return this
endfunction

function construct_DummyAlloc takes integer this returns nothing
endfunction

function new_DummyAlloc takes nothing returns integer
	local integer this = alloc_DummyAlloc()
	call construct_DummyAlloc(this)
	return this
endfunction

function act_10 takes nothing returns nothing
	local unit selected = null
	local real selectedRange = 2. * Knife_RADIUS
	local unit tU
	local unit iter
	local player p
	local real facing
	local real x
	local real y
	local unit dum
	local timer tim
	local timer cdTim
	local integer d
	if GetSpellAbilityId() == Knife_KNIFE_ID then
		set tU = GetTriggerUnit()
		set p = GetOwningPlayer(tU)
		set facing = GetUnitFacing(tU) * bj_DEGTORAD
		set x = GetUnitX(tU) + Knife_OFFSET * Cos(facing)
		set y = GetUnitY(tU) + Knife_OFFSET * Sin(facing)
		set dum = DummyUnitStack_get()
		call SetUnitX(dum, x)
		call SetUnitY(dum, y)
		call SetUnitFlyHeight(dum, Knife_EFFECT_HEIGHT, 0.)
		call DestroyEffect(AddSpecialEffectTarget(Knife_FX, dum, "origin"))
		set tim = CreateTimer()
		set d = new_DummyAlloc()
		set DummyAlloc_u[d] = dum
		call timer_setData(tim, d)
		call TimerStart(tim, Knife_FX_DURATION, false, ref_function_releaseDummy)
		call GroupEnumUnitsInRange(Knife_grp, x, y, Knife_RADIUS, null)
		loop
			set iter = FirstOfGroup(Knife_grp)
			exitwhen iter == null
			if IsUnitEnemy(iter, p) and UnitAlive(iter) and IsUnitInRangeXY(iter, x, y, selectedRange) then
				set selected = iter
				set selectedRange = TerrainData_distanceBetweenXY(GetUnitX(iter), x, GetUnitY(iter), y)
			endif
			call GroupRemoveUnit(Knife_grp, iter)
		endloop
		if selected != null then
			call DestroyEffect(AddSpecialEffectTarget(Knife_FX_PROC, selected, Knife_FX_PROC_ATTACH_POINT))
			if GetWidgetLife(selected) <= Knife_EXECUTE_MAX_HEALTH then
				call DestroyEffect(AddSpecialEffectTarget(Knife_FX_EXPLODED, selected, "origin"))
				call DamageType_dealCodeDamage(tU, selected, 2. * Knife_EXECUTE_MAX_HEALTH)
				set cdTim = CreateTimer()
				set d = new_DummyAlloc()
				set DummyAlloc_u[d] = tU
				call timer_setData(cdTim, d)
				call TimerStart(cdTim, Knife_SHORT_COOLDOWN, false, ref_function_resetCooldown)
			else
				call DamageType_dealCodeDamage(tU, selected, Knife_BASE_DAMAGE)
			endif
		endif
	endif
	set tU = null
	set iter = null
	set selected = null
	set p = null
	set dum = null
	set tim = null
	set cdTim = null
endfunction

function alloc_DuplicateDat_2 takes nothing returns integer
	local integer this
	if DuplicateDat_firstFree_2 == 0 then
		if DuplicateDat_maxIndex_2 < 8191 then
			set DuplicateDat_maxIndex_2 = DuplicateDat_maxIndex_2 + 1
			set this = DuplicateDat_maxIndex_2
			set DuplicateDat_typeId_2[this] = 33
		else
			call error("Out of memory: Could not create DuplicateDat.")
			set this = 0
		endif
	else
		set DuplicateDat_firstFree_2 = DuplicateDat_firstFree_2 - 1
		set this = DuplicateDat_nextFree_2[DuplicateDat_firstFree_2]
		set DuplicateDat_typeId_2[this] = 33
	endif
	return this
endfunction

function construct_DuplicateDat_2 takes integer this returns nothing
endfunction

function new_DuplicateDat_2 takes nothing returns integer
	local integer this = alloc_DuplicateDat_2()
	call construct_DuplicateDat_2(this)
	return this
endfunction

function act_11 takes nothing returns nothing
	local integer dd
	local player owner
	if GetSpellAbilityId() == OrganicHemisection_HEMISECTION_ID then
		set dd = new_DuplicateDat_2()
		set DuplicateDat_tU_2[dd] = GetTriggerUnit()
		set DuplicateDat_timeLeft_2[dd] = OrganicHemisection_DURATION
		set owner = GetOwningPlayer(DuplicateDat_tU_2[dd])
		set DuplicateDat_uX_2[dd] = GetUnitX(DuplicateDat_tU_2[dd])
		set DuplicateDat_uY_2[dd] = GetUnitY(DuplicateDat_tU_2[dd])
		set DuplicateDat_face_2[dd] = GetUnitFacing(DuplicateDat_tU_2[dd])
		set DuplicateDat_image0_2[dd] = CreateUnit(owner, OrganicHemisection_BEAST_ILLUSION_ID, DuplicateDat_uX_2[dd] + OrganicHemisection_OFFSET / 2. * Cos(DuplicateDat_face_2[dd] * bj_DEGTORAD - bj_PI / 2.), DuplicateDat_uY_2[dd] + OrganicHemisection_OFFSET / 2. * Sin(DuplicateDat_face_2[dd] * bj_DEGTORAD - bj_PI / 2.), DuplicateDat_face_2[dd])
		set DuplicateDat_image1_2[dd] = CreateUnit(owner, OrganicHemisection_BEAST_ILLUSION_ID, DuplicateDat_uX_2[dd], DuplicateDat_uY_2[dd], DuplicateDat_face_2[dd])
		set DuplicateDat_image2_2[dd] = CreateUnit(owner, OrganicHemisection_BEAST_ILLUSION_ID, DuplicateDat_uX_2[dd] + OrganicHemisection_OFFSET / 2. * Cos(DuplicateDat_face_2[dd] * bj_DEGTORAD + bj_PI / 2.), DuplicateDat_uY_2[dd] + OrganicHemisection_OFFSET / 2. * Sin(DuplicateDat_face_2[dd] * bj_DEGTORAD + bj_PI / 2.), DuplicateDat_face_2[dd])
		call SoundControl_play3D(OrganicHemisection_IMAGE_SOUND, 1., DuplicateDat_uX_2[dd], DuplicateDat_uY_2[dd], 0.)
		call SetUnitVertexColor(DuplicateDat_image0_2[dd], 255, 255, 255, 128)
		call SetUnitVertexColor(DuplicateDat_image1_2[dd], 255, 255, 255, 128)
		call SetUnitVertexColor(DuplicateDat_image2_2[dd], 255, 255, 255, 128)
		call SetUnitTimeScale(DuplicateDat_image0_2[dd], 0.)
		call SetUnitTimeScale(DuplicateDat_image1_2[dd], 0.)
		call SetUnitTimeScale(DuplicateDat_image2_2[dd], 0.)
		call Units_dischargeBall(DuplicateDat_tU_2[dd])
		call Units_dischargeBall(DuplicateDat_tU_2[dd])
		call Units_dischargeBall(DuplicateDat_tU_2[dd])
		call SetUnitFlyHeight(DuplicateDat_tU_2[dd], 1000., 0.)
		call SetUnitVertexColor(DuplicateDat_tU_2[dd], 0, 0, 0, 0)
		call PauseUnit(DuplicateDat_tU_2[dd], true)
		set OrganicHemisection_ddIndex = OrganicHemisection_ddIndex + 1
		set OrganicHemisection_ddStack[OrganicHemisection_ddIndex] = dd
		if OrganicHemisection_ddIndex == 0 then
			call TimerStart(OrganicHemisection_clock, OrganicHemisection_CLOCK_PERIOD, true, ref_function_ddPeriodic_2)
		endif
	endif
	set owner = null
endfunction

function countItems takes unit u, item i returns integer
	local integer typ = GetItemTypeId(i)
	local integer index = 0
	local integer count = 0
	loop
		exitwhen index > 5
		if GetItemTypeId(UnitItemInSlot(u, index)) == typ then
			set count = count + 1
		endif
		set index = index + 1
	endloop
	return count
endfunction

function act_12 takes nothing returns boolean
	local unit t = GetTriggerUnit()
	local item i = GetManipulatedItem()
	if countItems(t, i) > 1 then
		call UnitDropItemPoint(t, i, unit_getX(t), unit_getY(t))
		call simError(unit_getOwner(t), "You can't carry two of the same item.")
	endif
	set t = null
	set i = null
	return false
endfunction

function act_13 takes nothing returns nothing
	if IsUnitAlly(GetTriggerUnit(), GetOwningPlayer(GetAttacker())) then
		call IssueImmediateOrder(GetAttacker(), "stop")
	endif
endfunction

function item_setPos takes item this, real x, real y returns nothing
	call SetItemPosition(this, x, y)
endfunction

function fxSpawn takes unit u, real facing returns nothing
	call item_setPos(PedestalReceive_fakeRune, GetUnitX(u) + PedestalReceive_ITEM_DROP_OFFS * Cos(facing), GetUnitY(u) + PedestalReceive_ITEM_DROP_OFFS * Sin(facing))
	set PedestalReceive_spawnCount = PedestalReceive_SPAWN_COUNT
	call TimerStart(PedestalReceive_time, PedestalReceive_SPAWN_PERIOD, true, ref_function_fxSpawn2)
endfunction

function unit_getFacing takes unit this returns real
	return GetUnitFacing(this)
endfunction

function act_14 takes nothing returns nothing
	local unit iter
	call GroupEnumUnitsInRect(PedestalReceive_grp, PedestalReceive_rctEpsilon, null)
	loop
		set iter = FirstOfGroup(PedestalReceive_grp)
		exitwhen iter == null
		if UnitHasItem(iter, Units_artifact) or UnitHasItem(iter, Units_artifact2) and Game_roundEnabled then
			call SoundControl_play(PedestalReceive_RUNE_SECURED, 1., 127)
			call FogEnable(false)
			call PanCameraToTimed(GetUnitX(iter), GetUnitY(iter), 0.)
			call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 1024., 0.)
			call fxSpawn(iter, unit_getFacing(iter))
			call Game_hunterWin()
			call SetItemPosition(Units_artifact, TerrainData_SAFE_X, TerrainData_SAFE_Y)
			call SetItemPosition(Units_artifact2, TerrainData_SAFE_X, TerrainData_SAFE_Y)
			exitwhen true
		endif
		call GroupRemoveUnit(PedestalReceive_grp, iter)
	endloop
	set iter = null
endfunction

function afterDelay takes nothing returns nothing
	local integer index = 0
	call DialogClear(Initialization_dialo)
	call DialogSetMessage(Initialization_dialo, "Round wins required for victory")
	set Initialization_btns[0] = DialogAddButton(Initialization_dialo, "3", 51)
	set Initialization_btns[1] = DialogAddButton(Initialization_dialo, "5", 53)
	set Initialization_btns[2] = DialogAddButton(Initialization_dialo, "7", 55)
	set Initialization_btns[3] = DialogAddButton(Initialization_dialo, "9", 57)
	call TriggerRegisterDialogEvent(Initialization_diaClick, Initialization_dialo)
	call DisplayTextToPlayer(Players_locl, 0., 0., "|cffffcc00[Voting]|r Please wait up to |cffffcc0010|r seconds while players vote for round count.")
	call TimerStart(Initialization_voteTimer, 10., false, ref_function_endVotes)
	loop
		exitwhen index > Players_LAST_BEAST
		call DialogDisplay(Players_fromId[index], Initialization_dialo, true)
		set index = index + 1
	endloop
endfunction

function AutoDat_onDestroy takes integer this returns nothing
endfunction

function dealloc_AutoDat takes integer obj returns nothing
	if AutoDat_typeId[obj] == 0 then
		call error("Double free: object of type AutoDat")
	else
		set AutoDat_nextFree[AutoDat_firstFree] = obj
		set AutoDat_firstFree = AutoDat_firstFree + 1
		set AutoDat_typeId[obj] = 0
	endif
endfunction

function destroyAutoDat takes integer this returns nothing
	call AutoDat_onDestroy(this)
	call dealloc_AutoDat(this)
endfunction

function dispatch_AutoDat_destroyAutoDat takes integer this returns nothing
	if AutoDat_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling AutoDat.destroyAutoDat")
		else
			call error("Called AutoDat.destroyAutoDat on invalid object.")
		endif
	endif
	call destroyAutoDat(this)
endfunction

function autoTick takes nothing returns nothing
	local timer clock = GetExpiredTimer()
	local integer ad = timer_getData(clock)
	local real jitter
	if GetUnitCurrentOrder(AutoDat_attacker[ad]) == OrderId("channel") and dispatch_Table_Table_Table_loadInt(HunterAttack_logicalClock, handle_getHandleId(AutoDat_attacker[ad])) == AutoDat_logicalSecret[ad] then
		set jitter = GetRandomReal(HunterAttack_JITTER * ( - (1. / 2.)), HunterAttack_JITTER / 2.)
		call ProjectileStack_add(AutoDat_attacker[ad], AutoDat_uX[ad], AutoDat_uY[ad], AutoDat_tX[ad], AutoDat_tY[ad], jitter)
	else
		call DestroyTimer(clock)
		call dispatch_AutoDat_destroyAutoDat(ad)
	endif
	set clock = null
endfunction

function Cinematic_interrupt takes nothing returns nothing
	call PauseTimer(Cinematic_humanClock)
	call PauseTimer(Cinematic_beastClock)
	call Cinematic_endCinematic()
endfunction

function c takes nothing returns boolean
	local integer id = GetPlayerId(GetTriggerPlayer())
	if Game_singlePlayer and Cinematic_over then
		call FogEnable(false)
		call DisplayTextToPlayer(Players_locl, 0., 0., "|cffffcc00[Singleplayer]|r Fog Disabled!")
	endif
	if Cinematic_enabled and ( not Game_escapesPressed[id]) then
		set Game_escapesPressed[id] = true
		set Players_escapePressedCount = Players_escapePressedCount + 1
		if Players_escapePressedCount >= Players_humanCount then
			call Cinematic_interrupt()
			call DisplayTextToPlayer(Players_locl, 0., 0., "|cffffcc00[Notice]|r The cinematic was skipped due to popular vote.")
		else
			call DisplayTextToPlayer(GetTriggerPlayer(), 0., 0., "|cffffcc00[Notice]|r Your cinematic skip request has been registered.")
		endif
	endif
	return false
endfunction

function TextTag_regeneration takes real x, real y, player whom returns nothing
	local texttag t = CreateTextTag()
	call SetTextTagColor(t, 33, 120, 68, R2I(255 * 3 * 1. / 4))
	call SetTextTagLifespan(t, 2.)
	call SetTextTagFadepoint(t, 1.)
	call SetTextTagPermanent(t, false)
	call SetTextTagPos(t, x, y, 25.)
	call SetTextTagText(t, "+1", 10. * .0023)
	call SetTextTagVelocity(t, 50. * Cos(Maths_PI / 2.) * .071 / 128., 50. * Sin(Maths_PI / 2.) * .071 / 128.)
	call SetTextTagVisibility(t, false)
	if Players_locl == whom then
		call SetTextTagVisibility(t, true)
	endif
	set t = null
endfunction

function checkCombatDuration takes nothing returns nothing
	local integer index = 0
	local real life
	loop
		exitwhen index >= Players_FIRST_BEAST
		if UnitAlive(Units_hero[index]) and UnitHasItemOfTypeBJ(Units_hero[index], ItemFieldConditioningKit_DUST_ID) then
			set life = GetWidgetLife(Units_hero[index])
			if  not dispatch_Table_Table_Table_hasInt(ItemFieldConditioningKit_damageTimings, handle_getHandleId(Units_hero[index])) then
				call dispatch_Table_Table_Table_saveInt(ItemFieldConditioningKit_damageTimings, handle_getHandleId(Units_hero[index]), Statistics_secondsElapsed)
			elseif Statistics_secondsElapsed - dispatch_Table_Table_Table_loadInt(ItemFieldConditioningKit_damageTimings, handle_getHandleId(Units_hero[index])) > ItemFieldConditioningKit_COMBAT_TIME and life < GetUnitState(Units_hero[index], UNIT_STATE_MAX_LIFE) then
				call SetWidgetLife(Units_hero[index], life + 1.)
				call TextTag_regeneration(unit_getX(Units_hero[index]), unit_getY(Units_hero[index]), unit_getOwner(Units_hero[index]))
			endif
		endif
		set index = index + 1
	endloop
endfunction

function checkRoundSeconds takes nothing returns nothing
	if Game_roundEnabled and Statistics_roundEndTime - Statistics_secondsElapsed <= 0 then
		call FogEnable(false)
		call SoundControl_play(TimerUp_TIME_LIMIT_REACHED, 1., 127)
		call Game_beastWin()
	endif
endfunction

function AI_addPlayer takes player p returns nothing
	set AI_count = AI_count + 1
	set AI_players[AI_count] = p
	if AI_count == 0 then
		call TimerStart(AI_clock, AI_CLOCK_PERIOD, true, ref_function_AI_periodic)
	endif
endfunction

function cond takes nothing returns boolean
	local player tp = GetTriggerPlayer()
	local integer id = GetPlayerId(tp)
	call DisplayTimedTextToPlayer(Players_locl, 0., 0., 5., "|cffffcc00" + GetPlayerName(tp) + "|r left the game and replaced by AI.")
	call AI_addPlayer(tp)
	set Players_aiControlled[id] = true
	set Players_aiCount = Players_aiCount + 1
	set Players_humanCount = Players_humanCount - 1
	set tp = null
	return false
endfunction

function DuplicateDat_onDestroy takes integer this returns nothing
endfunction

function dealloc_DuplicateDat takes integer obj returns nothing
	if DuplicateDat_typeId_2[obj] == 0 then
		call error("Double free: object of type DuplicateDat")
	else
		set DuplicateDat_nextFree_2[DuplicateDat_firstFree_2] = obj
		set DuplicateDat_firstFree_2 = DuplicateDat_firstFree_2 + 1
		set DuplicateDat_typeId_2[obj] = 0
	endif
endfunction

function destroyDuplicateDat takes integer this returns nothing
	call DuplicateDat_onDestroy(this)
	call dealloc_DuplicateDat(this)
endfunction

function dispatch_DuplicateDat_destroyDuplicateDat takes integer this returns nothing
	if DuplicateDat_typeId_2[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling DuplicateDat.destroyDuplicateDat")
		else
			call error("Called DuplicateDat.destroyDuplicateDat on invalid object.")
		endif
	endif
	call destroyDuplicateDat(this)
endfunction

function ddPeriodic takes nothing returns nothing
	local integer index = 0
	local integer id
	local player owner
	local integer tempDat
	local real phaseOffset
	local real angle
	local real life
	loop
		exitwhen index > OrganicHemisection_ddIndex
		set tempDat = OrganicHemisection_ddStack[index]
		set phaseOffset = OrganicHemisection_PHASE_OFF * Cos(DuplicateDat_timeLeft_2[tempDat] * OrganicHemisection_PHASE_MULTIPLIER)
		set angle = DuplicateDat_face_2[tempDat] * bj_DEGTORAD + bj_PI / 2.
		call SetUnitX(DuplicateDat_image0_2[tempDat], DuplicateDat_uX_2[tempDat] + (OrganicHemisection_OFFSET / 2. + phaseOffset) * Cos(angle))
		call SetUnitX(DuplicateDat_image1_2[tempDat], DuplicateDat_uX_2[tempDat] + phaseOffset * Cos(angle))
		call SetUnitX(DuplicateDat_image2_2[tempDat], DuplicateDat_uX_2[tempDat] + (OrganicHemisection_OFFSET / ( - 2.) + phaseOffset) * Cos(angle))
		call SetUnitY(DuplicateDat_image0_2[tempDat], DuplicateDat_uY_2[tempDat] + (OrganicHemisection_OFFSET / 2. + phaseOffset) * Sin(angle))
		call SetUnitY(DuplicateDat_image1_2[tempDat], DuplicateDat_uY_2[tempDat] + phaseOffset * Sin(angle))
		call SetUnitY(DuplicateDat_image2_2[tempDat], DuplicateDat_uY_2[tempDat] + (OrganicHemisection_OFFSET / ( - 2.) + phaseOffset) * Sin(angle))
		set DuplicateDat_timeLeft_2[tempDat] = DuplicateDat_timeLeft_2[tempDat] - OrganicHemisection_CLOCK_PERIOD
		if DuplicateDat_timeLeft_2[tempDat] <= 0. then
			call RemoveUnit(DuplicateDat_image0_2[tempDat])
			call RemoveUnit(DuplicateDat_image1_2[tempDat])
			call RemoveUnit(DuplicateDat_image2_2[tempDat])
			set Statistics_beastsAlive = Statistics_beastsAlive + 1
			set owner = GetOwningPlayer(DuplicateDat_tU_2[tempDat])
			set id = GetPlayerId(owner)
			set Units_hero[id] = CreateUnit(owner, Units_LESSER_BEAST_ID, DuplicateDat_uX_2[tempDat] + OrganicHemisection_OFFSET * Cos(DuplicateDat_face_2[tempDat] * bj_DEGTORAD - bj_PI / 2.), DuplicateDat_uY_2[tempDat] + OrganicHemisection_OFFSET * Sin(DuplicateDat_face_2[tempDat] * bj_DEGTORAD - bj_PI / 2.), DuplicateDat_face_2[tempDat])
			set Units_subHero[id] = CreateUnit(owner, Units_LESSER_BEAST_ID, DuplicateDat_uX_2[tempDat] + OrganicHemisection_OFFSET * Cos(DuplicateDat_face_2[tempDat] * bj_DEGTORAD + bj_PI / 2.), DuplicateDat_uY_2[tempDat] + OrganicHemisection_OFFSET * Sin(DuplicateDat_face_2[tempDat] * bj_DEGTORAD + bj_PI / 2.), DuplicateDat_face_2[tempDat])
			call Units_initializeBeast(Units_hero[id])
			call Units_initializeBeast(Units_subHero[id])
			if Players_locl == owner and ( not Cinematic_enabled) then
				call SelectUnit(Units_hero[id], true)
				call SelectUnit(Units_subHero[id], true)
			endif
			set life = GetWidgetLife(DuplicateDat_tU_2[tempDat]) / 2.
			call SetWidgetLife(Units_hero[id], life)
			call SetWidgetLife(Units_subHero[id], life)
			call RemoveUnit(DuplicateDat_tU_2[tempDat])
			call dispatch_DuplicateDat_destroyDuplicateDat(tempDat)
			set OrganicHemisection_ddStack[index] = OrganicHemisection_ddStack[OrganicHemisection_ddIndex]
			set OrganicHemisection_ddIndex = OrganicHemisection_ddIndex - 1
			set index = index - 1
			if OrganicHemisection_ddIndex == -1 then
				call PauseTimer(OrganicHemisection_clock)
			endif
		endif
		set index = index + 1
	endloop
	set owner = null
endfunction

function DuplicateDat_onDestroy_2 takes integer this returns nothing
endfunction

function dealloc_DuplicateDat_2 takes integer obj returns nothing
	if DuplicateDat_typeId[obj] == 0 then
		call error("Double free: object of type DuplicateDat")
	else
		set DuplicateDat_nextFree[DuplicateDat_firstFree] = obj
		set DuplicateDat_firstFree = DuplicateDat_firstFree + 1
		set DuplicateDat_typeId[obj] = 0
	endif
endfunction

function destroyDuplicateDat_2 takes integer this returns nothing
	call DuplicateDat_onDestroy_2(this)
	call dealloc_DuplicateDat_2(this)
endfunction

function dispatch_DuplicateDat_destroyDuplicateDat_2 takes integer this returns nothing
	if DuplicateDat_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling DuplicateDat.destroyDuplicateDat")
		else
			call error("Called DuplicateDat.destroyDuplicateDat on invalid object.")
		endif
	endif
	call destroyDuplicateDat_2(this)
endfunction

function ddPeriodic_2 takes nothing returns nothing
	local integer index = 0
	local integer id
	local player owner
	local integer tempDat
	loop
		exitwhen index > OrganicConcatenation_ddIndex
		set tempDat = OrganicConcatenation_ddStack[index]
		call SetUnitX(DuplicateDat_image0[tempDat], DuplicateDat_uX[tempDat] + (2. * DuplicateDat_dist[tempDat] / 6. + OrganicConcatenation_PHASE_OFFSET) * Cos(DuplicateDat_axis[tempDat]))
		call SetUnitX(DuplicateDat_image1[tempDat], DuplicateDat_uX[tempDat] + (1. * DuplicateDat_dist[tempDat] / 6. + OrganicConcatenation_PHASE_OFFSET) * Cos(DuplicateDat_axis[tempDat]))
		call SetUnitX(DuplicateDat_image2[tempDat], DuplicateDat_uX[tempDat] - (1. * DuplicateDat_dist[tempDat] / 6. + OrganicConcatenation_PHASE_OFFSET) * Cos(DuplicateDat_axis[tempDat]))
		call SetUnitX(DuplicateDat_image3[tempDat], DuplicateDat_uX[tempDat] - (2. * DuplicateDat_dist[tempDat] / 6. + OrganicConcatenation_PHASE_OFFSET) * Cos(DuplicateDat_axis[tempDat]))
		call SetUnitY(DuplicateDat_image0[tempDat], DuplicateDat_uY[tempDat] + (2. * DuplicateDat_dist[tempDat] / 6. + OrganicConcatenation_PHASE_OFFSET) * Sin(DuplicateDat_axis[tempDat]))
		call SetUnitY(DuplicateDat_image1[tempDat], DuplicateDat_uY[tempDat] + (1. * DuplicateDat_dist[tempDat] / 6. + OrganicConcatenation_PHASE_OFFSET) * Sin(DuplicateDat_axis[tempDat]))
		call SetUnitY(DuplicateDat_image2[tempDat], DuplicateDat_uY[tempDat] - (1. * DuplicateDat_dist[tempDat] / 6. + OrganicConcatenation_PHASE_OFFSET) * Sin(DuplicateDat_axis[tempDat]))
		call SetUnitY(DuplicateDat_image3[tempDat], DuplicateDat_uY[tempDat] - (2. * DuplicateDat_dist[tempDat] / 6. + OrganicConcatenation_PHASE_OFFSET) * Sin(DuplicateDat_axis[tempDat]))
		set DuplicateDat_timeLeft[tempDat] = DuplicateDat_timeLeft[tempDat] - OrganicConcatenation_CLOCK_PERIOD
		if DuplicateDat_timeLeft[tempDat] <= 0. then
			call RemoveUnit(DuplicateDat_image0[tempDat])
			call RemoveUnit(DuplicateDat_image1[tempDat])
			call RemoveUnit(DuplicateDat_image2[tempDat])
			call RemoveUnit(DuplicateDat_image3[tempDat])
			set Statistics_beastsAlive = Statistics_beastsAlive - 1
			set owner = GetOwningPlayer(DuplicateDat_tU[tempDat])
			set id = GetPlayerId(owner)
			set Units_hero[id] = CreateUnit(owner, Units_BEAST_ID, DuplicateDat_uX[tempDat], DuplicateDat_uY[tempDat], DuplicateDat_face[tempDat])
			set Units_subHero[id] = null
			call Units_initializeBeast(Units_hero[id])
			call SetWidgetLife(Units_hero[id], GetWidgetLife(DuplicateDat_tU[tempDat]) + GetWidgetLife(DuplicateDat_friend[tempDat]))
			if Players_locl == owner then
				call SelectUnit(Units_hero[id], true)
			endif
			call RemoveUnit(DuplicateDat_tU[tempDat])
			call RemoveUnit(DuplicateDat_friend[tempDat])
			call dispatch_DuplicateDat_destroyDuplicateDat_2(tempDat)
			set OrganicConcatenation_ddStack[index] = OrganicConcatenation_ddStack[OrganicConcatenation_ddIndex]
			set OrganicConcatenation_ddIndex = OrganicConcatenation_ddIndex - 1
			set index = index - 1
			if OrganicConcatenation_ddIndex == -1 then
				call PauseTimer(OrganicConcatenation_clock)
			endif
		endif
		set index = index + 1
	endloop
	set owner = null
endfunction

function endVotes takes nothing returns nothing
	local integer n
	call ClearTextMessages()
	if Game_roundsToWin == 0 then
		call DisplayTextToPlayer(Players_locl, 0., 0., "|cffffcc00[Voting]|r No votes registered, reverting to |cffffcc004|r rounds to win (Best-of-7)")
		set Game_roundsToWin = 4
	else
		set n = R2I(I2R(Game_roundsToWin) / I2R(Initialization_votesCounted) + .5)
		set Game_roundsToWin = n
		call DisplayTextToPlayer(Players_locl, 0., 0., "|cffffcc00[Voting]|r Voting finished; |cffffcc00" + I2S(n) + "|r rounds to win (Best-of-" + I2S(n * 2 - 1) + ")")
	endif
	call TimerStart(Initialization_voteTimer, 3., false, ref_function_startC)
endfunction

function diaA takes nothing returns nothing
	local integer index = 0
	local integer btnVal = 0
	local button b = GetClickedButton()
	if b == Initialization_btns[0] then
		set btnVal = 3
	elseif b == Initialization_btns[1] then
		set btnVal = 5
	elseif b == Initialization_btns[2] then
		set btnVal = 7
	elseif b == Initialization_btns[3] then
		set btnVal = 9
	endif
	set Initialization_votesCounted = Initialization_votesCounted + 1
	set Game_roundsToWin = Game_roundsToWin + btnVal
	if Initialization_votesCounted >= Players_humanCount then
		call PauseTimer(Initialization_voteTimer)
		loop
			exitwhen index > Players_LAST_BEAST
			call DialogDisplay(Players_fromId[index], Initialization_dialo, false)
			set index = index + 1
		endloop
		call endVotes()
	endif
	set b = null
endfunction

function alloc_Effect takes nothing returns integer
	local integer this
	if Effect_firstFree == 0 then
		if Effect_maxIndex < 8191 then
			set Effect_maxIndex = Effect_maxIndex + 1
			set this = Effect_maxIndex
			set Effect_typeId[this] = 34
		else
			call error("Out of memory: Could not create Effect.")
			set this = 0
		endif
	else
		set Effect_firstFree = Effect_firstFree - 1
		set this = Effect_nextFree[Effect_firstFree]
		set Effect_typeId[this] = 34
	endif
	return this
endfunction

function construct_Effect takes integer this returns nothing
endfunction

function new_Effect takes nothing returns integer
	local integer this = alloc_Effect()
	call construct_Effect(this)
	return this
endfunction

function timer_startPeriodic takes timer this, real time, code timerCallBack returns nothing
	call TimerStart(this, time, true, timerCallBack)
endfunction

function unit_setFlyHeight takes unit this, real height, real rate returns nothing
	call SetUnitFlyHeight(this, height, rate)
endfunction

function unit_setPos takes unit this, real x, real y returns nothing
	call SetUnitPosition(this, x, y)
endfunction

function fxSpawn2 takes nothing returns nothing
	local real randTarget = GetRandomReal(0., 1.)
	local real randAng = GetRandomReal(0., 2. * Maths_PI)
	local integer fx
	local integer tempIndex
	local integer tempIndex_2
	local integer tempIndex_3
	if PedestalReceive_spawnCount > 0 and ( not Game_roundEnabled) then
		set fx = new_Effect()
		set tempIndex = fx
		set Effect_velocity[tempIndex] = PedestalReceive_INITIAL_VELOCITY * PedestalReceive_CLOCK_PERIOD * Cos(PedestalReceive_INITIAL_PITCH) * Cos(randAng)
		set Effect_velocity_2[tempIndex] = PedestalReceive_INITIAL_VELOCITY * PedestalReceive_CLOCK_PERIOD * Cos(PedestalReceive_INITIAL_PITCH) * Sin(randAng)
		set Effect_velocity_3[tempIndex] = PedestalReceive_INITIAL_VELOCITY * PedestalReceive_CLOCK_PERIOD * Sin(PedestalReceive_INITIAL_PITCH)
		set Effect_dummy[fx] = DummyUnitStack_get()
		set Effect_attached[fx] = AddSpecialEffectTarget(PedestalReceive_DUMMY_MODEL, Effect_dummy[fx], "origin")
		call unit_setFlyHeight(Effect_dummy[fx], PedestalReceive_ITEM_SPAWN_HEIGHT, 0.)
		call unit_setPos(Effect_dummy[fx], GetItemX(PedestalReceive_fakeRune), GetItemY(PedestalReceive_fakeRune))
		if randTarget < .5 then
			set tempIndex_2 = fx
			set Effect_target[tempIndex_2] = PedestalReceive_TARGET_PILLAR_LEFT_x
			set Effect_target_2[tempIndex_2] = PedestalReceive_TARGET_PILLAR_LEFT_y
			set Effect_target_3[tempIndex_2] = PedestalReceive_TARGET_PILLAR_LEFT_z
		else
			set tempIndex_3 = fx
			set Effect_target[tempIndex_3] = PedestalReceive_TARGET_PILLAR_RIGHT_x
			set Effect_target_2[tempIndex_3] = PedestalReceive_TARGET_PILLAR_RIGHT_y
			set Effect_target_3[tempIndex_3] = PedestalReceive_TARGET_PILLAR_RIGHT_z
		endif
		set PedestalReceive_effectIndex = PedestalReceive_effectIndex + 1
		set PedestalReceive_fxDb[PedestalReceive_effectIndex] = fx
		if PedestalReceive_effectIndex == 0 then
			call timer_startPeriodic(PedestalReceive_time2, PedestalReceive_CLOCK_PERIOD, ref_function_fxSpawn3)
		endif
		set PedestalReceive_spawnCount = PedestalReceive_spawnCount - 1
	else
		call timer_pause(PedestalReceive_time)
		call item_setPos(PedestalReceive_fakeRune, TerrainData_SAFE_X, TerrainData_SAFE_Y)
	endif
endfunction

function alloc_UnitAlloc takes nothing returns integer
	local integer this
	if UnitAlloc_firstFree == 0 then
		if UnitAlloc_maxIndex < 8191 then
			set UnitAlloc_maxIndex = UnitAlloc_maxIndex + 1
			set this = UnitAlloc_maxIndex
			set UnitAlloc_typeId[this] = 13
		else
			call error("Out of memory: Could not create UnitAlloc.")
			set this = 0
		endif
	else
		set UnitAlloc_firstFree = UnitAlloc_firstFree - 1
		set this = UnitAlloc_nextFree[UnitAlloc_firstFree]
		set UnitAlloc_typeId[this] = 13
	endif
	return this
endfunction

function construct_UnitAlloc takes integer this returns nothing
endfunction

function new_UnitAlloc takes nothing returns integer
	local integer this = alloc_UnitAlloc()
	call construct_UnitAlloc(this)
	return this
endfunction

function DummyUnitStack_delayedRelease takes unit u, real delay returns nothing
	local integer ua = new_UnitAlloc()
	local timer tim = CreateTimer()
	set UnitAlloc_u[ua] = u
	call timer_setData(tim, ua)
	call TimerStart(tim, delay, false, ref_function_DummyUnitStack_afterDelay)
	set tim = null
endfunction

function Effect_onDestroy takes integer this returns nothing
endfunction

function dealloc_Effect takes integer obj returns nothing
	if Effect_typeId[obj] == 0 then
		call error("Double free: object of type Effect")
	else
		set Effect_nextFree[Effect_firstFree] = obj
		set Effect_firstFree = Effect_firstFree + 1
		set Effect_typeId[obj] = 0
	endif
endfunction

function destroyEffect takes integer this returns nothing
	call Effect_onDestroy(this)
	call dealloc_Effect(this)
endfunction

function dispatch_Effect_destroyEffect takes integer this returns nothing
	if Effect_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Effect.destroyEffect")
		else
			call error("Called Effect.destroyEffect on invalid object.")
		endif
	endif
	call destroyEffect(this)
endfunction

function effect_destr takes effect this returns nothing
	call DestroyEffect(this)
endfunction

function real_op_mult takes real this, real v_x, real v_y, real v_z returns real
	set real_op_mult_return_x = v_x * this
	set real_op_mult_return_y = v_y * this
	set real_op_mult_return_z = v_z * this
	return real_op_mult_return_x
endfunction

function unit_getFlyHeight takes unit this returns real
	return GetUnitFlyHeight(this)
endfunction

function real_squared takes real this returns real
	return this * this
endfunction

function vec3_distToVec takes real this_x, real this_y, real this_z, real v_x, real v_y, real v_z returns real
	return SquareRoot(real_squared(v_x - this_x) + real_squared(v_y - this_y) + real_squared(v_z - this_z))
endfunction

function vec3_length takes real this_x, real this_y, real this_z returns real
	return SquareRoot(this_x * this_x + this_y * this_y + this_z * this_z)
endfunction

function vec3_norm takes real this_x, real this_y, real this_z returns real
	local real len = vec3_length(this_x, this_y, this_z)
	local real x = 0.
	local real y = 0.
	local real z = 0.
	if len != 0.0 then
		set x = this_x / len
		set y = this_y / len
		set z = this_z / len
	endif
	set vec3_norm_return_x = x
	set vec3_norm_return_y = y
	set vec3_norm_return_z = z
	return vec3_norm_return_x
endfunction

function vec3_op_minus takes real this_x, real this_y, real this_z, real v_x, real v_y, real v_z returns real
	set vec3_op_minus_return_x = this_x - v_x
	set vec3_op_minus_return_y = this_y - v_y
	set vec3_op_minus_return_z = this_z - v_z
	return vec3_op_minus_return_x
endfunction

function vec3_op_mult takes real this_x, real this_y, real this_z, real factor returns real
	set vec3_op_mult_return_x = this_x * factor
	set vec3_op_mult_return_y = this_y * factor
	set vec3_op_mult_return_z = this_z * factor
	return vec3_op_mult_return_x
endfunction

function vec3_op_plus takes real this_x, real this_y, real this_z, real v_x, real v_y, real v_z returns real
	set vec3_op_plus_return_x = this_x + v_x
	set vec3_op_plus_return_y = this_y + v_y
	set vec3_op_plus_return_z = this_z + v_z
	return vec3_op_plus_return_x
endfunction

function fxSpawn3 takes nothing returns nothing
	local integer index = 0
	local integer iter
	local real diff_x
	local real diff_y
	local real diff_z
	local real dX
	local real dY
	local real dH
	local integer tempIndex
	local real temp_diff_x
	local real temp_diff_y
	local real temp_diff_z
	local integer tempIndex_2
	local integer tempIndex_3
	local integer tempIndex_4
	local integer tempIndex_5
	local integer tempIndex_6
	local real tempTupleSelectionResult_1
	local real temp_tempTupleSelectionResult_1
	local integer tempIndex_7
	local real tempTupleSelectionResult_2
	local real temp_tempTupleSelectionResult_2
	local integer tempIndex_8
	local real tempTupleSelectionResult_3
	local real temp_tempTupleSelectionResult_3
	local integer tempIndex_9
	local real tempTupleSelectionResult_1_2
	local real temp_tempTupleSelectionResult_1_2
	local integer tempIndex_10
	local real tempTupleSelectionResult_2_2
	local real temp_tempTupleSelectionResult_2_2
	local integer tempIndex_11
	local real tempTupleSelectionResult_3_2
	local real temp_tempTupleSelectionResult_3_2
	local integer tempIndex_12
	local integer tempIndex_13
	local integer tempIndex_14
	local real tempTupleSelectionResult_1_3
	local real temp_tempTupleSelectionResult_1_3
	local integer tempIndex_15
	local real tempTupleSelectionResult_2_3
	local real temp_tempTupleSelectionResult_2_3
	local integer tempIndex_16
	local real tempTupleSelectionResult_3_3
	local real temp_tempTupleSelectionResult_3_3
	local integer temp
	local integer temp_2
	local real temp_3
	local unit temp_4
	local real temp_5
	local unit temp_6
	local real temp_7
	local unit temp_8
	local real temp_9
	local real temp_10
	local real temp_11
	local real temp_12
	local real temp_13
	local real temp_14
	local real temp_15
	local boolean andLeft
	local unit temp_16
	local unit temp_17
	local unit temp_18
	loop
		exitwhen index > PedestalReceive_effectIndex
		set iter = PedestalReceive_fxDb[index]
		set dX = unit_getX(Effect_dummy[iter])
		set dY = unit_getY(Effect_dummy[iter])
		set dH = unit_getFlyHeight(Effect_dummy[iter])
		set tempIndex = iter
		set temp_diff_x = vec3_op_minus(Effect_target[tempIndex], Effect_target_2[tempIndex], Effect_target_3[tempIndex], dX, dY, dH)
		set temp_diff_y = vec3_op_minus_return_y
		set temp_diff_z = vec3_op_minus_return_z
		set diff_x = temp_diff_x
		set diff_y = temp_diff_y
		set diff_z = temp_diff_z
		set tempIndex_2 = iter
		set temp = tempIndex_2
		set tempIndex_3 = iter
		set Effect_velocity[temp] = vec3_op_plus(Effect_velocity[tempIndex_3], Effect_velocity_2[tempIndex_3], Effect_velocity_3[tempIndex_3], real_op_mult(PedestalReceive_ACCELERATION * PedestalReceive_CLOCK_PERIOD, vec3_norm(diff_x, diff_y, diff_z), vec3_norm_return_y, vec3_norm_return_z), real_op_mult_return_y, real_op_mult_return_z)
		set Effect_velocity_2[tempIndex_2] = vec3_op_plus_return_y
		set Effect_velocity_3[tempIndex_2] = vec3_op_plus_return_z
		set tempIndex_4 = iter
		set temp_2 = tempIndex_4
		set tempIndex_5 = iter
		set Effect_velocity[temp_2] = vec3_op_mult(Effect_velocity[tempIndex_5], Effect_velocity_2[tempIndex_5], Effect_velocity_3[tempIndex_5], 1. - PedestalReceive_AIR_FRICTION)
		set Effect_velocity_2[tempIndex_4] = vec3_op_mult_return_y
		set Effect_velocity_3[tempIndex_4] = vec3_op_mult_return_z
		set temp_4 = Effect_dummy[iter]
		set temp_3 = dX
		set tempIndex_6 = iter
		set temp_tempTupleSelectionResult_1 = Effect_velocity[tempIndex_6]
		set tempTupleSelectionResult_1 = temp_tempTupleSelectionResult_1
		call unit_setX(temp_4, temp_3 + tempTupleSelectionResult_1)
		set temp_6 = Effect_dummy[iter]
		set temp_5 = dY
		set tempIndex_7 = iter
		set temp_tempTupleSelectionResult_2 = Effect_velocity_2[tempIndex_7]
		set tempTupleSelectionResult_2 = temp_tempTupleSelectionResult_2
		call unit_setY(temp_6, temp_5 + tempTupleSelectionResult_2)
		set temp_8 = Effect_dummy[iter]
		set temp_7 = dH
		set tempIndex_8 = iter
		set temp_tempTupleSelectionResult_3 = Effect_velocity_3[tempIndex_8]
		set tempTupleSelectionResult_3 = temp_tempTupleSelectionResult_3
		call unit_setFlyHeight(temp_8, temp_7 + tempTupleSelectionResult_3, 0.)
		if Game_roundEnabled then
			set andLeft = true
		else
			set temp_9 = dX
			set tempIndex_9 = iter
			set temp_tempTupleSelectionResult_1_2 = Effect_velocity[tempIndex_9]
			set tempTupleSelectionResult_1_2 = temp_tempTupleSelectionResult_1_2
			set temp_12 = temp_9 + tempTupleSelectionResult_1_2
			set temp_10 = dY
			set tempIndex_10 = iter
			set temp_tempTupleSelectionResult_2_2 = Effect_velocity_2[tempIndex_10]
			set tempTupleSelectionResult_2_2 = temp_tempTupleSelectionResult_2_2
			set temp_13 = temp_10 + tempTupleSelectionResult_2_2
			set temp_11 = dH
			set tempIndex_11 = iter
			set temp_tempTupleSelectionResult_3_2 = Effect_velocity_3[tempIndex_11]
			set tempTupleSelectionResult_3_2 = temp_tempTupleSelectionResult_3_2
			set temp_14 = temp_11 + tempTupleSelectionResult_3_2
			set tempIndex_12 = iter
			set temp_15 = vec3_distToVec(temp_12, temp_13, temp_14, Effect_target[tempIndex_12], Effect_target_2[tempIndex_12], Effect_target_3[tempIndex_12])
			set tempIndex_13 = iter
			set andLeft = temp_15 < 2. * vec3_length(Effect_velocity[tempIndex_13], Effect_velocity_2[tempIndex_13], Effect_velocity_3[tempIndex_13])
		endif
		if andLeft then
			call effect_destr(Effect_attached[iter])
			set temp_16 = Effect_dummy[iter]
			set tempIndex_14 = iter
			set temp_tempTupleSelectionResult_1_3 = Effect_target[tempIndex_14]
			set tempTupleSelectionResult_1_3 = temp_tempTupleSelectionResult_1_3
			call unit_setX(temp_16, tempTupleSelectionResult_1_3)
			set temp_17 = Effect_dummy[iter]
			set tempIndex_15 = iter
			set temp_tempTupleSelectionResult_2_3 = Effect_target_2[tempIndex_15]
			set tempTupleSelectionResult_2_3 = temp_tempTupleSelectionResult_2_3
			call unit_setY(temp_17, tempTupleSelectionResult_2_3)
			set temp_18 = Effect_dummy[iter]
			set tempIndex_16 = iter
			set temp_tempTupleSelectionResult_3_3 = Effect_target_3[tempIndex_16]
			set tempTupleSelectionResult_3_3 = temp_tempTupleSelectionResult_3_3
			call unit_setFlyHeight(temp_18, tempTupleSelectionResult_3_3, 0.)
			call effect_destr(AddSpecialEffectTarget(PedestalReceive_EFFECT_MODEL, Effect_dummy[iter], "origin"))
			call DummyUnitStack_delayedRelease(Effect_dummy[iter], 1.)
			call dispatch_Effect_destroyEffect(iter)
			set PedestalReceive_fxDb[index] = PedestalReceive_fxDb[PedestalReceive_effectIndex]
			set PedestalReceive_effectIndex = PedestalReceive_effectIndex - 1
			set index = index - 1
			if PedestalReceive_effectIndex == -1 then
				call timer_pause(PedestalReceive_time2)
			endif
		endif
		set index = index + 1
	endloop
	set temp_4 = null
	set temp_6 = null
	set temp_8 = null
	set temp_16 = null
	set temp_17 = null
	set temp_18 = null
endfunction

function DamageOverTime_unitHasFlag takes unit u, integer flag returns boolean
	local integer index = 0
	local integer iterator
	loop
		exitwhen index > DamageOverTime_dbIndex
		set iterator = DamageOverTime_dotDB[index]
		if DotData_target[iterator] == u and DotData_exFlag[iterator] == flag then
			return true
		endif
		set index = index + 1
	endloop
	return false
endfunction

function alloc_DotData takes nothing returns integer
	local integer this
	if DotData_firstFree == 0 then
		if DotData_maxIndex < 8191 then
			set DotData_maxIndex = DotData_maxIndex + 1
			set this = DotData_maxIndex
			set DotData_typeId[this] = 9
		else
			call error("Out of memory: Could not create DotData.")
			set this = 0
		endif
	else
		set DotData_firstFree = DotData_firstFree - 1
		set this = DotData_nextFree[DotData_firstFree]
		set DotData_typeId[this] = 9
	endif
	return this
endfunction

function construct_DotData takes integer this returns nothing
	set DotData_source[this] = null
	set DotData_target[this] = null
	set DotData_dps[this] = 0.
	set DotData_duration[this] = 1.
	set DotData_fx[this] = ""
	set DotData_fxFlag[this] = 0
	set DotData_exFlag[this] = 0
endfunction

function new_DotData takes nothing returns integer
	local integer this = alloc_DotData()
	call construct_DotData(this)
	return this
endfunction

function DamageOverTime_add takes unit source, unit target, real dps, real duration, string fx, integer fxFlag, integer exclusivityFlag returns nothing
	local integer tempDat
	if exclusivityFlag > 0 and DamageOverTime_unitHasFlag(target, exclusivityFlag) then
		return
	endif
	set tempDat = new_DotData()
	set DotData_source[tempDat] = source
	set DotData_target[tempDat] = target
	set DotData_dps[tempDat] = dps
	set DotData_duration[tempDat] = duration
	set DotData_fx[tempDat] = fx
	set DotData_fxFlag[tempDat] = fxFlag
	set DotData_exFlag[tempDat] = exclusivityFlag
	set DamageOverTime_dbIndex = DamageOverTime_dbIndex + 1
	set DamageOverTime_dotDB[DamageOverTime_dbIndex] = tempDat
	if DamageOverTime_dbIndex == 0 then
		call TimerStart(DamageOverTime_time, DamageOverTime_CLOCK_PERIOD, true, ref_function_DamageOverTime_damageTick)
	endif
endfunction

function hand takes nothing returns nothing
	local unit eS = GetEventDamageSource()
	local unit tU = GetTriggerUnit()
	local integer id = GetUnitTypeId(eS)
	local real bd = BeastAttack_BASE_DAMAGE
	if dispatch_Table_Table_Table_hasInt(ItemFieldConditioningKit_damageTimings, handle_getHandleId(tU)) then
		call dispatch_Table_Table_Table_saveInt(ItemFieldConditioningKit_damageTimings, handle_getHandleId(tU), Statistics_secondsElapsed)
	endif
	if id == Units_BEAST_ID or id == Units_LESSER_BEAST_ID and DamageType_get() == DamageType_NULLED then
		if UnitHasItemOfTypeBJ(tU, BeastAttack_STUDDED_LEATHER_ID) then
			set bd = bd - BeastAttack_LEATHER_DAMAGE_REDUCTION
		endif
		if dispatch_Table_Table_Table_hasInt(Units_thunderClock, handle_getHandleId(eS)) and Statistics_secondsElapsed - dispatch_Table_Table_Table_loadInt(Units_thunderClock, handle_getHandleId(eS)) < BeastAttack_THUNDER_DURATION then
			set bd = bd + GetUnitState(tU, UNIT_STATE_MAX_LIFE) * BeastAttack_THUNDER_BONUS_MULTIPLIER
			call dispatch_Table_Table_Table_saveInt(Units_thunderClock, handle_getHandleId(eS), 0)
			call DestroyEffect(AddSpecialEffectTarget(BeastAttack_THUNDER_FX_BIG, tU, "origin"))
			call DamageOverTime_add(eS, tU, 0., 2., BeastAttack_THUNDER_FX, DamageOverTime_FX_FLAG_COORDS, BeastAttack_THUNDER_EXCLUSIVITY)
		endif
		call DestroyEffect(AddSpecialEffectTarget(BeastAttack_FX, tU, "origin"))
		call DamageType_dealCodeDamage(eS, tU, bd)
		call DamageOverTime_add(eS, tU, BeastAttack_DAMAGE_PER_SECOND, BeastAttack_DOT_DURATION, BeastAttack_BLOOD_FX, DamageOverTime_FX_FLAG_ATTACH, BeastAttack_DOT_EXCLUSIVITY)
	endif
	set eS = null
	set tU = null
endfunction

function init_AI takes nothing returns boolean
	set AI_STATE_AGGRESSIVE = 0
	set AI_STATE_RETREAT = 1
	set AI_BEAST_ID = 1747988530
	set AI_THUNDER_CD = 10
	set AI_grp = CreateGroup()
	set AI_hunterLeader = null
	set AI_CLOCK_PERIOD = 1. / 2.
	set AI_count = -1
	set AI_clock = CreateTimer()
	return true
endfunction

function registerPlayerUnitEvent takes playerunitevent p, code c_2 returns nothing
	local integer i = GetHandleId(p)
	local integer k = 15
	if RegisterPlayerUnitEvent_t[i] == null then
		set RegisterPlayerUnitEvent_t[i] = CreateTrigger()
		loop
			call TriggerRegisterPlayerUnitEvent(RegisterPlayerUnitEvent_t[i], Player(k), p, null)
			exitwhen k == 0
			set k = k - 1
		endloop
	endif
	call TriggerAddCondition(RegisterPlayerUnitEvent_t[i], Filter(c_2))
endfunction

function init takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_ATTACKED, ref_function_act)
endfunction

function init_AttackTeammate takes nothing returns boolean
	call init()
	return true
endfunction

function init_Basics takes nothing returns boolean
	set Basics_ANIMATION_PERIOD = 0.03
	call Player(15)
	call Player(12)
	return true
endfunction

function StructuredDD_addHandler takes code func returns nothing
	local integer index = 0
	local integer tempDat
	set StructuredDD_conditionsIndex = StructuredDD_conditionsIndex + 1
	set StructuredDD_conditions[StructuredDD_conditionsIndex] = Condition(func)
	loop
		exitwhen index > StructuredDD_maxDBIndex
		set tempDat = StructuredDD_bucketDB[index]
		call TriggerAddCondition(Bucket_trig[tempDat], StructuredDD_conditions[StructuredDD_conditionsIndex])
		set index = index + 1
	endloop
endfunction

function ini takes nothing returns nothing
	call StructuredDD_addHandler(ref_function_hand)
endfunction

function init_BeastAttack takes nothing returns boolean
	set BeastAttack_FX = "Objects\\Spawnmodels\\NightElf\\EntBirthTarget\\EntBirthTarget.mdl"
	set BeastAttack_BLOOD_FX = "Objects\\Spawnmodels\\Other\\HumanBloodCinematicEffect\\HumanBloodCinematicEffect.mdl"
	set BeastAttack_THUNDER_FX_BIG = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl"
	set BeastAttack_THUNDER_FX = "Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl"
	set BeastAttack_DOT_EXCLUSIVITY = 1650553963
	set BeastAttack_THUNDER_EXCLUSIVITY = 1651799147
	set BeastAttack_STUDDED_LEATHER_ID = 1227894833
	set BeastAttack_BASE_DAMAGE = 50.
	set BeastAttack_LEATHER_DAMAGE_REDUCTION = 10.
	set BeastAttack_DAMAGE_PER_SECOND = 2.
	set BeastAttack_DOT_DURATION = 5.
	set BeastAttack_THUNDER_DURATION = 5.
	set BeastAttack_THUNDER_BONUS_MULTIPLIER = .2
	call ini()
	return true
endfunction

function init_2 takes nothing returns nothing
	call TimerStart(CreateTimer(), BinocularVision_CLOCK_PERIOD, true, ref_function_act_2)
endfunction

function init_BinocularVision takes nothing returns boolean
	set BinocularVision_CLOCK_PERIOD = 1. / 4.
	set BinocularVision_OFFSET = 500.
	set BinocularVision_RADIUS = 600.
	call init_2()
	return true
endfunction

function init_3 takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, ref_function_act_3)
endfunction

function init_Blink takes nothing returns boolean
	set Blink_BLINK_ID = 1093677105
	call init_3()
	return true
endfunction

function init_CameraControl takes nothing returns boolean
	set CameraControl_FILTER_MASK = "ReplaceableTextures\\CameraMasks\\White_mask.blp"
	set CameraControl_hunterFadeContinueTimer = null
	set CameraControl_hunterFadeFinishTimer = null
	set CameraControl_beastFadeContinueTimer = null
	set CameraControl_beastFadeFinishTimer = null
	return true
endfunction

function ObjectDefinition_setInt takes integer this_key, string modification, integer value returns nothing
endfunction

function ObjectDefinition_setReal takes integer this_key, string modification, real value returns nothing
endfunction

function ObjectDefinition_setString takes integer this_key, string modification, string value returns nothing
endfunction

function ObjectDefinition_setUnreal takes integer this_key, string modification, real value returns nothing
endfunction

function createObjectDefinition takes string fileType, integer newId, integer deriveFrom returns integer
	return 0
endfunction

function create_w3u_h008 takes nothing returns nothing
	local integer u_key
	if MagicFunctions_compiletime then
		set u_key = createObjectDefinition("w3u", 1747988536, 1752659063)
		call ObjectDefinition_setString(u_key, "uabi", "Aloc")
		call ObjectDefinition_setReal(u_key, "usca", 1.3)
		call ObjectDefinition_setString(u_key, "upat", "")
		call ObjectDefinition_setString(u_key, "upap", "")
		call ObjectDefinition_setString(u_key, "uubs", "")
		call ObjectDefinition_setString(u_key, "umdl", "buildings\\human\\TownHall\\TownHall.mdl")
		call ObjectDefinition_setString(u_key, "uani", "upgrade,second")
		call ObjectDefinition_setString(u_key, "unam", "Castle")
		call ObjectDefinition_setString(u_key, "utar", "none")
		call ObjectDefinition_setInt(u_key, "ubdg", 0)
		call ObjectDefinition_setUnreal(u_key, "ucol", 0.0)
		call ObjectDefinition_setInt(u_key, "uhom", 1)
	else
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988536,  - 1672.4, 2578.0, 230.626)
	endif
endfunction

function init_4 takes nothing returns nothing
	call create_w3u_h008()
endfunction

function init_Castle takes nothing returns boolean
	call init_4()
	return true
endfunction

function create_w3u_h00F takes nothing returns nothing
	local integer u_key
	if MagicFunctions_compiletime then
		set u_key = createObjectDefinition("w3u", 1747988550, 1752659063)
		call ObjectDefinition_setString(u_key, "uabi", "Aloc")
		call ObjectDefinition_setReal(u_key, "usca", 0.6)
		call ObjectDefinition_setString(u_key, "upat", "")
		call ObjectDefinition_setString(u_key, "upap", "")
		call ObjectDefinition_setString(u_key, "uubs", "")
		call ObjectDefinition_setString(u_key, "umdl", "buildings\\human\\TownHall\\TownHall.mdl")
		call ObjectDefinition_setString(u_key, "uani", "upgrade,second")
		call ObjectDefinition_setString(u_key, "unam", "Castle Small")
		call ObjectDefinition_setString(u_key, "utar", "none")
		call ObjectDefinition_setInt(u_key, "ubdg", 0)
		call ObjectDefinition_setUnreal(u_key, "ucol", 0.0)
		call ObjectDefinition_setInt(u_key, "uhom", 1)
	else
		call CreateUnit(Player(9), 1747988550, 3263.5, 4431.8, 206.900)
	endif
endfunction

function init_5 takes nothing returns nothing
	call create_w3u_h00F()
endfunction

function init_CastleSmall takes nothing returns boolean
	call init_5()
	return true
endfunction

function alloc_Slop takes nothing returns integer
	local integer this
	if Slop_firstFree == 0 then
		if Slop_maxIndex < 8191 then
			set Slop_maxIndex = Slop_maxIndex + 1
			set this = Slop_maxIndex
			set Slop_typeId[this] = 38
		else
			call error("Out of memory: Could not create Slop.")
			set this = 0
		endif
	else
		set Slop_firstFree = Slop_firstFree - 1
		set this = Slop_nextFree[Slop_firstFree]
		set Slop_typeId[this] = 38
	endif
	return this
endfunction

function construct_Slop takes integer this returns nothing
endfunction

function new_Slop takes nothing returns integer
	local integer this = alloc_Slop()
	call construct_Slop(this)
	return this
endfunction

function SoundControl_preload takes string str returns nothing
	local timer time = CreateTimer()
	local integer s = new_Slop()
	set Slop_snd[s] = str
	call timer_setData(time, s)
	call TimerStart(time, .01, false, ref_function_SoundControl_preloadAfter)
	set time = null
endfunction

function ini_2 takes nothing returns nothing
	call SoundControl_preload(Cinematic_TIP_SOUND)
	call SoundControl_preload(Cinematic_START_SOUND)
endfunction

function init_Cinematic takes nothing returns boolean
	set Cinematic_TIP_SOUND = "Sound\\Interface\\SecretFound.wav"
	set Cinematic_START_SOUND = "Sound\\Interface\\QuestNew.wav"
	set Cinematic_TITLE_ONE = "|cffffcc00Uzapils Kingdom|r"
	set Cinematic_TITLE_TWO = "|cffffcc00Game Objective|r"
	set Cinematic_TITLE_THREE = "|cffffcc00Hunter Properties|r"
	set Cinematic_TITLE_BEAST_ONE = "|cffffcc00The Wilderness|r"
	set Cinematic_TITLE_BEAST_TWO = "|cffffcc00Game Objective|r"
	set Cinematic_TITLE_BEAST_THREE = "|cffffcc00Beast Properties|r"
	set Cinematic_HUMAN_INTRO_TEXT = "Sixty years ago, a rapid " + "human expansion occured: technology insights provided a " + "booming population. Humans developed, spreading out a kingdom, and " + "leaving gaps of wilderness. This sprawling empire made a peaceful relation " + "with the land."
	set Cinematic_FORTRESS_EXPOSITION = "The |cffffcc00Uzapils Fortress|r " + "is guarded by the royal military - two platoons of over six hundred inactive " + "militia, none of which have ever been in a real battle."
	set Cinematic_TOWNS_EXPOSITION = "A number of smaller towns dot " + "the landscape, with various populations and military capacities."
	set Cinematic_CLASS_DIVIDE_EXPOSITION = "A class divide caused strife within the kingdom. A group of rebels " + "stole an artifact, the |cffffcc00Rune of Imperialization|r. The " + "rebel group was terminated, but the rune hasn't been recovered."
	set Cinematic_EXPOSITION_BEAST_SITUATION = "A new species of |cffffcc00beast|r has began " + "attacking the kingdom, and with great success. The origin of " + "these beast uprisings seems to be nearest to |cffffcc00Hunter's Hall|r, a " + "rather unusual military situation."
	set Cinematic_HUNTERS_HALL_EXPOSITION = "The Hunter's Hall is a village " + "with a population of less than fifty. Most of these villagers are farmers and " + "merchants, but historically the town was founded by |cffffcc00Hunters|r - " + "survivalists accustomed to living on the land."
	set Cinematic_HUNTER_COMPARISON = "Hunters aren't as properly " + "equipped as the royal militia, but they can still stand their ground. Survival " + "isn't likely, but with some tactical planning, perhaps the Kingdom can be saved."
	set Cinematic_RUNE_LOCATION_EXPOSITION = "Our scouts inform us that " + "the Beasts are in possession of the |cffffcc00Rune of Imperialization|r. " + "We believe this is their source of power. Thus, reclaiming it will guarantee " + "hunter victory."
	set Cinematic_ROUND_OBJECTIVE_EXPLANATION = "Each battle is split into rounds " + "of four and a half minutes. If you slaughter all beasts, or reclaim the rune of " + "imperialization in time, the round is a hunter victory."
	set Cinematic_HUMAN_PROPERTIES = "You are a |cffffcc00Human|r - " + "humans can't see far away, and can only see allies who are nearby. Your vision is " + "greatly increased in the forward-facing direction."
	set Cinematic_BEAST_TELEPATHY = "Beasts, however, are telepathic, " + "and can sense you from all directions - you can't sneak up on them."
	set Cinematic_HOW_TO_SHOOT = "To shoot, use the " + "|cffffcc00A|rttack ability. Some weapon modes provide a " + "|cffffcc00channeling|r attack."
	set Cinematic_MINIMAP_X = 3805.65
	set Cinematic_MINIMAP_Y = 4150.56
	set Cinematic_MINIMAP_AOA = 275.20
	set Cinematic_MINIMAP_DISTANCE = 1996.5
	set Cinematic_FARM_X = 1384.73
	set Cinematic_FARM_Y = 2189.64
	set Cinematic_FARM_AOA = 320.63
	set Cinematic_FARM_DISTANCE = 1024.52
	set Cinematic_FARM_ROTATION = 58.39
	set Cinematic_FOREST_X = 4165.56
	set Cinematic_FOREST_Y = 87.24
	set Cinematic_FOREST_AOA = 310.20
	set Cinematic_FOREST_DISTANCE = 931.38
	set Cinematic_CASTLE_X = 3250.
	set Cinematic_CASTLE_Y = 4420.
	set Cinematic_NORTH_X = 4050.
	set Cinematic_NORTH_Y = 4660.
	set Cinematic_SOUTH_X = 3180.
	set Cinematic_SOUTH_Y = 3700.
	set Cinematic_MTN_X = 3730.
	set Cinematic_MTN_Y = 3940.
	set Cinematic_HALL_X = 4320.
	set Cinematic_HALL_Y = 4170.
	set Cinematic_RED_X = 4630.
	set Cinematic_RED_Y = 3750.
	set Cinematic_tipSound = CreateSound(Cinematic_TIP_SOUND, false, false, false, 255, 255, "")
	set Cinematic_startSound = CreateSound(Cinematic_START_SOUND, false, false, false, 255, 255, "")
	set Cinematic_humanClock = CreateTimer()
	set Cinematic_beastClock = CreateTimer()
	set Cinematic_enabled = false
	set Cinematic_over = false
	call ini_2()
	return true
endfunction

function int_toString takes integer this returns string
	return I2S(this)
endfunction

function alloc_Table takes nothing returns integer
	local integer this
	if Table_firstFree == 0 then
		if Table_maxIndex < 8191 then
			set Table_maxIndex = Table_maxIndex + 1
			set this = Table_maxIndex
			set Table_typeId[this] = 45
		else
			call error("Out of memory: Could not create Table.")
			set this = 0
		endif
	else
		set Table_firstFree = Table_firstFree - 1
		set this = Table_nextFree[Table_firstFree]
		set Table_typeId[this] = 45
	endif
	return this
endfunction

function construct_Table takes integer this returns nothing
endfunction

function new_Table takes nothing returns integer
	local integer this = alloc_Table()
	call construct_Table(this)
	return this
endfunction

function init_Colors takes nothing returns boolean
	local integer i = 0
	local integer i2
	loop
		exitwhen i > 9
		call int_toString(i)
		set i = i + 1
	endloop
	set Colors_decs = new_Table()
	set i2 = 0
	loop
		exitwhen i2 > 9
		call dispatch_Table_Table_Table_saveInt(Colors_decs, StringHash(int_toString(i2)), i2)
		set i2 = i2 + 1
	endloop
	call dispatch_Table_Table_Table_saveInt(Colors_decs, StringHash("A"), 10)
	call dispatch_Table_Table_Table_saveInt(Colors_decs, StringHash("B"), 11)
	call dispatch_Table_Table_Table_saveInt(Colors_decs, StringHash("C"), 12)
	call dispatch_Table_Table_Table_saveInt(Colors_decs, StringHash("D"), 13)
	call dispatch_Table_Table_Table_saveInt(Colors_decs, StringHash("E"), 14)
	call dispatch_Table_Table_Table_saveInt(Colors_decs, StringHash("F"), 15)
	return true
endfunction

function init_DamageOverTime takes nothing returns boolean
	set DamageOverTime_CLOCK_PERIOD = .5
	set DamageOverTime_FX_FLAG_ATTACH = 0
	set DamageOverTime_FX_FLAG_COORDS = 1
	set DamageOverTime_dbIndex = -1
	set DamageOverTime_time = CreateTimer()
	return true
endfunction

function ini_3 takes nothing returns nothing
	local group grp = CreateGroup()
	local region reg = CreateRegion()
	local trigger addBracer = CreateTrigger()
	local unit iter
	call RegionAddRect(reg, bj_mapInitialPlayableArea)
	call TriggerRegisterEnterRegion(addBracer, reg, null)
	call TriggerAddCondition(addBracer, Condition(ref_function_DamageType_c))
	call StructuredDD_addHandler(ref_function_DamageType_handler)
	call GroupEnumUnitsInRect(grp, bj_mapInitialPlayableArea, null)
	loop
		set iter = FirstOfGroup(grp)
		exitwhen iter == null
		call UnitAddAbility(iter, DamageType_DAMAGE_TYPE_CHECK_ID)
		call UnitMakeAbilityPermanent(iter, true, DamageType_DAMAGE_TYPE_CHECK_ID)
		call GroupRemoveUnit(grp, iter)
	endloop
	call DestroyGroup(grp)
	set grp = null
	set reg = null
	set addBracer = null
	set iter = null
endfunction

function init_DamageType takes nothing returns boolean
	set DamageType_USE_BONUS_CALCULATOR = false
	set DamageType_DAMAGE_TYPE_CHECK_ID = 1093677112
	set DamageType_NULLED = -1
	set DamageType_ATTACK = 0
	set DamageType_SPELL = 1
	set DamageType_CODE = 2
	set DamageType_ATTACK_TYPE_UNIVERSAL = ConvertAttackType(7)
	set DamageType_DELAY_AMOUNT = 0.
	set DamageType_lastDamageType = DamageType_NULLED
	call ini_3()
	return true
endfunction

function ini_4 takes nothing returns nothing
	local integer index = 1
	if DummyUnitStack_DO_PIC then
		loop
			exitwhen index > DummyUnitStack_PRELOAD_INIT_COUNT
			call DummyUnitStack_add(true)
			set index = index + 1
		endloop
	endif
	if DummyUnitStack_DO_IDPC then
		set DummyUnitStack_deferredTodoCount = DummyUnitStack_INITIAL_DEFERRED_PRELOAD_COUNT
		call TimerStart(DummyUnitStack_clock, DummyUnitStack_CLOCK_PERIOD, true, ref_function_DummyUnitStack_deferredPreloader)
	endif
endfunction

function init_DummyUnitStack takes nothing returns boolean
	set DummyUnitStack_DUMMY_UNIT_ID = 1966092336
	set DummyUnitStack_MIN_PRELOAD_BLOCK_SIZE = 10
	set DummyUnitStack_PRELOAD_INIT_COUNT = 200
	set DummyUnitStack_DO_PIC = true
	set DummyUnitStack_DYNAMIC_DEFERRED_PRELOAD_COUNT = 10
	set DummyUnitStack_DO_DDPC = true
	set DummyUnitStack_INITIAL_DEFERRED_PRELOAD_COUNT = 20
	set DummyUnitStack_DO_IDPC = false
	set DummyUnitStack_MAX_PRELOADED_UNITS = 5000
	set DummyUnitStack_DO_MPU = true
	set DummyUnitStack_SAFE_LOC_X =  - 5650.
	set DummyUnitStack_SAFE_LOC_Y = 5565.
	set DummyUnitStack_CLOCK_PERIOD = 1. / 60.
	set DummyUnitStack_stackIndex = -1
	set DummyUnitStack_deferredTodoCount = 0
	set DummyUnitStack_clock = CreateTimer()
	call ini_4()
	return true
endfunction

function init_ErrorHandling takes nothing returns boolean
	set ErrorHandling_MUTE_ERROR_DURATION = 60
	set ErrorHandling_PRIMARY_ERROR_KEY = -1
	return true
endfunction

function init_6 takes nothing returns nothing
	local trigger t = CreateTrigger()
	local integer index = 0
	loop
		exitwhen index >= Players_COUNT
		call TriggerRegisterPlayerEvent(t, Players_fromId[index], EVENT_PLAYER_END_CINEMATIC)
		set index = index + 1
	endloop
	call TriggerAddCondition(t, Condition(ref_function_c))
	set t = null
endfunction

function init_EscapeKey takes nothing returns boolean
	call init_6()
	return true
endfunction

function ini_5 takes nothing returns nothing
	local integer index = 0
	call TimerStart(CreateTimer(), 1., true, ref_function_Game_countSeconds)
	loop
		exitwhen index >= Players_COUNT
		set Game_escapesPressed[index] = false
		set index = index + 1
	endloop
	call SoundControl_preload(Game_WIN_SOUND)
	call SoundControl_preload(Game_DEF_SOUND)
	call SoundControl_preload(Game_BEAST_VICTORY)
	call SoundControl_preload(Game_HUNTER_VICTORY)
endfunction

function init_Game takes nothing returns boolean
	set Game_WIN_SOUND = "Sound\\Interface\\ClanInvitation.wav"
	set Game_DEF_SOUND = "Sound\\Interface\\QuestFailed.wav"
	set Game_BEAST_VICTORY = "beast-victory.mp3"
	set Game_HUNTER_VICTORY = "hunter-victory.mp3"
	set Game_BEAST_PLACE_OFFSET = 300.
	set Game_VICTORY_SOUND_DELAY = 2.
	set Game_TEAM_HUNTERS = 0
	set Game_TEAM_BEASTS = 1
	set Game_POST_ROUND_DELAY = 5.
	set Game_POST_GAME_DELAY = 10.
	set Game_START_DELAY = .5
	set Game_ROUND_DURATION = R2I(60. * 4.5)
	set Game_postRoundTimer = CreateTimer()
	set Game_roundsToWin = 0
	set Game_singlePlayer = false
	set Game_roundEnabled = false
	call ini_5()
	return true
endfunction

function init_GameTimer takes nothing returns boolean
	set GameTimer_gameTimer = CreateTimer()
	call timer_start(GameTimer_gameTimer, 100000., null)
	call timer_startPeriodic(CreateTimer(), Basics_ANIMATION_PERIOD, ref_function_GameTimer_closure_impl)
	return true
endfunction

function i takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH, ref_function_a)
endfunction

function init_HeroDeath takes nothing returns boolean
	set HeroDeath_CONTRACT_ID = 1227894834
	set HeroDeath_GOLD_BONUS = 30
	set HeroDeath_GOLD_BONUS_LESSER = 15
	set HeroDeath_MAJOR_CONTRACT_BONUS = 50
	set HeroDeath_MINOR_CONTRACT_BONUS = 25
	call CreateTimer()
	call i()
	return true
endfunction

function init_7 takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, ref_function_act_4)
endfunction

function init_HunterAttack takes nothing returns boolean
	set HunterAttack_SPREAD_ARC = bj_PI / 48.
	set HunterAttack_JITTER = bj_PI / 24.
	set HunterAttack_SEPARATION_ARC = bj_PI / 8.
	set HunterAttack_SEPARATION_RADIUS = 32.
	set HunterAttack_AUTO_RATE = 1. / 4.
	set HunterAttack_POST_BURST_DELAY = 1. / 4.
	set HunterAttack_BURST_ID = 1093677122
	set HunterAttack_logicalClock = new_Table()
	call init_7()
	return true
endfunction

function HunterCamera_resetKernel takes nothing returns nothing
	local integer index = 0
	local integer j
	loop
		exitwhen index >= Players_COUNT
		set HunterCamera_kernelIndex[index] = 0
		set j = 0
		loop
			exitwhen j >= HunterCamera_KERNEL_SIZE
			set HunterCamera_kernel[index * HunterCamera_KERNEL_SIZE + j] = 270.
			set j = j + 1
		endloop
		set index = index + 1
	endloop
endfunction

function ini_6 takes nothing returns nothing
	call TimerStart(CreateTimer(), HunterCamera_CLOCK_PERIOD, true, ref_function_act_5)
	call HunterCamera_resetKernel()
endfunction

function init_HunterCamera takes nothing returns boolean
	set HunterCamera_CLOCK_PERIOD = 1. / 3.
	set HunterCamera_OFFSET_STATIC = 300.
	set HunterCamera_OFFSET_JITTER = 80.
	set HunterCamera_OFFSET_DYNAMIC = 400.
	set HunterCamera_JITTER_THRESHOLD = bj_PI / 3.
	set HunterCamera_KERNEL_SIZE = 4
	call ini_6()
	return true
endfunction

function init_8 takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, ref_function_act_6)
	call SoundControl_preload(HunterToggle_TOGGLE_SOUND)
endfunction

function init_HunterToggle takes nothing returns boolean
	set HunterToggle_TOGGLE_SOUND = "Abilities\\Spells\\Human\\Defend\\DefendCaster.wav"
	set HunterToggle_TOGGLE_ID = 1093677124
	set HunterToggle_BURST_ID = 1093677122
	set HunterToggle_AUTO_ID = 1093677123
	call init_8()
	return true
endfunction

function create_w3u_h00B takes nothing returns nothing
	local integer u_key
	if MagicFunctions_compiletime then
		set u_key = createObjectDefinition("w3u", 1747988546, 1752659063)
		call ObjectDefinition_setString(u_key, "uabi", "Aloc")
		call ObjectDefinition_setReal(u_key, "usca", 1.45)
		call ObjectDefinition_setString(u_key, "upat", "")
		call ObjectDefinition_setString(u_key, "upap", "")
		call ObjectDefinition_setString(u_key, "uubs", "")
		call ObjectDefinition_setString(u_key, "umdl", "buildings\\nightelf\\HuntersHall\\HuntersHall.mdl")
		call ObjectDefinition_setString(u_key, "uani", "upgrade,second")
		call ObjectDefinition_setString(u_key, "unam", "Hunter's Hall")
		call ObjectDefinition_setString(u_key, "utar", "none")
		call ObjectDefinition_setInt(u_key, "ubdg", 0)
		call ObjectDefinition_setUnreal(u_key, "ucol", 0.0)
		call ObjectDefinition_setInt(u_key, "uhom", 1)
	else
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988546,  - 1449.8, 3809.9, 257.457)
	endif
endfunction

function init_9 takes nothing returns nothing
	call create_w3u_h00B()
endfunction

function init_HuntersHall takes nothing returns boolean
	call init_9()
	return true
endfunction

function removeWalkability takes nothing returns nothing
	local real i_2 = Initialization_tempX - Initialization_OBELISK_PATH_RADIUS
	local real j
	loop
		exitwhen i_2 > Initialization_tempX + Initialization_OBELISK_PATH_RADIUS
		set j = Initialization_tempY - Initialization_OBELISK_PATH_RADIUS
		loop
			exitwhen j > Initialization_tempY + Initialization_OBELISK_PATH_RADIUS
			if TerrainData_distanceBetweenXY(Initialization_tempX, i_2, Initialization_tempY, j) <= Initialization_OBELISK_PATH_RADIUS then
				call SetTerrainPathable(i_2, j, PATHING_TYPE_WALKABILITY, false)
			endif
			set j = j + Initialization_PATH_ITERATE_SIZE
		endloop
		set i_2 = i_2 + Initialization_PATH_ITERATE_SIZE
	endloop
endfunction

function ini_7 takes nothing returns nothing
	local integer i_2
	local integer j
	local unit iter
	local unit dum
	local real ang
	set Initialization_diaClick = CreateTrigger()
	set Initialization_dialo = DialogCreate()
	call TriggerAddAction(Initialization_diaClick, ref_function_diaA)
	call SetTimeOfDayScale(0.)
	call TimerStart(CreateTimer(), Game_START_DELAY, false, ref_function_afterDelay)
	call GroupEnumUnitsOfPlayer(Initialization_grp, Players_fromId[Players_MARKERS], null)
	loop
		set iter = FirstOfGroup(Initialization_grp)
		exitwhen iter == null
		call RemoveUnit(iter)
		call GroupRemoveUnit(Initialization_grp, iter)
	endloop
	if Players_playingCount - Players_aiCount == 1 then
		set Game_singlePlayer = true
	endif
	if Players_playingCount == 1 and Initialization_SINGLEPLAYER_ADD_AI then
		if Players_playing[0] or Players_playing[1] or Players_playing[2] then
			call AI_addPlayer(Players_fromId[Players_FIRST_BEAST])
			set Players_playing[Players_FIRST_BEAST] = true
		else
			call AI_addPlayer(Players_fromId[Players_FIRST_HUNTER])
			set Players_playing[Players_FIRST_HUNTER] = true
		endif
	endif
	set i_2 = 0
	loop
		exitwhen i_2 >= Initialization_PILLAR_GROUP_COUNT
		set j = 0
		loop
			exitwhen j >= Initialization_PILLARS_PER_GROUP
			set ang = Initialization_PHASE + 2. * bj_PI * i_2 / Initialization_PILLAR_GROUP_COUNT - Initialization_GROUP_SEPARATION_ANGLE + j * Initialization_GROUP_SEPARATION_ANGLE
			set Initialization_tempX = TerrainData_RUNE_1_X + Initialization_RADIUS * Cos(ang)
			set Initialization_tempY = TerrainData_RUNE_1_Y + Initialization_RADIUS * Sin(ang)
			call CreateUnit(Players_fromId[Players_PASSIVE], Initialization_OBELISK_ID, Initialization_tempX, Initialization_tempY, (ang + Initialization_OBELISK_FACING_PHASE) * bj_RADTODEG)
			if j == R2I(Initialization_PILLARS_PER_GROUP * 1. / 2) then
				set dum = DummyUnitStack_get()
				call SetUnitX(dum, Initialization_tempX)
				call SetUnitY(dum, Initialization_tempY)
				call SetUnitFlyHeight(dum, Initialization_ORB_HEIGHT, 0.)
				call AddSpecialEffectTarget(Initialization_ORB_FX, dum, "overhead")
			endif
			call ExecuteFunc("removeWalkability")
			set j = j + 1
		endloop
		set i_2 = i_2 + 1
	endloop
	set i_2 = 0
	loop
		exitwhen i_2 >= Initialization_PILLAR_GROUP_COUNT
		set j = 0
		loop
			exitwhen j >= Initialization_PILLARS_PER_GROUP
			set ang = Initialization_PHASE + 2. * bj_PI * i_2 / Initialization_PILLAR_GROUP_COUNT - Initialization_GROUP_SEPARATION_ANGLE + j * Initialization_GROUP_SEPARATION_ANGLE
			set Initialization_tempX = TerrainData_RUNE_2_X + Initialization_RADIUS2 * Cos(ang)
			set Initialization_tempY = TerrainData_RUNE_2_Y + Initialization_RADIUS2 * Sin(ang)
			call CreateUnit(Players_fromId[Players_PASSIVE], Initialization_OBELISK_ID, Initialization_tempX, Initialization_tempY, (ang + Initialization_OBELISK_FACING_PHASE) * bj_RADTODEG)
			if j == R2I(Initialization_PILLARS_PER_GROUP * 1. / 2) then
				set dum = DummyUnitStack_get()
				call SetUnitX(dum, Initialization_tempX)
				call SetUnitY(dum, Initialization_tempY)
				call SetUnitFlyHeight(dum, Initialization_ORB_HEIGHT, 0.)
				call AddSpecialEffectTarget(Initialization_ORB_FX, dum, "overhead")
			endif
			call ExecuteFunc("removeWalkability")
			set j = j + 1
		endloop
		set i_2 = i_2 + 1
	endloop
	set i_2 = 0
	loop
		exitwhen i_2 >= Initialization_PILLAR_GROUP_COUNT_BEAST_SPAWN
		set j = 0
		loop
			exitwhen j >= Initialization_PILLARS_PER_GROUP
			set ang = Initialization_PHASE + 2. * bj_PI * i_2 / Initialization_PILLAR_GROUP_COUNT_BEAST_SPAWN - Initialization_GROUP_SEPARATION_ANGLE + j * Initialization_GROUP_SEPARATION_ANGLE
			set Initialization_tempX = TerrainData_BEAST_SPAWN_X + Initialization_RADIUS * Cos(ang)
			set Initialization_tempY = TerrainData_BEAST_SPAWN_Y + Initialization_RADIUS * Sin(ang)
			call CreateUnit(Players_fromId[Players_PASSIVE], Initialization_OBELISK_ID, Initialization_tempX, Initialization_tempY, (ang + Initialization_OBELISK_FACING_PHASE) * bj_RADTODEG)
			if j == R2I(Initialization_PILLARS_PER_GROUP * 1. / 2) then
				set dum = DummyUnitStack_get()
				call SetUnitX(dum, Initialization_tempX)
				call SetUnitY(dum, Initialization_tempY)
				call SetUnitFlyHeight(dum, Initialization_ORB_HEIGHT, 0.)
				call AddSpecialEffectTarget(Initialization_ORB_FX, dum, "overhead")
			endif
			call ExecuteFunc("removeWalkability")
			set j = j + 1
		endloop
		set i_2 = i_2 + 1
	endloop
	set Units_artifact = CreateItem(Units_ARTIFACT_ID, TerrainData_RUNE_1_X, TerrainData_RUNE_1_Y)
	set Units_artifact2 = CreateItem(Units_ARTIFACT_ID, TerrainData_RUNE_2_X, TerrainData_RUNE_2_Y)
	set i_2 = 0
	loop
		exitwhen i_2 >= Players_COUNT
		if Players_aiControlled[i_2] then
			call AI_addPlayer(Players_fromId[i_2])
		endif
		set i_2 = i_2 + 1
	endloop
	set i_2 = 0
	loop
		exitwhen i_2 >= Players_FIRST_BEAST
		call SetPlayerState(Players_fromId[i_2], PLAYER_STATE_RESOURCE_GOLD, Initialization_HUNTER_STARTING_GOLD)
		set i_2 = i_2 + 1
	endloop
	set iter = null
	set dum = null
endfunction

function init_Initialization takes nothing returns boolean
	set Initialization_ORB_FX = "Abilities\\Weapons\\ChimaeraAcidMissile\\ChimaeraAcidMissile.mdl"
	set Initialization_SINGLEPLAYER_ADD_AI = true
	set Initialization_PILLAR_GROUP_COUNT = 7
	set Initialization_PILLAR_GROUP_COUNT_BEAST_SPAWN = 5
	set Initialization_PILLARS_PER_GROUP = 3
	set Initialization_OBELISK_ID = 1747988535
	set Initialization_HUNTER_STARTING_GOLD = 1000
	set Initialization_PHASE =  - (1. * bj_PI / 2.)
	set Initialization_OBELISK_FACING_PHASE = bj_PI / 4.
	set Initialization_GROUP_SEPARATION_ANGLE = bj_PI / 24.
	set Initialization_RADIUS = 550.
	set Initialization_RADIUS2 = 450.
	set Initialization_OBELISK_PATH_RADIUS = 32.
	set Initialization_PATH_ITERATE_SIZE = 8.
	set Initialization_ORB_HEIGHT = 100.
	set Initialization_grp = CreateGroup()
	set Initialization_voteTimer = CreateTimer()
	set Initialization_votesCounted = 0
	call ini_7()
	return true
endfunction

function init_10 takes nothing returns nothing
	call TimerStart(CreateTimer(), 1., true, ref_function_checkCombatDuration)
endfunction

function init_ItemFieldConditioningKit takes nothing returns boolean
	set ItemFieldConditioningKit_DUST_ID = 1227894836
	set ItemFieldConditioningKit_COMBAT_TIME = 5
	call CreateTimer()
	set ItemFieldConditioningKit_damageTimings = new_Table()
	call init_10()
	return true
endfunction

function create_w3u_h00G takes nothing returns nothing
	local integer u_key
	if MagicFunctions_compiletime then
		set u_key = createObjectDefinition("w3u", 1747988551, 1752659063)
		call ObjectDefinition_setString(u_key, "uabi", "Aloc")
		call ObjectDefinition_setReal(u_key, "usca", 0.5)
		call ObjectDefinition_setString(u_key, "upat", "")
		call ObjectDefinition_setString(u_key, "upap", "")
		call ObjectDefinition_setString(u_key, "uubs", "")
		call ObjectDefinition_setString(u_key, "umdl", "buildings\\human\\TownHall\\TownHall.mdl")
		call ObjectDefinition_setString(u_key, "uani", "upgrade,first")
		call ObjectDefinition_setString(u_key, "unam", "Keep Small")
		call ObjectDefinition_setString(u_key, "utar", "none")
		call ObjectDefinition_setInt(u_key, "ubdg", 0)
		call ObjectDefinition_setUnreal(u_key, "ucol", 0.0)
		call ObjectDefinition_setInt(u_key, "uhom", 1)
	else
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988551, 4054.6, 4663.3, 329.050)
		call CreateUnit(Player(8), 1747988551, 3745.4, 3938.7, 232.990)
	endif
endfunction

function init_11 takes nothing returns nothing
	call create_w3u_h00G()
endfunction

function init_KeepSmall takes nothing returns boolean
	call init_11()
	return true
endfunction

function init_12 takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, ref_function_act_7)
endfunction

function init_Knife takes nothing returns boolean
	set Knife_KNIFE_ID = 1093677106
	set Knife_FX = "Abilities\\Weapons\\ShadowHunterMissile\\ShadowHunterMissile.mdl"
	set Knife_FX_PROC = "Abilities\\Weapons\\HydraliskImpact\\HydraliskImpact.mdl"
	set Knife_FX_EXPLODED = "Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl"
	set Knife_FX_PROC_ATTACH_POINT = "chest"
	set Knife_OFFSET = 70.
	set Knife_EFFECT_HEIGHT = 50.
	set Knife_FX_DURATION = 1.6
	set Knife_RADIUS = 75.
	set Knife_EXECUTE_MAX_HEALTH = 60.
	set Knife_BASE_DAMAGE = 35.
	set Knife_SHORT_COOLDOWN = 5.
	set Knife_grp = CreateGroup()
	call init_12()
	return true
endfunction

function init_MagicFunctions takes nothing returns boolean
	set MagicFunctions_compiletime = false
	return true
endfunction

function create_w3u_h00A takes nothing returns nothing
	local integer u_key
	if MagicFunctions_compiletime then
		set u_key = createObjectDefinition("w3u", 1747988545, 1752659063)
		call ObjectDefinition_setReal(u_key, "usca", 0.9)
		call ObjectDefinition_setString(u_key, "upat", "")
		call ObjectDefinition_setString(u_key, "upap", "")
		call ObjectDefinition_setString(u_key, "uubs", "")
		call ObjectDefinition_setString(u_key, "umdl", "buildings\\other\\Marketplace\\Marketplace.mdl")
		call ObjectDefinition_setString(u_key, "unam", "Market")
		call ObjectDefinition_setUnreal(u_key, "ucol", 0.0)
		call ObjectDefinition_setString(u_key, "uabi", "Ane2,Avul")
		call ObjectDefinition_setInt(u_key, "uhpm", 1000000000)
		call ObjectDefinition_setString(u_key, "urac", "other")
		call ObjectDefinition_setString(u_key, "utyp", "mechanical,neutral")
		call ObjectDefinition_setInt(u_key, "unbm", 1)
		call ObjectDefinition_setString(u_key, "usei", "I001,I004,I003,I002")
		call ObjectDefinition_setString(u_key, "usnd", "Marketplace")
	else
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988545,  - 2610.4, 2967.1, 205.869)
	endif
endfunction

function init_13 takes nothing returns nothing
	call create_w3u_h00A()
endfunction

function init_Marketplace takes nothing returns boolean
	call init_13()
	return true
endfunction

function init_Math takes nothing returns boolean
	set Math_DELTA = .0001
	return true
endfunction

function init_Maths takes nothing returns boolean
	set Maths_PI = 3.141592654
	return true
endfunction

function init_14 takes nothing returns nothing
	call TimerStart(CreateTimer(), MinimapVisionHints_CLOCK_PERIOD, true, ref_function_update)
endfunction

function init_MinimapVisionHints takes nothing returns boolean
	set MinimapVisionHints_CLOCK_PERIOD = 1. / 4.
	set MinimapVisionHints_RADIUS = 350.
	set MinimapVisionHints_CHECK_RADIUS = 2500.
	call init_14()
	return true
endfunction

function init_15 takes nothing returns nothing
	call TimerStart(CreateTimer(), 0., false, ref_function_act_8)
endfunction

function init_MultiboardControl takes nothing returns boolean
	set MultiboardControl_time = CreateTimer()
	call init_15()
	return true
endfunction

function init_Muscii takes nothing returns boolean
	set Muscii_dbIndex = -1
	return true
endfunction

function alloc_Note takes nothing returns integer
	local integer this
	if Note_firstFree == 0 then
		if Note_maxIndex < 8191 then
			set Note_maxIndex = Note_maxIndex + 1
			set this = Note_maxIndex
			set Note_typeId[this] = 25
		else
			call error("Out of memory: Could not create Note.")
			set this = 0
		endif
	else
		set Note_firstFree = Note_firstFree - 1
		set this = Note_nextFree[Note_firstFree]
		set Note_typeId[this] = 25
	endif
	return this
endfunction

function construct_Note takes integer this returns nothing
endfunction

function new_Note takes nothing returns integer
	local integer this = alloc_Note()
	call construct_Note(this)
	return this
endfunction

function Note_create takes string path, integer volume, real pitch returns integer
	local integer t = new_Note()
	set Note_path[t] = path
	set Note_volume[t] = volume
	set Note_pitch[t] = pitch
	set Note_next[t] = 0
	return t
endfunction

function alloc_Chord takes nothing returns integer
	local integer this
	if Chord_firstFree == 0 then
		if Chord_maxIndex < 8191 then
			set Chord_maxIndex = Chord_maxIndex + 1
			set this = Chord_maxIndex
			set Chord_typeId[this] = 20
		else
			call error("Out of memory: Could not create Chord.")
			set this = 0
		endif
	else
		set Chord_firstFree = Chord_firstFree - 1
		set this = Chord_nextFree[Chord_firstFree]
		set Chord_typeId[this] = 20
	endif
	return this
endfunction

function construct_Chord takes integer this returns nothing
endfunction

function new_Chord takes nothing returns integer
	local integer this = alloc_Chord()
	call construct_Chord(this)
	return this
endfunction

function Chord_create takes integer n returns integer
	local integer q = Note_create(Note_path[n], Note_volume[n], Note_pitch[n])
	local integer c_2 = new_Chord()
	set Chord_next[c_2] = 0
	set Chord_first[c_2] = q
	set Chord_last[c_2] = q
	return c_2
endfunction

function Note_copy takes integer this returns integer
	return Note_create(Note_path[this], Note_volume[this], Note_pitch[this])
endfunction

function dispatch_Note_Muscii_Note_copy takes integer this returns integer
	local integer Muscii_Note_copy_result
	if Note_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Note.Muscii_Note_copy")
		else
			call error("Called Note.Muscii_Note_copy on invalid object.")
		endif
	endif
	set Muscii_Note_copy_result = Note_copy(this)
	return Muscii_Note_copy_result
endfunction

function Chord_addNote takes integer this, integer n returns integer
	local integer copy = dispatch_Note_Muscii_Note_copy(n)
	local integer temp = Chord_last[this]
	set Note_next[temp] = copy
	return this
endfunction

function dispatch_Chord_Muscii_Chord_addNote takes integer this, integer n returns integer
	local integer Muscii_Chord_addNote_result
	if Chord_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Chord.Muscii_Chord_addNote")
		else
			call error("Called Chord.Muscii_Chord_addNote on invalid object.")
		endif
	endif
	set Muscii_Chord_addNote_result = Chord_addNote(this, n)
	return Muscii_Chord_addNote_result
endfunction

function Chord_copy takes integer this returns integer
	local integer iterator = Chord_first[this]
	local integer new = Chord_create(iterator)
	loop
		set iterator = Note_next[iterator]
		exitwhen iterator == 0
		call dispatch_Chord_Muscii_Chord_addNote(new, iterator)
	endloop
	return new
endfunction

function dispatch_Chord_Muscii_Chord_copy takes integer this returns integer
	local integer Muscii_Chord_copy_result
	if Chord_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Chord.Muscii_Chord_copy")
		else
			call error("Called Chord.Muscii_Chord_copy on invalid object.")
		endif
	endif
	set Muscii_Chord_copy_result = Chord_copy(this)
	return Muscii_Chord_copy_result
endfunction

function alloc_Muscii takes nothing returns integer
	local integer this
	if Muscii_firstFree == 0 then
		if Muscii_maxIndex < 8191 then
			set Muscii_maxIndex = Muscii_maxIndex + 1
			set this = Muscii_maxIndex
			set Muscii_typeId[this] = 21
		else
			call error("Out of memory: Could not create Muscii.")
			set this = 0
		endif
	else
		set Muscii_firstFree = Muscii_firstFree - 1
		set this = Muscii_nextFree[Muscii_firstFree]
		set Muscii_typeId[this] = 21
	endif
	return this
endfunction

function construct_Muscii takes integer this returns nothing
endfunction

function new_Muscii takes nothing returns integer
	local integer this = alloc_Muscii()
	call construct_Muscii(this)
	return this
endfunction

function Muscii_create takes integer c_2, real tempo returns integer
	local integer m = new_Muscii()
	local integer cop = dispatch_Chord_Muscii_Chord_copy(c_2)
	set Muscii_first[m] = cop
	set Muscii_last[m] = cop
	set Muscii_iterator[m] = cop
	set Muscii_tempo[m] = tempo
	set Muscii_clock[m] = CreateTimer()
	set Muscii_queued[m] = 0
	set Muscii_cbf[m] = 0
	call timer_setData(Muscii_clock[m], m)
	set Muscii_dbIndex = Muscii_dbIndex + 1
	return m
endfunction

function Muscii_addChord takes integer this, integer c_2 returns integer
	local integer q = Muscii_last[this]
	local integer copy = dispatch_Chord_Muscii_Chord_copy(c_2)
	set Chord_next[q] = copy
	set Muscii_last[this] = copy
	return this
endfunction

function dispatch_Muscii_Muscii_Muscii_addChord takes integer this, integer c_2 returns integer
	local integer Muscii_Muscii_addChord_result
	if Muscii_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Muscii.Muscii_Muscii_addChord")
		else
			call error("Called Muscii.Muscii_Muscii_addChord on invalid object.")
		endif
	endif
	set Muscii_Muscii_addChord_result = Muscii_addChord(this, c_2)
	return Muscii_Muscii_addChord_result
endfunction

function initializeGameMusic takes nothing returns nothing
	local integer hat = Note_create(Music_HI_HAT_HIT_CLOSED, 90, 1.)
	local integer nul = Note_create(Music_HI_HAT_HIT_CLOSED, 0, 1.)
	local integer tm1 = Note_create(Music_TOM_1_HIT, 110, 1.)
	local integer tm4 = Note_create(Music_TOM_4_HIT, 110, 1.)
	local integer t1 = Chord_create(tm1)
	local integer t4 = Chord_create(tm4)
	local integer z = Chord_create(nul)
	local integer h = Chord_create(hat)
	set Music_m = Muscii_create(t1, 240.)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, h)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, h)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, h)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, h)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, h)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_m, z)
endfunction

function initializeVoteMusic takes nothing returns nothing
	local integer tm4 = Note_create(Music_TOM_4_HIT, 80, 1.)
	local integer tm1 = Note_create(Music_TOM_1_HIT, 80, 1.)
	local integer nul = Note_create(Music_HI_HAT_HIT_CLOSED, 0, 1.)
	local integer t4 = Chord_create(tm4)
	local integer t1 = Chord_create(tm1)
	local integer z = Chord_create(nul)
	set Music_v = Muscii_create(t4, 120.)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, t4)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, t1)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
	call dispatch_Muscii_Muscii_Muscii_addChord(Music_v, z)
endfunction

function i_2 takes nothing returns nothing
	call initializeVoteMusic()
	call initializeGameMusic()
	call playVoteMusic()
	call SoundControl_preload(Music_HI_HAT_HIT_CLOSED)
	call SoundControl_preload(Music_TOM_1_HIT)
	call SoundControl_preload(Music_TOM_4_HIT)
endfunction

function init_Music takes nothing returns boolean
	set Music_HI_HAT_HIT_CLOSED = "musRad-khatClosed.mp3"
	set Music_TOM_1_HIT = "musRad-tom1.mp3"
	set Music_TOM_4_HIT = "musRad-tom4.mp3"
	call i_2()
	return true
endfunction

function init_16 takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, ref_function_act_9)
endfunction

function init_Net takes nothing returns boolean
	set Net_NET_FX = "Abilities\\Spells\\Orc\\Ensnare\\ensnareTarget.mdl"
	set Net_NET_MODEL = "Abilities\\Spells\\Orc\\Ensnare\\EnsnareMissile.mdl"
	set Net_NET_ID = 1093677110
	set Net_NET_SLOW_ID = 1093677109
	set Net_EXCLUSIVITY_NET = 1752065396
	set Net_RADIUS = 200.
	set Net_CLOCK_PERIOD = 1. / 30.
	set Net_NET_VELOCITY = 600.
	set Net_COLLISION_RADIUS = 80.
	set Net_MAX_DISTANCE = 500.
	set Net_grp = CreateGroup()
	set Net_clock = CreateTimer()
	set Net_dbIndex = -1
	call init_16()
	return true
endfunction

function trigger_addCondition takes trigger this, boolexpr condition returns nothing
	call TriggerAddCondition(this, condition)
endfunction

function trigger_registerAnyUnitEvent takes trigger this, playerunitevent whichEvent returns nothing
	call TriggerRegisterAnyUnitEventBJ(this, whichEvent)
endfunction

function init_17 takes nothing returns nothing
	local trigger trig = CreateTrigger()
	local trigger receiver = trig
	local trigger receiver_2
	call trigger_registerAnyUnitEvent(receiver, EVENT_PLAYER_UNIT_PICKUP_ITEM)
	set receiver_2 = receiver
	call trigger_addCondition(receiver_2, Condition(ref_function_act_10))
	set trig = null
	set receiver = null
	set receiver_2 = null
endfunction

function init_NoItemDuplicates takes nothing returns boolean
	call init_17()
	return true
endfunction

function alloc_IdGenerator takes nothing returns integer
	local integer this
	if IdGenerator_firstFree == 0 then
		if IdGenerator_maxIndex < 8191 then
			set IdGenerator_maxIndex = IdGenerator_maxIndex + 1
			set this = IdGenerator_maxIndex
		else
			call error("Out of memory: Could not create IdGenerator.")
			set this = 0
		endif
	else
		set IdGenerator_firstFree = IdGenerator_firstFree - 1
		set this = IdGenerator_nextFree[IdGenerator_firstFree]
	endif
	return this
endfunction

function construct_IdGenerator takes integer this, integer start returns nothing
endfunction

function new_IdGenerator takes integer start returns integer
	local integer this = alloc_IdGenerator()
	call construct_IdGenerator(this, start)
	return this
endfunction

function init_ObjectIdGenerator takes nothing returns boolean
	call new_IdGenerator(1932537904)
	call new_IdGenerator(1261449264)
	call new_IdGenerator(1098395696)
	call new_IdGenerator(1177563184)
	call new_IdGenerator(1328558128)
	return true
endfunction

function init_ObjectIds takes nothing returns boolean
	return true
endfunction

function init_18 takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, ref_function_act_11)
endfunction

function init_OrganicConcatenation takes nothing returns boolean
	set OrganicConcatenation_IMAGE_SOUND = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImage.wav"
	set OrganicConcatenation_CONCATENATION_ID = 1093677131
	set OrganicConcatenation_BEAST_ILLUSION_ID = 1747988549
	set OrganicConcatenation_DURATION = .5
	set OrganicConcatenation_RANGE = 300.
	set OrganicConcatenation_PHASE_OFFSET = 16.
	set OrganicConcatenation_CLOCK_PERIOD = 1. / 30.
	set OrganicConcatenation_ddIndex = -1
	set OrganicConcatenation_clock = CreateTimer()
	call init_18()
	return true
endfunction

function init_19 takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, ref_function_act_12)
	call SoundControl_preload(OrganicHemisection_IMAGE_SOUND)
endfunction

function init_OrganicHemisection takes nothing returns boolean
	set OrganicHemisection_IMAGE_SOUND = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImage.wav"
	set OrganicHemisection_HEMISECTION_ID = 1093677127
	set OrganicHemisection_BEAST_ILLUSION_ID = 1747988549
	set OrganicHemisection_DURATION = .5
	set OrganicHemisection_OFFSET = 64.
	set OrganicHemisection_PHASE_OFF = 16.
	set OrganicHemisection_CLOCK_PERIOD = 1. / 30.
	set OrganicHemisection_PHASE_MULTIPLIER = 16. * bj_PI
	set OrganicHemisection_ddIndex = -1
	set OrganicHemisection_clock = CreateTimer()
	call init_19()
	return true
endfunction

function create_w3u_h003 takes nothing returns nothing
	local integer u_key
	if MagicFunctions_compiletime then
		set u_key = createObjectDefinition("w3u", 1747988531, 1752659063)
		call ObjectDefinition_setString(u_key, "uabi", "Aloc,Avul,A000")
		call ObjectDefinition_setString(u_key, "upat", "")
		call ObjectDefinition_setString(u_key, "upap", "")
		call ObjectDefinition_setString(u_key, "uubs", "")
		call ObjectDefinition_setString(u_key, "umdl", "buildings\\other\\BookOfSummoning\\BookOfSummoning.mdl")
		call ObjectDefinition_setString(u_key, "uani", "upgrade,second")
		call ObjectDefinition_setString(u_key, "unam", "Pedestal")
		call ObjectDefinition_setString(u_key, "utar", "ground")
		call ObjectDefinition_setInt(u_key, "ubdg", 0)
		call ObjectDefinition_setUnreal(u_key, "ucol", 0.0)
		call ObjectDefinition_setInt(u_key, "uhom", 1)
		call ObjectDefinition_setString(u_key, "utyp", "")
		call ObjectDefinition_setReal(u_key, "ussc", 1.35)
		call ObjectDefinition_setInt(u_key, "uhpm", 1000000000)
		call ObjectDefinition_setInt(u_key, "uuch", 1)
		call ObjectDefinition_setString(u_key, "udty", "fort")
	else
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988531,  - 1472.1, 3637.6, 221.417)
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988531,  - 1627.9, 3787.0, 312.910)
	endif
endfunction

function init_20 takes nothing returns nothing
	call create_w3u_h003()
endfunction

function init_Pedestal takes nothing returns boolean
	call init_20()
	return true
endfunction

function init_21 takes nothing returns nothing
	local trigger trig = CreateTrigger()
	local rect rct = Rect(TerrainData_HALL_MIN_X, TerrainData_HALL_MIN_Y, TerrainData_HALL_MAX_X, TerrainData_HALL_MAX_Y)
	local region reg = CreateRegion()
	call RegionAddRect(reg, rct)
	set PedestalReceive_rctEpsilon = Rect(TerrainData_HALL_MIN_X - PedestalReceive_ENUM_EPSILON, TerrainData_HALL_MIN_Y - PedestalReceive_ENUM_EPSILON, TerrainData_HALL_MAX_X + PedestalReceive_ENUM_EPSILON, TerrainData_HALL_MAX_Y + PedestalReceive_ENUM_EPSILON)
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_PICKUP_ITEM, ref_function_act_13)
	call TriggerRegisterEnterRegion(trig, reg, null)
	call TriggerAddAction(trig, ref_function_act_13)
	call SoundControl_preload(PedestalReceive_RUNE_SECURED)
	call RemoveRect(rct)
	set trig = null
	set rct = null
	set reg = null
endfunction

function init_PedestalReceive takes nothing returns boolean
	local real temp_PedestalReceive_TARGET_PILLAR_LEFT_x
	local real temp_PedestalReceive_TARGET_PILLAR_LEFT_y
	local real temp_PedestalReceive_TARGET_PILLAR_LEFT_z
	local real temp_PedestalReceive_TARGET_PILLAR_RIGHT_x
	local real temp_PedestalReceive_TARGET_PILLAR_RIGHT_y
	local real temp_PedestalReceive_TARGET_PILLAR_RIGHT_z
	set PedestalReceive_DUMMY_MODEL = "Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl"
	set PedestalReceive_EFFECT_MODEL = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl"
	set PedestalReceive_RUNE_SECURED = "rune-secured.mp3"
	set PedestalReceive_SPAWN_COUNT = 20
	set PedestalReceive_ENUM_EPSILON = 32.
	set temp_PedestalReceive_TARGET_PILLAR_LEFT_x =  - 1630.
	set temp_PedestalReceive_TARGET_PILLAR_LEFT_y = 3798.
	set temp_PedestalReceive_TARGET_PILLAR_LEFT_z = 100.
	set PedestalReceive_TARGET_PILLAR_LEFT_x = temp_PedestalReceive_TARGET_PILLAR_LEFT_x
	set PedestalReceive_TARGET_PILLAR_LEFT_y = temp_PedestalReceive_TARGET_PILLAR_LEFT_y
	set PedestalReceive_TARGET_PILLAR_LEFT_z = temp_PedestalReceive_TARGET_PILLAR_LEFT_z
	set temp_PedestalReceive_TARGET_PILLAR_RIGHT_x =  - 1470.
	set temp_PedestalReceive_TARGET_PILLAR_RIGHT_y = 3644.
	set temp_PedestalReceive_TARGET_PILLAR_RIGHT_z = 100.
	set PedestalReceive_TARGET_PILLAR_RIGHT_x = temp_PedestalReceive_TARGET_PILLAR_RIGHT_x
	set PedestalReceive_TARGET_PILLAR_RIGHT_y = temp_PedestalReceive_TARGET_PILLAR_RIGHT_y
	set PedestalReceive_TARGET_PILLAR_RIGHT_z = temp_PedestalReceive_TARGET_PILLAR_RIGHT_z
	set PedestalReceive_ITEM_DROP_OFFS = 100.
	set PedestalReceive_ITEM_SPAWN_HEIGHT = 40.
	set PedestalReceive_SPAWN_PERIOD = 1. / 10.
	set PedestalReceive_INITIAL_PITCH = 13. * Maths_PI / 32.
	set PedestalReceive_INITIAL_VELOCITY = 500.
	set PedestalReceive_ACCELERATION = 80.
	set PedestalReceive_CLOCK_PERIOD = 1. / 30.
	set PedestalReceive_AIR_FRICTION = PedestalReceive_CLOCK_PERIOD * 7. / 5.
	set PedestalReceive_time = CreateTimer()
	set PedestalReceive_time2 = CreateTimer()
	set PedestalReceive_grp = CreateGroup()
	set PedestalReceive_fakeRune = CreateItem(1227894832, TerrainData_SAFE_X, TerrainData_SAFE_Y)
	set PedestalReceive_effectIndex = -1
	call init_21()
	return true
endfunction

function init_Player takes nothing returns boolean
	local integer i_3 = 0
	local integer temp = bj_MAX_PLAYER_SLOTS - 1
	loop
		exitwhen i_3 > temp
		call Player(i_3)
		set i_3 = i_3 + 1
	endloop
	return true
endfunction

function init_22 takes nothing returns nothing
	local integer index = 0
	local trigger t = CreateTrigger()
	loop
		exitwhen index >= Players_COUNT
		call TriggerRegisterPlayerEvent(t, Players_fromId[index], EVENT_PLAYER_LEAVE)
		set index = index + 1
	endloop
	call TriggerAddCondition(t, Condition(ref_function_cond))
	set t = null
endfunction

function init_PlayerLeaves takes nothing returns boolean
	call init_22()
	return true
endfunction

function ini_8 takes nothing returns nothing
	local integer index = 0
	set Players_locl = GetLocalPlayer()
	set Players_fromId[Players_MARKERS] = Player(Players_MARKERS)
	set Players_fromId[Players_PASSIVE] = Player(Players_PASSIVE)
	loop
		exitwhen index > Players_COUNT - 1
		set Players_fromId[index] = Player(index)
		set Players_playing[index] = GetPlayerSlotState(Players_fromId[index]) == PLAYER_SLOT_STATE_PLAYING or GetPlayerController(Players_fromId[index]) == MAP_CONTROL_COMPUTER
		set Players_aiControlled[index] = GetPlayerController(Players_fromId[index]) == MAP_CONTROL_COMPUTER and GetPlayerController(Players_fromId[index]) != MAP_CONTROL_USER
		if Players_playing[index] then
			set Players_playingCount = Players_playingCount + 1
		endif
		if Players_playing[index] and ( not Players_aiControlled[index]) then
			set Players_humanCount = Players_humanCount + 1
		endif
		if Players_aiControlled[index] then
			set Players_aiCount = Players_aiCount + 1
		endif
		set index = index + 1
	endloop
endfunction

function init_Players takes nothing returns boolean
	set Players_COUNT = 12
	set Players_FIRST_HUNTER = 0
	set Players_LAST_BEAST = 11
	set Players_MARKERS = 11
	set Players_PASSIVE = 15
	set Players_FIRST_BEAST = 6
	set Players_aliveCount = 0
	set Players_aiCount = 0
	set Players_humanCount = 0
	set Players_playingCount = 0
	set Players_escapePressedCount = 0
	call ini_8()
	return true
endfunction

function trigger_addAction takes trigger this, code actionFunc returns nothing
	call TriggerAddAction(this, actionFunc)
endfunction

function trigger_registerPlayerChatEvent takes trigger this, player whichPlayer, string chatMessageToDetect, boolean exactMatchOnly returns nothing
	call TriggerRegisterPlayerChatEvent(this, whichPlayer, chatMessageToDetect, exactMatchOnly)
endfunction

function init_PrintingHelper takes nothing returns boolean
	local trigger t
	local integer i_3
	set PrintingHelper_DEBUG_MSG_DURATION = 45.
	set t = CreateTrigger()
	call trigger_addAction(t, ref_function_switchDebug)
	set i_3 = 0
	loop
		exitwhen i_3 > 11
		set PrintingHelper_wantDebug[i_3] = false
		call trigger_registerPlayerChatEvent(t, Player(i_3), "-d", true)
		set i_3 = i_3 + 1
	endloop
	set t = null
	return true
endfunction

function init_ProjectileStack takes nothing returns boolean
	set ProjectileStack_DUST_FX = "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl"
	set ProjectileStack_ERROR_NO_PROJECTILE = "Error: projectile was not found for attacking unit! Reverting to Hunter projectile."
	set ProjectileStack_ERROR_NO_SPEED = "Error: projectile speed was not found! Reverting to 20."
	set ProjectileStack_ERROR_NO_DAMAGE = "Error: projectile damage was not found! Reverting to 10."
	set ProjectileStack_PROJECTILE_OFFSET = 50.
	set ProjectileStack_DEFAULT_VELOCITY = 20.
	set ProjectileStack_BULLET_ENUM_RADIUS = 75.
	set ProjectileStack_PROJECTILE_VELOCITY = 25.
	set ProjectileStack_PROJECTILE_DAMAGE = 30.
	set ProjectileStack_DEFAULT_DAMAGE = 10.
	set ProjectileStack_CLOCK_PERIOD = 1. / 30.
	set ProjectileStack_FLY_HEIGHT = 60.
	set ProjectileStack_RANGE = 1200.
	set ProjectileStack_time = CreateTimer()
	set ProjectileStack_dbIndex = -1
	set ProjectileStack_g = CreateGroup()
	return true
endfunction

function addQuest takes string desc, string iconPath, boolean required, string title returns quest
	local quest q = CreateQuest()
	call QuestSetCompleted(q, false)
	call QuestSetDescription(q, desc)
	call QuestSetDiscovered(q, true)
	call QuestSetEnabled(q, true)
	call QuestSetIconPath(q, iconPath)
	call QuestSetRequired(q, required)
	call QuestSetTitle(q, title)
	set addQuesttempReturn = q
	set q = null
	return addQuesttempReturn
endfunction

function init_23 takes nothing returns nothing
	call addQuest(Quests_ABOUT_DESC, Quests_ABOUT_ICONPATH, false, Quests_ABOUT_TITLE)
	call addQuest(Quests_MODEL_CREDITS_DESC, Quests_MODEL_CREDITS_ICONPATH, false, Quests_MODEL_CREDITS_TITLE)
	call addQuest(Quests_CREDITS_DESC, Quests_CREDITS_ICONPATH, false, Quests_CREDITS_TITLE)
	if GetPlayerId(Players_locl) < Players_FIRST_BEAST then
		call addQuest(Quests_HOWTO_HUNTER_DESC, Quests_HOWTO_ICONPATH, true, Quests_HOWTO_TITLE)
	else
		call addQuest(Quests_HOWTO_BEAST_DESC, Quests_HOWTO_ICONPATH, true, Quests_HOWTO_TITLE)
	endif
endfunction

function init_Quests takes nothing returns boolean
	set Quests_CREDITS_DESC = "|n|cff999999Vexorian, Pitzermike, lookingforhelp|r, among others who contributed to Jass Newgen Pack." + "|n|cff999999Shadow Daemon|r for the Button Manager tool, used to generate icons." + "|n|cff999999Kiesman at DeviantArt, and Magic the Gathering|r for the image used in the map preview." + "|n|cff999999sigelang|r for the cats eye icon." + "|n|cff999999-Berz-|r for the Nether Bolt icon." + "|n|cff999999JollyD|r for the Treant Hide icon." + "|n|cff999999The Panda|r for the Electric Charge icon." + "|n|cff999999NFWar|r for the SandalZ2 and Rifle01 icons." + "|n|cff999999bigapple90|r for the Sharp Blades 2 icon." + "|n|cff999999Charlie Cleveland|r, of Unknown Worlds Entertainment, for the production of Natural Selection, by which this map is heavily influenced." + "|n|cff999999Blizzard|r, who provide this wonderful world editor."
	set Quests_CREDITS_ICONPATH = "ReplaceableTextures\\CommandButtons\\BTNBookOfTheDead.blp"
	set Quests_CREDITS_TITLE = "Other Credits"
	set Quests_MODEL_CREDITS_DESC = "Special thanks to |cff999999DTuGuR|r for the Wall model." + "|n|cff999999assasin_lord|r for the hero glow model." + "|n|cff999999Fingolfin|r for the Oak (variation 3) model." + "|n|cff999999Fingolfin|r for the Birch (variation 3) model." + "|n|cff999999PROXY|r for the Pickaxe + Item model." + "|n|cff999999Aquis|r for the Villager Man model." + "|n|cff999999imforfun|r for the Bench Long and Bench Bend models." + "|n|cff999999.KC and diosilva16|r for the Villager in robe model."
	set Quests_MODEL_CREDITS_ICONPATH = "ReplaceableTextures\\CommandButtons\\BTNTomeBrown.blp"
	set Quests_MODEL_CREDITS_TITLE = "Model Credits"
	set Quests_HOWTO_HUNTER_DESC = "|cffffcc00-|r Search for and kill all the beasts to win the round.|n" + "|cffffcc00-|r Use teamwork and organization to overwhelm the beasts with a barrage of fire.|n" + "|cffffcc00-|r The beasts have stolen an ancient artifact from your kingdom. It emanates power and boosts their strength. Secure it before the time runs out."
	set Quests_HOWTO_BEAST_DESC = "|cffffcc00-|r Search for and kill all the hunters to win the round.|n" + "|cffffcc00-|r Use guerilla tactics, health regeneration, and your sight range advantage to outsmart the hunters.|n" + "|cffffcc00-|r Your source of power is the ancient artifact. All is lost if the hunters secure it before the time runs out."
	set Quests_HOWTO_ICONPATH = "ReplaceableTextures\\CommandButtons\\BTNTomeRed.blp"
	set Quests_HOWTO_TITLE = "|cff999999How to Play|r"
	set Quests_ABOUT_DESC = "This map is made by |cffffcc00Cokemonkey11|r."
	set Quests_ABOUT_ICONPATH = "ReplaceableTextures\\CommandButtons\\BTNTomeOfRetraining.blp"
	set Quests_ABOUT_TITLE = "About"
	call init_23()
	return true
endfunction

function init_Rect takes nothing returns boolean
	call new_Table()
	return true
endfunction

function create_w3u_h006 takes nothing returns nothing
	local integer u_key
	if MagicFunctions_compiletime then
		set u_key = createObjectDefinition("w3u", 1747988534, 1752659063)
		call ObjectDefinition_setString(u_key, "uabi", "Aloc")
		call ObjectDefinition_setReal(u_key, "usca", 1.5)
		call ObjectDefinition_setString(u_key, "upat", "")
		call ObjectDefinition_setString(u_key, "upap", "")
		call ObjectDefinition_setString(u_key, "uubs", "")
		call ObjectDefinition_setString(u_key, "utar", "none")
		call ObjectDefinition_setInt(u_key, "uhom", 1)
	else
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988534,  - 1280.0, 3200.0, 270.000)
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988534,  - 1280.0, 2752.0, 270.000)
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988534,  - 2432.0, 2176.0, 270.000)
		call CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 1747988534,  - 2048.0, 2176.0, 270.000)
	endif
endfunction

function init_24 takes nothing returns nothing
	call create_w3u_h006()
endfunction

function init_ScoutTower takes nothing returns boolean
	call init_24()
	return true
endfunction

function init_25 takes nothing returns nothing
	set SimError_error = CreateSoundFromLabel("InterfaceError", false, false, false, 10, 10)
endfunction

function init_SimError takes nothing returns boolean
	call init_25()
	return true
endfunction

function init_Statistics takes nothing returns boolean
	set Statistics_roundEndTime = 0
	set Statistics_secondsElapsed = 0
	set Statistics_hunterWins = 0
	set Statistics_beastWins = 0
	set Statistics_huntersAlive = 0
	set Statistics_beastsAlive = 0
	set Statistics_hunterKills = 0
	set Statistics_beastKills = 0
	return true
endfunction

function string_length takes string this returns integer
	return StringLength(this)
endfunction

function init_String takes nothing returns boolean
	set String_charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	set String_numberset = "0123456789"
	call string_length(String_numberset)
	call string_length(String_charset)
	return true
endfunction

function ini_9 takes nothing returns nothing
	local group grp
	local region reg
	local trigger autoAddUnits
	local timer perCleanup
	local unit iter
	if StructuredDD_ADD_ALL_UNITS then
		set grp = CreateGroup()
		call GroupEnumUnitsInRect(grp, bj_mapInitialPlayableArea, null)
		loop
			set iter = FirstOfGroup(grp)
			exitwhen iter == null
			call StructuredDD_add(iter)
			call GroupRemoveUnit(grp, iter)
		endloop
		set autoAddUnits = CreateTrigger()
		set reg = CreateRegion()
		call RegionAddRect(reg, bj_mapInitialPlayableArea)
		call TriggerRegisterEnterRegion(autoAddUnits, reg, null)
		call TriggerAddCondition(autoAddUnits, Condition(ref_function_StructuredDD_autoAddC))
	endif
	set perCleanup = CreateTimer()
	call TimerStart(perCleanup, StructuredDD_PER_CLEANUP_TIMEOUT, true, ref_function_StructuredDD_perCleanup)
	set grp = null
	set reg = null
	set autoAddUnits = null
	set perCleanup = null
	set iter = null
endfunction

function init_StructuredDD takes nothing returns boolean
	set StructuredDD_ADD_ALL_UNITS = true
	set StructuredDD_BUCKET_SIZE = 5
	set StructuredDD_PER_CLEANUP_TIMEOUT = 60.
	set StructuredDD_conditionsIndex = -1
	set StructuredDD_dbIndex = -1
	set StructuredDD_maxDBIndex = -1
	call ini_9()
	return true
endfunction

function init_Table takes nothing returns boolean
	set Table_ht = InitHashtable()
	return true
endfunction

function init_TempGroups takes nothing returns boolean
	call CreateGroup()
	return true
endfunction

function init_Terrain takes nothing returns boolean
	set Terrain_DUMMY_ITEM_ID = 2003790951
	call Location(0., 0.)
	set Terrain_dItem = null
	call Rect(0., 0., 128., 128.)
	set Terrain_dItem = CreateItem(Terrain_DUMMY_ITEM_ID, 0., 0.)
	call SetItemVisible(Terrain_dItem, false)
	return true
endfunction

function init_TerrainData takes nothing returns boolean
	set TerrainData_HUNTER_SPAWN_X =  - 1710.
	set TerrainData_HUNTER_SPAWN_Y = 3570.
	set TerrainData_BEAST_SPAWN_X = 3584.
	set TerrainData_BEAST_SPAWN_Y =  - 4240.
	set TerrainData_HALL_MIN_X =  - 1820.
	set TerrainData_HALL_MAX_X =  - 1290.
	set TerrainData_HALL_MIN_Y = 3460.
	set TerrainData_HALL_MAX_Y = 3970.
	set TerrainData_RUNE_1_X = 3906.
	set TerrainData_RUNE_1_Y =  - 1018.
	set TerrainData_RUNE_2_X =  - 327.
	set TerrainData_RUNE_2_Y =  - 4093.
	set TerrainData_RUNE_RETURN_X =  - 1625.
	set TerrainData_RUNE_RETURN_Y = 3660.
	set TerrainData_MIN_X =  - 5580.
	set TerrainData_MAX_X = 5390.
	set TerrainData_MIN_Y =  - 5620.
	set TerrainData_MAX_Y = 5270.
	set TerrainData_SAFE_X =  - 5030.
	set TerrainData_SAFE_Y = 5030.
	set TerrainData_loc = Location(0., 0.)
	return true
endfunction

function init_TextTag takes nothing returns boolean
	set TextTag_labelIndex = -1
	return true
endfunction

function init_26 takes nothing returns nothing
	call registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, ref_function_act_14)
endfunction

function init_Thunder takes nothing returns boolean
	set Thunder_THUNDER_ID = 1093677135
	call init_26()
	return true
endfunction

function init_27 takes nothing returns nothing
	call TimerStart(CreateTimer(), 1., true, ref_function_checkRoundSeconds)
	call SoundControl_preload(TimerUp_TIME_LIMIT_REACHED)
endfunction

function init_TimerUp takes nothing returns boolean
	set TimerUp_TIME_LIMIT_REACHED = "time-limit-reached.mp3"
	call CreateTimer()
	call init_27()
	return true
endfunction

function init_TimerUtils takes nothing returns boolean
	set TimerUtils_freeTimersCount = 0
	set TimerUtils_timerData = new_Table()
	set TimerUtils_HELD = 679645218
	return true
endfunction

function init_Trigger takes nothing returns boolean
	call new_Table()
	return true
endfunction

function init_TypeCasting takes nothing returns boolean
	call new_Table()
	return true
endfunction

function ini_10 takes nothing returns nothing
	local integer index = 0
	loop
		exitwhen index >= Players_COUNT
		set Units_subHero[index] = null
		set index = index + 1
	endloop
endfunction

function init_Units takes nothing returns boolean
	set Units_LIGHTNING_BALL_FX = "Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl"
	set Units_CLOCK_PERIOD = 1. / 30.
	set Units_LIGHTNING_CHECK_PERIOD = 5.
	set Units_BALL_OFF = 64.
	set Units_PHASE_ANGULAR_VELOCITY = bj_PI / 8. * Units_CLOCK_PERIOD
	set Units_EFFECT_SCALE = .5
	set Units_EFFECT_HEIGHT = 60.
	set Units_BLINK_PASSIVE_ID = 1093677125
	set Units_BLINK_ID = 1093677105
	set Units_HEMISECT_PASSIVE_ID = 1093677128
	set Units_HEMISECT_ID = 1093677127
	set Units_CONCAT_PASSIVE_ID = 1093677130
	set Units_CONCAT_ID = 1093677131
	set Units_HUNTER_ID = 1211117644
	set Units_BEAST_ID = 1211117645
	set Units_LESSER_BEAST_ID = 1211117617
	set Units_HUNTER_PROJECTILE_ID = 1747988528
	set Units_ARTIFACT_ID = 1227894832
	set Units_GAS_ACTION = 1227894835
	set Units_INITIAL_BALLS = 0
	set Units_MAX_BALLS = 5
	set Units_MAX_BALLS_LESSER = 3
	set Units_grp = CreateGroup()
	set Units_clock = CreateTimer()
	set Units_beastHead = 0
	set Units_fromBeast = new_Table()
	set Units_thunderCd = new_Table()
	set Units_thunderClock = new_Table()
	set Units_beastState = new_Table()
	set Units_sitePref = new_Table()
	call ini_10()
	return true
endfunction

function init_Vectors takes nothing returns boolean
	return true
endfunction

function pauseForGameMusic takes nothing returns nothing
	call DestroyTimer(GetExpiredTimer())
	call playGameMusic()
endfunction

function periodic takes nothing returns nothing
	local string colorCode = "|cffffffff"
	local integer secondsLeft = Statistics_roundEndTime - Statistics_secondsElapsed
	local string seconds = "0"
	local string minutes = " "
	local integer minutesLeft
	if secondsLeft < 0 then
		set secondsLeft = 0
	endif
	set minutesLeft = R2I(secondsLeft * 1. / 60)
	set secondsLeft = ModuloInteger(secondsLeft, 60)
	if secondsLeft < 10 then
		set seconds = seconds + I2S(secondsLeft)
	else
		set seconds = I2S(secondsLeft)
	endif
	if minutesLeft > 0 then
		set minutes = I2S(minutesLeft)
	elseif secondsLeft <= 0 then
		set colorCode = "|cff444444"
	elseif secondsLeft < 10 and ModuloInteger(secondsLeft, 2) == 0 then
		set colorCode = "|cffee0000"
	elseif secondsLeft < 30 and ModuloInteger(secondsLeft, 2) == 0 then
		set colorCode = "|cff999999"
	endif
	call MultiboardSetTitleText(MultiboardControl_mb, "|cff999999Hunters|r  " + I2S(Statistics_hunterWins) + " - " + I2S(Statistics_beastWins) + "  |cff411d0aBeasts|r")
	call MultiboardSetItemValue(MultiboardGetItem(MultiboardControl_mb, 0, 1), colorCode + minutes + "|r:" + colorCode + seconds + "|r")
endfunction

function strikeUnits takes real x, real y, player caster returns nothing
	local unit iter
	local unit dummy
	call GroupEnumUnitsInRange(Net_grp, x, y, Net_RADIUS, null)
	loop
		set iter = FirstOfGroup(Net_grp)
		exitwhen iter == null
		if IsUnitEnemy(iter, caster) and UnitAlive(iter) then
			set dummy = DummyUnitStack_get()
			call SetUnitX(dummy, GetUnitX(iter))
			call SetUnitY(dummy, GetUnitY(iter))
			call UnitAddAbility(dummy, Net_NET_SLOW_ID)
			call IssueTargetOrder(dummy, "slow", iter)
			call DamageOverTime_add(null, iter, 0., 9., Net_NET_FX, DamageOverTime_FX_FLAG_COORDS, Net_EXCLUSIVITY_NET)
			call DummyUnitStack_delayedRelease(dummy, 3.)
		endif
		call GroupRemoveUnit(Net_grp, iter)
	endloop
	set iter = null
	set dummy = null
endfunction

function periodic_2 takes nothing returns nothing
	local integer index = 0
	local integer tempDat
	local unit iter
	local real dX
	local real dY
	local boolean hit
	local unit receiver
	local unit receiver_2
	local unit receiver_3
	loop
		exitwhen index > Net_dbIndex
		set tempDat = Net_dataDb[index]
		set dX = unit_getX(NetData_dummy[tempDat])
		set dY = unit_getY(NetData_dummy[tempDat])
		set hit = false
		set receiver = NetData_dummy[tempDat]
		call unit_setX(receiver, dX + NetData_delX[tempDat])
		set receiver_2 = receiver
		call unit_setY(receiver_2, dY + NetData_delY[tempDat])
		set receiver_3 = receiver_2
		call unit_setFlyHeight(receiver_3, 50., 0.)
		set NetData_distance[tempDat] = NetData_distance[tempDat] - Net_NET_VELOCITY * Net_CLOCK_PERIOD
		call GroupEnumUnitsInRange(Net_grp, dX, dY, Net_COLLISION_RADIUS, null)
		loop
			set iter = FirstOfGroup(Net_grp)
			exitwhen iter == null
			if IsUnitEnemy(iter, NetData_caster[tempDat]) and UnitAlive(iter) then
				set hit = true
				exitwhen true
			endif
			call GroupRemoveUnit(Net_grp, iter)
		endloop
		if hit or NetData_distance[tempDat] < 0. then
			call strikeUnits(dX, dY, NetData_caster[tempDat])
			call effect_destr(NetData_attached[tempDat])
			call DummyUnitStack_delayedRelease(NetData_dummy[tempDat], 3.)
			set Net_dataDb[index] = Net_dataDb[Net_dbIndex]
			set Net_dbIndex = Net_dbIndex - 1
			set index = index - 1
			if Net_dbIndex == -1 then
				call PauseTimer(Net_clock)
			endif
		endif
		set index = index + 1
	endloop
	set iter = null
	set receiver = null
	set receiver_2 = null
	set receiver_3 = null
endfunction

function DummyAlloc_onDestroy takes integer this returns nothing
endfunction

function dealloc_DummyAlloc takes integer obj returns nothing
	if DummyAlloc_typeId[obj] == 0 then
		call error("Double free: object of type DummyAlloc")
	else
		set DummyAlloc_nextFree[DummyAlloc_firstFree] = obj
		set DummyAlloc_firstFree = DummyAlloc_firstFree + 1
		set DummyAlloc_typeId[obj] = 0
	endif
endfunction

function destroyDummyAlloc takes integer this returns nothing
	call DummyAlloc_onDestroy(this)
	call dealloc_DummyAlloc(this)
endfunction

function dispatch_DummyAlloc_destroyDummyAlloc takes integer this returns nothing
	if DummyAlloc_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling DummyAlloc.destroyDummyAlloc")
		else
			call error("Called DummyAlloc.destroyDummyAlloc on invalid object.")
		endif
	endif
	call destroyDummyAlloc(this)
endfunction

function releaseDummy takes nothing returns nothing
	local timer tim = GetExpiredTimer()
	local integer d = timer_getData(tim)
	call DummyUnitStack_release(DummyAlloc_u[d])
	call dispatch_DummyAlloc_destroyDummyAlloc(d)
	call DestroyTimer(tim)
	set tim = null
endfunction

function resetCooldown takes nothing returns nothing
	local timer tim = GetExpiredTimer()
	local integer d = timer_getData(tim)
	call UnitRemoveAbility(DummyAlloc_u[d], Knife_KNIFE_ID)
	call UnitAddAbility(DummyAlloc_u[d], Knife_KNIFE_ID)
	call dispatch_DummyAlloc_destroyDummyAlloc(d)
	call DestroyTimer(tim)
	set tim = null
endfunction

function Cinematic_neutral0 takes nothing returns nothing
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 3., "    |cffffcc00Hunter's Hall|r")
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 3., " ")
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 3., " ")
	call DisplayTimedTextToPlayer(Players_locl, .2, 0., 3., " ")
	call Cinematic_biconditionalScene(2., ref_function_Cinematic_neutral1)
endfunction

function Units_clearAll takes nothing returns nothing
	local integer index = 0
	local unit iter
	loop
		exitwhen index > Players_LAST_BEAST
		call GroupEnumUnitsOfPlayer(Units_grp, Players_fromId[index], null)
		loop
			set iter = FirstOfGroup(Units_grp)
			exitwhen iter == null
			call GroupRemoveUnit(Units_grp, iter)
			call RemoveUnit(iter)
		endloop
		set index = index + 1
	endloop
	set iter = null
endfunction

function Cinematic_start takes nothing returns nothing
	call Units_clearAll()
	set Cinematic_enabled = true
	call FogMaskEnable(false)
	call FogEnable(false)
	call CameraControl_fadeOutHunter(.01)
	call CameraControl_fadeOutBeast(.01)
	call EnableUserUI(false)
	call EnableUserControl(false)
	call ShowInterface(false, 0.)
	call Cinematic_neutral0()
endfunction

function startC takes nothing returns boolean
	call ClearTextMessages()
	call Cinematic_start()
	return false
endfunction

function switchDebug takes nothing returns nothing
	local player p = GetTriggerPlayer()
	local integer id = player_getId(p)
	if PrintingHelper_wantDebug[id] then
		set PrintingHelper_wantDebug[id] = false
		call DisplayTimedTextToPlayer(p, 0., 0., 20., "|cff9C9C9CDEBUG-View|r |cffB55208deactivated")
	else
		set PrintingHelper_wantDebug[id] = true
		call DisplayTimedTextToPlayer(p, 0., 0., 20., "|cff9C9C9CDEBUG-View|r |cff3AAD42activated")
	endif
	set p = null
endfunction

function update takes nothing returns nothing
	local integer index = 0
	local integer j
	if  not Cinematic_enabled then
		loop
			exitwhen index >= Players_FIRST_BEAST
			set j = 0
			loop
				exitwhen j >= Players_FIRST_BEAST
				if j != index then
					call FogModifierStop(MinimapVisionHints_hints[index * Players_FIRST_BEAST + j])
					call DestroyFogModifier(MinimapVisionHints_hints[index * Players_FIRST_BEAST + j])
					if (UnitAlive(Units_hero[index]) and UnitAlive(Units_hero[j]) and IsUnitInRange(Units_hero[index], Units_hero[j], MinimapVisionHints_CHECK_RADIUS)) or (( not UnitAlive(Units_hero[index])) and UnitAlive(Units_hero[j])) then
						set MinimapVisionHints_hints[index * Players_FIRST_BEAST + j] = CreateFogModifierRadius(Players_fromId[index], FOG_OF_WAR_VISIBLE, GetUnitX(Units_hero[j]), GetUnitY(Units_hero[j]), MinimapVisionHints_RADIUS, false, true)
						call FogModifierStart(MinimapVisionHints_hints[index * Players_FIRST_BEAST + j])
					endif
				endif
				set j = j + 1
			endloop
			set index = index + 1
		endloop
	endif
endfunction

function initGlobals takes nothing returns nothing
	set CallbackSingle_firstFree = 0
	set CallbackSingle_maxIndex = 0
	set DotData_firstFree = 0
	set DotData_maxIndex = 0
	set DelayDat_firstFree = 0
	set DelayDat_maxIndex = 0
	set UnitAlloc_firstFree = 0
	set UnitAlloc_maxIndex = 0
	set AutoDat_firstFree = 0
	set AutoDat_maxIndex = 0
	set DummyAlloc_firstFree = 0
	set DummyAlloc_maxIndex = 0
	set Chord_firstFree = 0
	set Chord_maxIndex = 0
	set Muscii_firstFree = 0
	set Muscii_maxIndex = 0
	set MyCallBackFunc_firstFree = 0
	set MyCallBackFunc_maxIndex = 0
	set Note_firstFree = 0
	set Note_maxIndex = 0
	set NetData_firstFree = 0
	set NetData_maxIndex = 0
	set IdGenerator_firstFree = 0
	set IdGenerator_maxIndex = 0
	set DuplicateDat_firstFree = 0
	set DuplicateDat_maxIndex = 0
	set DuplicateDat_firstFree_2 = 0
	set DuplicateDat_maxIndex_2 = 0
	set Effect_firstFree = 0
	set Effect_maxIndex = 0
	set ProjectileDat_firstFree = 0
	set ProjectileDat_maxIndex = 0
	set Slop_firstFree = 0
	set Slop_maxIndex = 0
	set Bucket_firstFree = 0
	set Bucket_maxIndex = 0
	set Table_firstFree = 0
	set Table_maxIndex = 0
	set BeastLightningDat_firstFree = 0
	set BeastLightningDat_maxIndex = 0
	set LightningBallDat_firstFree = 0
	set LightningBallDat_maxIndex = 0
	set ref_function_init_String = function init_String
	set ref_function_init_Table = function init_Table
	set ref_function_init_Trigger = function init_Trigger
	set ref_function_init_Player = function init_Player
	set ref_function_init_PrintingHelper = function init_PrintingHelper
	set ref_function_init_MagicFunctions = function init_MagicFunctions
	set ref_function_init_Basics = function init_Basics
	set ref_function_init_GameTimer = function init_GameTimer
	set ref_function_init_ErrorHandling = function init_ErrorHandling
	set ref_function_init_TimerUtils = function init_TimerUtils
	set ref_function_init_Maths = function init_Maths
	set ref_function_init_Vectors = function init_Vectors
	set ref_function_init_TempGroups = function init_TempGroups
	set ref_function_init_Colors = function init_Colors
	set ref_function_init_Rect = function init_Rect
	set ref_function_init_Terrain = function init_Terrain
	set ref_function_init_TypeCasting = function init_TypeCasting
	set ref_function_init_ObjectIds = function init_ObjectIds
	set ref_function_init_ObjectIdGenerator = function init_ObjectIdGenerator
	set ref_function_init_TerrainData = function init_TerrainData
	set ref_function_init_Players = function init_Players
	set ref_function_init_DummyUnitStack = function init_DummyUnitStack
	set ref_function_init_Units = function init_Units
	set ref_function_init_Statistics = function init_Statistics
	set ref_function_init_AI = function init_AI
	set ref_function_init_AttackTeammate = function init_AttackTeammate
	set ref_function_init_StructuredDD = function init_StructuredDD
	set ref_function_init_DamageType = function init_DamageType
	set ref_function_init_MultiboardControl = function init_MultiboardControl
	set ref_function_init_CameraControl = function init_CameraControl
	set ref_function_init_Game = function init_Game
	set ref_function_init_DamageOverTime = function init_DamageOverTime
	set ref_function_init_TextTag = function init_TextTag
	set ref_function_init_ItemFieldConditioningKit = function init_ItemFieldConditioningKit
	set ref_function_init_BeastAttack = function init_BeastAttack
	set ref_function_init_Cinematic = function init_Cinematic
	set ref_function_init_BinocularVision = function init_BinocularVision
	set ref_function_init_Blink = function init_Blink
	set ref_function_init_Castle = function init_Castle
	set ref_function_init_CastleSmall = function init_CastleSmall
	set ref_function_init_EscapeKey = function init_EscapeKey
	set ref_function_init_HeroDeath = function init_HeroDeath
	set ref_function_init_ProjectileStack = function init_ProjectileStack
	set ref_function_init_HunterAttack = function init_HunterAttack
	set ref_function_init_Math = function init_Math
	set ref_function_init_HunterCamera = function init_HunterCamera
	set ref_function_init_HunterToggle = function init_HunterToggle
	set ref_function_init_HuntersHall = function init_HuntersHall
	set ref_function_init_Initialization = function init_Initialization
	set ref_function_init_KeepSmall = function init_KeepSmall
	set ref_function_init_Knife = function init_Knife
	set ref_function_init_Marketplace = function init_Marketplace
	set ref_function_init_MinimapVisionHints = function init_MinimapVisionHints
	set ref_function_init_Muscii = function init_Muscii
	set ref_function_init_Music = function init_Music
	set ref_function_init_Net = function init_Net
	set ref_function_init_SimError = function init_SimError
	set ref_function_init_NoItemDuplicates = function init_NoItemDuplicates
	set ref_function_init_OrganicConcatenation = function init_OrganicConcatenation
	set ref_function_init_OrganicHemisection = function init_OrganicHemisection
	set ref_function_init_Pedestal = function init_Pedestal
	set ref_function_init_PedestalReceive = function init_PedestalReceive
	set ref_function_init_PlayerLeaves = function init_PlayerLeaves
	set ref_function_init_Quests = function init_Quests
	set ref_function_init_ScoutTower = function init_ScoutTower
	set ref_function_init_Thunder = function init_Thunder
	set ref_function_init_TimerUp = function init_TimerUp
	set ref_function_AI_periodic = function AI_periodic
	set ref_function_act = function act_13
	set ref_function_hand = function hand
	set ref_function_act_2 = function act_9
	set ref_function_act_3 = function act
	set ref_function_CameraControl_endFadeHunter = function CameraControl_endFadeHunter
	set ref_function_CameraControl_endFadeBeast = function CameraControl_endFadeBeast
	set ref_function_Cinematic_cleanup = function Cinematic_cleanup
	set ref_function_Cinematic_endCinematic = function Cinematic_endCinematic
	set ref_function_Cinematic_human24 = function Cinematic_human24
	set ref_function_Cinematic_human23 = function Cinematic_human23
	set ref_function_Cinematic_human22 = function Cinematic_human22
	set ref_function_Cinematic_human21 = function Cinematic_human21
	set ref_function_Cinematic_human20 = function Cinematic_human20
	set ref_function_Cinematic_human19 = function Cinematic_human19
	set ref_function_Cinematic_human18 = function Cinematic_human18
	set ref_function_Cinematic_human17 = function Cinematic_human17
	set ref_function_Cinematic_human16 = function Cinematic_human16
	set ref_function_Cinematic_human15 = function Cinematic_human15
	set ref_function_Cinematic_human14c = function Cinematic_human14c
	set ref_function_Cinematic_human14b = function Cinematic_human14b
	set ref_function_Cinematic_human14a = function Cinematic_human14a
	set ref_function_Cinematic_human14 = function Cinematic_human14
	set ref_function_Cinematic_human13 = function Cinematic_human13
	set ref_function_Cinematic_human12a = function Cinematic_human12a
	set ref_function_Cinematic_human12 = function Cinematic_human12
	set ref_function_Cinematic_human11 = function Cinematic_human11
	set ref_function_Cinematic_human10 = function Cinematic_human10
	set ref_function_Cinematic_human9 = function Cinematic_human9
	set ref_function_Cinematic_human8b = function Cinematic_human8b
	set ref_function_Cinematic_human8 = function Cinematic_human8
	set ref_function_Cinematic_human7 = function Cinematic_human7
	set ref_function_Cinematic_human6 = function Cinematic_human6
	set ref_function_Cinematic_human5 = function Cinematic_human5
	set ref_function_Cinematic_human4 = function Cinematic_human4
	set ref_function_Cinematic_human3 = function Cinematic_human3
	set ref_function_Cinematic_human2 = function Cinematic_human2
	set ref_function_Cinematic_human1 = function Cinematic_human1
	set ref_function_Cinematic_beast35 = function Cinematic_beast35
	set ref_function_Cinematic_beast34 = function Cinematic_beast34
	set ref_function_Cinematic_beast33b = function Cinematic_beast33b
	set ref_function_Cinematic_beast33a = function Cinematic_beast33a
	set ref_function_Cinematic_beast33 = function Cinematic_beast33
	set ref_function_Cinematic_beast32 = function Cinematic_beast32
	set ref_function_Cinematic_beast31b = function Cinematic_beast31b
	set ref_function_Cinematic_beast31a = function Cinematic_beast31a
	set ref_function_Cinematic_beast31 = function Cinematic_beast31
	set ref_function_Cinematic_beast30 = function Cinematic_beast30
	set ref_function_Cinematic_beast28 = function Cinematic_beast28
	set ref_function_Cinematic_beast29 = function Cinematic_beast29
	set ref_function_Cinematic_beast26 = function Cinematic_beast26
	set ref_function_Cinematic_beast25 = function Cinematic_beast25
	set ref_function_Cinematic_beast23 = function Cinematic_beast23
	set ref_function_Cinematic_beast23b = function Cinematic_beast23b
	set ref_function_Cinematic_beast24 = function Cinematic_beast24
	set ref_function_Cinematic_beast22 = function Cinematic_beast22
	set ref_function_Cinematic_beast21 = function Cinematic_beast21
	set ref_function_Cinematic_beast20 = function Cinematic_beast20
	set ref_function_Cinematic_beast19 = function Cinematic_beast19
	set ref_function_Cinematic_beast18 = function Cinematic_beast18
	set ref_function_Cinematic_beast17 = function Cinematic_beast17
	set ref_function_Cinematic_beast16 = function Cinematic_beast16
	set ref_function_Cinematic_beast15 = function Cinematic_beast15
	set ref_function_Cinematic_beast14 = function Cinematic_beast14
	set ref_function_Cinematic_beast13 = function Cinematic_beast13
	set ref_function_Cinematic_beast12 = function Cinematic_beast12
	set ref_function_Cinematic_beast11b = function Cinematic_beast11b
	set ref_function_Cinematic_beast11a = function Cinematic_beast11a
	set ref_function_Cinematic_beast11 = function Cinematic_beast11
	set ref_function_Cinematic_beast10 = function Cinematic_beast10
	set ref_function_Cinematic_beast9 = function Cinematic_beast9
	set ref_function_Cinematic_beast8 = function Cinematic_beast8
	set ref_function_Cinematic_beast7 = function Cinematic_beast7
	set ref_function_Cinematic_beast6 = function Cinematic_beast6
	set ref_function_Cinematic_beast5 = function Cinematic_beast5
	set ref_function_Cinematic_beast4 = function Cinematic_beast4
	set ref_function_Cinematic_beast3 = function Cinematic_beast3
	set ref_function_Cinematic_beast2 = function Cinematic_beast2
	set ref_function_Cinematic_beast1 = function Cinematic_beast1
	set ref_function_Cinematic_human0 = function Cinematic_human0
	set ref_function_Cinematic_beast0 = function Cinematic_beast0
	set ref_function_Cinematic_neutral2 = function Cinematic_neutral2
	set ref_function_Cinematic_neutral1 = function Cinematic_neutral1
	set ref_function_CallbackSingle_staticCallback = function CallbackSingle_staticCallback
	set ref_function_DamageOverTime_damageTick = function DamageOverTime_damageTick
	set ref_function_DamageType_c = function DamageType_c
	set ref_function_DamageType_handler = function DamageType_handler
	set ref_function_DamageType_after = function DamageType_after
	set ref_function_DummyUnitStack_deferredPreloader = function DummyUnitStack_deferredPreloader
	set ref_function_DummyUnitStack_afterDelay = function DummyUnitStack_afterDelay
	set ref_function_c = function c
	set ref_function_GameTimer_closure_impl = function GameTimer_closure_impl
	set ref_function_Game_countSeconds = function Game_countSeconds
	set ref_function_Game_gameOver2 = function Game_gameOver2
	set ref_function_Game_hunterVictorySound = function Game_hunterVictorySound
	set ref_function_Game_gameOver = function Game_gameOver
	set ref_function_Game_roundStart = function Game_roundStart
	set ref_function_Game_beastVictorySound = function Game_beastVictorySound
	set ref_function_a = function a
	set ref_function_autoTick = function autoTick
	set ref_function_act_4 = function act_6
	set ref_function_act_5 = function act_3
	set ref_function_act_6 = function act_4
	set ref_function_startC = function startC
	set ref_function_endVotes = function endVotes
	set ref_function_diaA = function diaA
	set ref_function_afterDelay = function afterDelay
	set ref_function_checkCombatDuration = function checkCombatDuration
	set ref_function_releaseDummy = function releaseDummy
	set ref_function_resetCooldown = function resetCooldown
	set ref_function_act_7 = function act_10
	set ref_function_update = function update
	set ref_function_periodic = function periodic
	set ref_function_act_8 = function act_8
	set ref_function_Muscii_p = function Muscii_p
	set ref_function_pauseForGameMusic = function pauseForGameMusic
	set ref_function_periodic_2 = function periodic_2
	set ref_function_act_9 = function act_2
	set ref_function_act_10 = function act_12
	set ref_function_ddPeriodic = function ddPeriodic_2
	set ref_function_act_11 = function act_7
	set ref_function_ddPeriodic_2 = function ddPeriodic
	set ref_function_act_12 = function act_11
	set ref_function_fxSpawn3 = function fxSpawn3
	set ref_function_fxSpawn2 = function fxSpawn2
	set ref_function_act_13 = function act_14
	set ref_function_cond = function cond
	set ref_function_switchDebug = function switchDebug
	set ref_function_ProjectileStack_bulletTick = function ProjectileStack_bulletTick
	set ref_function_SoundControl_preloadAfter = function SoundControl_preloadAfter
	set ref_function_StructuredDD_autoAddC = function StructuredDD_autoAddC
	set ref_function_StructuredDD_perCleanup = function StructuredDD_perCleanup
	set ref_function_act_14 = function act_5
	set ref_function_checkRoundSeconds = function checkRoundSeconds
	set ref_function_Units_beastLightningTick = function Units_beastLightningTick
	set ref_function_Units_filterItems = function Units_filterItems
endfunction

function main takes nothing returns nothing
	local trigger initTrig
	call initGlobals()
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_String))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package String.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Table))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Table.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Trigger))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Trigger.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Player))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Player.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_PrintingHelper))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package PrintingHelper.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_MagicFunctions))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package MagicFunctions.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Basics))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Basics.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_GameTimer))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package GameTimer.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_ErrorHandling))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package ErrorHandling.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_TimerUtils))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package TimerUtils.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Maths))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Maths.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Vectors))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Vectors.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_TempGroups))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package TempGroups.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Colors))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Colors.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Rect))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Rect.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Terrain))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Terrain.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_TypeCasting))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package TypeCasting.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_ObjectIds))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package ObjectIds.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_ObjectIdGenerator))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package ObjectIdGenerator.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_TerrainData))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package TerrainData.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Players))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Players.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_DummyUnitStack))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package DummyUnitStack.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Units))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Units.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Statistics))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Statistics.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_AI))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package AI.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_AttackTeammate))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package AttackTeammate.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_StructuredDD))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package StructuredDD.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_DamageType))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package DamageType.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_MultiboardControl))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package MultiboardControl.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_CameraControl))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package CameraControl.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Game))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Game.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_DamageOverTime))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package DamageOverTime.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_TextTag))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package TextTag.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_ItemFieldConditioningKit))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package ItemFieldConditioningKit.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_BeastAttack))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package BeastAttack.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Cinematic))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Cinematic.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_BinocularVision))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package BinocularVision.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Blink))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Blink.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Castle))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Castle.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_CastleSmall))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package CastleSmall.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_EscapeKey))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package EscapeKey.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_HeroDeath))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package HeroDeath.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_ProjectileStack))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package ProjectileStack.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_HunterAttack))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package HunterAttack.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Math))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Math.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_HunterCamera))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package HunterCamera.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_HunterToggle))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package HunterToggle.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_HuntersHall))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package HuntersHall.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Initialization))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Initialization.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_KeepSmall))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package KeepSmall.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Knife))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Knife.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Marketplace))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Marketplace.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_MinimapVisionHints))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package MinimapVisionHints.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Muscii))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Muscii.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Music))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Music.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Net))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Net.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_SimError))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package SimError.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_NoItemDuplicates))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package NoItemDuplicates.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_OrganicConcatenation))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package OrganicConcatenation.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_OrganicHemisection))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package OrganicHemisection.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Pedestal))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Pedestal.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_PedestalReceive))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package PedestalReceive.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_PlayerLeaves))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package PlayerLeaves.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Quests))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Quests.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_ScoutTower))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package ScoutTower.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_Thunder))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package Thunder.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = CreateTrigger()
	call TriggerAddCondition(initTrig, Condition(ref_function_init_TimerUp))
	if  not TriggerEvaluate(initTrig) then
		call DisplayTimedTextToPlayer(GetLocalPlayer(), 0., 0., 45., "Could not initialize package TimerUp.")
	endif
	call DestroyTrigger(initTrig)
	set initTrig = null
endfunction

function config takes nothing returns nothing
endfunction

