Here's a list of all unit events. Each item in the list below should be self explanatory but here's a little
clarification.

- You can have your own function called when the event occurs using the function specified under "Add function".
- The function you wanna have called when the event occurs must look like what's specified under
  "Callback templ". The function name is not important but the number of arguments are.
- The newly added events can be overwritten in the same way GPG does almost everytime they need to. You only need 
  one of the two methods; either overwrite derived events from other classes or use the callback functionality.


##################################################################################################################
## Stock Forged Alliance unit events
##################################################################################################################

Event Name:       OnKilled
Location:         \lua\sim\Unit.lua in event function OnKilled
Info:             Fired when unit dies
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnKilledEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnUnitBuilt
Location:         \lua\sim\Unit.lua in event function OnUnitBuilt
Info:             Fired when unit is built
Add function:     AddOnUnitBuiltCallback( [function to run] , [unit category required] )
Callback templ:   OnUnitBuiltEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnStartBuild
Location:         \lua\sim\Unit.lua in event function OnStartBuild
Info:             Fired when unit is being build
Add function:     AddOnStartBuildCallback( [function to run] , [unit category required] )
Callback templ:   OnStartBuildEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnReclaimed
Location:         \lua\sim\Unit.lua in event function OnReclaimed
Info:             Fired when the unit is reclaimed (it is already dead when this event occurs)
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnReclaimedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnStartReclaim
Location:         \lua\sim\Unit.lua in event function OnStartReclaim
Info:             Fired when the unit is reclaiming something
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnReclaimedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnStopReclaim
Location:         \lua\sim\Unit.lua in event function OnStopReclaim
Info:             Fired when the unit stopped reclaiming something
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnStopReclaimEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnStopBeingBuilt
Location:         \lua\sim\Unit.lua in event function OnStopBeingBuilt
Info:             Fired when the unit is no longer being built. Its probably not completed yet.
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnStopBeingBuiltEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnHorizontalStartMove
Location:         \lua\sim\Unit.lua in event function OnMotionHorzEventChange
Info:             Fired when the unit starts moving (after having stopped first)
Add function:     AddOnHorizontalStartMoveCallback( [function to run] )
Callback templ:   OnHorizontalStartMoveEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnCaptured
Location:         \lua\sim\Unit.lua in event function OnCaptured
Info:             Fired when the unit is captured by an enemy
Add function:     AddOnCapturedCallback( [old unit] , [new unit] )
Callback templ:   OnCapturedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnCapturedNewUnit
Location:         \lua\sim\Unit.lua in event function OnCapturedNewUnit
Info:             Fired when the unit captures a unit from an enemy
Add function:     AddOnCapturedCallback( [old unit] , [new unit] )
Callback templ:   OnCapturedNewUnitEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnDamaged
Location:         \lua\sim\Unit.lua in event function OnDamaged
Info:             Fired when the unit is damaged (by enemy, reclaiming, falling wreckage)
Add function:     AddOnDamagedCallback( [function to run] , [required health percentage remaining], [repeat] )
Callback templ:   OnDamagedEvent = function(self, instigator)

notes:
- For "required health percentage remaining" use -1 if you don't care about this.
- I don't know what "repeat" does

------------------------------------------------------------------------------------------------------------------

Event Name:       OnStartCapture
Location:         \lua\sim\Unit.lua in event function OnStartCapture
Info:             Fired when the unit starts capturing
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnStartCaptureEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnStopCapture
Location:         \lua\sim\Unit.lua in event function OnStopCapture
Info:             Fired when the unit stops capturing (probably didnt finish capturing)
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnStopCaptureEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnFailedCapture
Location:         \lua\sim\Unit.lua in event function OnFailedCapture
Info:             Fired when the unit failed capturing a unit
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnFailedCaptureEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnStartBeingCaptured
Location:         \lua\sim\Unit.lua in event function OnStartBeingCaptured
Info:             Fired when the unit is being captured by an enemy unit
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnStartBeingCapturedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnStopBeingCaptured
Location:         \lua\sim\Unit.lua in event function OnStopBeingCaptured
Info:             Fired when the unit is no longer being captured by an enemy unit
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnStopBeingCapturedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnFailedBeingCaptured
Location:         \lua\sim\Unit.lua in event function OnFailedBeingCaptured
Info:             Fired when the enemy unit failed to capture this unit
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnFailedBeingCapturedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnFailedToBuild
Location:         \lua\sim\Unit.lua in event function OnFailedToBuild
Info:             Fired when the unit failed to start building what it was ordered to build
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnFailedToBuildEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnVeteran
Location:         \lua\sim\Unit.lua in event function SetVeteranLevel
Info:             Fired when the unit gains a veteran level
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnVeteranEvent = function(self)

