Generated by bsfdoc 1.0 by roguedjack
from E:\Games\SteamLibrary\steamapps\common\Field of Glory II
107 files
1189 functions
ignored Campaigns\ Multiplayer\

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\SCENARIOTEMPLATE.BSF
:::: 9 functions
::::   StartTurn(side)
::::   StartTurnPost(side)
::::   PreBattleSetup()
::::   VictoryConditions()
::::   Tick(side)
::::   PrintScenarioUI()
::::   WIN_SCENARIO_CALLBACK(winner)
::::   CustomiseUnits()
::::   FORCE_POINTS_CALLBACK(side, points)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// called at the start of every turn.
// You would tend to use this for events
StartTurn(side)

StartTurnPost(side)

PreBattleSetup()

// This function applies standard victory conditions. The actual StandardVictoryConditions() function code can be found in MoreScenarioTools.BSF.
// The parameters are (breakpoint0a, breakpoint0b, breakpoint1a, breakpoint1b, drawdecider, MPgame)
// breakpoint0a is Side 0 first breakpoint (in % troops UNrouted), breakpoint0b is Side 0 second breakpoint.
// breakpoint1a is Side 1 first breakpoint (in % troops UNrouted), breakpoint1b is Side 1 second breakpoint.
// An army is defeated if it reaches its second breakpoint, or if it reaches its first breakpoint (or anywhere between that and its second breakpoint)
// and the enemy has at least 25% more troops UNrouted.
// drawdecider indicates which side wins if the game is drawn ("ScenarioDeadline" turn limit reached or both sides are "defeated" on same turn).
// drawdecider == 0 means that Side 0 wins draws. drawdecider == 1 means that Side 1 wins draws. drawdecider == 2 means that whichever side is ahead wins draws.
// MPgame = 1 means that the game is an MP game. In non-random MP games, the victory conditions can automatically be adjusted to take account of initial disparity in forces,
// so that the losing army will win the scenario if the enemy victory was too Pyrrhic. To implement this, the StartTurnPost() function needs to include SetMPForceRatio();
// If this is likely to happen, the ScenarioUI text in the top left of the screen will report that the losing side is �ahead on points�.
// Special victory conditions can be applied using SpecialScenarioVictoryConditions() - see Lostwithiel.BSF for an example of this. If present in the scenario .bsf file,
// this function is run by StandardVictoryConditions() if neither army is broken.
VictoryConditions()

// called every game tick.
// You would tend to use this for reactive logic and win situations etc
Tick(side)

PrintScenarioUI()

WIN_SCENARIO_CALLBACK(winner)

// Any scenario that needs units to vary from their standard definition should have a version of this function
// The basic function just randomises the number of men in the unit slightly.
CustomiseUnits()

// Adjust available points according to difficulty. This over-rides the points set in the editor.
// The units that will be chosen from with these points need to be set as Unfixed in the editor.
// If all the units are Fixed, then this function will have no effect.
// MP scenarios are all played on normal difficulty.
FORCE_POINTS_CALLBACK(side, points)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\SCENARIOTEMPLATE.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\Core.BSF
:::: 8 functions
::::   StartTurn(side)
::::   StartTurnPost(side)
::::   Tick(side)
::::   PrintScenarioUI()
::::   PreStartBattle()
::::   PreStartBattle_Control(mode)
::::   PreStartEditor(mode)
::::   SCORE_BATTLE_CALLBACK()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// called at the start of every turn.
// You would tend to use this for events
// Uses Work String 0
StartTurn(side)

StartTurnPost(side)

Tick(side)

PrintScenarioUI()

PreStartBattle()

PreStartBattle_Control(mode)

PreStartEditor(mode)

SCORE_BATTLE_CALLBACK()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\Core.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\AI\AI.bsf
:::: 13 functions
::::   AI_BUILD_LIST(side)
::::   AI_REBUILD(side)
::::   OldAI_SetTeamDestination(side, team, destx, desty)
::::   AI_SetTeamDestination(side, team, destx, desty)
::::   AI_TEAM(side, team)
::::   AI_UNIT(me)
::::   UnloadUnits(me)
::::   AI_RouteWithCost(me, x, y, cost, side, team)
::::   AI_AttemptMove(me, side, team)
::::   MoveAIUnit(me)
::::   AI_CheckRouteForFlankThreats(me)
::::   AI_BugOut(me)
::::   AI_FallBack(me, target)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

//  OPTIONAL FUNCTION: build the list which holds the order in which the AI units are processed
AI_BUILD_LIST(side)

//  REQUIRED FUNCTION:  Called before anything else to rebuild any global AI data
AI_REBUILD(side)

OldAI_SetTeamDestination(side, team, destx, desty)

// All new function that will keep units in formation longer - until they get an actual target. Note that this won't work if we want units to converge on an arbitrary location, not near enemy troops.
// Hence it won't work for terrain objectives. But we deprecate those.
AI_SetTeamDestination(side, team, destx, desty)

// REQUIRED FUNCTION : this is called for each team after the AI Rebuild is called each Ai turn
AI_TEAM(side, team)

//  REQUIRED FUNCTION : This is called by the AI until it returns -1
AI_UNIT(me)

//  Unload a unit from the designated unit if possible
UnloadUnits(me)

// Do a routefind, taking into account whether we want to use threat or not
AI_RouteWithCost(me, x, y, cost, side, team)

AI_AttemptMove(me, side, team)

//  // this is called repeatedly per unit until a return value of -1 is set
MoveAIUnit(me)

// Checks route to current temporary unit destination for flank threat. Changes temporary unit destination to match last safe position in route.
// Uses work arrays 0 and 1
AI_CheckRouteForFlankThreats(me)

// Light Troops decide if it is time to bug out - if fragmented or close to autobreak and danger nearby. May be able to extend this to some other troops?
// Returns 1 if they bug out, otherwise 0;
AI_BugOut(me)

AI_FallBack(me, target)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\AI\AI.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\ChooseCampaign.BSF
:::: 5 functions
::::   UI_OBJ_RENDER(x,y,width,height,pass)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_DEACTIVATE()
::::   UI_OBJ_HANDLE(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x,y,width,height,pass)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_DEACTIVATE()

UI_OBJ_HANDLE(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\ChooseCampaign.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\Confirm.BSF
:::: 5 functions
::::   UI_OBJ_RENDER(x,y,width,height,pass)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_DEACTIVATE()
::::   UI_OBJ_HANDLE(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x,y,width,height,pass)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_DEACTIVATE()

UI_OBJ_HANDLE(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\Confirm.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\HelpPopup.BSF
:::: 5 functions
::::   UI_OBJ_RENDER(x,y,width,height,pass)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_HANDLE(id)
::::   LS_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x,y,width,height,pass)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_HANDLE(id)

LS_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\HelpPopup.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\LoadSave.BSF
:::: 5 functions
::::   UI_OBJ_RENDER(x,y,width,height,pass)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_HANDLE(id)
::::   LS_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x,y,width,height,pass)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_HANDLE(id)

LS_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\LoadSave.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\Lobby.BSF
:::: 7 functions
::::   UI_OBJ_RENDER()
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_DEACTIVATE()
::::   UI_OBJ_HANDLE(id)
::::   MULTIPLAYER_USERDATA_CALLBACK(SKIRMISH)
::::   MULTIPLAYER_USERDATA_TOOLTIP_CALLBACK()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER()

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_DEACTIVATE()

UI_OBJ_HANDLE(id)

// this should fill the work array with up to 16 values
// generally this would be driven by custom UI
MULTIPLAYER_USERDATA_CALLBACK(SKIRMISH)

MULTIPLAYER_USERDATA_TOOLTIP_CALLBACK()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\Lobby.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\MainMenu.bsf
:::: 6 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE()
::::   UI_OBJ_DEACTIVATE()
::::   UI_OBJ_RENDER()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE()

UI_OBJ_DEACTIVATE()

UI_OBJ_RENDER()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\MainMenu.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\MainMenuOverlay.bsf
:::: 6 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE()
::::   UI_OBJ_DEACTIVATE()
::::   UI_OBJ_RENDER()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE()

UI_OBJ_DEACTIVATE()

UI_OBJ_RENDER()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\MainMenuOverlay.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\MPHelp.BSF
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   MPH_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

MPH_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\MPHelp.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\NewCampaign.BSF
:::: 5 functions
::::   UI_OBJ_RENDER(x,y,width,height,pass)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_DEACTIVATE()
::::   UI_OBJ_HANDLE(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x,y,width,height,pass)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_DEACTIVATE()

UI_OBJ_HANDLE(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\NewCampaign.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\OPTIONS.BSF
:::: 5 functions
::::   UI_OBJ_RENDER(x,y,width,height,pass)
::::   UI_OBJ_HANDLE(data, event, id)
::::   Options_SetUI()
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x,y,width,height,pass)

UI_OBJ_HANDLE(data, event, id)

Options_SetUI()

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\OPTIONS.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\QuestControls.bsf
:::: 6 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE()
::::   UI_OBJ_DEACTIVATE()
::::   UI_OBJ_RENDER()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Note that GetCampaignEntry() uses workstrings 0-2
UI_OBJ_HANDLE(data, event, id)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE()

UI_OBJ_DEACTIVATE()

// Uses Work Strings 0-1
UI_OBJ_RENDER()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\QuestControls.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\QuestControls_ScenariosList.BSF
:::: 3 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)
::::   UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)

// Uses WorkStrings 0 to 4
UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\QuestControls_ScenariosList.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\ScenEd.bsf
:::: 6 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   ScenEd_SetUI()
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   UI_OBJ_DEACTIVATE()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

ScenEd_SetUI()

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

UI_OBJ_DEACTIVATE()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\ScenEd.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\ScenedGenerals.BSF
:::: 7 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER()
::::   ScenedGenerals_SetUpUI()
::::   ScenedGeneralsPopulateGeneralsListBox()
::::   ScenedGeneralsPopulateGeneralsNamesListBox()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER()

ScenedGenerals_SetUpUI()

ScenedGeneralsPopulateGeneralsListBox()

ScenedGeneralsPopulateGeneralsNamesListBox()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\ScenedGenerals.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\ScenedUnitNames.BSF
:::: 7 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER()
::::   ScenedUnitNames_SetUpUI()
::::   ScenedUnitNamesPopulateUnitsListBox()
::::   ScenedUnitNamesPopulateNamesListBox()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER()

ScenedUnitNames_SetUpUI()

ScenedUnitNamesPopulateUnitsListBox()

ScenedUnitNamesPopulateNamesListBox()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\ScenedUnitNames.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\ShowInfo.BSF
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   ShowInfo_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

ShowInfo_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\ShowInfo.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\ShowTip.BSF
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   ShowTip_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

ShowTip_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\ShowTip.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\Skirmish.bsf
:::: 6 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   SkirmishHideAll()
::::   SetMapSizeButtonVisibility()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Uses workstrings 0 and 1
UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

// Hides all right hand side items
SkirmishHideAll()

SetMapSizeButtonVisibility()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\Skirmish.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Core\UI\SystemMenu.BSF
:::: 4 functions
::::   UI_OBJ_RENDER(x,y,width,height,pass)
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x,y,width,height,pass)

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Core\UI\SystemMenu.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\$DEFAULT.BSF
:::: no functions declared
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Assault.BSF
:::: 8 functions
::::   UNIT_ASSAULT(me, unit, pursuit)
::::   CHECK_UNIT_ASSAULT(me, unit)
::::   UISETUP_UNIT_ASSAULT(me, tilex, tiley)
::::   UIBUTTON_UNIT_ASSAULT(me, x,y,width, height, tilex, tiley)
::::   DoEvadeAndPursuit(me, enemy, adjacent_X, adjacent_Y)
::::   ResolveAssault(me, enemy, evaded, already_routed, pursuit)
::::   SetAssaultString(me, enemy, linefeed)
::::   FlankRearPopUp(unit, morale_state)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// basic assault functionality
UNIT_ASSAULT(me, unit, pursuit)

CHECK_UNIT_ASSAULT(me, unit)

UISETUP_UNIT_ASSAULT(me, tilex, tiley)

UIBUTTON_UNIT_ASSAULT(me, x,y,width, height, tilex, tiley)

// Checks whether unit should evade, performs evade and enemy pursuit
// Returns 0 if unit did not evade, 1 if unit evaded but was caught, 2 if unit successfully outdistanced pursuit
DoEvadeAndPursuit(me, enemy, adjacent_X, adjacent_Y)

ResolveAssault(me, enemy, evaded, already_routed, pursuit)

SetAssaultString(me, enemy, linefeed)

