What is the best way to detect air fighter?
Moderator: Moderators
What is the best way to detect air fighter?
Hello,
I'm making simple widget that will remove all commands from air units leaving factory, except for fighters. (i dont want anything else on patrol anyway... brawlers on patrol are pretty useless, radar planes on patrol lag the game a LOT (i'd say 20 radars = 200 fighters), bombers on patrol are lulz, etc)
I'm using factory kickstart widget as starting point, so everything is there.
I only need to do something like
if ud.canFly and its a fighter then Spring.GiveOrderToUnit(id,CMD.STOP,{},{}) end
What is the best way to tell if it is fighter?
Should i check all weapons and see if it can shot air? (like defencerange widget does) Or theres better way?
I'm making simple widget that will remove all commands from air units leaving factory, except for fighters. (i dont want anything else on patrol anyway... brawlers on patrol are pretty useless, radar planes on patrol lag the game a LOT (i'd say 20 radars = 200 fighters), bombers on patrol are lulz, etc)
I'm using factory kickstart widget as starting point, so everything is there.
I only need to do something like
if ud.canFly and its a fighter then Spring.GiveOrderToUnit(id,CMD.STOP,{},{}) end
What is the best way to tell if it is fighter?
Should i check all weapons and see if it can shot air? (like defencerange widget does) Or theres better way?
Re: What is the best way to detect air fighter?
Looks like you can literally check if ud.type == "Fighter"
Re: What is the best way to detect air fighter?
Thanks! Very nice.lurker wrote:Looks like you can literally check if ud.type == "Fighter"
Re: What is the best way to detect air fighter?
done, doesnt work well though.
Using
if ud.canFly and not (ud.type == "Fighter") then
Spring.GiveOrderToUnit(unitID,CMD.STOP,{},{})
end
In BA 6.21 it doesnt stop:
all scouts, radars, and sonars
fighters
liche
I'll try to add check that it has weapons, and that weapons fire by themselves rather than have to be set with attack order (how to check for that). Also gonna check if theres some isscout or whatever
Using
if ud.canFly and not (ud.type == "Fighter") then
Spring.GiveOrderToUnit(unitID,CMD.STOP,{},{})
end
In BA 6.21 it doesnt stop:
all scouts, radars, and sonars
fighters
liche
I'll try to add check that it has weapons, and that weapons fire by themselves rather than have to be set with attack order (how to check for that). Also gonna check if theres some isscout or whatever
Re: What is the best way to detect air fighter?
Oh. I thought you wanted to know if units were fighters, not if they were fighters.
There is no such thing as a scout unit in the context of the engine.
If you want a custom profile, then yeah, you'll have to make it yourself. I think making sure that it has a fighter type and at least one weapon can attack air units should work. Then you exclude scouts and divebombers.
There is no such thing as a scout unit in the context of the engine.
If you want a custom profile, then yeah, you'll have to make it yourself. I think making sure that it has a fighter type and at least one weapon can attack air units should work. Then you exclude scouts and divebombers.
Re: What is the best way to detect air fighter?
Well, now, i'm doing that:
--- liche: workaround for BA bug
if ud.canFly and (ud.weaponCount==0 or (not (ud.type == "Fighter")) or (ud.humanName=="Liche")) then
Spring.GiveOrderToUnit(unitID,CMD.STOP,{},{})
end
Works in BA 6.21 at least, feel free to test with your fav mod and make compatible.
I dont want to check weapons just because in BA liche's type is "fighter".
Link:
http://dmytry.no-ip.org/unit_only_fighters_patrol.lua
--- liche: workaround for BA bug
if ud.canFly and (ud.weaponCount==0 or (not (ud.type == "Fighter")) or (ud.humanName=="Liche")) then
Spring.GiveOrderToUnit(unitID,CMD.STOP,{},{})
end
Works in BA 6.21 at least, feel free to test with your fav mod and make compatible.
I dont want to check weapons just because in BA liche's type is "fighter".
Link:
http://dmytry.no-ip.org/unit_only_fighters_patrol.lua
Re: What is the best way to detect air fighter?
The liche's type is fighter because it is a dive bomber. No, it's not truely a 'fighter', but it's not a bomber that flies overhead releasing bombs either, and it moves as fighters do. It's not a bug.
If you want to be compatible with other mods, you should check if it has any weapons that can shoot air. That will take care of the liche as well as the Evolution dive bombers, and possibly others. But it's not a big deal to make people edit in the names of dive bombers.
If you want to be compatible with other mods, you should check if it has any weapons that can shoot air. That will take care of the liche as well as the Evolution dive bombers, and possibly others. But it's not a big deal to make people edit in the names of dive bombers.
Re: What is the best way to detect air fighter?
hmm, I may add weapon check later on. The problem is, Liche does some (very tiny) damage to air units, and fighter does some damage to ground, so it has to compare damages etc.
Is there a quick way to see if weapon is aimed and fired automatically? that should exclude all bombers in most mods.
Is there a quick way to see if weapon is aimed and fired automatically? that should exclude all bombers in most mods.
Re: What is the best way to detect air fighter?
Not really. You can put the CA bombers at least on fire at will.
But you're thinking the wrong way. It's not whether it can damage planes, it's whether it will attack planes. The liche has onlytargetcategory1=NOTAIR; and most mods will have the same NOTAIR category.
But you're thinking the wrong way. It's not whether it can damage planes, it's whether it will attack planes. The liche has onlytargetcategory1=NOTAIR; and most mods will have the same NOTAIR category.
Re: What is the best way to detect air fighter?
ahh, right. Need to dump out weapondefs then and see.
Re: What is the best way to detect air fighter?
well i checked weapon defs.
In the WeaponDefs for liche's weapon, i have onlyTargetCategories
i dumped it out like this
and got
I'm checking for ud.noAutoFire now too, to exclude stuff at least in mods where bombers don't fire at will.
In the WeaponDefs for liche's weapon, i have onlyTargetCategories
i dumped it out like this
Code: Select all
local wd = WeaponDefs[ weapon.weaponDef ]
for name,param in wd:pairs() do
Spring.Echo("wd:",name,param)
end
categories=wd.onlyTargetCategories
if categories then
for name,value in pairs(categories) do
Spring.Echo("wdtc:",name,value)
end
end
Code: Select all
wdtc:, antiflame, true
wdtc:, vtol, true
wdtc:, notland, true
wdtc:, fort, true
wdtc:, special, true
wdtc:, notair, true
wdtc:, kbot, true
wdtc:, antiemg, true
wdtc:, commander, true
wdtc:, jam, true
wdtc:, tport, true
wdtc:, constr, true
wdtc:, strategic, true
wdtc:, kamikaze, true
wdtc:, minelayer, true
wdtc:, hover, true
wdtc:, noweapon, true
wdtc:, plant, true
wdtc:, ship, true
wdtc:, antilaser, true
wdtc:, phib, true
wdtc:, mine, true
wdtc:, notstructure, true
wdtc:, tank, true
wdtc:, mobile, true
wdtc:, underwater, true
wdtc:, antigator, true
wdtc:, notship, true
wdtc:, all, true
wdtc:, notsub, true
wdtc:, weapon, true
Re: What is the best way to detect air fighter?
I use GROUND...lurker wrote:Not really. You can put the CA bombers at least on fire at will.
But you're thinking the wrong way. It's not whether it can damage planes, it's whether it will attack planes. The liche has onlytargetcategory1=NOTAIR; and most mods will have the same NOTAIR category.
EDIT: How about checking if the unit is part of its own target categories?
Re: What is the best way to detect air fighter?
the stuff i'm getting for liche's weapon's onlyTargetCategories isnt useful at all, everything in it is true.
BTW i updated the widget. Would be good to get people to use this widget, it is really helpful for reducing lag.
The only problem so far is that it removes orders of air conses, thus conflicting with factory guard widget. However, air conses have such crappy nanopower for their cost and buildtime (in BA at least), that factory guard widget for airlab is IMO really not worth it, for me its better when air constructors go idle and show up on idlebuilders list, so i see when them become avaliable and can use them to make nanos.
BTW i updated the widget. Would be good to get people to use this widget, it is really helpful for reducing lag.
The only problem so far is that it removes orders of air conses, thus conflicting with factory guard widget. However, air conses have such crappy nanopower for their cost and buildtime (in BA at least), that factory guard widget for airlab is IMO really not worth it, for me its better when air constructors go idle and show up on idlebuilders list, so i see when them become avaliable and can use them to make nanos.