##################################################################################################################
## Added in Community Bug Fix Patch version 2
##################################################################################################################

Event Name:       OnCreated
Location:         \lua\sim\Unit.lua in event function OnCreate at end
Info:             Fired when new unit is created (probably in the factory as soon as it starts building the unit)
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnCreatedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnPaused
Location:         \lua\sim\Unit.lua in event function OnPaused
Info:             Fired when used presses pause button (left of construction icons)
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnPausedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnUnpaused
Location:         \lua\sim\Unit.lua in event function OnUnPaused
Info:             Fired when used presses resume button (left of construction icons), should be paused first
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnUnpausedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnHealthChanged
Location:         \lua\sim\Unit.lua in event function OnHealthChanged
Info:             Fired only when unit reaches 25%, 50%, 75% or 100% of full health to whatever cause (repair,
                  reclaim, damaged)
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnHealthChangedEvent = function(self, newHP, oldHP)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnProductionPaused
Location:         \lua\sim\Unit.lua in event function OnProductionPaused
Info:             Fired when production is paused by player. Doesn't work on factories, does work on massfabs f.e.
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnProductionPausedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnProductionUnpaused
Location:         \lua\sim\Unit.lua in event function OnProductionUnpaused
Info:             Fired when production is resumed by player.
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnProductionUnpausedEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnShieldIsUp
Location:         \lua\shield.lua in function CreateShieldMesh
                  \lua\sim\Unit.lua in event function OnShieldOnline
Info:             Fired when the shield starts working (again)
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnShieldIsUpEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnShieldIsDown
Location:         \lua\shield.lua in function RemoveShield 
                  \lua\sim\Unit.lua in event function OnShieldOffline
Info:             Fired when the shield is taken offline due to damage, user intervention, death of unit or 
                  low power. There could be more causes.
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnShieldIsDownEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnShieldIsCharging
Location:         \lua\shield.lua in function ChargingUp 
                  \lua\sim\Unit.lua in event function OnShieldCharging
Info:             Fired when the shield begins to recharge
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnShieldIsChargingEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnStartRefueling
Location:         \lua\sim\Unit.lua in event function OnStartRefueling
Info:             Fired when the unit (probably air) starts to receive fuel (probably on ground or air staging)
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnStartRefuelingEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnRunOutOfFuel
Location:         \lua\sim\Unit.lua in event function OnRunOutOfFuel
Info:             Fired when the unit (probably air) has no more fuel left and starts to move slower than usual
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnRunOutOfFuelEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnGotFuel
Location:         \lua\sim\Unit.lua in event function OnGotFuel
Info:             Fired when the unit (probably air) goes from no fuel to (some). Doesnt indicate that the unit has
                  full fuel tanks again, it only means it can move fast again (for whatever length of time)
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnGotFuelEvent = function(self)

------------------------------------------------------------------------------------------------------------------

Event Name:       OnTMLAmmoIncrease
Location:         \lua\sim\Unit.lua in function CheckCountedMissileAmmoIncrease and in function 
                  AddOnMLammoIncreaseCallback
Info:             Fired when the launchers ammo is increased by 1 or more. This is event is fired by a polling
                  thread that checks each 6 seconds whether the ammo has increased since last check. If yes then
                  this event is fired. Because it uses polling its not accurate. Uses special addcallback function.
Add function:     AddOnMLammoIncreaseCallback( [function to run] , [event name as string] )
Callback templ:   OnTMLAmmoIncreaseEvent = function(self)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnTMLaunched
Location:         \lua\sim\defaultweapons.lua in state RackSalvoFiringState, in function main, in while loop about
                  half way through.
                  \lua\sim\Unit.lua in event function OnCountedMissileLaunch
Info:             Fired when a tactical missile leaves the launcher.
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnTMLaunchedEvent = function(self)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnSMLAmmoIncrease
Location:         \lua\sim\Unit.lua in function CheckCountedMissileAmmoIncrease and in function 
                  AddOnMLammoIncreaseCallback
