Functions Documentation
View Function Edit Function
Name sysCalcFireSolution
Syntax (sysCalcFireSolution targetPos targetVel speed)
Argument List targetPos - The vector position of the target
targetVel - The vector velocity of the target
speed - The speed of the projectile
Returns angle or Nil
Category weapon, math
Description A very useful function when using sysCreateWeaponFire. Automactically performs all trigonometry required to properly lead a target (assuming it moves in a straight line at constant speed)
(sysCalcFireSolution (sysVectorSubtract (objGetpos aTargetobj) aFirePos) (objGetVel aTargetObj) (typGetDataField (itmGetUNID gItem) 'speed))
The above will return the correct angle to fire a projectile in order to hit aTargetObj.
(sysCalcFireSolution (sysVectorSubtract (objGetPos aTargetObj) aFirePos) (sysVectorSubtract (objGetVel aTargetObj) (objGetVel gSource)) (typGetDataField (itmGetUNID gItem) 'speed))

This one will return the correct lead angle to hit aTargetObj when run in the event <OnFireWeapon>, unlike the above, this one will factor in the velocity added to the projectile from the movement of the firing ship.
Comment (sysCalcFireSolution (sysVectorSubtract (objGetPos Target) gSource) (sysVectorSubtract (objGetVel Target) (objGetVel gSource)) 99999999) can be used to determine the relative angle of any two spaceObjects, Target from gSource in this example.