// Helper function for Tutorial Mode
FlankRearPopUp(unit, morale_state)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Assault.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Callbacks.BSF
:::: 21 functions
::::   MOVE_SHOW_CALLBACK(me, ap)
::::   MOVE_SHOW_TILE_CALLBACK(me, tilex, tiley, 0)
::::   KILL_CALLBACK(id, side)
::::   FLAG_TILES_CALLBACK(me)
::::   DRAW_UNIT_TILE_CALLBACK(me)
::::   ShowFacingIndicator(x, y, facing, char colourstring[32])
::::   ShowShootableIndicator(me)
::::   ShowChargeableIndicator(me)
::::   FORMATION_CALLBACK(me)
::::   SetFormationRowXYExtended(n, x, y)
::::   AdjustFormationRowXY(n, dx, dy, diagonal)
::::   CUSTOM_UNIT_ANIM_CALLBACK(me, man, flags, currentRand, currentIndex)
::::   ShowZOCs(me)
::::   ShowZOCIndicator(x, y, facing, zoc)
::::   ShowCloseCombatIndicator(x, y, facing)
::::   ShowGroupMovementIndicator(x, y, facing, general, inCommandRange)
::::   ShowFallBacks(me)
::::   ShowFallBackIndicator(x, y, facing)
::::   ShowPassThroughs(me)
::::   ShowPassThroughIndicator(x, y, facing)
::::   DEPLOY_DRAG_CALLBACK(me, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Callback for when we show where a unit can move to. Some movement is blocked because things cannot move
// for other reasons than lack of APs for the terrain cost.  E.g. artillery
// takes in the unit and current AP, returns the real movement AP they can use
MOVE_SHOW_CALLBACK(me, ap)

MOVE_SHOW_TILE_CALLBACK(me, tilex, tiley, 0)

// Callback used when a unit is killed
KILL_CALLBACK(id, side)

// Callback used to update dynamic tile highlighting
FLAG_TILES_CALLBACK(me)

DRAW_UNIT_TILE_CALLBACK(me)

// Helper function for Draw_Unit_Tile_Callback()
ShowFacingIndicator(x, y, facing, char colourstring[32])

// Helper function for Draw_Unit_Tile_Callback()
ShowShootableIndicator(me)

// Helper function for Draw_Unit_Tile_Callback()
ShowChargeableIndicator(me)

// Uses WorkArray 3 to return information from GetFormationMapping(). Need to avoid use of WrokArray 3 elsewhere in the scripts (unless not involving battle mode)
FORMATION_CALLBACK(me)

// Workaround function to store locations of men within unit formation - hopefully we will get GetformationRowX() and GetFormationRowY() functions which will make this unnecessary
SetFormationRowXYExtended(n, x, y)

// Helper function for FORMATION_CALLBACK(). Adjusts position point in unit formation by dx,dy
AdjustFormationRowXY(n, dx, dy, diagonal)

CUSTOM_UNIT_ANIM_CALLBACK(me, man, flags, currentRand, currentIndex)

// Show ZOCs affecting this units movement
ShowZOCs(me)

// Helper function for Draw_Unit_Tile_Callback().
ShowZOCIndicator(x, y, facing, zoc)

// Helper function for Draw_Unit_Tile_Callback()
ShowCloseCombatIndicator(x, y, facing)

// Helper function for Draw_Unit_Tile_Callback()
ShowGroupMovementIndicator(x, y, facing, general, inCommandRange)

ShowFallBacks(me)

// Helper function for Draw_Unit_Tile_Callback().
ShowFallBackIndicator(x, y, facing)

ShowPassThroughs(me)

// Helper function for Draw_Unit_Tile_Callback().
ShowPassThroughIndicator(x, y, facing)

DEPLOY_DRAG_CALLBACK(me, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Callbacks.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\CloseCombatLogic.BSF
:::: 14 functions
::::   ResolveCloseCombat(me, enemy, phase, flank_rear_severity, test, index, pursuit, notional_turn)
::::   FinaliseCombatResolution(me, enemy, loser, phase, meDamageInflicted, enemyDamageInflicted, notional_turn)
::::   ImmediateConsequences(me, enemy, loser, phase)
::::   ModifiedCloseCombatDamage(me, enemy, EffectiveSize, POA, moraleModifier, attacking, test)
::::   ResolveMelees(me)
::::   CheckBreakOff(me, enemy, loser, notional_turn)
::::   MoveBreakOff(me, x, y, direction)
::::   MoveFollowUp(follower, x, y)
::::   PursuitPopUp(unit)
::::   BreakOffPopUp(unit)
::::   PushBackPopUp(unit)
::::   HighlightCombatants(x1,y1,x2,y2)
::::   ShowCloseCombatReportPopup(stringIndex)
::::   CheckFollowUp(me, enemy, enemyCurrentX, enemyCurrentY, enemyNewX, enemyNewY)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// phase = 0 is impact, 1 = melee - If impact then assume unit me is charging.
// If test == 1 then no damage or other effects applied, and prints strings to UI string immediately rather than via a VizQ call.
// index is the index for PrintWinDrawLoseString() - needed to stop it recalculating constantly when displaying melee tooltip for unit that is fighting more than one enemy unit.
// Aborts if the units are no longer adjacent by the time it is processed.
// pursuit == 1 when this is a pursuit charge impact.
// Flank_rear_severity == 1 for lesser effect flank attack, 2 for lesser effect rear attack, 3 for full effect flank or rear attack
// Notional turn is the turn in which the combat takes place. Melees resolved in the melee phase belong to the previous turn. (Pursuit impacts belong to the current turn).
ResolveCloseCombat(me, enemy, phase, flank_rear_severity, test, index, pursuit, notional_turn)

// Helper function for last part of ResolveCloseCombat(), to avoid duplicating code
FinaliseCombatResolution(me, enemy, loser, phase, meDamageInflicted, enemyDamageInflicted, notional_turn)

// Check for immediate effects if unit breaks - routs, pursuits and proximity morale tests (including those for general deaths).
ImmediateConsequences(me, enemy, loser, phase)

// Returns close combat damage factor. test == 1 if only testing - in which case return value is not randomized.
ModifiedCloseCombatDamage(me, enemy, EffectiveSize, POA, moraleModifier, attacking, test)

// Do all melees for unit
ResolveMelees(me)

// Checks whether unit wants to and is able to break off and performs break off if so.
CheckBreakOff(me, enemy, loser, notional_turn)

// Helper function for CheckBreakOff. Checks that route has not been blocked while break off was in VizQ before activating the move. Note that unit will still have broken off from combat even if it does not move.
// Also moves any follower-up - currently the only troops who follow up are shock foot following up foot, so will always only be one square.
MoveBreakOff(me, x, y, direction)

// Helper function for CheckBreakOff. Moves follower up. (Nothing should happen if breaker off failed to move because move blocked).
MoveFollowUp(follower, x, y)

// Helper function for Tutorial Mode
PursuitPopUp(unit)

// Helper function for Tutorial Mode
BreakOffPopUp(unit)

// Helper function for Tutorial Mode
PushBackPopUp(unit)

// Helper function for ResolveCloseCombat()
HighlightCombatants(x1,y1,x2,y2)

// Show UI popup with UI string. Note that camera should be centred by calling function.
// (Not done in this function to avoid duplication resulting in camera hopping about)
ShowCloseCombatReportPopup(stringIndex)

// Returns id of following up unit, if any, otherwise -1.
// Removes all other close combats.
// Assumes that foot cannot break off from mounted. Also assumes that follow ups will only apply vs troops that fall back only 1 square.
// Currently only shock foot follow up, and not if they would be severely disordered in the new position
// - either by following up into severely disordering terrain, or fighting the enemy unit that has fallen back into severely disordering terrain.
CheckFollowUp(me, enemy, enemyCurrentX, enemyCurrentY, enemyNewX, enemyNewY)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\CloseCombatLogic.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\FallBack.BSF
:::: 4 functions
::::   ALL_FALLBACK(me, tilex, tiley)
::::   CHECK_ALL_FALLBACK(me, tilex, tiley)
::::   UISETUP_ALL_FALLBACK(me, tilex, tiley)
::::   UIBUTTON_ALL_FALLBACK(me, x,y,width, height, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Non-light troops fall back facing to front - risk of dropping cohesion if attempt within charge reach of enemy non-light troops
ALL_FALLBACK(me, tilex, tiley)

CHECK_ALL_FALLBACK(me, tilex, tiley)

UISETUP_ALL_FALLBACK(me, tilex, tiley)

UIBUTTON_ALL_FALLBACK(me, x,y,width, height, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\FallBack.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\FightMelee.BSF
:::: 5 functions
::::   ALL_FIGHTMELEE(me, tilex, tiley)
::::   CHECK_ALL_FIGHTMELEE(me, tilex, tiley)
::::   UISETUP_ALL_FIGHTMELEE(me, tilex, tiley)
::::   UIBUTTON_ALL_FIGHTMELEE(me, x,y,width, height, tilex, tiley)
::::   MakeFightMeleeTooltip(me, tilex, tiley, tooltipStr)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ALL_FIGHTMELEE(me, tilex, tiley)

CHECK_ALL_FIGHTMELEE(me, tilex, tiley)

UISETUP_ALL_FIGHTMELEE(me, tilex, tiley)

UIBUTTON_ALL_FIGHTMELEE(me, x,y,width, height, tilex, tiley)

MakeFightMeleeTooltip(me, tilex, tiley, tooltipStr)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\FightMelee.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\FormSquare.BSF
:::: 10 functions
::::   ALL_FORMSQUARE(me, tilex, tiley)
::::   CHECK_ALL_FORMSQUARE(me, tilex, tiley)
::::   DEPLOYCHECK_ALL_FORMSQUARE(me, tilex, tiley)
::::   UISETUP_ALL_FORMSQUARE(me, tilex, tiley)
::::   UIBUTTON_ALL_FORMSQUARE(me, x,y,width, height, tilex, tiley)
::::   ALL_LEAVESQUARE(me, tilex, tiley)
::::   CHECK_ALL_LEAVESQUARE(me, tilex, tiley)
::::   DEPLOYCHECK_ALL_LEAVESQUARE(me, tilex, tiley)
::::   UISETUP_ALL_LEAVESQUARE(me, tilex, tiley)
::::   UIBUTTON_ALL_LEAVESQUARE(me, x,y,width, height, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ALL_FORMSQUARE(me, tilex, tiley)

CHECK_ALL_FORMSQUARE(me, tilex, tiley)

DEPLOYCHECK_ALL_FORMSQUARE(me, tilex, tiley)

UISETUP_ALL_FORMSQUARE(me, tilex, tiley)

UIBUTTON_ALL_FORMSQUARE(me, x,y,width, height, tilex, tiley)

ALL_LEAVESQUARE(me, tilex, tiley)

CHECK_ALL_LEAVESQUARE(me, tilex, tiley)

DEPLOYCHECK_ALL_LEAVESQUARE(me, tilex, tiley)

UISETUP_ALL_LEAVESQUARE(me, tilex, tiley)

UIBUTTON_ALL_LEAVESQUARE(me, x,y,width, height, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\FormSquare.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Helpers.bsf
:::: 5 functions
::::   HELPER_TERRAIN_TOOLTIP(side, terrain, terrainString, tilex, tiley)
::::   HELPER_TILE_TOOLTIP(terrain, tilex, tiley, side)
::::   HELPER_UNIT_EDITOR_TOOLTIP(id, unit)
::::   HELPER_UNIT_TOOLTIP(side, unit, tilex, tiley)
::::   HELPER_SELECT_UNIT_CALLBACK()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

HELPER_TERRAIN_TOOLTIP(side, terrain, terrainString, tilex, tiley)

//  If we want to give more info for a tile, just put it into the UI string
HELPER_TILE_TOOLTIP(terrain, tilex, tiley, side)

// Makes tooltip for editor unit list. id is the unit type stringIndex, unit is the unit typeIndex
HELPER_UNIT_EDITOR_TOOLTIP(id, unit)

HELPER_UNIT_TOOLTIP(side, unit, tilex, tiley)

HELPER_SELECT_UNIT_CALLBACK()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Helpers.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Init.BSF
:::: 1 functions
::::   INIT_UnitData(me)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

INIT_UnitData(me)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Init.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\keys.bsf
:::: 2 functions
::::   KEYBOARD_LOS(me, key)
::::   KEYBOARD_DEBUG(me, key)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

KEYBOARD_LOS(me, key)

KEYBOARD_DEBUG(me, key)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\keys.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Load.BSF
:::: 6 functions
::::   ALL_UNLOAD(me, tilex, tiley)
::::   CHECK_ALL_UNLOAD(me, tilex, tiley)
::::   DEPLOYCHECK_ALL_UNLOAD(me, tilex, tiley)
::::   UISETUP_ALL_UNLOAD(me, tilex, tiley)
::::   UIBUTTON_ALL_UNLOAD(me, x,y,width, height, tilex, tiley)
::::   UIBUTTON_ALL_LIMBER(me, x,y, width, height, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ALL_UNLOAD(me, tilex, tiley)

CHECK_ALL_UNLOAD(me, tilex, tiley)

DEPLOYCHECK_ALL_UNLOAD(me, tilex, tiley)

UISETUP_ALL_UNLOAD(me, tilex, tiley)

UIBUTTON_ALL_UNLOAD(me, x,y,width, height, tilex, tiley)

UIBUTTON_ALL_LIMBER(me, x,y, width, height, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Load.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\MapGenerate.BSF
:::: 10 functions
::::   RandomMap_Build(type, style, cosmeticBytes, scenarioLimitAndType, date, army0, army1, fixed0, select0, fixed1, select1, custom)
::::   RandomMap_ForcePoints(scenario, forceSize, points0, points1, forceSelect, vsAI, army0, army1)
::::   ClearMap(style, group)
::::   ClearTile(x, y)
::::   RM_Abs(x)
::::   AddFromArmyList(side, army, points, scenarioType, auto)
::::   ReadArmyList(side, army, points, loadArmy)
::::   OldReadArmyList(side, army, points, loadArmy)
::::   AddUnitsToMap(side, num)
::::   RandomMap_MapSize(mapSize, width, height, type, points0, points1, scenarioType)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

RandomMap_Build(type, style, cosmeticBytes, scenarioLimitAndType, date, army0, army1, fixed0, select0, fixed1, select1, custom)

RandomMap_ForcePoints(scenario, forceSize, points0, points1, forceSelect, vsAI, army0, army1)

ClearMap(style, group)

ClearTile(x, y)

RM_Abs(x)

AddFromArmyList(side, army, points, scenarioType, auto)

ReadArmyList(side, army, points, loadArmy)

OldReadArmyList(side, army, points, loadArmy)

// Add units to map. Note that these are in the border because we don't want to see them until AutoDeploy() has put them in a sensible formation.
AddUnitsToMap(side, num)

RandomMap_MapSize(mapSize, width, height, type, points0, points1, scenarioType)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\MapGenerate.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\MapGenerateBattle.BSF
:::: 31 functions
::::   GenerateBattleMap(style, fortification, open, damage, scenarioType, region, terrain)
::::   BM_Blob(x, y, r, data)
::::   BM_PopulateFromTileData(region, terrain, style, fortification, damage)
::::   BM_InterestPoint(style, region, x, y, width, height, index, data, terrain)
::::   BM_RemoveSurplusTracks()
::::   BM_RouteStream(style, mid)
::::   BM_PlaceHedgerow(x, y, orientation, style, region, data)
::::   BM_PlaceRandomTree(x,y, style)
::::   BM_PlaceVillages(style, total_villages)
::::   BM_DrawForestEdge(style)
::::   BM_PlaceForestEdge(x, y, orientation, style, addextra)
::::   BM_Clear_Border(style)
::::   BM_PlaceCropTile(x, y, style, type, rotation)
::::   BM_PlaceHalfCropTile(x, y, style, type, rotation, furrow_rotation)
::::   BM_GetTileDataX(x, y, index)
::::   BM_GetTileDataY(x, y, index)
::::   BM_PlaceMarshes(style)
::::   BM_Connect(style, indexA, indexB, data)
::::   BM_RemoveVestigialTerrain()
::::   BM_DrawHedgerows(style, region)
::::   BM_IsField(x,y)
::::   BM_DrawPartialFields(style, region)
::::   BM_RouteRiver(style)
::::   BM_AddCoast()
::::   BM_FinaliseCoast()
::::   BM_PlaceRiverOverlays(style)
::::   BM_SmoothStreamMouths()
::::   PlaceNonOpenTerrainHillEdging(x, y, style, terrainString, autoedge)
::::   BM_PlaceRoughTerrainVegetation(x, y, style, hill)
::::   BM_KeepMountainsBack()
::::   BM_PlaceDoubleOutsideWaterEdge(x, y, style)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

GenerateBattleMap(style, fortification, open, damage, scenarioType, region, terrain)

BM_Blob(x, y, r, data)

BM_PopulateFromTileData(region, terrain, style, fortification, damage)

BM_InterestPoint(style, region, x, y, width, height, index, data, terrain)

// Removes surplus track connections
BM_RemoveSurplusTracks()

BM_RouteStream(style, mid)

// Orientation 0 = facing up y-axis, 1 = facing up x-axis, 2 = facing down y-axis, 3 = facing down x-axis.
BM_PlaceHedgerow(x, y, orientation, style, region, data)

// Place random single tree.
BM_PlaceRandomTree(x,y, style)

BM_PlaceVillages(style, total_villages)

// Draws forest edge
BM_DrawForestEdge(style)

// Orientation 0 = facing up y-axis, 1 = facing up x-axis, 2 = facing down y-axis, 3 = facing down x-axis.
BM_PlaceForestEdge(x, y, orientation, style, addextra)

BM_Clear_Border(style)

// Type = 0 is no crop
BM_PlaceCropTile(x, y, style, type, rotation)

// Type = 0 is no crop
BM_PlaceHalfCropTile(x, y, style, type, rotation, furrow_rotation)

// Helper function for BM_PopulateFromTileData. Returns -1 if tile is off the playable map.
BM_GetTileDataX(x, y, index)

BM_GetTileDataY(x, y, index)

BM_PlaceMarshes(style)

BM_Connect(style, indexA, indexB, data)

// Removes vestigial marshes and lakes - needs to be done prior to drawing streams.
BM_RemoveVestigialTerrain()

BM_DrawHedgerows(style, region)

// Helper function
BM_IsField(x,y)

// Draw partial fields adjacent to roads
BM_DrawPartialFields(style, region)

BM_RouteRiver(style)

// Adds coastline to one flank of map. 1 = high x, 2 = low x
BM_AddCoast()

// Find most medial point of sea, and convert sea data (18) to water (4) so that any adjoining lakes get incorporated.
BM_FinaliseCoast()

BM_PlaceRiverOverlays(style)

// Attempts to make autoedging work for stream mouths into coast.
BM_SmoothStreamMouths()

// Uses first three work arrays
PlaceNonOpenTerrainHillEdging(x, y, style, terrainString, autoedge)

BM_PlaceRoughTerrainVegetation(x, y, style, hill)

// Keep mountains away from roads, villages, rivers and streams
BM_KeepMountainsBack()

BM_PlaceDoubleOutsideWaterEdge(x, y, style)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\MapGenerateBattle.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Move.BSF
:::: 7 functions
::::   ALL_Move(me, tilex, tiley)
::::   CHECK_ALL_MOVE(me, tilex, tiley, force, noSingleClick)
::::   DEPLOYCHECK_ALL_MOVE(me, unit, tilex, tiley)
::::   MakeMoveTooltip(me, tilex, tiley, cost, tooltipStr)
::::   UISETUP_ALL_MOVE(me, tilex, tiley)
::::   UIBUTTON_ALL_MOVE(me, x,y,width, height, tilex, tiley)
::::   CheckDeploymentStandard(me, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// basic move functionality
ALL_Move(me, tilex, tiley)

CHECK_ALL_MOVE(me, tilex, tiley, force, noSingleClick)

// deployment via the UI
DEPLOYCHECK_ALL_MOVE(me, unit, tilex, tiley)

MakeMoveTooltip(me, tilex, tiley, cost, tooltipStr)

UISETUP_ALL_MOVE(me, tilex, tiley)

UIBUTTON_ALL_MOVE(me, x,y,width, height, tilex, tiley)

// Checks whether deployment square is legal using standard deployment rules. Returns 0 if legal, -1 if illegal.
CheckDeploymentStandard(me, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Move.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Move_Command.BSF
:::: 6 functions
::::   ALL_Move_Command(me, tilex, tiley)
::::   CHECK_ALL_Move_Command(me, tilex, tiley, force, noSingleClick)
::::   DEPLOYCHECK_ALL_Move_Command(me, unit, tilex, tiley)
::::   MakeMoveCommandTooltip(me, tilex, tiley, cost, tooltipStr)
::::   UISETUP_ALL_Move_Command(me, tilex, tiley)
::::   UIBUTTON_ALL_Move_Command(me, x,y,width, height, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// basic move functionality.
ALL_Move_Command(me, tilex, tiley)

CHECK_ALL_Move_Command(me, tilex, tiley, force, noSingleClick)

// deployment via the UI
DEPLOYCHECK_ALL_Move_Command(me, unit, tilex, tiley)

MakeMoveCommandTooltip(me, tilex, tiley, cost, tooltipStr)

UISETUP_ALL_Move_Command(me, tilex, tiley)

UIBUTTON_ALL_Move_Command(me, x,y,width, height, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Move_Command.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Move_General.BSF
:::: 5 functions
::::   ALL_MOVE_GENERAL(me, tilex, tiley)
::::   CHECK_ALL_MOVE_GENERAL(me, tilex, tiley)
::::   DEPLOYCHECK_ALL_MOVE_GENERAL(me, tilex, tiley)
::::   UISETUP_ALL_MOVE_GENERAL(me, tilex, tiley)
::::   UIBUTTON_ALL_MOVE_GENERAL(me, x,y,width, height, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ALL_MOVE_GENERAL(me, tilex, tiley)

CHECK_ALL_MOVE_GENERAL(me, tilex, tiley)

DEPLOYCHECK_ALL_MOVE_GENERAL(me, tilex, tiley)

UISETUP_ALL_MOVE_GENERAL(me, tilex, tiley)

UIBUTTON_ALL_MOVE_GENERAL(me, x,y,width, height, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Move_General.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\MultiBattleCampaign.bsf
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   MPSHideAll()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Uses workstrings 0 and 1
UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

// Hides all right hand side items
MPSHideAll()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\MultiBattleCampaign.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\PassThrough.BSF
:::: 5 functions
::::   ALL_PassThrough(me, tilex, tiley)
::::   CHECK_ALL_PASSTHROUGH(me, tilex, tiley, force, noSingleClick)
::::   MakePassThroughTooltip(me, tilex, tiley, cost, tooltipStr)
::::   UISETUP_ALL_PassThrough(me, tilex, tiley)
::::   UIBUTTON_ALL_PassThrough(me, x,y,width, height, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// basic pass through functionality
ALL_PassThrough(me, tilex, tiley)

CHECK_ALL_PASSTHROUGH(me, tilex, tiley, force, noSingleClick)

MakePassThroughTooltip(me, tilex, tiley, cost, tooltipStr)

UISETUP_ALL_PassThrough(me, tilex, tiley)

UIBUTTON_ALL_PassThrough(me, x,y,width, height, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\PassThrough.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\QuickBattles.bsf
:::: 6 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)
::::   UI_OBJ_RENDER()
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE()
::::   CampDispHideAll()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)

UI_OBJ_RENDER()

UI_OBJ_INIT()

UI_OBJ_ACTIVATE()

// Hide all the right-hand side stuff
CampDispHideAll()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\QuickBattles.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Shooting.BSF
:::: 6 functions
::::   SetShootingString(me, tilex, tiley, volley, terrainLOSClear, unitBlocksLOS)
::::   UISETUP_Unit_Shoot(me, tilex, tiley)
::::   UIBUTTON_Unit_Shoot(me, x,y,width, height, tilex, tiley)
::::   Unit_Shoot(me, unit)
::::   CHECK_Unit_Shoot(me, unit, tilex, tiley, reaction, doNotSetIcons)
::::   REACT_Unit_Shoot(me, unit)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// terrainBlocksLOS, unitBlocksLOS passed as parameter to avoid redoing those checks
// Note that the values of these two parameters will be 0 and meaningless when called from Check_Unit_Shoot if out of range, because the tests will have been skipped.
SetShootingString(me, tilex, tiley, volley, terrainLOSClear, unitBlocksLOS)

UISETUP_Unit_Shoot(me, tilex, tiley)

UIBUTTON_Unit_Shoot(me, x,y,width, height, tilex, tiley)

// The basic shooting functionality. Reaction shooting no longer occurs but has not been removed from the scripts to avoid breaking anything.
Unit_Shoot(me, unit)

// Because we are limited to 6 parametera in order for CallUnitFunctionDirect() to work with this function, doNotSetIcons also used to decide whether to set tooltip
CHECK_Unit_Shoot(me, unit, tilex, tiley, reaction, doNotSetIcons)

// This currently gets called when AI units move because SetRouteWithCostWithThreat(id, x, y, cost, threatMapIndex, [reverse], [minMove]) currently has no way to turn reaction shooting off.
// Also shooting current sets unit for reaction.
// -1 means don't even consider firing
REACT_Unit_Shoot(me, unit)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Shooting.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Shooting_Logic.BSF
:::: 2 functions
::::   CalculateShootingAttack(me, unit, x, y, volley, reaction) // volley = 1 left volley, 2 right volley, 3 both volleys
::::   CalculateShootingDamage(me, target, volley, test, print, reaction)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// work out whether the shooting attack worked.
CalculateShootingAttack(me, unit, x, y, volley, reaction) // volley = 1 left volley, 2 right volley, 3 both volleys

// returns the damage done
CalculateShootingDamage(me, target, volley, test, print, reaction)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Shooting_Logic.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Slith_RandomMap2.BSF
:::: 23 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   PLUGIN_TICK()
::::   PLUGIN_INIT()
::::   SetUIStrings()
::::   StartTurn(side)
::::   StartTurnPost(side)
::::   ConcealEnemyDeployment(side)
::::   IsValidSkirmishMapType(n)
::::   CustomiseUnits()
::::   PrintScenarioUI()
::::   RM_VictoryConditions()
::::   Tick(side)
::::   RM_StartTurnShell1(side)
::::   RM_StartTurnShell2(side)
::::   RM_StartTurnShell3(side)
::::   RM_StartTurnShell4(side)
::::   RM_StartTurnShell5(side)
::::   RM_StartTurnShell6(side)
::::   RM_StartTurnFinal(side)
::::   PostLOSActions()
::::   RM_GetDeploymentType(side)
::::   SKIRMISH_NEW_CAMPAIGN_CALLBACK()
::::   GetArmyListNameStringIDs()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

PLUGIN_TICK()

PLUGIN_INIT()

SetUIStrings()

StartTurn(side)

StartTurnPost(side)

// Conceal the enemy deployment area. side is the viewing side. Call from PostLOSActions so that LOS has been updated first.
ConcealEnemyDeployment(side)

IsValidSkirmishMapType(n)

CustomiseUnits()

PrintScenarioUI()

RM_VictoryConditions()

Tick(side)

// This and the other associated Shell functions are to allow all (most of) the pursuits and pursuit impacts etc. to be shown
// before the victory conditions.
RM_StartTurnShell1(side)

RM_StartTurnShell2(side)

RM_StartTurnShell3(side)

RM_StartTurnShell4(side)

RM_StartTurnShell5(side)

RM_StartTurnShell6(side)

RM_StartTurnFinal(side)

// Note that (like other Slith_RandomMap.BSF standard functions) this gets run in non-skirmish games, so we are using it as the core PostLOSActions() function.
PostLOSActions()

// Gets Deployment type of army from ArmyList.txt. Returns deployment type:
// 0 = Hellenistic, 1 = Roman, 2 = Skythian. -1 means type not found.
RM_GetDeploymentType(side)

// Callback used when skirmish campaign is changed. This has to be included in Slith_RandomMap.BSF in order to work.
SKIRMISH_NEW_CAMPAIGN_CALLBACK()

// Uses Work Strings 0 and 1
GetArmyListNameStringIDs()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Slith_RandomMap2.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\StartTurn.BSF
:::: 14 functions
::::   StartTurn(me)
::::   StartTurnMoraleUpdate(me, lastTurnShootingDamage)
::::   StartTurnCloseCombatUpdate(me)
::::   StartTurnShootingUpdate(me)
::::   CheckReturnToBattlefield(me)
::::   ShowStartTurnPopUp(side)
::::   StartTurnShell1(side)
::::   StartTurnShell2(side)
::::   StartTurnShell3(side)
::::   StartTurnShell4(side)
::::   StartTurnShell5(side)
::::   StartTurnShell6(side)
::::   StartTurnFinal(side)
::::   StartTurnPostFinal(side)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// default functionality for starting a turn
StartTurn(me)

// Morale related Start of Turn stuff - separated off for clarity
StartTurnMoraleUpdate(me, lastTurnShootingDamage)

// Melees and all other close combat related Start of Turn stuff
StartTurnCloseCombatUpdate(me)

// Shooting related Start of Turn stuff
StartTurnShootingUpdate(me)

// Check to see if unit is pursuing/evaded off playable area and if so, test to see if it returns
CheckReturnToBattlefield(me)

// Show start turn pop up
ShowStartTurnPopUp(side)

// This and the other associated Shell functions are to allow all the pursuits and pursuit impacts etc. to be shown
// before the victory conditions, StartTurnPost scenario stuff and StartTurn Popop.
StartTurnShell1(side)

StartTurnShell2(side)

StartTurnShell3(side)

StartTurnShell4(side)

StartTurnShell5(side)

StartTurnShell6(side)

StartTurnFinal(side)

// Needs to run after PlayOn UI has been run in victory conditions and EndBattle possible performed by CheckBattleEnded().
StartTurnPostFinal(side)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\StartTurn.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Switch_Command.BSF
:::: 6 functions
::::   ALL_SWITCH_COMMAND(me, tilex, tiley)
::::   CHECK_ALL_SWITCH_COMMAND(me, tilex, tiley)
::::   DEPLOYCHECK_ALL_SWITCH_COMMAND(me, tilex, tiley)
::::   UISETUP_ALL_SWITCH_COMMAND(me, tilex, tiley)
::::   UIBUTTON_ALL_SWITCH_COMMAND(me, x,y,width, height, tilex, tiley)
::::   SetSwitchCommandString(me, tilex, tiley, ret)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ALL_SWITCH_COMMAND(me, tilex, tiley)

CHECK_ALL_SWITCH_COMMAND(me, tilex, tiley)

DEPLOYCHECK_ALL_SWITCH_COMMAND(me, tilex, tiley)

UISETUP_ALL_SWITCH_COMMAND(me, tilex, tiley)

UIBUTTON_ALL_SWITCH_COMMAND(me, x,y,width, height, tilex, tiley)

SetSwitchCommandString(me, tilex, tiley, ret)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Switch_Command.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\trigger.bsf
:::: 1 functions
::::   CUSTOM_TRIGGER(me, man, a, b, c)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Custom trigger function for projectile animations
// called through the animation TXT file scripts
// a = 0 is shooting, a = 1 is impact
CUSTOM_TRIGGER(me, man, a, b, c)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\trigger.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Turn.BSF
:::: 6 functions
::::   ALL_TURN(me, tilex, tiley)
::::   DEPLOYCHECK_ALL_TURN(me, tilex, tiley)
::::   CHECK_ALL_TURN(me, tilex, tiley, hideTooltip)
::::   UISETUP_ALL_TURN(me, tilex, tiley)
::::   UIBUTTON_ALL_TURN(me, x,y,width, height, tilex, tiley)
::::   PriorityPreventsTurn(me, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// basic move functionality
ALL_TURN(me, tilex, tiley)

DEPLOYCHECK_ALL_TURN(me, tilex, tiley)

CHECK_ALL_TURN(me, tilex, tiley, hideTooltip)

UISETUP_ALL_TURN(me, tilex, tiley)

UIBUTTON_ALL_TURN(me, x,y,width, height, tilex, tiley)

// Helper function for CHECK_ALL_TURN() and UISETUP_ALL_TURN()
// Returns -1 if there is no priority target that would prevent turn, otherwise id of unit that prevents turn
PriorityPreventsTurn(me, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Turn.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\TurnAndShoot.BSF
:::: 6 functions
::::   SetTurnAndShootString(me, tilex, tiley)
::::   UISETUP_Unit_TurnAndShoot(me, tilex, tiley)
::::   UIBUTTON_Unit_TurnAndShoot(me, x,y,width, height, tilex, tiley)
::::   UNIT_TURNANDSHOOT(me, unit)
::::   CHECK_Unit_TurnAndShoot(me, unit, tilex, tiley, reaction, doNotSetIcons)
::::   REACT_Unit_TurnAndShoot(me, unit)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// terrainBlocksLOS, unitBlocksLOS passed as parameter to avoid redoing those checks
// Note that the values of these two parameters will be 0 and meaningless when called from Check_Unit_Shoot if out of range, because the tests will have been skipped.
SetTurnAndShootString(me, tilex, tiley)

UISETUP_Unit_TurnAndShoot(me, tilex, tiley)

UIBUTTON_Unit_TurnAndShoot(me, x,y,width, height, tilex, tiley)

// The basic TurnAndShooting functionality. Reaction shooting no longer occurs but has not been removed from the scripts to avoid breaking anything.
UNIT_TURNANDSHOOT(me, unit)

CHECK_Unit_TurnAndShoot(me, unit, tilex, tiley, reaction, doNotSetIcons)

// This currently gets called when AI units move because SetRouteWithCostWithThreat(id, x, y, cost, threatMapIndex, [reverse], [minMove]) currently has no way to turn reaction shooting off.
// Also shooting current sets unit for reaction.
// -1 means don't even consider firing
REACT_Unit_TurnAndShoot(me, unit)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\TurnAndShoot.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Turn_Command.BSF
:::: 6 functions
::::   ALL_TURN_COMMAND(me, tilex, tiley)
::::   DEPLOYCHECK_ALL_TURN_COMMAND(me, tilex, tiley)
::::   CHECK_ALL_TURN_COMMAND(me, tilex, tiley)
::::   UISETUP_ALL_TURN_COMMAND(me, tilex, tiley)
::::   UIBUTTON_ALL_TURN_COMMAND(me, x,y,width, height, tilex, tiley)
::::   Turn_Individual_Unit(me, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// basic move functionality
ALL_TURN_COMMAND(me, tilex, tiley)

DEPLOYCHECK_ALL_TURN_COMMAND(me, tilex, tiley)

CHECK_ALL_TURN_COMMAND(me, tilex, tiley)

UISETUP_ALL_TURN_COMMAND(me, tilex, tiley)

UIBUTTON_ALL_TURN_COMMAND(me, x,y,width, height, tilex, tiley)

Turn_Individual_Unit(me, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Turn_Command.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\UI.BSF
:::: 4 functions
::::   DrawSelectedUI(me)
::::   DrawTargetUI(me, target)
::::   DrawUnitBattleUIStrings(me, char string[32])
::::   SetBattleUIBannerTexture(me, char string[32])
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// UI function to draw the panel for a selected unit
// Uses Work Strings 0 and 1
DrawSelectedUI(me)

DrawTargetUI(me, target)

// Print the text for DrawSelectedUI() and DrawTargetUI()
// Uses Work String 0
DrawUnitBattleUIStrings(me, char string[32])

SetBattleUIBannerTexture(me, char string[32])

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\UI.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\Battle\Scripts\Undo.BSF
:::: 7 functions
::::   ALL_UNDO(me, tilex, tiley)
::::   CHECK_ALL_UNDO(me, tilex, tiley, force, noSingleClick)
::::   DEPLOYCHECK_ALL_UNDO(me, unit, tilex, tiley)
::::   MakeUndoTooltip(me, tilex, tiley, cost, tooltipStr)
::::   UISETUP_ALL_UNDO(me, tilex, tiley)
::::   UIBUTTON_ALL_UNDO(me, x,y,width, height, tilex, tiley)
::::   UndoIndividualMove(me)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// basic move functionality
ALL_UNDO(me, tilex, tiley)

CHECK_ALL_UNDO(me, tilex, tiley, force, noSingleClick)

// deployment via the UI
DEPLOYCHECK_ALL_UNDO(me, unit, tilex, tiley)

MakeUndoTooltip(me, tilex, tiley, cost, tooltipStr)

UISETUP_ALL_UNDO(me, tilex, tiley)

UIBUTTON_ALL_UNDO(me, x,y,width, height, tilex, tiley)

UndoIndividualMove(me)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\Battle\Scripts\Undo.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\AITools.bsf
:::: 71 functions
::::   AI_GetTeamMovementGrouped(side, team)
::::   AI_GetTeamAvoidEnemy(side, team)
::::   AI_GetTeamIgnoreEnemyUnlessClose(side, team)
::::   AI_GetTeamSeekAndDestroy(side, team)
::::   AI_GetTeamUseThreat(side, team)
::::   AI_GetTeamStayPut(side, team)
::::   AI_GetTeamIgnoreLightTroops(side, team)
::::   AI_GetTeamIgnoreFoot(side, team)
::::   AI_GetTeamIgnoreMounted(side, team)
::::   AI_GetTeamBugOut(side, team)
::::   AI_GetTeamIgnoreArtillery(side, team)
::::   AI_FindBestTarget(side, team, me, target)
::::   AI_GetRangeForTarget(side, team, me, target)
::::   AI_DoShootingAttack(side, team, me, target)
::::   AI_DoAssault(me, target)
::::   AI_SelectDirectFireTarget(me, list)
::::   AI_TargetRating(me, enemy, distance)
::::   GetUnitThreat(me, enemy, distance)
::::   CheckEnemyAdjacent (me)
::::   UpdateAmbushThreat ()
::::   LikesTerrain(me)
::::   GetFlankThreatModifier(me, enemy, test_whether_possible)
::::   EstimateFlankThreat(me, facing, imminent)
::::   AI_WhetherToTurn(me)
::::   GetFacingFromIndex(index)
::::   AI_FindAlternativeShootingTarget(me, reaction)
::::   TargetHidden(target)
::::   PrepareREPQueue(me)
::::   AddToREPQueue(fleer, pursuer)
::::   REPQueueCount(me)
::::   ProcessREPQueue(me, type, ongoing_rout)
::::   StepREPQueue(fleeingUnit, i, fleer_done_index, type, ongoing_rout)
::::   DoUnitNextREPQueueStep(id, fleeingUnit, i, k, type, ongoing_rout, ap)
::::   GetNextRetreatStep(me, enemy, index, type, ongoing_rout)
::::   PursuersRoutesClash(fleeingUnit, i, k, nextX, nextY)
::::   TurntoFaceEvadersRouters(pursuers, fleers)
::::   CheckWhetherPursuerGoesOffTableAnyway(router, pursuer)
::::   ReportFinalPosition(me)
::::   AI_ChanceOfCharging(me, enemy, ignoreFlankThreat)
::::   AI_SetRandomUnitDestination(me)
::::   AI_UnwarrantedShootingRisk(me, x, y, destX, destY)
::::   CheckPursuersSwitchTarget(me, type)
::::   AI_ReassignTeams(side)
::::   GetTeamCount(side, team)
::::   GetTeamActivePoints(side, team)
::::   GetTeamActiveFirepower(side, team)
::::   AI_Masterplan(deadline)
::::   AI_GetDistanceToClosestEnemyUnit(side, team, ignoreLights)
::::   AI_GetClosestDistanceToClosestEnemyUnit(side, team, ignoreLights)
::::   FurthestForwardTeamY(side, team)
::::   SetTeamActivationStage(side, team, stage)
::::   GetTeamActivationStage(side, team)
::::   AI_SwitchToBlockingTarget(me, target)
::::   GetTileTerrainThreat(me, x, y)
::::   MakeThreatMap(side, me, terrainOnly)
::::   TileDefensibility(me, enemy, x, y)
::::   HasCavalryThreat(me)
::::   DoAnyPursuitImpacts(me, oldTarget)
::::   AI_NumberOfEnemySkirmisherUnitsInRange(side, team)
::::   GetTeamActiveX(side, team)
::::   GetTeamActiveY(side, team)
::::   CheckPursuitDiagonalStepNotBlocked(oldX,oldY,newX,newY)
::::   InitialRoutFacing(me, enemy)
::::   AI_TimeToWithdrawPsiloi()
::::   AI_SimpleTeamAdvanceOrders(team, enemy_team, MaxAP, ignoreLights)
::::   AI_SimpleCentreLightFootAdvance(team, own_centre_foot_team, enemy_centre_foot_team, MaxAP)
::::   AI_FormSquare(me)
::::   AI_LeaveSquare(me)
::::   CheckAITeamGroupMove(team)
::::   AI_GetEnemyFrontY()
::::   AI_GetTotalActiveEnemyPoints()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Should the team stick together when it is moving?
AI_GetTeamMovementGrouped(side, team)

// Should the team units try and avoid the enemy?
AI_GetTeamAvoidEnemy(side, team)

// should the team ignore the enemy when they have a destination
AI_GetTeamIgnoreEnemyUnlessClose(side, team)

// should the team seek out enemies if it has no destination or target given
AI_GetTeamSeekAndDestroy(side, team)

// should the team try and work around enemies using the threat map? RBS: Moved here because it is used in some other files and not just in AI.BSF
AI_GetTeamUseThreat(side, team)

// should we all stay in our foxholes?
AI_GetTeamStayPut(side, team)

// should team's non-light troops ignore light troops (unless they are very close)?
AI_GetTeamIgnoreLightTroops(side, team)

// should team try to ignore non-light enemy foot (unless they are very close)?
AI_GetTeamIgnoreFoot(side, team)

// should team try to ignore enemy mounted (unless they are very close)?
AI_GetTeamIgnoreMounted(side, team)

// should light troops team bug out
AI_GetTeamBugOut(side, team)

// should team try to ignore enemy artillery (unless we are close enough to possibly charge them)?
AI_GetTeamIgnoreArtillery(side, team)

// RETURN -1 if no target, otherwise the ID of the target unit.
// takes any current target to see if we are better than it
// works in conjunction with mission scripting, Mission scripting overrides this so static units will not advance and fire.
// called for every unit, multiple times. It gets called every time the AI does something. E.g. If it spots a new unit, if it comes under attack. See AI.bsf for details.
AI_FindBestTarget(side, team, me, target)

// return how close we should try and get to the target before we attack
AI_GetRangeForTarget(side, team, me, target)

// a function which actually does an attack on a target
// returns 1 if shooting attack happened, otherwise returns 0
AI_DoShootingAttack(side, team, me, target)

AI_DoAssault(me, target)

AI_SelectDirectFireTarget(me, list)

// score the suitability of this target
AI_TargetRating(me, enemy, distance)

// AI assess threat of enemy unit
GetUnitThreat(me, enemy, distance)

// Works out if you are adjacent to enemy units and if so how many - used to make AI less like to bombard enemy units next to friendly targets
CheckEnemyAdjacent (me)

// Updates ambush threat map for AI
UpdateAmbushThreat ()

// Returns 1 if unit prefers to be in terrain, 0 if not
LikesTerrain(me)

GetFlankThreatModifier(me, enemy, test_whether_possible)

// For AI use only. Returns hypothetical flank threat rating for unit if it had the specified facing (which does not have to be its actual facing). 0 if no flank threat at all.
// If imminent == 1, ignores flank attacks by light troops on battle troops, and potential flankers that cannot charge on their next turn
// Note: Currently the function is ONLY used with imminent == 1. However, option left for immininent == 0 in case a future use is found for it.
EstimateFlankThreat(me, facing, imminent)

// Determines whether AI unit wants to turn either to avoid flank threats or to maximise shooting vs chosen target.
// Uses work arrays 0, 1 and 2.
AI_WhetherToTurn(me)

// Helper function for AI_WhetherToTurn().
// We want AI to favour directions that are closest to facing enemy lines if all things are otherwise equal
GetFacingFromIndex(index)

// Tries to find an alternative shooting target for use if main target cannot be shot at (because it is outside arc of fire).
// Prioritises by arc of fire and prefers shooting heavies to lights and artillery.
// Returns -1 if no valid target found, otherwise the id of the target.
// If no ideal target can be found, takes the nearest target of any type
AI_FindAlternativeShootingTarget(me, reaction)

// Helper function for AI_FindAlternativeShootingTarget(). Needed because GetTileLOS() is not valid in Start Turn functions. Returns 0 if target is not hidden, 1 if it is
TargetHidden(target)

// REPQueue is used to co-ordinate routers/evaders and their pursuers
// The REPQueue consists of the fleeing unit itself, plus a list of up to 8 pursuers held in the fleeing unit's "REPQueue" AttribArray.
// Initialises fleers REP Queue AttribArray. Index 0 is principal pursuers, Other indices are any additional pursuers.
PrepareREPQueue(me)

// Adds unit to REP Queue.
// Note that the total REP Queue consists of the fleeing unit, plus up to 8 pursuers listed in the fleeing unit's "REPQueue" attrib array
// Note that "AnimSituation" is not set to 6 inside this function, because we don't want it set for troops pursuing evaders.
AddToREPQueue(fleer, pursuer)

// Returns total number of units in REP Queue (including fleer)
REPQueueCount(me)

// Process REP Queue.  me is the fleeing unit. // type == 0: Normal retreat (bugout) - not pursued but can be reaction fired against. type = 1: Rout. type = 2: Evade.
// Units in the queue each move one tile step at a time, in sequence. Each unit in the Queue leads off one step later than the previous one.
// This helps stop the later ones in the queue from catching up with the earlier ones and being blocked from moving.
ProcessREPQueue(me, type, ongoing_rout)

// Perform REP Queue step.
// "FleerDoneIndex" is the step index in which fleer has ALREADY completed move BEFORE that step is made.
// Note that each unit starts its overall move one step after the last, so that they each clear a square before another tries to enter it.
// Otherwise the later unit will (sometimes? always?) have its move blocked by the unit leaving the square.
// This is more or less guaranteed to work for the router/evader and primary pursuer.
// It does not always work for secondary pursuers because they are trying to enter the same square as the primary pursuer.
// However, they will mark time for one step (they still pay the AP for the failed step) and get another chance to move on their next step.
StepREPQueue(fleeingUnit, i, fleer_done_index, type, ongoing_rout)

DoUnitNextREPQueueStep(id, fleeingUnit, i, k, type, ongoing_rout, ap)

// Helper function for DoUnitNextREPQueueStep().
// Gets next retreat step. type 0 is normal move (bug out), type 1 is routers, type 2 is evaders.
GetNextRetreatStep(me, enemy, index, type, ongoing_rout)

// Helper function for DoUnitNextREPQueueStep() - checks pursuers planned next step to make sure it isn't the same as that of any previous pursuers
PursuersRoutesClash(fleeingUnit, i, k, nextX, nextY)

// Turns pursuers to face evaders/routers final position (unless they have changed target)
TurntoFaceEvadersRouters(pursuers, fleers)

CheckWhetherPursuerGoesOffTableAnyway(router, pursuer)

//DEBUG
ReportFinalPosition(me)

AI_ChanceOfCharging(me, enemy, ignoreFlankThreat)

// Get random destination for seek and destroy AI unit if none available
AI_SetRandomUnitDestination(me)

// Check square to see it doesn't present excessive shooting danger to AI unit
// Ignore enemy if they are not close to path of move. Also ignore artillery as it will be necessary to suck up artillery fire in order to advance.
// At presently it is simply designed to stop units without firepower from moving into range of units with firepower that they would not be willing to charge
// But it could be generalised to stop units with firepower from moving closer to units with much greater firepower
// x,y is the route square being tested. destX, destY is the moving unit's preferred destination.
AI_UnwarrantedShootingRisk(me, x, y, destX, destY)

// Test for potential charge target within 45 degrees of streight ahead. Returns -1 if none that they want to charge, unit id if they do.
//  type == 1: Pursuing routers, type == 2: Pursuing evaders.
CheckPursuersSwitchTarget(me, type)

// Reassigns teams to assist in using standardized AI grand tactics. For semi-random single player games.
// Standard teams are 0) Centre light troops, 1) Foot and guns (centre), 2) Left wing cavalry, 3) Right wing cavalry, 4) Reserve/Centre cavalry, 5) Left wing light troops, 6) Right wing light troops
// Left and right are reversed for Side1, so that the opposing wing teams face the same numbered team on the other side.
// 0 is also used to denote unit with team as yet un-reassigned
// Team 7 - immobile artillery
// Does not reassign escort the baggage scenario flank marchers. Note that this would not work correctly, and might affect other units,
// if AI_ReassignTeams(1) was called during a normal turn after the deployment phase of the battle.
// Therefore only AI_ReassignTeams(0) should be called after the start of a battle.
AI_ReassignTeams(side)

// Returns the number of active non-routing on-table units in the team
GetTeamCount(side, team)

// Returns the total points value of active on-table non-routing units in the team - adjusted if enemy (non AI unit) is uphill.
// Takes into account units being understrength. Does not currently take into account quality adjustments.
GetTeamActivePoints(side, team)

// Returns quick estimate of on-table firepower of team. Takes into account units being understrength.
// Does not currently take into account the fact that very large units' firepower degrades slower as they have spare ranks,
// but function is currently only used to estimate firepower of light troops and cavalry.
// Does not currently take into account quality adjustments.
GetTeamActiveFirepower(side, team)

// Attempt to make sensible plan for AI for semi-random single player games
// deadline is turn on which AI infantry centre starts advancing if it did not advance initially. -1 if this is never going to happen
AI_Masterplan(deadline)

// Returns distance from team centre to closest unrouted enemy unit
AI_GetDistanceToClosestEnemyUnit(side, team, ignoreLights)

// Returns distance from any member of team to closest unrouted enemy unit
AI_GetClosestDistanceToClosestEnemyUnit(side, team, ignoreLights)

// Returns furthest forward Y of team (excluding routed units).
FurthestForwardTeamY(side, team)

// Use TeamData index 2 as activation stage flag
SetTeamActivationStage(side, team, stage)

// Returns team activation stage
GetTeamActivationStage(side, team)

// Switch to blocking unit if it blocks route to best target. Ignore routers.
AI_SwitchToBlockingTarget(me, target)

// Returns a terrain threat value for tile x, y for unit me.
GetTileTerrainThreat(me, x, y)

MakeThreatMap(side, me, terrainOnly)

// Function to determine value of tile as a position to remain in vs current target
TileDefensibility(me, enemy, x, y)

// Function to determine whether foot unit lack protective weapons and have non-light cavalry within potential charge reach.
// Currently intended mainly as helper function for TileDefensibility()
// NB: Not suitable as currently written for using as part of Cohesion Test.
HasCavalryThreat(me)

DoAnyPursuitImpacts(me, oldTarget)

// Returns distance from any member of team to closest unrouted enemy unit
AI_NumberOfEnemySkirmisherUnitsInRange(side, team)

// Returns the average X position of on-table non-routing units in the team. Returns 0 if no units in team.
GetTeamActiveX(side, team)

// Returns the average Y position of on-table non-routing units in the team. Returns 0 if no units in team.
GetTeamActiveY(side, team)

// Check pursuit step to make sure that it is not a diagonal step through a close combat or pursuit.
// Returns -2 if not possible, otherwise 0
CheckPursuitDiagonalStepNotBlocked(oldX,oldY,newX,newY)

// Returns initial facing for routing unit (if unit was not in close combat, enemy should be the nearest enemy unit)
InitialRoutFacing(me, enemy)

// Use to determine time to withdraw light foot
AI_TimeToWithdrawPsiloi()

// Set team to advance towards a particular enemy team. MaxAP allows mounted in mixed groups to be kept down to infantry speed until reasonably close to the enemy.
// Should work correctly whether AI is on left or right of map
AI_SimpleTeamAdvanceOrders(team, enemy_team, MaxAP, ignoreLights)

// Set centre light foot team to advance towards a particular enemy team. MaxAP allows advance to be kept down to heavy infantry speed until reasonably close to the enemy.
// Should work correctly whether AI is on left or right of map
// Light foot retreat for a turn when close to enemy foot, then halt for a turn before resuming the advance.
AI_SimpleCentreLightFootAdvance(team, own_centre_foot_team, enemy_centre_foot_team, MaxAP)

// Forms square if the unit is able to do so. Returns 0 if it didn't form square, 1 if it did.
AI_FormSquare(me)

// Leaves square if the unit is able to do so. Returns 0 if it didn't leave square, 1 if it did.
AI_LeaveSquare(me)

// Do AI Group Moves
CheckAITeamGroupMove(team)

// Helper function for AI_Masterplan(). Returns enemy front line Y for determining when wings are past. Only works with standard team sasignments and AI armies the standard way round on the map.
AI_GetEnemyFrontY()

// Helper function for AI_Masterplan()
AI_GetTotalActiveEnemyPoints()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\AITools.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\AnimationTools.bsf
:::: 9 functions
::::   TriggerDifferentialAnimation(me, anim1, anim2, wait, loop)
::::   TriggerMeleeIdleIfInCloseCombat(me)
::::   GetCloseCombatFacingsAndRank(me)
::::   EnemyFightingAtRelativeFacing(me, relativeFacing)
::::   FacingDiagonally(me)
::::   CasualtiesDie(me)
::::   GetDeathMaskManDead(me, man)
::::   EndStepForward(me)
::::   UpdateBannerAnimations()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Use to set different animation for front rank and rear ranks.
TriggerDifferentialAnimation(me, anim1, anim2, wait, loop)

TriggerMeleeIdleIfInCloseCombat(me)

// Calculates close combat facings and puts them in global gFormationManFacing[] array.
GetCloseCombatFacingsAndRank(me)

// Helper function for GetClosecombatFacingsAndRank(). Returns -1 if none, unit id if any.
// relativeFacing is the facing from the unit using the usual facing system but relative to the unit's current facing.
// So directly ahead relativeFacing would be 0, whatever the actual facing of the unit.
EnemyFightingAtRelativeFacing(me, relativeFacing)

// returns 1 if the unit is facing diagonally, otherwise 0
FacingDiagonally(me)

// Removes newly dead men.
// Note, keeps a separate track of the unit's dead men in the "DeathMask" attrib to avoid VizQ issues with multiple calls to CasualtiesDie() before DestroyUnit() gets executed.
CasualtiesDie(me)

// Used instead of GetUnitManDead() in CasualtiesDie(), because CasualtiesDie() can be called more than once before DestroyUnit() is executed. 
// "DeathMask" attrib is used to keep track of men marked as dead before they have been marked as dead by AddVizFunctionCall("DestroyUnit", me, killMask);
GetDeathMaskManDead(me, man)

EndStepForward(me)

// Brute force banner animation update - TEST VERSION
UpdateBannerAnimations()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\AnimationTools.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\CampaignTools.bsf
:::: 57 functions
::::   ReadArmyListForCampaign(side, points1, points2)
::::   GetTotalFixedCost(num)
::::   GetTotalUnfixedCost(num)
::::   PrintArmyListName(side)
::::   GetCampaignUnitExperienceModifier(unitIndex, side)
::::   SetCampaignUnitExperienceModifier(unitIndex, side, modifier)
::::   GetCampaignUnitStrengthModifier(unitIndex, side)
::::   SetCampaignUnitStrengthModifier(unitIndex, side, modifier)
::::   GetCampaignUnitArmy(unitIndex, side)
::::   SetCampaignUnitArmy(unitIndex, side, armyIndex)
::::   GetCampaignUnitElanModifier(unitIndex, side)
::::   SetCampaignUnitElanModifier(unitIndex, side, modifier)
::::   GetCampaignUnitTypeIndex(unitIndex, side)
::::   SetCampaignUnitTypeIndex(unitIndex, side, typeIndex)
::::   AddNewCampaignArmy(side, province, num)
::::   NextCampaignArmy(side)
::::   AddCampaignUnit(side, type, army)
::::   AddArmyToMap(side, province)
::::   ArmiesInProvince(province, side)
::::   StrengthInProvince(province, side)
::::   CombineArmies(province, side, includeBesieged)
::::   StandardCampaignVictoryConditions(breakpoint0a, breakpoint0b, breakpoint1a, breakpoint1b, drawdecider, MPgame)
::::   BattleEndedCallback(winner)
::::   LoadFromState()
::::   SaveToState()
::::   CustomiseCampaignUnits(side)
::::   GetCampaignArmySide(army)
::::   GetCampaignDifficultyModifier()
::::   GetCampaignUnitPointsValue(unitIndex, side)
::::   GetCampaignArmyStrength(army)
::::   GetCampaignArmyListChunkName(side)
::::   AddStringToLog(colour)
::::   PrintArmyName(army, side)
::::   PrintNumberOrderString(number)
::::   PrintNumberOrderStringX(stringIndex, immediate, number)
::::   PrintUnitNameForCampaign(id)
::::   PrintUnitNameForCampaignX(stringIndex, immediate, id)
::::   PrintCampaignUnitName(unitIndex, side)
::::   AssignUnitNumber(unit, unitType, side)
::::   GetCampaignUnitNumber(unitIndex, side)
::::   SetCampaignUnitNumber(unitIndex, side, number)
::::   GetCampaignUnitActive(unitIndex, side)
::::   SetCampaignUnitActive(unitIndex, side, active)
::::   GetCampaignArmyAP(army)
::::   SetCampaignArmyAP(army, AP)
::::   SetTreasury(side, value)
::::   GetTreasury(side)
::::   SetCampaignArmyLastProvince(army, province)
::::   GetCampaignArmyLastProvince(army)
::::   BackupWorkArrays()
::::   RestoreWorkArrays()
::::   GetProvinceOwner(province)
::::   SetProvinceOwner(province, owner)
::::   ConsolidateArmy(army)
::::   GetCampaignArmyFOWModifier(army)
::::   SetCampaignArmyFOWModifier(army, modifier)
::::   GetFOWRandom()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Reads army list into system Array(0) (for use by InitForceControl()) from the ArmyLists.txt file using the "ArmyListChunkIndex" for the side.
// points1 is used to calculate minima.
// points 2 is used to calculate maxima.
// This is used for player army raising so that the mimima are not increased by the extra manpower potentially borrowed from other provinces.
ReadArmyListForCampaign(side, points1, points2)

// Returns the total fixed cost of the units held in system Array(0) as used in InitForceControl() so they can be deducted from the available points.
// num is number of unit types in array.
GetTotalFixedCost(num)

// Returns the total fixed cost of the units held in system Array(0) as used in InitForceControl() so they can be deducted from the available points.
// num is number of unit types in array.
GetTotalUnfixedCost(num)

// Print the name of the army list taken from the ArmyLists.txt file using the "ArmyListChunkIndex" for the side.
PrintArmyListName(side)

// Gets unit experience modifier. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
GetCampaignUnitExperienceModifier(unitIndex, side)

// Sets unit experience modifier. Logs warning if attempt to set it outside the range 0-255. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
SetCampaignUnitExperienceModifier(unitIndex, side, modifier)

// Gets unit quality modifier. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
GetCampaignUnitStrengthModifier(unitIndex, side)

// Sets unit strength modifier. Logs warning if attempt to set it outside the range 0-255. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
SetCampaignUnitStrengthModifier(unitIndex, side, modifier)

// Returns the army that unit belongs to. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
GetCampaignUnitArmy(unitIndex, side)

// Sets army that unit belongs to. Logs warning if attempt to set it outside the range 0-MAX_UNITS-1. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
SetCampaignUnitArmy(unitIndex, side, armyIndex)

// Gets unit elan modifier. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
GetCampaignUnitElanModifier(unitIndex, side)

// Sets unit elan modifier. Logs warning if attempt to set it outside the range 0-255. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
SetCampaignUnitElanModifier(unitIndex, side, modifier)

// Returns campaign unit type index.
GetCampaignUnitTypeIndex(unitIndex, side)

// Sets campaign unit type index.
SetCampaignUnitTypeIndex(unitIndex, side, typeIndex)

// Adds a new campaign army - returns cost in points. The unit information is in the first work array - placed there by GetForceControlState();
AddNewCampaignArmy(side, province, num)

// Find the index number of the next available campaign army (0-MAX_UNITS-1). Returns -1 if no spaces left for more armies.
NextCampaignArmy(side)

// Adds campaign unit to unit array. Returns unit campaign array index if successful, -1 if fails - due to lack of space in array.
// CampaignUnitTypeIndex -1 means unit does not exist, -2 means unit used to exist but has been disbanded or put in garrison.
// Purpose of this is so that unit numbers don't get recycled until (hopefully) a decent interval after unit was destroyed or put into garrison.
AddCampaignUnit(side, type, army)

// Add army from campaign array to skirmish map. (Assumes all units belonging to the side in the province, except besieged troops and the detachment left to hold them, will fight).
// Allows more than 64 units to be added, as of v7.31
AddArmyToMap(side, province)

// Returns the number of armies the side has in the province
ArmiesInProvince(province, side)

// Returns the total strength of armies the side has in the province
StrengthInProvince(province, side)

// Combines all side's troops in a province into one army. Return number of resulting combined army.
// Uses first work array.
CombineArmies(province, side, includeBesieged)

// Standard Victory Conditions function
// If drawdecider == 0 side0 wins draws, drawdecider == 1 side1 wins draws, drawdecider == 2 side who is winning wins draws
// If UniversalVar "MPForceRatio" has been set - see SetMPForceRatio() - it will use the MP adjusted victory conditions
StandardCampaignVictoryConditions(breakpoint0a, breakpoint0b, breakpoint1a, breakpoint1b, drawdecider, MPgame)

// Deal with aftermath of battle on campaign units.
// Note that losses logic needs to match that in Results.BSF.
// Work arrays used by called functions
BattleEndedCallback(winner)

// set up the region data from the campaign vars
LoadFromState()

// save our changes to the campaign vars so it will get saved
SaveToState()

// Customise Battle Units according to Campaign data
// Assumes that all troops belonging to side in the province have been combined into one army (except besieged troops and holding forces)
CustomiseCampaignUnits(side)

// Returns army side
GetCampaignArmySide(army)

// Return campaign difficult modifier
GetCampaignDifficultyModifier()

// Get current modified points value of campaign unit
GetCampaignUnitPointsValue(unitIndex, side)

// Returns the current army strength in points
GetCampaignArmyStrength(army)

// Get Army List army chunk name in WorkString(0) using "ArmyListChunkIndex".
GetCampaignArmyListChunkName(side)

// Add system string to campaign log
AddStringToLog(colour)

PrintArmyName(army, side)

PrintNumberOrderString(number)

PrintNumberOrderStringX(stringIndex, immediate, number)

// Prints in-battle unit name with campaign unit numbering
PrintUnitNameForCampaign(id)

PrintUnitNameForCampaignX(stringIndex, immediate, id)

// Prints campaign unit name with campaign unit numbering
PrintCampaignUnitName(unitIndex, side)

// Assigns unique unit number to unit.
AssignUnitNumber(unit, unitType, side)

// Gets unit regimental number. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
GetCampaignUnitNumber(unitIndex, side)

// Sets unit regimental number. Logs warning if attempt to set it outside the range 0-65535. Note: To save processing, does not check that unit exists.
SetCampaignUnitNumber(unitIndex, side, number)

// Returns whether unit is active. active = 1 means it is active, 0 means it doesn't exist, 2 means it is inactive (disbanded or put in garrison), 3 = local militia raised for single battle.
// The purpose of this is so that unit regimental numbers don't get immediately reassigned after units removed from active roll.
GetCampaignUnitActive(unitIndex, side)

// Sets whether unit is active. active = 1 means it is active, 0 means it doesn't exist, 2 means it is inactive (disbanded or put in garrison), 3 = local militia raised for single battle.
// The purpose of this is so that unit numbers don't get immediately reassigned after units removed from active roll.
//  Logs warning if attempt to set it outside the range 0-3.
SetCampaignUnitActive(unitIndex, side, active)

GetCampaignArmyAP(army)

SetCampaignArmyAP(army, AP)

SetTreasury(side, value)

GetTreasury(side)

SetCampaignArmyLastProvince(army, province)

GetCampaignArmyLastProvince(army)

// Used to backup work arrays so a called function can use them, then they can be restored
BackupWorkArrays()

// Used to restore work arrays after a called function has used them. Obviously BackupWorkArrays() has to be called before this function.
RestoreWorkArrays()

GetProvinceOwner(province)

SetProvinceOwner(province, owner)

// Consolidate units by using weakest to reinforce strongest and disband the weakest.
// Uses first three work arrays
ConsolidateArmy(army)

GetCampaignArmyFOWModifier(army)

SetCampaignArmyFOWModifier(army, modifier)

// Returns Fog of war randomiser. Put in its own function so it can be tweaked only in one place.
// The wider the range, the more likely battles are to occur - because of enemy armies underestimated each other
GetFOWRandom()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\CampaignTools.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\CombatTools.BSF
:::: 90 functions
::::   TurnMenAndShoot(me, x, y, unit, volley)
::::   GetFacingForShooting(me, unit, tilex, tiley)
::::   ChangeMenFacing(me, facing)
::::   ResetTemporaryFacingGlobal(side)
::::   Shooting_Attack(unit, damage)
::::   CalculateCoverModifier(me, unit, x, y, ignoreMovement)
::::   AmbushCheck(me, unit)
::::   AmbushThreatUpdate (x, y, increase)
::::   UpdateAlarmLevel (alarmIncrease)
::::   ChangeViewDistance (me, type, change)
::::   RemoveCasualties(me, enemy, damage, combatLog, red)
::::   DisplayCasualties(me, casualties, combatLog, red)
::::   PercentDamage(unit, damage)
::::   GetMoraleDisorderModifier(me, enemy, attacking)
::::   PercentDisordered(me, enemy, attacking)
::::   TileDisorder(me, x, y)
::::   IsOpen(x,y)
::::   IsCombatInOpen(me, enemy)
::::   IsKeil(me)
::::   Percent16RanksPike(me)
::::   Percent12RanksPike(me)
::::   Percent12RanksImpactFoot(me)
::::   PercentNotSteady(me, enemy, attacking)
::::   InProtectiveTerrain(me, enemy, attacking)
::::   GetCombatStrength(me)
::::   IsInCloseCombat(me)
::::   IsInCloseCombatVsOtherEnemy(me,enemy)
::::   DisplayIsInCloseCombat(me)
::::   MightPursue(me)
::::   IsBeingPursued(me)
::::   AddCloseCombat(me, enemy)
::::   RemoveCloseCombat(me, enemy)
::::   RemoveAllCloseCombats(me)
::::   TurnToFaceCloseCombat(me)
::::   NumberOfCloseCombatOpponents(me)
::::   IsArtillery(me)
::::   IsLimber(me)
::::   IsFlankRearAttack(me, enemy)
::::   IsLightTroops(me)
::::   IsMounted(me)
::::   IsChariots(me)
::::   IsFoot(me)
::::   IsShockTroops(me)
::::   OldHasThreatenedFlank(me)
::::   HasThreatenedFlank(me)
::::   MaximumRange(me)
::::   OptimumRange(me)
::::   GetShootingWeaponModifier(me, target, distance, volley, test, print)
::::   AdjustedShootingPercent(percent, POA)
::::   CalculateShootingRating(me,enemy,range)
::::   CalculateModifiedShootingRating(me,enemy,range)
::::   TargetEnfiladed(me, target)
::::   UnitBlockingLOS(me, target)
::::   CheckRouteForBlockingUnit(me)
::::   CalculateCloseCombatRating(me, enemy)
::::   CalculateModifiedCloseCombatRating(me, enemy, charger, melee_only)
::::   ChargePermitted(me, enemy)
::::   ArcOfFire(me, target)
::::   ArcOfFireToTile(me, x, y)
::::   WillUnitPursue(me, enemy, type)
::::   OldWillUnitPursue(me, enemy, type)
::::   CheckPursuerStillInContact(me, enemy)
::::   PriorityChargeTarget(me, current_target)
::::   PriorityChargeTargetAtTile(x, y, facing, me, current_target)
::::   OldPriorityChargeTargetAtTile(x, y, facing, me, current_target)
::::   AddOtherOpponentsToREPQueue(router, primary_pursuer)
::::   AdditionalEnemiesModifier(me, plus)
::::   PercentShooters(me)
::::   MountedShootingModifier(me)
::::   GetImpactPOA(me, enemy, charging, print, test)
::::   GetMeleePOA(me, enemy, attacking, print, test)
::::   GetLosses(me, damage)
::::   GetLossFactor(me, damage)
::::   PrintShootingWeaponModifier(test, POA)
::::   PrintEffectiveShots(test, me, percent, volley, equivalent)
::::   CalculateWinDrawLose(me, enemy, phase, meEffectiveSize, enemyEffectiveSize, meDamageInflicted, enemyDamageInflicted, index, forceRecalc)
::::   PrintWinDrawLoseString(phase, index, linefeed)
::::   IsLongRange(me, target)
::::   GetDisplayCloseCombatRating(me)
::::   PrintAdvantage(stringIndex, me, enemy, phase, combatIndex)
::::   CloseRangeNonLightFootShootingModifier(me)
::::   ClearMeleeDueFlags(me, enemy)
::::   IsMeleeDue(me, enemy)
::::   IsAnyMeleeDue(me)
::::   IsAmmunitionLow(me)
::::   IsBaggage(id)
::::   HasAnyTarget(me, max_range)
::::   HasPoorStamina(me)
::::   UnitTypeHasPoorStamina(typeIndex)
::::   IsWarband(me)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Show the visual stuff with men in a unit turning to face the target and shooting.
TurnMenAndShoot(me, x, y, unit, volley)

// Determine facing for individual men to face shooting target - within 5 degrees currently
GetFacingForShooting(me, unit, tilex, tiley)

// Change facing of men in unit without changing facing of unit (and hence their positions on the ground). Used in TurnMenAndShoot() to turn shooters to face target unit.
ChangeMenFacing(me, facing)

// It is vital that gTemporaryFacingGlobal[side] is reset to 0 after archers turn back, as this global is shared by all units on same side.
// This function is called to make absolutely sure.
ResetTemporaryFacingGlobal(side)

// Calculated shooting attack, but don't remove casualties yet
Shooting_Attack(unit, damage)

CalculateCoverModifier(me, unit, x, y, ignoreMovement)

// check if the firing unit is in ambush and if it is give it a chance to reveal
AmbushCheck(me, unit)

// Increase the ambush threat when a unit fires from ambush
AmbushThreatUpdate (x, y, increase)

// For missions with alarm level increase alarm
UpdateAlarmLevel (alarmIncrease)

// change view distance for LOS and cover LOS
ChangeViewDistance (me, type, change)

// Removes losses and returns 100 times the % of current strength just lost. Any randomization of damage needs to be done before calling this function.
// Note that it returns 100 x % lost so as to minimise rounding errors.
// if combatLog = 1 then also writes to combat log
// Uses Work Array 0. Note that it calls GetCloseCombatFacingsAndRank() which uses Work Arrays 0 and 1, but this function does not use Work Array 0 till after that function has resolved.
RemoveCasualties(me, enemy, damage, combatLog, red)

// Displays casualtees as floating text (and prints them to UI string). combatLog == 1 means also write to combat log
// If "StrengthMultipler" is less than 100%, gives random chance of rounding up reported casualties - to avoid invisible attrition.
DisplayCasualties(me, casualties, combatLog, red)

// Reporting function to report % damage for tool tips.
PercentDamage(unit, damage)

// returns combat damage reduction modifier (%) for Morale State and Disorder
// Attacking indicates whether unit is attacking
// enemy is unit we are deciding whther to attack (if any)
GetMoraleDisorderModifier(me, enemy, attacking)

// Returns 0 if not disordered, otherwise % disordered: 100 = all Disordered, 200 = all Severely Disordered
// attacking indicates whether unit is attacking
// enemy is unit we are testing whether to attack (if any)
PercentDisordered(me, enemy, attacking)

// Return tile disorder value for unit (Returns a standard value if unit not specified)
TileDisorder(me, x, y)

// Returns 1 if Tile is open terrain, 0 if not.
IsOpen(x,y)

// Determines whether close combat is in open ground. Returns 1 if it is, 0 if it isn't.
IsCombatInOpen(me, enemy)

// Determines if unit has enough pikes, heavy weapon men and swordsmen left to qualify as a keil. Returns 0 if not keil, otherwise 1.
// No individual man should have more than one of these attribs.
IsKeil(me)

// Determines if unit has enough pikes, heavy weapon men and swordsmen left to qualify as 16 ranks deep pikes. Returns 0 if no 16 ranks deep pikes.
Percent16RanksPike(me)

// Determines if unit has enough pikes, heavy weapon men and swordsmen left to qualify as 12 ranks deep pikes. Returns 0 if no 12 ranks deep pikes.
Percent12RanksPike(me)

// Determines if impact foot unit has enough men to qualify as deep impact foot. Returns 0 if no 12 ranks deep pikes.
Percent12RanksImpactFoot(me)

// Returns 0 if unit is steady, otherwise the % of unit that it not steady.
// attacking indicates whether we are attacking
// enemy is the unit we are thinking of attacking (if any)
PercentNotSteady(me, enemy, attacking)

// Returns 1 if unit is foot in protective (vs cavalry) terrain, otherwise 0. Protection is lost if the unit attacks.
InProtectiveTerrain(me, enemy, attacking)

// Get effective combat size of unit (foot get maximum 600 UnitSize worth of men on any one enemy, mounted get 400).
GetCombatStrength(me)

// Returns 1 if unit is in close combat,otherwise 0
IsInCloseCombat(me)

// Returns 1 if unit is in close combat vs enemy other than the one specified in the parameter,otherwise 0
IsInCloseCombatVsOtherEnemy(me,enemy)

// Returns 1 if unit is to be displayed as in close combat,otherwise 0
DisplayIsInCloseCombat(me)

// Returns 1 if unit can pursue,otherwise 0
MightPursue(me)

// Returns -1 if not being pursued, otherwise id of first pursuer in list
IsBeingPursued(me)

// Checks if a close combat/pursuit is already recorded in "Enemy" lists. If not, add it. Unit "me" should be the attacker.
// Main reason it is written this way is to add "Enemy" to each unit if charged fragged unit breaks prior to contact when charged and chargers still manage to end in contact.
// Aborts if the units are no longer adjacent by the time it is processed.
AddCloseCombat(me, enemy)

// Removes a close combat from both units' lists of active close combats
RemoveCloseCombat(me, enemy)

// Removes all close combats from a unit's list of active close combats, and it from theirs
RemoveAllCloseCombats(me)

// Turns unit to face whichever of its melee opponents is nearest to straight ahead.
TurnToFaceCloseCombat(me)

// Returns the number of close combat opponents a unit has
NumberOfCloseCombatOpponents(me)

// Returns 1 if unit is artillery, 0 if not
IsArtillery(me)

// Returns 1 if unit is limber, 0 if not
IsLimber(me)

// Determines whether attack by me on enemy would be a Flank/Rear attack. Returns 0 if not flank attack, 1 if flank attack, 2 if rear attack.
// Note that this function does not take into account whether me is actually close enough to charge enemy, if only checks the relative positions.
// Also note that it only counts a rear threat if the enemy is directly behind.
// Note that pursuers who change target will take their initial position as being the tile adjacent to the new target,
// so effectively have much more lenient requirement for flank charging. This makes it all the more important for players to position their units taking
// into account possible pursuits, which is propably a good thing.
IsFlankRearAttack(me, enemy)

// Returns 1 if unit is light troops, 0 if not
IsLightTroops(me)

// Returns 1 if unit qualifies as mounted, otherwise 0
IsMounted(me)

// Returns 1 if unit qualifies as chariots, otherwise 0
IsChariots(me)

// Returns 1 if unit qualifies as foot, otherwise 0
IsFoot(me)

// Returns 1 if unit qualifies as shock troops, otherwise 0
IsShockTroops(me)

// Returns 1 if unit has threatened flank, otherwise 0
OldHasThreatenedFlank(me)

// This should only be used for malus, not for AI purposes. It is too slow to be used for shooting tooltips - so malus removed from shooting.
HasThreatenedFlank(me)

// Returns the maximum shooting range of the unit
MaximumRange(me)

// Returns the range at which all shooters in unit can shoot at maximum effect
OptimumRange(me)

// Calculates shooting weapon modifier for distance and POA. Also (with target set at -1) used to calculate unit's overall ShootingRating. Returns 0 if no weapons can shoot at this range.
// Note that it works on the assumption that no men can have more than one shooting weapon. A unit can have a mixture of shooting capabilities, but the total of all shooting capabilities must be less than or equal to 100%.
// Currently does not do Cover which it may be desirable to do separately
GetShootingWeaponModifier(me, target, distance, volley, test, print)

// Helper function for GetShootingWeaponModifier
AdjustedShootingPercent(percent, POA)

// An overall rating for shooting power (will feed into threat maps). Longer range weapons exert more shooting power overall and hence threat. The resulting rating is only used for AI purposes, not to calculate results of combat.
// If enemy == -1 then it works out a general rating, if a unit id is specified it works out the shooting rating against that unit. Does not take into account losses, cohesion loss, disorder.
// If range == -1 calculate an average estimate of a variety of ranges, otherwise calculate the shooting rating at the specified range.
CalculateShootingRating(me,enemy,range)

// Modified rating for shooting power. Takes into account losses, cohesion loss, disorder, enemy cover. The resulting rating is only used for AI purposes, not to calculate results of combat.
// If enemy == -1 then it works out a general rating, if a unit id is specified it works out the shooting rating against that unit.
// If range == -1 calculate an average estimate of a variety of ranges, otherwise calculate the shooting rating at the specified range.
CalculateModifiedShootingRating(me,enemy,range)

// Returns 1 if target enfiladed, otherwise 0
TargetEnfiladed(me, target)

UnitBlockingLOS(me, target)

// Helper function for UnitBlockingLOS() function. Depends on route having already been set by GetRouteCost() in that function.
// Also checks for heavy fortifications blocking line of fire.
CheckRouteForBlockingUnit(me)

// Returns unit's close combat rating. If enemy == -1 it returns a general purpose rating, otherwise a specific rating against the specified enemy. The resulting rating is only used for AI purposes, not to calculate results of combat.
// Does not take into account losses, cohesion loss or disorder.
CalculateCloseCombatRating(me, enemy)

// Returns unit's close combat rating against an individual enemy unit, taking into account own morale and disorder. The resulting rating is only used for AI purposes, not to calculate results of combat.
// If enemy == -1, uses average POAs.
// charger == -1 if neither unit is charging, == id of assaulting unit if either is assaulting
// If melee_only flag set, reports melee rating only, otherwise reports rating based on 1/3 impact, 2/3 melee.
CalculateModifiedCloseCombatRating(me, enemy, charger, melee_only)

// Returns 1 if unit would be permitted to charge enemy (NOT taking into account morale or move distance), otherwise 0.
// Current version only takes into account troops that can never charge.
// Needs additional functionaly to be added to take into account troop types that can sometimes charge in some cicumstances.
ChargePermitted(me, enemy)

ArcOfFire(me, target)

ArcOfFireToTile(me, x, y)

// Returns 1 if unit will Pursue, otherwise 0
// Type 0 = initial pursuit. Type 1 = follow on pursuit. Type 2 = Pursuit off playable area.
// Assumes that units are still in adjacent squares prior to any pursuit
// All chances tweakable
WillUnitPursue(me, enemy, type)

// Returns 1 if unit will Pursue, otherwise 0
// Type 0 = initial pursuit. Type 1 = follow on pursuit. Type 2 = Pursuit off playable area.
// Assumes that units are still in adjacent squares prior to any pursuit
// All chances tweakable
OldWillUnitPursue(me, enemy, type)

// Checks whether Pursuer is still close enough. If so, damages router. If not, removes units from each others' close combat list.
CheckPursuerStillInContact(me, enemy)

PriorityChargeTarget(me, current_target)

// Helper function for PriorityChargeTarget(), but can also be used to determine hypothetical priority target if "me" was at the specified tile, with the specified facing.
// Used thus in Check_Unit_Assault() to check whether charge target qualifies as charge target at end of charge as well as at beginning.
PriorityChargeTargetAtTile(x, y, facing, me, current_target)

// Helper function for PriorityChargeTarget(), but can also be used to determine hypothetical priority target if "me" was at the specified tile, with the specified facing.
// Used thus in Check_Unit_Assault() to check whether charge target qualifies as charge target at end of charge as well as at beginning.
OldPriorityChargeTargetAtTile(x, y, facing, me, current_target)

// Adds additional close combat opponents to REP Queue
AddOtherOpponentsToREPQueue(router, primary_pursuer)

// Returns combat strength multiplier for additional enemies (%). plus == 1 version takes into account unit considering charging (for SetAssaultString()).
AdditionalEnemiesModifier(me, plus)

// Returns the percent of Shot in the unit
PercentShooters(me)

// Reduce relative shooting power of non-light mounted to 75% if 100% shooters, or pro-rata if more than 50% shooters. (Half and half units shoot at full effect).
MountedShootingModifier(me)

// Returns Impact POA (* 100). If print == 1, prints information to current string. If test == 1 it prints directly to UIstring, otherwise via AddVizFunctionCall.
GetImpactPOA(me, enemy, charging, print, test)

// Returns Melee POA (* 100) against the current enemy.
// If enemy == -1 then this give a general purpose POA for calculating general purpose close combat rating - which does not take into account cohesion state or disorder
// attacking indicates whether "me" is attacking - needed for terrain disorder and defending obstacles to work correctly
GetMeleePOA(me, enemy, attacking, print, test)

// Returns the number of men lost
GetLosses(me, damage)

GetLossFactor(me, damage)

// Prints shooting weapon modifier - helper function for shooting tooltip
PrintShootingWeaponModifier(test, POA)

// Prints number of effective shots - helper function for shooting tooltip
PrintEffectiveShots(test, me, percent, volley, equivalent)

// Print win/draw/lose string for assault tooltip
// index is the index for the WinDrawLose Universal Variable arrays - needed to stop string being recalculated constantly when been done for multiple opponents of unit in melee
// if forceRecalc == 1, forces recalculate
CalculateWinDrawLose(me, enemy, phase, meEffectiveSize, enemyEffectiveSize, meDamageInflicted, enemyDamageInflicted, index, forceRecalc)

// Print win/draw/lose string for assault tooltip
// index is the index for the WinDrawLose Campaign Variable arrays - needed to stop string being recalculated constantly when been done for multiple opponents of unit in melee
// If linefeed = 1 print a linefeed before the win/draw/lose string.
PrintWinDrawLoseString(phase, index, linefeed)

// This function is only used to trigger shooting tooltip "Long Range" message and is therefore designed for speed, does not determine if target is actually out of range.
// Returns 1 if target is outside close range of any type in the unit that has a long and short range. Otherwise 0.
IsLongRange(me, target)

// Gets close combat rating to display - emphasises differences by cubing internal close combat rating
GetDisplayCloseCombatRating(me)

// Helper function for Close Combat reporting - calculates "Advantage/Disadvantage" string from Win/Draw/Loss ratings.
PrintAdvantage(stringIndex, me, enemy, phase, combatIndex)

// Modifier to reduce close range shooting by non-light foot (to roughly equivalent to max 1.5 FOGAM ranks). Intended to cope (approximately) with units including mixed shooters.
CloseRangeNonLightFootShootingModifier(me)

// Clears both units Melee Due flag against each other
ClearMeleeDueFlags(me, enemy)

// Returns 1 if Melee is due between these two units
IsMeleeDue(me, enemy)

// Returns 1 if any melee is still to be fought by this unit, otherwise 0
IsAnyMeleeDue(me)

// Returns 0 if ammunition is not low, 1 if it is
IsAmmunitionLow(me)

// Returns 1 if unit is baggage, otherwise 0
IsBaggage(id)

// Helper function for unit list and next unshot
HasAnyTarget(me, max_range)

// Returns 1 if unit has poor stamina, otherwise 0. 
// Currently only applies to warbands.
HasPoorStamina(me)

UnitTypeHasPoorStamina(typeIndex)

// Returns 1 if unit qualifies as warband, 0 if not
IsWarband(me)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\CombatTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\CustomCampaignTools.bsf
:::: 1 functions
::::   CustomisedReadArmyListForCampaign(province, side, points1, points2)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Allows army list chunk to be switched for certain sides and province before reading army list in custom campaign
// Needs to be able to cope with reading in forces for non-original province owner for adding garrison to field army.
CustomisedReadArmyListForCampaign(province, side, points1, points2)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\CustomCampaignTools.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\ForceSelectionTools.bsf
:::: 15 functions
::::   ForceSelect_InitialiseList(side)
::::   ForceSelect_SortRating(unitTypeIndex)
::::   ForceSelect_PopulateListBox(char string[32])
::::   ShowForceSelectTooltip(char string[32], mousey, unitTypeIndex)
::::   ForceSelect_PrintUnitTypeStatsInfo(typeIndex, side)
::::   UnAutoDeploy(side)
::::   RemoveUnpurchasedUnits(side)
::::   ResetOriginalTeams(side)
::::   ForceSelect_MoreUnitsAffordable()
::::   FinaliseForceSelection(side)
::::   ForceSelect_AutoFill(side)
::::   ArmyList_InitialiseList(side, num, points)
::::   ForceSelect_CanPurchaseAllUnits(side)
::::   ForceSelect_RenderListItem(char string[32], x, y, width, height, pass, flags, item, name)
::::   ForceSelect_SelectAll(side)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ForceSelect_InitialiseList(side)

ForceSelect_SortRating(unitTypeIndex)

// Uses WorkString 2
ForceSelect_PopulateListBox(char string[32])

// index is the listbox item the mouse is currently over. mousey is the screen mouse y position (in 1024 x 768)
// Uses WorkStrings 0 - 4;
ShowForceSelectTooltip(char string[32], mousey, unitTypeIndex)

// Print unit type stats for Force Select
ForceSelect_PrintUnitTypeStatsInfo(typeIndex, side)

// Moves deployed troops back into off map predeployment area.
UnAutoDeploy(side)

// Remove all unpurchased unfixed units permanently
RemoveUnpurchasedUnits(side)

ResetOriginalTeams(side)

// Returns 0 if there are no affordable unchosen units, 1 if there are any.
ForceSelect_MoreUnitsAffordable()

FinaliseForceSelection(side)

ForceSelect_AutoFill(side)

// Initialise ArmyListPreview data from data in work array
ArmyList_InitialiseList(side, num, points)

// returns 1 if there are enough force points to purchase all unfixed units
ForceSelect_CanPurchaseAllUnits(side)

// Uses WorkStrings 0 to 4.
ForceSelect_RenderListItem(char string[32], x, y, width, height, pass, flags, item, name)

// Used to select all units before autodeployment if they can all be purchased because list has been culled.
ForceSelect_SelectAll(side)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\ForceSelectionTools.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\Functions.BSF
:::: 53 functions
::::   MoveTeam(side, team, point, aggr)
::::   MoveTeamCoord(side, team, x, y, aggr)
::::   CheckVP(marker, owner, x, y)
::::   FindTarget(side, x, y, radius, visible)
::::   IsSideInRegion(side, x, y, radius)
::::   CheckAreaClear(side,x1,y1,x2,y2)
::::   TeamArrived(side, team)
::::   TeamAttackNearest(side, team)
::::   TeamLoadInfantry(side, team)
::::   TeamUnloadInfantry(side, team, newTeam)
::::   ClearAreaLOS(x, y, x2, y2, side)
::::   ClearLOS(x, y, x2, y2)
::::   SetAreaLOS(x, y, x2, y2, side, visible)
::::   HoldAllTeams(side)
::::   ReactiveAI(side)
::::   DeployTeam(side, team)
::::   PlaceUnitX(x, y, facing, side, team, type, recycle)
::::   PlaceUnit(x, y, facing, side, team, type)
::::   UnitDeployX(id, x, y)
::::   UnitDeployIfPositionDifferent(me, x, y, leaveMenInPlace)
::::   GetWeakestDestroyedUnit(side)
::::   ShowUIScreenX(type, anim, text, icon)
::::   ShowUIScreenY(type, anim, text)
::::   ShowUIScreenToSide(type, anim, text, icon, side)
::::   AddRandom(x1, y1, x2, y2, x3, y3, facing, side, team, type, recycle) ;
::::   MakeAIOrderAIPoint(point, aggr)
::::   MakeAIOrderCoord(x, y, aggr)
::::   PrepareToReturnToBattlefield(me)
::::   ReturnToBattlefield(me)
::::   PrintStringX(stringIndex, immediate, stringID)
::::   PrintStringLiteralX(stringIndex, immediate, string)
::::   PrintIntX(stringIndex, immediate, value)
::::   PrintStringIndexedX(stringIndex, immediate, stringID, index)
::::   SetUnitStatusFlag(me)
::::   FromFileChunkIndex(fileID, chunk)
::::   CheckResetArcFlags()
::::   ResetArcFlags(side, selectedUnit)
::::   GetStrengthMultiplier()
::::   DebugLogX(string, p1, p2, p3, p4);
::::   DebugLogY(string, p1);
::::   UpdateAllUnitIcons()
::::   ShowMovedIcons()
::::   SetShootableFlag(me, value)
::::   GetShootableFlag(me)
::::   SetIndicatorEnemyFacing(me, facing)
::::   GetIndicatorEnemyFacing(me)
::::   SetChargeableFlag(me, value)
::::   GetChargeableFlag(me)
::::   PlaceTileByTypeAndRotation(x, y, style, group, autoedge, layer, rotation)
::::   GetTotalForcePoints(side)
::::   GetForcePointsX(side)
::::   GetOriginalTeamCount(side, team)
::::   UnDeployUnit(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

MoveTeam(side, team, point, aggr)

MoveTeamCoord(side, team, x, y, aggr)

CheckVP(marker, owner, x, y)

// Returns a random target unit within the radius (for targetting bonus weapons)
FindTarget(side, x, y, radius, visible)

// Check if unit of side is in region (note: FindTarget also returns this)
IsSideInRegion(side, x, y, radius)

// Returns 1 if no units from "side" are found within the area x1<->x2, y1<->y2
CheckAreaClear(side,x1,y1,x2,y2)

// Returns 1 if the team has arrived within 1 tiles of the destination
TeamArrived(side, team)

TeamAttackNearest(side, team)

// Attempts to load all infantry from team in transports (from same team).
// Returns 0 when all infantry is loaded or none is found, or if all transports are full or none are found.
// Returns 1 if infantry was found but did not yet make it to transport
TeamLoadInfantry(side, team)

// Attempt to unload all infantry from transports. Priority is given to tiles with good cover values.
TeamUnloadInfantry(side, team, newTeam)

// Clear the LOS in the area
// Mostly used to clear up area to inform player about event + recon pilot popup explaining event
ClearAreaLOS(x, y, x2, y2, side)

ClearLOS(x, y, x2, y2)

// Used to block or clear the LOS in the area
// Mostly used to restrict deploy zones & revealing events
SetAreaLOS(x, y, x2, y2, side, visible)

// Set all teams to hold position (aggression 64)
HoldAllTeams(side)

ReactiveAI(side)

// Move all members of a team to defensive positions
DeployTeam(side, team)

// AddUnit with more options. If recycle == 1 and all 64 available unit ids are occupied, recycles id of weakest destroyed unit if any.
// Note that this effectively raises the morale of the army slightly by increasing the value of PercentRemaining(side), but by the least possible amount.
// This can be justified on the basis that the arrival of reinforcements WOULD improve morale.
// Returns the id of the new unit.
PlaceUnitX(x, y, facing, side, team, type, recycle)

// Vanilla version without recycling - to allow editor generated reinforcements code to work
// Returns the id of the new unit.
PlaceUnit(x, y, facing, side, team, type)

UnitDeployX(id, x, y)

// Extended UnitDeploy() which checks for unit being placed on its own position and if so does not attempt to UnitDeploy() it.
// (Although attempting to UnitDeploy() a unit to its current location appears to cause a crash only if the unit is Inactive e.g. carried or destroyed.)
// If leaveMenInPlace != 0 then the actual men will not be moved by this command. Use to test something with the unit in a different position and then move the unit back.
UnitDeployIfPositionDifferent(me, x, y, leaveMenInPlace)

// Helper function for PlaceUnitX()
// Returns id of weakest destroyed unit (for recycling)
GetWeakestDestroyedUnit(side)

// Extended function with viz queue delay. Only works with 4 parameters
ShowUIScreenX(type, anim, text, icon)

// Extended function with viz queue delay. Only works with 3 parameters
ShowUIScreenY(type, anim, text)

// Show a UI screen with a viz queue delay. Multiplayer safe.
ShowUIScreenToSide(type, anim, text, icon, side)

//Adds unit randomly on one of the 3 sets of coordinates.
AddRandom(x1, y1, x2, y2, x3, y3, facing, side, team, type, recycle) ;

// Helper functions to make an AI order value for either an AI point, or x,y coordinates
MakeAIOrderAIPoint(point, aggr)

MakeAIOrderCoord(x, y, aggr)

// Set unit men to face the correct direction before arriving on battlefield
PrepareToReturnToBattlefield(me)

// Return off playable area unit to battlefield
ReturnToBattlefield(me)

// Extended PrintString function. immediate flag determines whether the PrintString call is direct or through the VizQ
// Note that when printing immediately it uses UI String 0, when printing through the VizQ it uses UI String stringIndex
PrintStringX(stringIndex, immediate, stringID)

// Extended PrintStringLiteral function. immediate flag determines whether the PrintStringLiteral() call is direct or through the VizQ
// Note that when printing immediately it uses UI String 0, when printing through the VizQ it uses UI String stringIndex
PrintStringLiteralX(stringIndex, immediate, string)

// Extended PrintInt function. immediate flag determines whether the PrintInt call is direct or through the VizQ
// Note that when printing immediately it uses UI String 0, when printing through the VizQ it uses UI String stringIndex
PrintIntX(stringIndex, immediate, value)

// Extended PrintString function. immediate flag determines whether the PrintString call is direct or through the VizQ
// Note that when printing immediately it uses UI String 0, when printing through the VizQ it uses UI String stringIndex
PrintStringIndexedX(stringIndex, immediate, stringID, index)

SetUnitStatusFlag(me)

// Returns -1 if chunk not found, otherwise index of chunk
// Uses WorkString(2). Note that chunk must not point to WorkString(2) or it will be overwritten.
FromFileChunkIndex(fileID, chunk)

CheckResetArcFlags()

// Resets arc flags and chargeable flags for a side's units, with respect to the selected enemy unit.
ResetArcFlags(side, selectedUnit)

// Returns value of UniversalVar "StrengthMultiplier", or 100 if that is 0 - i.e. has not been set.
GetStrengthMultiplier()

// Sends debug message with 4 integer parameters to the error log. Need to specify all parameters - suggest 999 if they are not relevant.
DebugLogX(string, p1, p2, p3, p4);

// Sends debug message with 1 integer parameter to the error log.
DebugLogY(string, p1);

// Resets all unit icons then performs SetUnitStatusFlag(). (Does not update arcs of fire icons).
UpdateAllUnitIcons()

ShowMovedIcons()

// Set shootable flag: 0 = no, 1 = half arc, 2 = full arc
SetShootableFlag(me, value)

GetShootableFlag(me)

// Record enemy facing for shootable and chargeable indicators
SetIndicatorEnemyFacing(me, facing)

// Returns the (previously recorded) facing of the selected enmy for showing shootable and chargeable indicators.
GetIndicatorEnemyFacing(me)

// Set shootable flag: 0 = no, 1 = yes
SetChargeableFlag(me, value)

GetChargeableFlag(me)

// Extended version of place tile by type, which allows rotation to be specified.
PlaceTileByTypeAndRotation(x, y, style, group, autoedge, layer, rotation)

// Get total force points before paying for fixed units - for use in force selection.
GetTotalForcePoints(side)

// Extended version of GetForcePointsX() that works differently for MPS
GetForcePointsX(side)

// Returns the number of active non-routing on-table units in the original team
GetOriginalTeamCount(side, team)

// Moves deployed unit back into off map predeployment area.
UnDeployUnit(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\Functions.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\GeneralTools.bsf
:::: 10 functions
::::   AddScenarioGenerals(scenario)
::::   IsThisGeneralInCommandRange(me, id, type)
::::   GetGeneralRange(me, type)
::::   GeneralInCommandRange(me, type)
::::   SetProximityMoraleFlagsGeneralIncapacitated(generalUnit)
::::   TestForGeneralLost(me, loser, pursuit, notional_turn)
::::   GetRandomGeneralName(main, sideID, mainNameIndex)
::::   GetNonDuplicateRandomGeneralName(side, main, mainNameIndex)
::::   PrintGeneralName(stringIndex, immediate, me)
::::   SetCommandRangeFlags(me)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Reads info for generals from a .txt file in the campaign folder
// scenario is the name of the scenario - (as per the CAMPAIGN.TCT chunks
// General data files should be named scenarioGenerals.txt - e.g. CannaeGenerals.txt
AddScenarioGenerals(scenario)

// Returns 1 if id is a general in line of command and in range of me
// type == 0 is for morale purposes, type == 1 is for movement purposes
IsThisGeneralInCommandRange(me, id, type)

// Returns general's command range - me is general's unit - function assumes that it has already been tested that unit does in fact have general
// type == 0 is for morale purposes, type == 1 is for movement purposes
GetGeneralRange(me, type)

// Returns -1 if no general in command reach, otherwise id of most senior general in command range
// type == 0 is for morale purposes, type == 1 is for movement purposes
GeneralInCommandRange(me, type)

// Sets cohesion test flags for friendly units close to incapacitated general.
SetProximityMoraleFlagsGeneralIncapacitated(generalUnit)

// test whether general killed. Returns 1 if he is, 0 if not.
TestForGeneralLost(me, loser, pursuit, notional_turn)

// Get index of general name appropriate to nation. If main == 1 this is the main name as used by all generals. If main == 0 name is supplementary name shown before main name
GetRandomGeneralName(main, sideID, mainNameIndex)

// Get index of non-duplicate general name appropriate to nation. If main == 1 this is the main name as used by all generals. If main == 0 name is supplementary name shown before main name
GetNonDuplicateRandomGeneralName(side, main, mainNameIndex)

// Print general name
PrintGeneralName(stringIndex, immediate, me)

SetCommandRangeFlags(me)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\GeneralTools.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\Globals.bsf
:::: no functions declared
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\HelperTools.BSF
:::: 23 functions
::::   IsUnitStatic(id)
::::   PrintIntForToolTip(desc, val)
::::   PrintIDSIntForTooltip(ids, value)
::::   PrintIntForToolTipPerc(desc, val)
::::   PrintIDSIntForTooltipPerc(ids, value)
::::   PrintIDSForTooltip(ids)
::::   PrintAttribIntRangeForToolTip(unit, desc, attribName, numVals)
::::   PrintIDSAttribIntRangeForToolTip(unit, ids, attribName, numVals)
::::   MOUSE_CLICK_HANDLER(action, tilex, tiley)
::::   PrintObjectData(tilex, tiley)
::::   ShowUIStringPopup(stringIndex)
::::   ShowUIStringPopupTimed(image, stringIndex)
::::   ShowTutorialPopup(string)
::::   UseTutorialMode()
::::   UseAdvancedTT()
::::   UseCombatReports()
::::   UseCombatLog()
::::   UseFacingMarkers()
::::   SetTutorialMode(mode)
::::   SetDetailedTooltips(mode)
::::   SetCombatReports(mode)
::::   ResetWinDrawLoseFlags()
::::   ResetTooltipFlags()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

IsUnitStatic(id)

PrintIntForToolTip(desc, val)

PrintIDSIntForTooltip(ids, value)

PrintIntForToolTipPerc(desc, val)

PrintIDSIntForTooltipPerc(ids, value)

PrintIDSForTooltip(ids)

PrintAttribIntRangeForToolTip(unit, desc, attribName, numVals)

PrintIDSAttribIntRangeForToolTip(unit, ids, attribName, numVals)

// Can be used for custom handling of mouse events
// return !=0 to prevent the normal handling of events.
MOUSE_CLICK_HANDLER(action, tilex, tiley)

// Prints object data for tile helper
PrintObjectData(tilex, tiley)

// Show UI popup with UI string. Note that camera should be centred by calling function.
// (Not done in this function to avoid duplication resulting in camera hopping about)
ShowUIStringPopup(stringIndex)

// Show UI popup with UI string with time delay instead of OK button. Note that camera should be centred by calling function.
// (Not done in this function to avoid duplication resulting in camera hopping about)
ShowUIStringPopupTimed(image, stringIndex)

ShowTutorialPopup(string)

UseTutorialMode()

UseAdvancedTT()

// Returns 0 if close combat reports OFF, 1 if Simple, 2 if detailed
UseCombatReports()

// Returns 0 if close combat log is OFF, 1 if on
UseCombatLog()

UseFacingMarkers()

// Sets tutorial mode - 0 = off, 1 = on
SetTutorialMode(mode)

// Set detailed tooltips  - 0 = off, 1 = on
SetDetailedTooltips(mode)

// Set close combat report popups  - 0 = off, 1 = simple, 2 = detailed
SetCombatReports(mode)

ResetWinDrawLoseFlags()

ResetTooltipFlags()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\HelperTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\Macros.bsf
:::: no functions declared
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\MapTools.bsf
:::: 3 functions
::::   GetCentrifugalLocus(mapsize, border)
::::   GetSuperCentrifugalLocus(mapsize, border)
::::   SetValidTileData(x, y, index, value)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Gets random x or y coordinate skewed towards edges of map. (Avoiding the 8 squares at the extreme border).
// mapsize is map width for x, map height for y.
// border is exclusion zone where blob won't start
GetCentrifugalLocus(mapsize, border)

// Gets random x or y coordinate skewed towards edges of map. (Avoiding the 8 squares at the extreme border).
// mapsize is map width for x, map height for y.
// border is exclusion zone where blob won't start
// Mostly avoids centre of map
GetSuperCentrifugalLocus(mapsize, border)

// Checks whether tile is on at least map border before attempting to set its data.
SetValidTileData(x, y, index, value)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\MapTools.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\MoraleTools.BSF
:::: 14 functions
::::   MoraleUpdate(me, enemy, reason, loser, combatLog, shot, notional_turn)
::::   CohesionTest(me, enemy, reason, combatLog, shot, notional_turn)
::::   ConvertLossFactorToMoraleDamage(me, damage)
::::   IsAutobroken(me)
::::   CohesionRandomScore(me)
::::   SetProximityMoraleFlags(router)
::::   DoProximityMoraleTests(side)
::::   IterateProximityMoraleTests(side)
::::   LostCloseCombatBadly(me, notional_turn)
::::   LostCloseCombat(me, notional_turn)
::::   DisperseRouters(me)
::::   LogCohesionTestResults(me, modifiers, score)
::::   UpdateDisplayMoraleState(me, moraleState)
::::   ShowHeldFirmPopup(morale_state, unit)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Update morale. Reason is the reason for the update - 0 = Shooting, 1 = Impact Close Combat, 2 = Melee Close Combat, 3 = Other reason, (4 = bolster/rally - does not use MoraleUpdate()), 5 = automatic morale state drop
// Note that the "Morale" attrib is no longer used at all.
// Returns the morale state
// If combatLog == 1 also sends info to combatLog
// If update is for shooting, shot == 0 is first shot, shot == 1 is second shot
// notional_turn - some morale updates (e.g. from autoresolved melees) use data from the previous turn
MoraleUpdate(me, enemy, reason, loser, combatLog, shot, notional_turn)

// Cohesion test
// reason 0 - shooting test, 1 = impact close combat test, 2 = melee close combat test, 3 = other cohesion test, 4 = bolster/rally test
// if combatLog == 1 also writes to combat log
// if this is shooting test, shot = 0 is first shot, shot = 1 is second shot.
// notional_turn allows some morale test to assume data from the previous turn (e.g. morale tests for autoresolved melees)
CohesionTest(me, enemy, reason, combatLog, shot, notional_turn)

// Calculate 100 x % morale damage from 100 x % actual damage to unit. (Ignore rear ranks of very big units). (Use 100 x to avoid rounding errors).
ConvertLossFactorToMoraleDamage(me, damage)

// Determines whether a unit is autobroken due to losses. Returns 1 if autobroken, 0 if not. Autobreak point is <50% strength if Quality = 100, and is adjusted by 10% per 100 quality either side of 100
IsAutobroken(me)

// Gets cohesion test random score, including quality rerolls
CohesionRandomScore(me)

// Sets cohesion test flags for friendly units close to units that breaks or is destroyed
SetProximityMoraleFlags(router)

// Does proximity morale tests and actions their results
DoProximityMoraleTests(side)

// Returns 1 if any done
IterateProximityMoraleTests(side)

// Returns 1 if bad close combat loss, 0 if not. Is used in Cohesion Test and also in Break Off scripts.
LostCloseCombatBadly(me, notional_turn)

// Returns 1 if close combat loss, 0 if not. Not currently used.
LostCloseCombat(me, notional_turn)

// Helper function to Disperse routers, remove close combats etc.
DisperseRouters(me)

// DEBUG
LogCohesionTestResults(me, modifiers, score)

UpdateDisplayMoraleState(me, moraleState)

ShowHeldFirmPopup(morale_state, unit)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\MoraleTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\MoreCampaignTools.bsf
:::: 52 functions
::::   FXSkewedRandom(min, max, skew_type)
::::   PrintLogDivider()
::::   PrintCampaignUnitStats(unitIndex, side, short)
::::   SetOverallBattleLosses(side, losses)
::::   GetOverallBattleLosses(side)
::::   PrintArmyListNameFromChunkIndex(chunk)
::::   GetSideIDFromChunkIndex(chunkIndex)
::::   GetCampaignGeneralQuality(generalIndex, side)
::::   SetCampaignGeneralQuality(generalIndex, side, value)
::::   GetCampaignGeneralCombatSkill(generalIndex, side)
::::   SetCampaignGeneralCombatSkill(generalIndex, side, value)
::::   GetCampaignGeneralSeniority(generalIndex, side)
::::   SetCampaignGeneralSeniority(generalIndex, side, value)
::::   GetCampaignGeneralSideID(generalIndex, side)
::::   SetCampaignGeneralSideID(generalIndex, side, value)
::::   GetCampaignGeneralArmy(generalIndex, side)
::::   SetCampaignGeneralArmy(generalIndex, side, value)
::::   GetCampaignGeneralActive(generalIndex, side)
::::   SetCampaignGeneralActive(generalIndex, side, value)
::::   GetCampaignGeneralNameIndex(generalIndex, side, nameType)
::::   SetCampaignGeneralNameIndex(generalIndex, side, nameType, nameIndex)
::::   PrintCampaignGeneralName(stringIndex, immediate, generalIndex, side)
::::   AddNewCampaignArmyGeneral(side, army, sideID, seniority, combatSkill, type, quality)
::::   SetCampaignNonDuplicateRandomGeneralName(generalIndex, side)
::::   MapCampaignGeneralsToBattle(side)
::::   GetCampaignArmyGeneralIndex(army)
::::   SetCampaignArmyGeneralIndex(army, value)
::::   PrintCampaignArmyGeneralName(army, linefeed)
::::   AddCampaignGeneralToUnit(me, generalIndex, side, generalType)
::::   GetCampaignArmyMostSeniorGeneral(army)
::::   CheckCinCPromotionDemotion(army, winner)
::::   GetProvinceNameIndex(province)
::::   SetProvinceNameIndex(province, index)
::::   DisbandCampaignArmy(army)
::::   GetProvinceSideID(province)
::::   SetProvinceSideID(province, sideID)
::::   GetProvinceArmyListChunkIndex(province)
::::   SetProvinceArmyListChunkIndex(province, chunkIndex)
::::   GetCampaignUnitSideID(unitIndex, side)
::::   SetCampaignUnitSideID(unitIndex, side, sideID)
::::   GetCampaignUnitTextureIndex(unitIndex, side)
::::   SetCampaignUnitTextureIndex(unitIndex, side, variantIndex)
::::   GetCampaignArmyUnderSiege(army)
::::   SetCampaignArmyUnderSiege(army, value)
::::   GetCampaignArmyHoldingForce(army)
::::   SetCampaignArmyHoldingForce(army, value)
::::   GetCampaignArmyProvince(army)
::::   SetCampaignArmyProvince(army, province)
::::   ClearCampaignGlobals()
::::   CustomiseUnitManCount(me)
::::   AssignTextureVariantToCampaignUnit(unitIndex, side)
::::   GetArmyListChunkIndexFromChunkName(chunkName)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Returns skewed randomly generated number using FXRand.
FXSkewedRandom(min, max, skew_type)

// Prints divider for campaign log - note, cannot be centralised on both PC and iPad.
PrintLogDivider()

// If shot == 1, prints shorter version
PrintCampaignUnitStats(unitIndex, side, short)

// Record total battle losses
SetOverallBattleLosses(side, losses)

GetOverallBattleLosses(side)

PrintArmyListNameFromChunkIndex(chunk)

// Gets SideID from army list chunk index - needed for 2 listbox version of Campaign setup.
// NOTE: Uses WorkString 0;
GetSideIDFromChunkIndex(chunkIndex)

GetCampaignGeneralQuality(generalIndex, side)

// Sets campaign general quality. Logs warning if attempt to set it outside the range 0-3. Note: To save processing, does not check that general exists. If it doesn't the data returned will be meaningless.
SetCampaignGeneralQuality(generalIndex, side, value)

// Used in Japanese game, not here
GetCampaignGeneralCombatSkill(generalIndex, side)

// Sets campaign general combat skill. Logs warning if attempt to set it outside the range 0-15. Note: To save processing, does not check that general exists. If it doesn't the data returned will be meaningless. (Currently only used in Japanese game)
SetCampaignGeneralCombatSkill(generalIndex, side, value)

GetCampaignGeneralSeniority(generalIndex, side)

// Sets campaign general seniority. Logs warning if attempt to set it outside the range 0-15. Note: To save processing, does not check that general exists. If it doesn't the data returned will be meaningless. (Currently only used in Japanese game)
SetCampaignGeneralSeniority(generalIndex, side, value)

GetCampaignGeneralSideID(generalIndex, side)

// Sets campaign general combat skill. Logs warning if attempt to set it outside the range 0-15. Note: To save processing, does not check that general exists. If it doesn't the data returned will be meaningless.
SetCampaignGeneralSideID(generalIndex, side, value)

GetCampaignGeneralArmy(generalIndex, side)

// Sets campaign general combat skill. Logs warning if attempt to set it outside the range 0-15. Note: To save processing, does not check that general exists. If it doesn't the data returned will be meaningless.
SetCampaignGeneralArmy(generalIndex, side, value)

GetCampaignGeneralActive(generalIndex, side)

// Sets whether campaign general is active. 0 = does not exist, 1 = active, 2 = wounded.
// Logs warning if attempt to set it outside the range 0-3. Note: To save processing, does not check that general exists. If it doesn't the data returned will be meaningless.
SetCampaignGeneralActive(generalIndex, side, value)

// Returns index number of general name. nameType 0 corresponds to "General", nameType 1 corresponds to "GeneralNomen" (or "GivenNameA in Japanese version, nameType2 corrseponds to "GivenNameB" in Japanese version).
GetCampaignGeneralNameIndex(generalIndex, side, nameType)

// Sets campaign general name. nameType 0 corresponds to "General", nameType 1 corresponds to "GeneralNomen" (or "GivenNameA in Japanese version, nameType2 corrseponds to "GivenNameB" in Japanese version).
SetCampaignGeneralNameIndex(generalIndex, side, nameType, nameIndex)

// Print general name
PrintCampaignGeneralName(stringIndex, immediate, generalIndex, side)

// Add commanders to newly formed army
AddNewCampaignArmyGeneral(side, army, sideID, seniority, combatSkill, type, quality)

// Get index of non-duplicate campaign general name appropriate to nation. If main == 1 this is the main name as used by all generals. If main == 0 name is supplementary name shown before main name
SetCampaignNonDuplicateRandomGeneralName(generalIndex, side)

// Maps campaign generals to battle and vice versa. Uses first and second system arrays
MapCampaignGeneralsToBattle(side)

GetCampaignArmyGeneralIndex(army)

// Set Campaign Army's General Index. Note, -1 means there is no general.
SetCampaignArmyGeneralIndex(army, value)

// Prints campaign army general name if not generic.
PrintCampaignArmyGeneralName(army, linefeed)

AddCampaignGeneralToUnit(me, generalIndex, side, generalType)

// Returns generalIndex of most senior general in army, otherwise returns -1
GetCampaignArmyMostSeniorGeneral(army)

// Does C-in-C promotions and demotions after battle. If general demoted he will get replaced by another general if one is now more senior.
CheckCinCPromotionDemotion(army, winner)

// Used for province names in random map campaigns (index permitted values 0-511. No check performed.)
GetProvinceNameIndex(province)

// Used for province names in random map campaigns (index permitted values 0-511. No check performed.)
SetProvinceNameIndex(province, index)

// Disbands campaign army - if it exists
DisbandCampaignArmy(army)

// Used if Province SideID is recorded
GetProvinceSideID(province)

// Used for recording province SideID if needed. 255 used to indicate that SideID has not yet been set. NOTE: There must not be more than 255 Side IDs.
SetProvinceSideID(province, sideID)

// Used if Province ArmyList chunk is recorded
GetProvinceArmyListChunkIndex(province)

// Used for recording special province army list chunk index if needed. 255 used to indicate that chunk has not yet been set.
// NOTE: There must not be more than 255 chunks in ArmyList.txt.
SetProvinceArmyListChunkIndex(province, chunkIndex)

// Gets unit SideID. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
GetCampaignUnitSideID(unitIndex, side)

// Sets unit SideID. Logs warning if attempt to set it outside the range 0-255. Note: To save processing, does not check that unit exists.
SetCampaignUnitSideID(unitIndex, side, sideID)

// Gets unit SideID. Note: To save processing, does not check that unit exists. If it doesn't the data returned will be meaningless.
GetCampaignUnitTextureIndex(unitIndex, side)

// Sets unit SideID. Logs warning if attempt to set it outside the range 0-255. Note: To save processing, does not check that unit exists.
SetCampaignUnitTextureIndex(unitIndex, side, variantIndex)

GetCampaignArmyUnderSiege(army)

// Set Campaign Army's Under Siege Flag
SetCampaignArmyUnderSiege(army, value)

GetCampaignArmyHoldingForce(army)

// Set Campaign Army's Holding Force Flag
SetCampaignArmyHoldingForce(army, value)

// Returns the army's current location. Returns -1 if army does not exist (i.e. is not anywhere)
GetCampaignArmyProvince(army)

SetCampaignArmyProvince(army, province)

// Clear all campaign global arrays at start of each campaign (because unlike Campaign variables they are not automatically cleared)
ClearCampaignGlobals()

// Sets the number of figures in a unit at the start of a campaign battle
CustomiseUnitManCount(me)

AssignTextureVariantToCampaignUnit(unitIndex, side)

// Note: FromFileChunkIndex uses Work String 2
GetArmyListChunkIndexFromChunkName(chunkName)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\MoreCampaignTools.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\MoreScenarioTools.BSF
:::: 78 functions
::::   IsTurnEven(side)
::::   ClearTeamAllDestinations(side, team)
::::   AnyTeamMemberNear(side, team, x, y)
::::   SetStandardDeploymentBounds()
::::   SetAllTileData()
::::   PlayerUnitReachedY(y, excludeFoot, excludeMounted, excludeLights)
::::   PlayerUnitIn(x1, y1, x2, y2, excludeFoot, excludeMounted, excludeLights)
::::   TeamUnitIn(side, team, x1, y1, x2, y2, excludeFoot, excludeMounted, excludeLights)
::::   TeamUnitReachedY(side, team, y, excludeFoot, excludeMounted, excludeLights)
::::   AnyTeamMemberMorale(side, team, moraleState)
::::   PercentRemaining(side)
::::   DisplayPercentRemaining(side)
::::   AllRouted(side)
::::   DistanceToNearestEnemy(me, excludeFoot, excludeMounted, excludeLights)
::::   NumberOfPlayerUnitsIn(x1, y1, x2, y2, excludeFoot, excludeMounted, excludeLights)
::::   NumberOfTeamUnitsIn(side, team, x1, y1, x2, y2, excludeFoot, excludeMounted, excludeLights)
::::   ShiftUnits(x1, y1, x2, y2, side, shiftX, shiftY)
::::   UnitDeployShiftedUnit(id, x, y, shiftX, shiftY)
::::   PrintTotalPoints()
::::   ArmyPoints(side)
::::   MPStandardIntro()
::::   StandardScenarioUI(string, extended)
::::   SetMPForceRatio()
::::   AutoDeploy(side, deployment_type)
::::   AssignHorse(side, wing1_terrain, wing2_terrain, cavalry_army, deployment_type)
::::   AssignLights(side, centre_terrain, wing1_terrain, wing2_terrain, deployment_type, centre_width)
::::   GetTerrainDensity(x1,y1,x2,y2)
::::   UnitDeployY(id, x, y)
::::   GetArtilleryBlockScore(side, x, y)
::::   SeekBetterArtilleryPosition(id, x, y)
::::   CheckForSkirmishReinforcements(side)
::::   IsCavalryArmy(side)
::::   GetColdStorageY(side)
::::   CheckForSkirmishFlankMarch(side)
::::   GetFlankMarchArrivalFlank(side)
::::   FlankMarchArrive(side, wing, centreY, reverse)
::::   GetNumberOfSequesteredUnits(side)
::::   GetFlankMarchCentreY(side)
::::   GetFlankMarchStartY(side, centreY, units)
::::   ReSkinArmy(side, reverse)
::::   ReSkinUnit(id, foldernumber)
::::   StandardVictoryConditions(breakpoint0a, breakpoint0b, breakpoint1a, breakpoint1b, drawdecider, MPgame)
::::   MaybeEndBattle()
::::   CheckBattleEnded()
::::   RevealOwnDeploymentArea(side)
::::   RestrictedZone()
::::   SetTeamMaxAP(side, team, AP, excludeLightTroops)
::::   GovernTeamSpeed(side, team, ignoreSlowLights, governLights)
::::   GetArmyListChunkNameFromChunkIndex(chunk)
::::   SetBattlefieldControlBoundaryMarkers()
::::   UpdateBattlefieldControlVictoryPoints()
::::   DeployEscortMissionFlankingForces(side)
::::   DeployBaggageTrain(side, FootCentreX, yLine, cavalry_army)
::::   EscortMissionVictoryConditions()
::::   GetTerrain(type)
::::   GetRegion(type)
::::   GetMapType(region, terrain)
::::   PrintSkirmishData(side, scenario, intro)
::::   PrintFlankReinforcementData(side, intro)
::::   GetWingsTerrain(side, footMinX, footMaxX)
::::   IsTileBeyondRiver(x,y)
::::   SetBannerIndex(side, reverse)
::::   SetBannerIndices()
::::   AutoDeployGenerals(side)
::::   SequesterOffMapUnits(side)
::::   SequesterFlankMarch(side, percent)
::::   SequesterReinforcements(side)
::::   RoughDeploy(me)
::::   GetTotalSequesterablePoints(side)
::::   IsBaggageScenarioFlankMarcher(me)
::::   GetRandomArmyList(side, years, enemyArmy, enemyChunkIndex)
::::   GetArmyYears(army)
::::   SetUpHypotheticalBattle(FightNow)
::::   IsInColdStorage(id)
::::   IsLightArmy(side)
::::   SetRegionalDaylight()
::::   CheckForReversedStartingPositions()
::::   TotalUnfixed(side)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Returns 1 if turn is Even for the side - e.g. Turn 3 is side 1's turn 2, and hence even
IsTurnEven(side)

// Clear team destination and all of its units' individual destinations.
ClearTeamAllDestinations(side, team)

// Returns 1 if any team member is within 1 square of x,y.
AnyTeamMemberNear(side, team, x, y)

// Set bounds for standard deployment, using campaign variables DeploymentX and DeploymentY.
// Indices: 0,1 x1,x2 for non-lights of side 0, 2,3 x1,x2 for lights of side 0, then 4,5,6,7 the same for side 1.
SetStandardDeploymentBounds()

// Used in Core.BSF Tick function to set up obstacle tile data for UI helpers and IsTileDefendibleObstacle() to use.
// Should be called once only after game start or reload, using "if (GetTransientFlag() == 0)". (See Tick() function in Core.BSF).
SetAllTileData()

// Function to report if enemy advance has reached y - excluding routed units - and with optional other exclusions.
// NOTE: Assumes that armies are in "standard" positions - player lined up parallel to X axis at low Y values, AI lined up parallel to X axis on high Y values. Won't be much use otherwise.
PlayerUnitReachedY(y, excludeFoot, excludeMounted, excludeLights)

// Function to report if any unrouted enemy unit is within the specified rectangle - with optional exclusions.
PlayerUnitIn(x1, y1, x2, y2, excludeFoot, excludeMounted, excludeLights)

// Function to report if any unit of team is within the specified rectangle - with optional exclusions.
TeamUnitIn(side, team, x1, y1, x2, y2, excludeFoot, excludeMounted, excludeLights)

// Function to report if team member has reached y - excluding routed units - and with optional other exclusions.
// NOTE: Assumes that armies are in "standard" positions - player lined up parallel to X axis at low Y values, AI lined up parallel to X axis on high Y values. Won't be much use otherwise.
TeamUnitReachedY(side, team, y, excludeFoot, excludeMounted, excludeLights)

// Returns 1 if any team member has reached specified morale state
AnyTeamMemberMorale(side, team, moraleState)

// Returns % of army unrouted, based on base UnitSize with mounted troops counting 50% more proportionately.
PercentRemaining(side)

// Returns % of army unrouted, based on base UnitSize with mounted troops counting 50% more proportionately.
// Works on "DisplayMoraleState" attrib rather than "MoraleState" attrib.
// Used only for UI display, not victory conditions.
DisplayPercentRemaining(side)

// Returns 1 if all side's on-table units are routed or destroyed. (Ignores unrouted units that are evading or pursuing off playable map).
AllRouted(side)

// Returns distance to nearest unbroken enemy of a non-excluded type. (Returns 64000 if none found).
DistanceToNearestEnemy(me, excludeFoot, excludeMounted, excludeLights)

// Function to report number of unrouted enemy non-artillery units within the specified rectangle - with optional exclusions.
NumberOfPlayerUnitsIn(x1, y1, x2, y2, excludeFoot, excludeMounted, excludeLights)

// Function to report number of unrouted team units within the specified rectangle - with optional exclusions.
NumberOfTeamUnitsIn(side, team, x1, y1, x2, y2, excludeFoot, excludeMounted, excludeLights)

// Used to shift units from an area so that reinforcements can be deployed. Can be used to shift friends or foes.
// If both are to be shifted, will need two calls to the function.
// Don't shift units that are in close combat/pursuing/being pursued
ShiftUnits(x1, y1, x2, y2, side, shiftX, shiftY)

// Helper function for ShiftUnits() which will try nearby squares if the stated square is occupied or severely disordering.
// Uses random method. Tries to go in direction of shift.
// Returns 1 if successful, 0 if not. Does NOT swap units if no clear tile found.
UnitDeployShiftedUnit(id, x, y, shiftX, shiftY)

// Prints total points of army
PrintTotalPoints()

// Returns total starting points value of army
ArmyPoints(side)

// Show MP standard into if it is either player's first turn
MPStandardIntro()

// Shows the current status and victory conditions in the top left corner of the screen.
// If UniversalVar "MPForceRatio" has been set - see SetMPForceRatio() - it will show the MP adjusted victory conditions
// If extended = 0, displays only the string sent to the function, otherwise shows standard extensions.
// For preset scenarios, looks to see if there are bespoke sidename strings to use for the specific scenario instead of the default ones for the SideIDs. 
// These take the form IDS_SIDENAME_[scenario filename]_0 and IDS_SIDENAME_[scenario filename]_1.
// [scenario filename] does not include the extension.
// Uses WorkStrings 0 and 1.
StandardScenarioUI(string, extended)

// Sets "MPForceRatio" UniversalVar - which is the ratio (%) of Side0's total forces to Side1's total forces in points.
// If this is called by the scenario script, StandardVictoryConditions() will use MP adjusted victory conditions.
// If called each turn from StartTurnPost() in the scenario script, it will update the VCs to take into account the arrival of reinforcements.
SetMPForceRatio()

// Do standard pre-deployment-phase deployment for Skirmish games.
// Assumes minimal amounts of impassable terrain.
// deployment_type = 0 for Hellenistic, 1 for Roman, 2 for Skythian
AutoDeploy(side, deployment_type)

// Helper function for AutoDeploy(). Main purpose is to reduce number of local variables in the main function which otherwise go beyond limit.
AssignHorse(side, wing1_terrain, wing2_terrain, cavalry_army, deployment_type)

// Helper function for AutoDeploy(). Main purpose is to reduce number of local variables in the main function which otherwise go beyond limit.
AssignLights(side, centre_terrain, wing1_terrain, wing2_terrain, deployment_type, centre_width)

// Returns a terrain density value for the area under consideration. (For use in AutoDeploy()).
GetTerrainDensity(x1,y1,x2,y2)

// Further extended UnitDeploy() which will try nearby squares if the stated square is occupied or severely disordering.
// Uses random method. Tries to go backwards in preference to forwards (the reverse for artillery).
// Returns 1 if successful, 0 if not. Does NOT swap units if no clear tile found.
// Also avoids squares beyond river
UnitDeployY(id, x, y)

// Returns a value for the column of 6 squares directly ahead of artillery location - estimating how blocked it is be terrain.
// The closer the blocking terrain is to the artillery, the worse it is.
GetArtilleryBlockScore(side, x, y)

// Seeks better artillery position (if current position blocked)
SeekBetterArtilleryPosition(id, x, y)

CheckForSkirmishReinforcements(side)

// Returns 1 if army deemed to be a cavalry army (for deployment and AI purposes), 0 if not.
IsCavalryArmy(side)

// Gets Y value of cold storage region for units that have already been created but are awaiting arrival on the battlefield (Reinforcements or Flank Marches).
// The base line of the side's map margin is used for this purpose.
GetColdStorageY(side)

// Tests to see whether there is a flank march and if so whether it will arrive and where
CheckForSkirmishFlankMarch(side)

// Helper function for CheckForSkirmishFlankMarch(). 1 = high x wing, 2 = low x wing
GetFlankMarchArrivalFlank(side)

// Helper function for CheckForSkirmishFlankMarch()
FlankMarchArrive(side, wing, centreY, reverse)

// Helper function for CheckForSkirmishFlankMarch()
// Returns number of sequestered units.
// Places their ids in global array: gSequesteredUnits[]
GetNumberOfSequesteredUnits(side)

// Helper function for CheckForSkirmishFlankMarch()
GetFlankMarchCentreY(side)

// Helper function for CheckForSkirmishFlankMarch()
GetFlankMarchStartY(side, centreY, units)

// Re-Skins whole army. Uses WorkString(0), WorkString(1).
// if (reverse == 1) reverses the usual side skins - i.e. side0 uses the second half of the skins, side1 uses the first half. 
// This is useful for reversed scenarios, so that the same skins are used for the same army in both versions.
ReSkinArmy(side, reverse)

// Re-Skins unit from the specified unit textures sub-folder
// This function uses WorkString(0) and WorkString(1)
ReSkinUnit(id, foldernumber)

// Standard Victory Conditions function
// If drawdecider == 0 side0 wins draws, drawdecider == 1 side1 wins draws, drawdecider == 2 side who is winning wins draws
// If UniversalVar "MPForceRatio" has been set - see SetMPForceRatio() - it will use the MP adjusted victory conditions
StandardVictoryConditions(breakpoint0a, breakpoint0b, breakpoint1a, breakpoint1b, drawdecider, MPgame)

// Show Popup allowing player (SP only) to continue the game after the enemy is defeated
MaybeEndBattle()

// Helper function for MaybeEndBattle.
CheckBattleEnded()

// Used to make sure all of own deployment area is visible, so that troops can be deployed in cover.
// Only works if standard deployment bounds have been set.
RevealOwnDeploymentArea(side)

// Returns width of no-deploy zone for non-light infantry
RestrictedZone()

// Reduces whole team to certain maximum AP. Optionally exclude light troops from this.
SetTeamMaxAP(side, team, AP, excludeLightTroops)

// Reduce team AP to AP of slowest non-routing, non-fragmented non-artillery/train/naval unit.
// ignoreSlowLights parameter allows choice of whether (for example) faster mounted troops keep to speed of light foot in their team or not.
// governLights parameter allows choice of whether light troops should be allowed to go on ahead or not.
GovernTeamSpeed(side, team, ignoreSlowLights, governLights)

// Gets Army List Chunk Name in WorkString(0);
GetArmyListChunkNameFromChunkIndex(chunk)

// Set markers for battlecontrol for advance guard skirmish.
SetBattlefieldControlBoundaryMarkers()

UpdateBattlefieldControlVictoryPoints()

// Helper function for Autodeploy in Escot missions
DeployEscortMissionFlankingForces(side)

// Deploy baggage train (for escort scenario)
DeployBaggageTrain(side, FootCentreX, yLine, cavalry_army)

EscortMissionVictoryConditions()

// Get terrain type from map type
// Region: 0 = Agricultural, 1 = Hilly, 2 = Woody, 3 = Mountainous, 4 = Steppe, 5 = Desert, 6 = Tropical, 7 = Marsh, 8 = Sea.
GetTerrain(type)

// Get region from map type
// Region: 0 = Mediterranean, 1 = Northern Europe, 2 = Middle East, 3 = Tropical
GetRegion(type)

GetMapType(region, terrain)

PrintSkirmishData(side, scenario, intro)

// Print Flank March and Reinforcements data.
// If intro == 1 print intro version, otherwise on going version.
PrintFlankReinforcementData(side, intro)

GetWingsTerrain(side, footMinX, footMaxX)

IsTileBeyondRiver(x,y)

// Set banner index for side. Lists of which sideIDs get which banners are held in BannerSideIDs.txt in Core or custom campaign folder. 
// This must have an even number of chunks, matching the chunks in Banner.txt in /Data/Battale/Banners.
// The chunks are in pairs, representing the side0 and side1 version of each banner type.
// Uses Work String 0
SetBannerIndex(side, reverse)

// Set both sides' banner indices.
SetBannerIndices()

AutoDeployGenerals(side)

// Sets aside units that will be used for flank marches and reinforcements.
SequesterOffMapUnits(side)

SequesterFlankMarch(side, percent)

SequesterReinforcements(side)

// Deploy unit in a predeployment block on map when first purchased. Also used to place units that cannot be correctly deployed by AutoDeploy()
RoughDeploy(me)

// Calculate total points of troops for Sequester functions. 
// If all units are fixed, use the total cost of those, otherwise use fixed + GetForcePointsX(side).
// Should therefore work for side0 and side1 whether or not there is any force selection stage.
GetTotalSequesterablePoints(side)

// Returns 1 if unit is part of a defend the baggage scenario flank march. Note that this only works correctly before any troops move from their start positions.
IsBaggageScenarioFlankMarcher(me)

// Get a random army list on the appropriate side
// Uses WorkString() for the random army name, and WorkString(1) for the enemy army name.
// enemyArmy is the chunk name string of the enemy army
// enemyChunkIndex is the Chunk Index of the enemy army, to be used for Side1 if the Side0 army is PotLuck. If not, the parameter passed should be -1.
GetRandomArmyList(side, years, enemyArmy, enemyChunkIndex)

// Returns the year range of the army in the standard format
GetArmyYears(army)

// Uses Workstring 0, 1, 2 and Work Array 0, 1 and 2
SetUpHypotheticalBattle(FightNow)

// Returns 1 if unit is in cold storage (sequestered for flank march or reinforcements)
IsInColdStorage(id)

// Returns 1 is enemy army is considered light - at least 70% light
IsLightArmy(side)

// Uses work strings 0 and 1. Note there is no error checking, so the file needs to exist in the /Lighting folder.
// Also sets a regional vignette.
SetRegionalDaylight()

// Sets global flag for the armies being in reversed starting positions.
CheckForReversedStartingPositions()

// Returns total number of unfixed units in side
TotalUnfixed(side)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\MoreScenarioTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\MoveCommandTools.BSF
:::: 5 functions
::::   MoveTowardsDestination(me)
::::   CanGroupMove(id, team)
::::   AICanGroupMove(id, team)
::::   TooCloseToGroupMove(me)
::::   AnyVisibleEnemyCloserToOriginalTeamThan(side, originalTeam, testDistance, ignoreLights)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Moves unit as far as it can towards destination
MoveTowardsDestination(me)

// Returns 1 if unit is elegible to take part in group move by this team, 0 otherwise. (Player version).
CanGroupMove(id, team)

// Returns 1 if unit is elegible to take part in group move by this team, 0 otherwise. (AI version).
AICanGroupMove(id, team)

// Not currently used.
// Returns 1 if visible enemy are too close to allow unit to participate in group move
// Probably won't work correctly for units hidden in terrain. Probably needs to use MakeClosestUnitsToUnitList(me, 0), in which case the GetTileLOS() stuff would be redundant
// but then won't work in StartTurnFunctions.
TooCloseToGroupMove(me)

// Returns 1 if any enemy closer to (original) team than testDistance
AnyVisibleEnemyCloserToOriginalTeamThan(side, originalTeam, testDistance, ignoreLights)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\MoveCommandTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\MPSShowArmyTools.BSF
:::: 13 functions
::::   MPSShowArmy_SetUpUI()
::::   MPSShowArmy_SortRating(campaignUnitIndex,side)
::::   MPSShowArmy_MoveSelectedUnits(array1, array2, side)
::::   MPSShowArmy_PopulateListBox(box, side)
::::   MPSShowArmy_CalculateStoodDownPoints()
::::   MPSShowArmy_CalculateRefitCost()
::::   MPSShowArmy_StandDownUnits()
::::   MPSShowArmyRenderListItem(x, y, width, height, pass, flags, item, name)
::::   MPSShowArmy_PrintQualityString(experience,elan)
::::   ShowMPSShowArmyTooltip(char string[32], mousey, data)
::::   MPSShowArmy_PrintUnitStatsInfo(unitIndex, side)
::::   MPSShowArmy_DisplayPoints(list)
::::   MPSShowArmy_IsUnitUnwieldy(typeIndex, unitIndex, side)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Uses Work Arrays 0,1,2,3
MPSShowArmy_SetUpUI()

MPSShowArmy_SortRating(campaignUnitIndex,side)

// Moves unit from one array to the other
MPSShowArmy_MoveSelectedUnits(array1, array2, side)

// Populate list box - box = 0 is left, box = 1 is right
MPSShowArmy_PopulateListBox(box, side)

MPSShowArmy_CalculateStoodDownPoints()

MPSShowArmy_CalculateRefitCost()

MPSShowArmy_StandDownUnits()

// Uses WorkStrings 0 - 5
MPSShowArmyRenderListItem(x, y, width, height, pass, flags, item, name)

// Prints quality string
MPSShowArmy_PrintQualityString(experience,elan)

// index is the listbox item the mouse is currently over. mousey is the screen mouse y position (in 1024 x 768)
// Uses WorkStrings 0 - 4;
// unitIndex is the unit's campaign unit index
ShowMPSShowArmyTooltip(char string[32], mousey, data)

// Print unit type stats for Force Select
MPSShowArmy_PrintUnitStatsInfo(unitIndex, side)

// Uses workstring 0
MPSShowArmy_DisplayPoints(list)

// returns 1 if unit type qualifies as unwieldy. Allows for campaign changes to experience
MPSShowArmy_IsUnitUnwieldy(typeIndex, unitIndex, side)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\MPSShowArmyTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\MultiPartSkirmishTools.BSF
:::: 45 functions
::::   MPS_RaiseArmy(side, province, points1, points2)
::::   MPS_AI_RaiseArmy(side, province, points1, points2)
::::   MPS_SetArmyListIntro(side)
::::   MPS_SetUpBattle()
::::   MPS_GetPointsFromSizeCode(size)
::::   MPS_CopyArmy(army, province)
::::   DebugListArmies()
::::   MPS_StartBattle(province)
::::   MPS_CopyArmiesForward(province)
::::   MPS_Revert_Campaign_Stage()
::::   MPS_SetUpDecisionTree()
::::   MPS_GetIdealBattlePoints(stage)
::::   MPS_CalcReinforcementAndGarrisonPoints(stage, side)
::::   MPS_GetTrueUnitPointsValue(id)
::::   ActivateMPSUI(retainSelected)
::::   MPS_SetUpCampaign()
::::   MPS_GetMapSetandAllies(side)
::::   MPS_RaiseBrandNewAIArmy(province, side1points)
::::   MPS_GetRegionFromMapSet(mapSet)
::::   MPS_GetPotluckMapType(mapSet)
::::   MPS_SetUpPursuit(province)
::::   MPS_PursuitRating(unitIndex, side)
::::   MPS_Show_Strategic_Choices()
::::   MPS_GetStageAdjustedDifficultyModifier(stage)
::::   InitMPSUI()
::::   MPS_RefitArmy(province, side)
::::   MPS_SetUpCustomCampaign()
::::   MPS_TestRefitCost(province, side, excludeBesieged)
::::   MPS_AddRearEchelonTroopsToArmy(province, army, side, points)
::::   MPS_AddCustomGeneral(side, army, sideID, seniority, combatSkill, type, quality, nameIndex)
::::   MPS_AddAndRetireGenerals()
::::   MPS_Housekeeping()
::::   MPS_UpdateArmyLists()
::::   ClearMPSGlobals()
::::   SetCampaignUnitFixed(unitIndex, side, fixed)
::::   GetCampaignUnitFixed(unitIndex, side)
::::   MPS_PrintQualityString(unitIndex, side)
::::   MPS_SetFirstForceSizeButton(size)
::::   MPS_SetLastForceSizeButton(size)
::::   MPS_SetLastForceSizeButtonVisibility()
::::   MPS_SetDiffProgButton(value)
::::   MPS_RePrintBattleResult()
::::   PlaceMPSMapMarker(index, mapX, mapY)
::::   MPS_GetCustomMapMarkerLocations()
::::   MPS_SetSortButtons()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// points1 is the points on which the nimima are based, points2 is the actual total points available
MPS_RaiseArmy(side, province, points1, points2)

// Raise AI army, returns actual points spent
MPS_AI_RaiseArmy(side, province, points1, points2)

MPS_SetArmyListIntro(side)

MPS_SetUpBattle()

MPS_GetPointsFromSizeCode(size)

// Puts an exact copy of an army in a different "province", so that the previous one can be retained for restoring to previous position.
// Note that the campaign province system is use to mark stages along the MPS track.
// Returns index of copied army
MPS_CopyArmy(army, province)

DebugListArmies()

MPS_StartBattle(province)

// Copies armies from province to province + 1;
MPS_CopyArmiesForward(province)

MPS_Revert_Campaign_Stage()

MPS_SetUpDecisionTree()

// Returns the ideal side 1 battle points for this stage in campaign
MPS_GetIdealBattlePoints(stage)

// Returns reinforcement points directly, and garrison points in the gMPSGarrison global variable
MPS_CalcReinforcementAndGarrisonPoints(stage, side)

// Gets pre-battle points value of unit. (Does not take into account Diffulty mode 0 or 5 quality adjustments).
MPS_GetTrueUnitPointsValue(id)

// This need to be run in UI_OBJ_RENDER() otherwise SkirmishSetArmyLists() [I think] crashes the program.
// Uses WorkStrings 0 and 1
ActivateMPSUI(retainSelected)

// uses Work String 0
MPS_SetUpCampaign()

// Uses WorkStrings 0, 1, 3, 4. WorkString 2 used by FromfilechunkIndex().
MPS_GetMapSetandAllies(side)

MPS_RaiseBrandNewAIArmy(province, side1points)

MPS_GetRegionFromMapSet(mapSet)

// Get potluck map type from map set
MPS_GetPotluckMapType(mapSet)

// Sequester units that will not take part in pursuit by moving them to a separate army and marking that as "under siege"
MPS_SetUpPursuit(province)

// Returns the pursuit rating of a campaign unit
MPS_PursuitRating(unitIndex, side)

// Uses Work Strings 0, 1
MPS_Show_Strategic_Choices()

// Returns difficulty modifier for MPS Campaigns
MPS_GetStageAdjustedDifficultyModifier(stage)

InitMPSUI()

// Refits all side's armies in "province" as far as available reinforcements allow, and deducts the cost from the expected reinforcements variable.
MPS_RefitArmy(province, side)

// Uses WorkStrings 0, 1, 2, 3. (Work String 0 used by GetSideIDFromChunkIndex() and in setting up map marker locations. Work String 2 used by GetArmyListChunkIndexFromChunkName())
MPS_SetUpCustomCampaign()

// Returns refit cost in province. Does not perform refit.
MPS_TestRefitCost(province, side, excludeBesieged)

// Add rear echelon troops to army. Uses first 3 work arrays. Returns 1 if any units were added, otherwise 0
MPS_AddRearEchelonTroopsToArmy(province, army, side, points)

// Add custom CinC
MPS_AddCustomGeneral(side, army, sideID, seniority, combatSkill, type, quality, nameIndex)

MPS_AddAndRetireGenerals()

// Set up pursuits, and determine required garrison, expected reinforcements and refit cost
MPS_Housekeeping()

// Update allies and main army lists if changed by battle data from CustomCampaign.txt
// Also set gNoCoastal for battle.
// Also check for custom strengthMultiplier
MPS_UpdateArmyLists()

ClearMPSGlobals()

SetCampaignUnitFixed(unitIndex, side, fixed)

GetCampaignUnitFixed(unitIndex, side)

// Prints quality string for a particular campaign unit
MPS_PrintQualityString(unitIndex, side)

// uses Work String 0
MPS_SetFirstForceSizeButton(size)

// uses Work String 0
MPS_SetLastForceSizeButton(size)

MPS_SetLastForceSizeButtonVisibility()

MPS_SetDiffProgButton(value)

MPS_RePrintBattleResult()

// uses WorkString 0
PlaceMPSMapMarker(index, mapX, mapY)

MPS_GetCustomMapMarkerLocations()

MPS_SetSortButtons()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\MultiPartSkirmishTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\ObstacleTools.BSF
:::: 4 functions
::::   IsTileEdgeDefendibleObstacle(x1, y1, x2, y2)
::::   IsTileEdgeReallyDefendibleObstacle(x1, y1, x2, y2)
::::   Function FindObstacle(x1, y1, edgeObjectX, edgeObjectY, orientation, x2, y2)
::::   PrintObstacleStatus(me, tilex, tiley)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Performs preliminary check against TileData before testing objects
IsTileEdgeDefendibleObstacle(x1, y1, x2, y2)

// Determines whether there is a defensible obstacle between defender and assaulter or shooter.
// Returns type of obstacle: -1 = no obstacle, 0 = obstacle providing protection against cavalry but no cover, 1 = obstacle providing protection against cavalry plus cover (excpet vs artillery),
// 2 = obstacle providing a POA as well as protection against cavalry and cover (essentially field fortifications),
// 3 = can only be crossed from outside using scaling ladders (or if destroyed - not yet implemented)
// x1, y1 are location of defender, x2, y2 are location of attacker. Function assumes that a linear obstacle protects at anything more to the front than directly to the side
IsTileEdgeReallyDefendibleObstacle(x1, y1, x2, y2)

Function FindObstacle(x1, y1, edgeObjectX, edgeObjectY, orientation, x2, y2)

// DEBUG
// Print defensive obstacle data - if we want to use this for UI purposes will need to define strings in localisation files.
PrintObstacleStatus(me, tilex, tiley)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\ObstacleTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\QuestControlsTools.BSF
:::: 9 functions
::::   ScenariosList_RenderListItem(char string[32], x, y, width, height, pass, flags, item, name)
::::   PrintScenarioSideName(side, index)
::::   FindReverseScenario(index)
::::   PopulateCampaignList()
::::   PopulateBattleList()
::::   QC_SetBannerIndices(scenarioIndex)
::::   QC_SetBannerIndex(scenarioIndex, side, reverse)
::::   ReadScenarioData()
::::   PlaceScenarioMapMarker(index)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Uses WorkString 0.
ScenariosList_RenderListItem(char string[32], x, y, width, height, pass, flags, item, name)

// index is index of scenario
// Uses workstrings 0 and 1
PrintScenarioSideName(side, index)

// Returns index of reversed scenario if any, otherwise -1
// Uses WorkString 0
FindReverseScenario(index)

// Note that this works on campaigns filtered by TYPE specified in campaign.txt and set by SetCampaignScreenFilter().
PopulateCampaignList()

PopulateBattleList()

QC_SetBannerIndices(scenarioIndex)

QC_SetBannerIndex(scenarioIndex, side, reverse)

// reads scenario data for the current campaign (for use in QuestControls)
// Uses WorkStrings 0 and 1
ReadScenarioData()

PlaceScenarioMapMarker(index)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\QuestControlsTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\ScenarioTools.BSF
:::: 2 functions
::::   ShowTip(string)
::::   Invite_ShowHelpPopups(sideid)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

//	Misc tools useful for doing scenario related functions
ShowTip(string)

// The following is a function that you can add to StartTurn to give some beginner info for MP invite missions
// it will feed a tip at the start of each turn
// sideid is 0 for US, 1 for Germans.
Invite_ShowHelpPopups(sideid)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\ScenarioTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\StartTurnPreTools.BSF
:::: 4 functions
::::   StartTurnPreHousekeeping(side)
::::   CompleteLastTurnShooting(side)
::::   DoHousekeepingShooting(id)
::::   SetAllStatusFlags()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// This function needs to be included in the SCENARIO StartTurn(side) function in every "Scenario".BSF file so that it gets processed before the unit APs update
StartTurnPreHousekeeping(side)

// This completes the shooting of any AI units that have not already shot last turn - either because the AI did not get around to it, or because the units group moved.
CompleteLastTurnShooting(side)

// Helper function for CompleteLastTurnShooting()
// NOTE: Need to stop units that are in Ambush (or have Hold Fire orders if we implement them) from shooting here - NOT YET IMPLEMENTED
// However, GetTileLOS() does not work in StartTurn functions, so will need an alternative method - might have to set a unit flag.
DoHousekeepingShooting(id)

SetAllStatusFlags()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\StartTurnPreTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\Tools.BSF
:::: 64 functions
::::   RenderVCenteredString(x, y, width, height, left, font, colour)
::::   ResetViewDistance(me)
::::   GetSneakMultiplier( me )
::::   EnterSneakMode(me)
::::   LeaveSneakMode( me )
::::   BonusTimerCheck(unit, name)
::::   BonusIconUI(x, y, name)
::::   BonusCheck(x, y, unit, name)
::::   BonusShowButtonInfo(name)
::::   BonusUICheck(name)
::::   CanUnitEverGoHere(me, x, y, ignoreUnseen)
::::   CheckMovePossible(me, x, y, mode, showRoute, ignoreUnseen)
::::   CheckFallBackPossible(me, tilex, tiley)
::::   PlayVoice(sfx, unit)
::::   GetEnemySide(me)
::::   GetPlayerSide ()
::::   GetAISide ()
::::   IsTileInMap (x, y)
::::   UtilCanDoMove(me, x, y)
::::   UtilIsUnitSneaky( me )
::::   CheckFeedbackOptionsValue(index)
::::   SetFeedbackOptions(feedback)
::::   FlagMissFeedback(index)
::::   HideUnit (unit)
::::   System_TryUnitUnload(me, tilex, tiley)
::::   TurnCost(me, tilex, tiley, test)
::::   IsUnwieldy(me)
::::   SkewedRandom(min, max, skew_type)
::::   AdjacentX(x, facing)
::::   AdjacentY(y, facing)
::::   GetFacing(x1,y1,x2,y2)
::::   CorrectedFacing(me)
::::   GetQuality(me)
::::   AdjustedExperience(me)
::::   AdjustedElan(me)
::::   ProximityToMapEdge(x,y)
::::   VariableMoveAdjustment()
::::   AreTilesAdjacent(x1,y1,x2,y2)
::::   GetReachableDestination(me, free_turns)
::::   GetCostTileStep(me,x1,y1,x2,y2)
::::   FlushVizQueue()
::::   NearestPlayableX(x)
::::   NearestPlayableY(y)
::::   EdgeOfPlayableArea(x,y)
::::   Absolute(x)
::::   StartingStrength(me)
::::   CheckRouteNotZOCd(me, ignoreLastTile)
::::   SquareZOCd(x, y, me, ignore_routers, ignore_hidden, wideZOC)
::::   IsTileZOCing(me, myX, myY, tilex, tiley, ignore_routers, wideZOC)
::::   TileZOCingType(me, myX, myY, tilex, tiley, ignore_routers)
::::   CanZOC(unit, me, ignore_routers)
::::   PrintZOC(id)
::::   CheckRouteDiagonalStepNotBlocked(me, mode)
::::   DiagonalZOC(me, oldX, oldY, newX, newY)
::::   MoveOffTableUnitAwayFromEdge(me)
::::   RandomiseStartingStrength(id, starting_strength)
::::   PermittedInterpenetration(me,unit)
::::   GetInterpenetrationX(x1,y1,x2,y2)
::::   GetInterpenetrationY(x1,y1,x2,y2)
::::   CheckPassThroughPossible(me, x, y, mode, showRoute, ignoreUnseen, APcheck)
::::   CheckRetreatPassThroughPossible(me, type, x, y, i, j, APcheck)
::::   MovePassThrough(me, x, y, type, retreat)
::::   IsUnitHidden(me)
::::   IsZOCBlocked(x1,y1,x2,y2)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// render a string vertically centered in the provided box
// left is the x coord of the string
RenderVCenteredString(x, y, width, height, left, font, colour)

ResetViewDistance(me)

GetSneakMultiplier( me )

EnterSneakMode(me)

LeaveSneakMode( me )

//  Generic check function for delayed bonuses
BonusTimerCheck(unit, name)

// deal with the logic for a bonus button
BonusIconUI(x, y, name)

// simple check to allow for cancelling etc.
BonusCheck(x, y, unit, name)

BonusShowButtonInfo(name)

// determine whether we can see the button enabled or not
BonusUICheck(name)

CanUnitEverGoHere(me, x, y, ignoreUnseen)

// Check if a move is possible. When routing or evading you don't need enough AP and turns don't cost anything.
// Returns cost of move if it is possible, otherwise -2;
// mode: 0 = normal move, 1 = routing, 2 = evading
CheckMovePossible(me, x, y, mode, showRoute, ignoreUnseen)

// Checks whether fall back is possible
// Returns true cost of fallback if it is possible, otherwise -2;
CheckFallBackPossible(me, tilex, tiley)

// Not currently used
PlayVoice(sfx, unit)

GetEnemySide(me)

GetPlayerSide ()

GetAISide ()

IsTileInMap (x, y)

//  Is it possible to move to the tile denoted?  Return 1 if yes, 0 if no
UtilCanDoMove(me, x, y)

//  Should the unit gain advantages for not moving and/or being in sneak
UtilIsUnitSneaky( me )

// should we show this
CheckFeedbackOptionsValue(index)

// increase the value and move on
SetFeedbackOptions(feedback)

// Helper function which checks the option value and then sets the miss feedback global
FlagMissFeedback(index)

HideUnit (unit)

// helper function to try and unload the unit
System_TryUnitUnload(me, tilex, tiley)

// Returns AP cost of turn required to face tile. Test = 1 if only testing turn, 0 if actually turning
// If test == 0, then this function will set the "MadeFreeTurn" flag unless the angle is less than 45 degrees.
// Turns of 45 degrees are free if unit has not already made a free turn, otherwise are costed.
TurnCost(me, tilex, tiley, test)

// returns 1 if unit qualifies as unwieldy
IsUnwieldy(me)

// Returns skewed randomly generated number.
SkewedRandom(min, max, skew_type)

// Returns x value for adjacent square in direction of facing. Note that facing does not appear to be precise.
AdjacentX(x, facing)

// Returns y value for adjacent square in direction of facing. Note that facing does not appear to be precise.
AdjacentY(y, facing)

// Returns facing to face x2,y2 from x1,y1. Note that these squares must be adjacent. If fails, returns -1, otherwise returns facing
GetFacing(x1,y1,x2,y2)

// Returns facing corrected to standard directions
CorrectedFacing(me)

// Returns quality value - result tweaked if game is being played on Very Easy mode or Very Hard mode.
GetQuality(me)

// Returns experience attrib adjusted for Very Easy and Nightmare difficulty modes
AdjustedExperience(me)

// Returns experience attrib adjusted for Very Easy and Nightmare difficulty modes
AdjustedElan(me)

// Returns -1 if not in playable area, 0 if away from all table edges, 1 if in flank zone, 2 if in rear zone
ProximityToMapEdge(x,y)

// Returns variable move distance AP adjustment: 25% chance of -4, 50% chance of 0, 25% chance of +4
VariableMoveAdjustment()

// Returns 1 if tiles are adjacent, 0 if they are not adjacent, -1 if they are the same tile.
AreTilesAdjacent(x1,y1,x2,y2)

// Sets temporary unit destination to match the furthest point it can reach along route to original destination, taking account of required turn.
// Uses work arrays 0 and 1. If free_turns == 1, ignores turn cost.
// Returns cost of reaching destination
GetReachableDestination(me, free_turns)

// Returns cost of tile step from x1,y1 to x2,y2 - locations must be adjacent or the same
GetCostTileStep(me,x1,y1,x2,y2)

//Function to set flag to force VizQ to flush
FlushVizQueue()

// Returns X of nearest square in playable area
NearestPlayableX(x)

// Returns Y of nearest square in playable area
NearestPlayableY(y)

// Returns 1 if tile is right on edge of playable area, otherwise 0
EdgeOfPlayableArea(x,y)

// Returns absolute value of x
Absolute(x)

// Returns starting strength of unit in men
StartingStrength(me)

// Check route for crossing enemy front. Assumes route already got. Returns -1 if route not ZOCd, id of ZOCing unit if it is.
// Can only move away from enemy ZOC in start square if end of move is further away from that enemy, and less than 45 degrees from directly in front
// If ignoreLastTile is 1, only checks the route to the penultimate tile
CheckRouteNotZOCd(me, ignoreLastTile)

// Returns -1 if square not ZOCd, otherwise id of first ZOCing enemy found
SquareZOCd(x, y, me, ignore_routers, ignore_hidden, wideZOC)

// Check if tile contains a ZOCCer. If so, returns the unit id, otherwise -1
IsTileZOCing(me, myX, myY, tilex, tiley, ignore_routers, wideZOC)

// Returns 0 if tile not ZOCd, 1 if minor ZOC, 2 if full ZOC
TileZOCingType(me, myX, myY, tilex, tiley, ignore_routers)

// Returns 1 if "unit" is of a type that can ZOC "me"
CanZOC(unit, me, ignore_routers)

// Prints ZOCed message. id is zoccing unit.
PrintZOC(id)

// Check route to make sure that it does not include a diagonal move step that is through a close combat or pursuit or (if normal move) across the front of a ZOCing enemy.
// Returns -2 if not possible, otherwise 0
// mode = 0 for normal moves, 1 = routing, 2 = evading, 3 = shooting, 4 = charging. 
// Note that modes 1,2, 3 and 4 currently all behave the same.
// Mode 0 is different in that it won't allow a normal move to cross diagonally in front of a "ZOC" capable enemy.
CheckRouteDiagonalStepNotBlocked(me, mode)

// Returns -1 if diagonal move step does not pass across front of an eligible ZOCer, otherwise the id of one such ZOCer.
DiagonalZOC(me, oldX, oldY, newX, newY)

// Moves off table unit a random distance away from the edge, to make room for more
// Don't move units that are in the first Y line of the side - they are unit that are for reinforcements or flank march.
// Also sets unit icons to 0 using SetUnitStatusFlag().
MoveOffTableUnitAwayFromEdge(me)

// Randomises unit starting strength by 5% either way. The starting_strength parameter is used to customise unit starting strength: 100 = normal size.
RandomiseStartingStrength(id, starting_strength)

// Returns 1 if interpenetration is ever permitted
PermittedInterpenetration(me,unit)

// Return X of square unit on x1,y1 would move to if it interpenetrated a unit in square x2,y2
// Returns -1 if unit is facing at right-angles to direction of travel.
GetInterpenetrationX(x1,y1,x2,y2)

// Return Y of square unit on x1,y1 would move to if it interpenetrated a unit in square x2,y2
// Returns -1 if unit is facing at right-angles to direction of travel.
GetInterpenetrationY(x1,y1,x2,y2)

// Check if a pass through is possible. When routing or evading you only need enough AP to enter the square containing the blocking unit and turns don't cost anything.
// Returns cost of move if it is possible, otherwise -2
// For routing/evading unit the cost of the move is the cost minus the cost of entering the square beyond the passed through unit.
// mode: 0 = normal move / bug out move, 1 = routing, 2 = evading
// if APCheck = 1, check unit has enough AP for move, if 0 then don't. (Needed when call is used after AP cost already deducted by GetNextRetreatStep())
CheckPassThroughPossible(me, x, y, mode, showRoute, ignoreUnseen, APcheck)

// Check pass through possible for retreaters - when trying to move from x,y to i,j where i,j contains a unit.
// Returns move cost (-2 if no move found)
// If APcheck is 1, check against units available AP. If 0 then don't (for when AP has already been deducted in GetNextRetreatStep())
CheckRetreatPassThroughPossible(me, type, x, y, i, j, APcheck)

// Function to move pass through. Currently teleports unit but hopefully will be replaced by an engine move command.
// Type: 0 = normal move or bug out move, 1 = rout, 2 = evade,
// retreat = 1 for bug out, rout or evade, 0 for normal move)
MovePassThrough(me, x, y, type, retreat)

// Returns 1 if unit is hidden from enemy, 0 if not. (Not valid during StartTurn functions).
IsUnitHidden(me)

// Checks whether diagonal ZOC is blocked by two units in close combat.
IsZOCBlocked(x1,y1,x2,y2)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\Tools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\TournamentTools.bsf
:::: 2 functions
::::   StandardTournamentScore()
::::   StandardInterimTournamentVictoryTest()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

StandardTournamentScore()

// Precalculate victory for interim tournament scoring. 
// Only works for skirmish battles (excluding rearguard actions, advanced guard actions and escort missions), and preset scenarios with default victory conditions.
// Should work for MP adjusted victory conditions but this has not yet been tested.
StandardInterimTournamentVictoryTest()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\TournamentTools.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\TutorialTools.BSF
:::: 5 functions
::::   ResetTutorialFlags()
::::   ShowOnceOnlyTutorialString(index, id, forced, nonmodal)
::::   HelperTutorialStuff(terrain, tilex, tiley, side)
::::   OnceOnlyUnitPopUps(unit, tilex, tiley, can_shoot, can_charge, can_undo, can_group_move)
::::   ShowOnceOnlyUnitInfo(unit)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ResetTutorialFlags()

// Show once only tutorial string. index is the string index. id is the unit id if any, otherwise -1
// If forced === 1, show popup regardless of whether moused over unit has changed.
// if nonmodal == 1, use nonmodal version of tutorial popup
ShowOnceOnlyTutorialString(index, id, forced, nonmodal)

HelperTutorialStuff(terrain, tilex, tiley, side)

// Show once only Popup Unit messages
OnceOnlyUnitPopUps(unit, tilex, tiley, can_shoot, can_charge, can_undo, can_group_move)

ShowOnceOnlyUnitInfo(unit)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\TutorialTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\UITools.BSF
:::: 68 functions
::::   PrintMoraleDisorderString(immediate, me, enemy, attacking)
::::   PrintMoraleDisorderStringShort(immediate, me, enemy, attacking)
::::   PrintQualityString(me)
::::   PrintTroopTypesString(me)
::::   PrintTroopTypesStringX(stringIndex, immediate, me)
::::   PrintUnitPossession(stringIndex, immediate, me, details)
::::   PrintStrengthString(me)
::::   GetHeadImage(side, prefix, workingString)
::::   PrintCapabilitiesString(me)
::::   PrintCapability(capability, percent, any_printed)
::::   ArmourRating(me)
::::   PrintSideString(side)
::::   PrintUnitTypeTroopTypeString(typeIndex)
::::   IsUnitTypeSquadType(typeIndex, string)
::::   IsUnitTypeKeil(typeIndex)
::::   IsUnitTypeUnwieldy(typeIndex)
::::   PrintUnitTypeQualityString(typeIndex, side)
::::   PrintUnitTypeCapabilitiesString(typeIndex)
::::   PrintUnitTypeArmourString(typeIndex)
::::   PrintArmourString(me)
::::   PrintUnitName(id)
::::   PrintUnitNameX(stringIndex, immediate, id)
::::   PrintUIStringToListBox(listboxname, index, colour)
::::   PopulateHypotheticalSideList(side)
::::   GetHypotheticalData()
::::   PopulateHypotheticalCampaignList()
::::   PopulateArmyListsBox(prefix, side, retainSelected)
::::   GetArmyListIntroNameFromChunkIndex(chunk)
::::   OldSetArmyListIntro(side)
::::   SetArmyListIntro(side)
::::   PopulateScenarioList()
::::   PopulateMapTypeList()
::::   ActivateSkirmishUI(retainSelected)
::::   InitSkirmishUI()
::::   PassArmyListsToSkirmish()
::::   GetUnitListIcon(id, index, selected)
::::   PrintSideName(side)
::::   PrintRoutedString(side)
::::   PrintBriefingString(headingFont, char headingColour[12])
::::   UpdateBriefing()
::::   PrintBattleName()
::::   PreSetScenario_Intro(side)
::::   RM_Intro(side, scenario)
::::   SetStandard3DViewLighting(objectName)
::::   SetForceSizeButton(size)
::::   SetMapSizeButton(size)
::::   GetTooltipBackground(bannerIndex, index)
::::   GetNextUnshot(side)
::::   UnitEligibleToShoot(me)
::::   SetDifficultyButton(char string[32], diff)
::::   Skirmish_SetSortButtons()
::::   Tools_SetButtons()
::::   PlayCloseCombatSounds(me, enemy)
::::   PlayRallySounds(me)
::::   PlayMoraleDropSounds(me)
::::   PlayRoutSounds(me)
::::   PlayChargeSounds(me)
::::   ResetUnitMoveUIFlags()
::::   PlayImpactSounds(shooter, target)
::::   PlayStartTurnFanfare()
::::   PlayVictoryDefeatSounds(winner)
::::   MeleeCount()
::::   SetAmbientBattleTrack(forceRestart)
::::   UnsetAmbientBattleTrack()
::::   UseAmbientSounds()
::::   MinimapSetup()
::::   SetUIObjectDraggedPosition(char objectName[64], optionsDataIndex)
::::   PrintAdvancedGuardVPString(side)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Prints Morale / Disorder string to UIstring - with option to print immediately or via VizQ
PrintMoraleDisorderString(immediate, me, enemy, attacking)

// Short version for Batle UI - only prints one string
// Prints Morale / Disorder string to UIstring - with option to print immediately or via VizQ
PrintMoraleDisorderStringShort(immediate, me, enemy, attacking)

// Prints quality string
PrintQualityString(me)

// Get string with unit's troop type
PrintTroopTypesString(me)

// Extended postponable version
PrintTroopTypesStringX(stringIndex, immediate, me)

// According to side viewing map, prints "Own " or "Enemy " with a trailing space. If details == 1, also prints "UNIT ". If details == 2, prints name of unit.
// If immediate == 1 prints to UI directly, otherwise via VizQ
PrintUnitPossession(stringIndex, immediate, me, details)

PrintStrengthString(me)

// Get the name of an image appopriate for giving messages. For example:
//   GetHeadImage(GetCurrentSide(), "BP0Image:", 3)
//   ShowUIScreen("BattlePop0", "Anim1", "IDS_MESSAGE", GetWorkString(3))
// Note that this is rendered redundant for BattlePop0 because this now automatically chooses the appropriate sideicon portrait for GetSideID(GetShowSide()).
GetHeadImage(side, prefix, workingString)

// Get string with list of unit's capabilities
PrintCapabilitiesString(me)

// Print individual capability
PrintCapability(capability, percent, any_printed)

// Returns Armour Rating for UI purposes only
ArmourRating(me)

// Prints Side A or Side B appropriately
PrintSideString(side)

// Get string with unit type's troop type
PrintUnitTypeTroopTypeString(typeIndex)

IsUnitTypeSquadType(typeIndex, string)

// Determines if unit type has enough pikes, heavy weapon men and swordsmen to qualify as a keil. Returns 0 if not keil, otherwise 1.
// No individual man should have more than one of these attribs.
IsUnitTypeKeil(typeIndex)

// returns 1 if unit type qualifies as unwieldy
IsUnitTypeUnwieldy(typeIndex)

// Prints quality string for unit type
PrintUnitTypeQualityString(typeIndex, side)

// Get string with list of unit type's capabilities
PrintUnitTypeCapabilitiesString(typeIndex)

// Get string describing unit type's level of protection
PrintUnitTypeArmourString(typeIndex)

// Get string describing unit type's level of protection
PrintArmourString(me)

PrintUnitName(id)

PrintUnitNameX(stringIndex, immediate, id)

// Prints indexed UI string to named listbox
PrintUIStringToListBox(listboxname, index, colour)

// Uses Workstring 0.
PopulateHypotheticalSideList(side)

GetHypotheticalData()

// Uses WorkString(0)
PopulateHypotheticalCampaignList()

// Populate army lists list box. Uses Array(0) for FromFile data.
// prefix is first part of UI list box object name.
// Uses WorkStrings 0, 1, 2, 3 and 4.
// if retainSelected == 1, retains the current selection if possible.
PopulateArmyListsBox(prefix, side, retainSelected)

// Gets Army List Intro IDS in WorkString(1). Returns 1 if data was found, 0 if not
GetArmyListIntroNameFromChunkIndex(chunk)

OldSetArmyListIntro(side)

SetArmyListIntro(side)

PopulateScenarioList()

PopulateMapTypeList()

ActivateSkirmishUI(retainSelected)

InitSkirmishUI()

PassArmyListsToSkirmish()

// Gets the name of the appropriate unit type icon in WorkString(index)
GetUnitListIcon(id, index, selected)

// Prints side name for battle UI - looks for custom strings for preset scenarios
PrintSideName(side)

// Print % routed for battle UI
PrintRoutedString(side)

// Uses work strings 0, 1 (in PrintBattleName()) and 2
PrintBriefingString(headingFont, char headingColour[12])

UpdateBriefing()

// uses WorkStrings 0 and 1
PrintBattleName()

// Uses Work Strings 0 and 1
PreSetScenario_Intro(side)

// Intro for random map games. Uses Work Strings 0 and 1
RM_Intro(side, scenario)

// objectName is the name of the 3DView object, passed either as GetWorkString() or as a literal string in "" marks.
// Note that the objectName parameter is not defined as the char type because if it is, GetWorkString() cannot be passed as a parameter. (Wrong type so causes a crash).
SetStandard3DViewLighting(objectName)

// uses Work String 0
SetForceSizeButton(size)

// uses Work String 0
SetMapSizeButton(size)

// Returns name of unit info "tooltip" background in Work String index.
GetTooltipBackground(bannerIndex, index)

// Get next unit that has not shot and has a valid target
GetNextUnshot(side)

// Test whether unit is on the map, eligible to shoot and has a valid target - for GetNextUnshot
UnitEligibleToShoot(me)

// uses Work String 0
SetDifficultyButton(char string[32], diff)

Skirmish_SetSortButtons()

Tools_SetButtons()

PlayCloseCombatSounds(me, enemy)

PlayRallySounds(me)

PlayMoraleDropSounds(me)

PlayRoutSounds(me)

PlayChargeSounds(me)

// Resets flags for recalculating ZOC, fall back and pass through displays
ResetUnitMoveUIFlags()

PlayImpactSounds(shooter, target)

PlayStartTurnFanfare()

PlayVictoryDefeatSounds(winner)

// Used for determining which ambient track to play. Returns number of melees currently in action.
MeleeCount()

// Picks the correct ambient battle track to play. Only forces restart if track changes.
// Also switches music to use the volume setting on the SFX slider.
SetAmbientBattleTrack(forceRestart)

// restore normal music volume
UnsetAmbientBattleTrack()

UseAmbientSounds()

MinimapSetup()

// Sets draggable objects position based on the recorded position. Stops the object from going off screen
// Recorded position is actual position +1 so that a 0 value means dragged has not yet been set.
SetUIObjectDraggedPosition(char objectName[64], optionsDataIndex)

PrintAdvancedGuardVPString(side)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\UITools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\scripts\UndoTools.BSF
:::: 6 functions
::::   ResetMovedLastFlags(side)
::::   CheckGroupUndoPossible(me)
::::   ResetUndoPosition(me)
::::   ResetGroupUndoPosition(me)
::::   LastMoveWasGroupMove(me)
::::   SetVisibleUnitCount(me)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// Resets all units of side move last flags, and also their starting undo position
ResetMovedLastFlags(side)

// Returns -2 if group undo impossible because of other actions, -1 if impossible because of seeing previously hidden enemy, 0 if possible.
CheckGroupUndoPossible(me)

ResetUndoPosition(me)

ResetGroupUndoPosition(me)

// Returns 1 if unit was the last moved but did that as part of a group.
LastMoveWasGroupMove(me)

// Used to set global variable used by Undo routines to detemrine when hidden units have been revealed.
SetVisibleUnitCount(me)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\scripts\UndoTools.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\ArmyListPreview.BSF
:::: 4 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_ACTIVATE(id)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)

UI_OBJ_RENDER(x, y, width, height, pass)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\ArmyListPreview.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\ArmyList_ListBox.BSF
:::: 3 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)
::::   UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)

// Uses WorkStrings 0 to 4
UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\ArmyList_ListBox.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\BattleAdvancedPanel.bsf
:::: 2 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_ACTIVATE(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_ACTIVATE(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\BattleAdvancedPanel.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\BattleAdvancedPanel_Left.bsf
:::: 3 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   UI_OBJ_ACTIVATE(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_RENDER(x, y, width, height, pass)

UI_OBJ_ACTIVATE(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\BattleAdvancedPanel_Left.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\BattleCommon.bsf
:::: 7 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_DEACTIVATE()
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   BattleCommon_SetUI()
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_DEACTIVATE()

UI_OBJ_RENDER(x, y, width, height, pass)

// Use workstring 0, 1, 3
BattleCommon_SetUI()

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\BattleCommon.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\BattlePop0.BSF
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   BP0_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

BP0_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\BattlePop0.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\BattleResults.bsf
:::: 3 functions
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   UI_OBJ_HANDLE()
::::   GetBattleLosses()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x, y, width, height, pass)

UI_OBJ_HANDLE()

// UI function to feed battle losses to UI objects
GetBattleLosses()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\BattleResults.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\CloseCombatReport.BSF
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   CCR_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

CCR_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\CloseCombatReport.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\DeployMessage.BSF
:::: 2 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_ACTIVATE(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_ACTIVATE(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\DeployMessage.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\EndBattle.BSF
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   EndBattle_SetUI()
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

EndBattle_SetUI()

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\EndBattle.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\EndReview.BSF
:::: 4 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\EndReview.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\Force.BSF
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   Force_SetUI()
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

Force_SetUI()

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\Force.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\ForceOverlay.BSF
:::: 4 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_ACTIVATE(id)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags)

UI_OBJ_RENDER(x, y, width, height, pass)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\ForceOverlay.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\ForceSelect_ListBox.BSF
:::: 3 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)
::::   UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)

// Uses WorkStrings 0 to 4
UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\ForceSelect_ListBox.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\MPSShowArmy.BSF
:::: 4 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\MPSShowArmy.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\MPSShowArmy_ListBox.BSF
:::: 3 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

// Uses WorkString 0
UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\MPSShowArmy_ListBox.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\MPSShowArmy_ListBox2.BSF
:::: 3 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)
::::   UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

// Uses WorkString 0
UI_OBJ_RENDER_ITEM(x, y, width, height, pass, flags, item, name)

UI_OBJ_UPDATE(mousex, mousey, buttons, over, dragging, flags, data)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\MPSShowArmy_ListBox2.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\MPSurrender.bsf
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_DEACTIVATE()
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_DEACTIVATE()

UI_OBJ_RENDER(x, y, width, height, pass)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\MPSurrender.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\PlayOn.BSF
:::: 1 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\PlayOn.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\Results.bsf
:::: 3 functions
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   UI_OBJ_HANDLE()
::::   GetBattleLosses()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x, y, width, height, pass)

UI_OBJ_HANDLE()

// UI function to feed battle losses to UI objects
GetBattleLosses()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\Results.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\TimedPop.BSF
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   TimedPop_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

TimedPop_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\TimedPop.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\TutorialPop.BSF
:::: 5 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   TutPop_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

TutPop_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\TutorialPop.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\TutorialPopNonModal.BSF
:::: 6 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_OBJ_INIT()
::::   UI_OBJ_ACTIVATE(id)
::::   UI_OBJ_DEACTIVATE(id)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   TutPopNM_SetUI()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_OBJ_INIT()

UI_OBJ_ACTIVATE(id)

UI_OBJ_DEACTIVATE(id)

UI_OBJ_RENDER(x, y, width, height, pass)

TutPopNM_SetUI()

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\TutorialPopNonModal.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\UnitInfoPopup.bsf
:::: 6 functions
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   UI_OBJ_HANDLE(id)
::::   UI_OBJ_ACTIVATE(id)
::::   DrawUnitInfo(me)
::::   DrawStatsInfo(me)
::::   PrintShootingInfo(me)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_RENDER(x, y, width, height, pass)

UI_OBJ_HANDLE(id)

UI_OBJ_ACTIVATE(id)

// UI function to draw the panel for a unit in the force selection screen
DrawUnitInfo(me)

DrawStatsInfo(me)

// Prints shooting info for Detailed Troop Info
PrintShootingInfo(me)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\UnitInfoPopup.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\Data\UI\UnitList.bsf
:::: 6 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   UI_ITEM_HEIGHT()
::::   UI_ITEM_RENDER(x, y, width, height, me)
::::   UNITLIST_VALIDATE(me)
::::   UI_OBJ_RENDER(x, y, width, height, pass)
::::   UI_OBJ_ACTIVATE(id)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

UI_ITEM_HEIGHT()

// Uses WorkStrings 4 and 5
UI_ITEM_RENDER(x, y, width, height, me)

// Don't show Dispersed units or Limbers in unit list.
UNITLIST_VALIDATE(me)

UI_OBJ_RENDER(x, y, width, height, pass)

UI_OBJ_ACTIVATE(id)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\Data\UI\UnitList.bsf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\TOOLS\Slith_RandomEnemy\UI\Slith_RandomEnemy.BSF
:::: 8 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   PLUGIN_TICK()
::::   PLUGIN_INIT()
::::   SetUIStrings()
::::   StartTurn(side)
::::   Tick(side)
::::   Slith_RE_GetTeamCost(team)
::::   Slith_RE_Team(team, points)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

PLUGIN_TICK()

PLUGIN_INIT()

SetUIStrings()

StartTurn(side)

Tick(side)

Slith_RE_GetTeamCost(team)

Slith_RE_Team(team, points)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\TOOLS\Slith_RandomEnemy\UI\Slith_RandomEnemy.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\TOOLS\Slith_RandomMap\UI\Slith_RandomMap.BSF
:::: no functions declared
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: file .\TOOLS\Slith_VictoryPoints\UI\Slith_VictoryPoints.BSF
:::: 11 functions
::::   UI_OBJ_HANDLE(data, event, id)
::::   PLUGIN_TICK()
::::   PLUGIN_INIT()
::::   SetUIStrings()
::::   StartTurn(side)
::::   Slith_VP_CheckAITeams()
::::   Tick(side)
::::   Slith_VP_CheckVP(point)
::::   Slith_VP_MoveTeam(side, team, point, aggr)
::::   Slith_VP_EndBattle(side)
::::   Slith_VP_CanWin(side)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

UI_OBJ_HANDLE(data, event, id)

PLUGIN_TICK()

PLUGIN_INIT()

SetUIStrings()

StartTurn(side)

Slith_VP_CheckAITeams()

Tick(side)

Slith_VP_CheckVP(point)

Slith_VP_MoveTeam(side, team, point, aggr)

Slith_VP_EndBattle(side)

// Updated functionality.  You can set universal variables to allow or disallow win or loss for either side based on other logic
// from the mission scripting etc.  Obviously if you want to outright win or lose the mission from the script you still can.
Slith_VP_CanWin(side)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: end of file .\TOOLS\Slith_VictoryPoints\UI\Slith_VictoryPoints.BSF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