Info:             Fired when the launchers ammo is increased by 1 or more. This is event is fired by a polling
                  thread that checks each 6 seconds whether the ammo has increased since last check. If yes then
                  this event is fired. Because it uses polling its not accurate. Uses special addcallback function.
Add function:     AddOnMLammoIncreaseCallback( [function to run] , [event name as string] )
Callback templ:   OnSMLAmmoIncreaseEvent = function(self)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnSMLaunched
Location:         \lua\sim\defaultweapons.lua in state RackSalvoFiringState, in function main, in while loop about
                  half way through.
                  \lua\sim\Unit.lua in event function OnCountedMissileLaunch
Info:             Fired when a strategic missile leaves the launcher.
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnSMLaunchedEvent = function(self)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnTransportAttach
Location:         \lua\sim\Unit.lua in event function OnTransportAttach
Info:             Fired when a transport begins tractoring a unit onto a transport slot
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnTransportAttachEvent = function(self)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnTransportDetach
Location:         \lua\sim\Unit.lua in event function OnTransportDetach
Info:             Fired when a transport releases a unit
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnTransportDetachEvent = function(self)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnCmdrUpgradeFinished
Location:         \lua\sim\Unit.lua in state WorkingState in OnWorkEnd function
Info:             Fired when an ACU or SCU (or another unit that can be fitted with upgrades) is upgraded
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnCmdrUpgradeFinishedEvent = function(self)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnCmdrUpgradeStart
Location:         \lua\sim\Unit.lua in state WorkingState in main function
Info:             Fired when an ACU or SCU (or another unit that can be fitted with upgrades) starts being upgraded
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnCmdrUpgradeStartEvent = function(self)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnTeleportCharging
Location:         \lua\sim\Unit.lua in function InitiateTeleportThread at begin
Info:             Fired when an ACU or SCU (or another unit that can teleport) starts to charge the teleport device
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnTeleportChargingEvent = function(self, targetLocation)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnTeleported
Location:         \lua\sim\Unit.lua in function InitiateTeleportThread at end
Info:             Fired when an ACU or SCU (or another unit that can teleport) was teleported.
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnTeleportedEvent = function(self, targetLocation)


##################################################################################################################
## Added in Community Bug Fix Patch version 3
##################################################################################################################

Event Name:       OnTimedEvent
Location:         \lua\sim\Unit.lua in function TimedEventThread, OnTimedEvent, AddOnTimedEventCallback and
                  DoOnTimedEventCallbacks.
Info:             Fired when a given amount of seconds have passed (fires continuesly). You can pass data to the
                  callback function using the passData argument. Whatever you put in that variable when adding your
                  callback will be passed to the callback function when the event fires. Multiple instances work.
Add function:     AddOnTimedEventCallback( [function to run] , [event fire interval] , [data to pass to callback function] )
Callback templ:   OnTimedEvent = function(self, passData)

notes:
- The interval is specified in seconds, accepts floats
- "data to pass to callback function" can be anything you want to use when the event occurs

------------------------------------------------------------------------------------------------------------------


Event Name:       OnAttachedToTransport
Location:         \lua\sim\Unit.lua in function OnAttachedToTransport and in OnTransportAttach
Info:             Fired when the unit is being loaded in a transport
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnAttachedToTransport = function(self, transport)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnDetachedToTransport
Location:         \lua\sim\Unit.lua in function OnDetachedToTransport and in OnTransportDetach
Info:             Fired when the unit is being unloaded from a transport
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnDetachedToTransport = function(self, transport)


##################################################################################################################
## Added in Community Bug Fix Patch version 4
##################################################################################################################

Event Name:       OnBeforeTransferingOwnership
Location:         \lua\sim\Unit.lua in function OnBeforeTransferingOwnership
Info:             Fired before the unit is changing army
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnBeforeTransferingOwnership = function(self, ToArmy)

------------------------------------------------------------------------------------------------------------------


Event Name:       OnAfterTransferingOwnership
Location:         \lua\sim\Unit.lua in function OnAfterTransferingOwnership
Info:             Fired after the unit changed army
Add function:     AddUnitCallback( [function to run] , [event name as string] )
Callback templ:   OnAfterTransferingOwnership = function(self, FromArmy)

------------------------------------------------------------------------------------------------------------------

