@resin_smoker The ones I'm aware of for weapons are
:GetCurrentTarget() - returns the unit, if there is a unit being targeted
:GetCurrentTargetPos() - returns the target, i.e. for ground attack targets (I've not tested to see all the cases in which this triggers, e.g. if it will return a value for a unit target's position)
:WeaponHasTarget() - I've not used this one myself but I'd noted it down for reference when I was looking at how to get weapon target information
with weapons being cycled through with something like:
for iWeapon, oWeapon in oUnit.WeaponInstances do
if oWeapon.GetCurrentTarget then
local oCurTarget = oWeapon:GetCurrentTarget()
if oCurTarget then
‘Have a target for the weapon
end
end
end
You can also use the Navigator object to get the current target position of a unit, e.g.:
oUnit:GetNavigator():GetCurrentTargetPos() - This isn’t just a move order target – e.g. if the unit is building something, it returns the target of that building
I found it unreliable, and made a note when I tested that with attack-move orders although I’ve not tested it extensively to confirm, it appeared that giving an attack-move order to a unit that caused that unit to then stop and attack a target, would result in the navigator position being that unit’s position.
There's also a :GetGoalPos() function (which I think is based off the navigator as well)
You can also use oUnit:GetFocusUnit() (which works e.g. in the case of a building a unit, I've not checked if it also works in the case of an attack order)
Another one is oUnit:GetGuardedUnit()
I've not tested this one but presume it works with the guard order.
My rough notes on these and other commands are in section 5 of the AI development guide (linked to from the FAF wiki https://wiki.faforever.com/en/Development/AI/AI-Modding) although I don't think they'll add much more than what's here, other than you can look at e.g. unit.lua in the FAF Git as various comments have been added documenting functions available for units (and similarly with other files) which might provide further alternatives.
You could also look into oUnit:GetCommandQueue() and analysing this - there might be documentation on this in the FAF repo as from memory some of the devs were able to figure out how to interpret the results of this (but it's not something I needed to look into beyond checking if a unit's command queue was empty as for my AI I track the orders given to each AI unit anyway which I rely on)