Getting AI to target more than FIGHTER and FREIGHTER
-
I seriously hate to make another hack request, and it’s an issue I’ve just worked around for a while, but it’d be great to figure out a formal solution. So, here goes:
For some bizarre reason, AI by default only attack target types of FIGHTER and FREIGHTER. They’ll shoot at other types, but they won’t ever actually move to engage them (constantly switching between having a target and going “all clear”), even if the type in question is explicitly defined as top-priority under the JobBlock in pilots_population. It’s like AI just don’t know how to attack types other than FIGHTER or FREIGHTER or something. They’re also incredibly awkward about attacking Solars, but that’s a little more understandable as they’re stationary objects.
I figure this is tied into how only FIGHTER or FREIGHTER can be used as pilotable types - everything else has whacked up controls and doesn’t show names properly for players.
Any ideas?
-
Absolutely confirm this weird issue. I also got stuck at it 2 months ago, and understood why fox used only FIGHTER and later FREIGHTER types.
I also noticed that npc will first engage types that are declared first in the attack_priority. That leeds sometimes to weird things(npcs turn on FIGHTERs leaving FREIGHTERs(read caps and cruisers) untouched until FIGHTERs are killed.
will post my observations a bit later today, 'cos short of time. sorry
-
Nothing definite, but if you search a disassembly for “, 00030000” (depending on your listing), you’ll possibly find the FIGHTER | FREIGHTER test. One in particular that might be useful is at common.dll:62b24ee (CShip::notify_set_target). Change it to 007F0000 and it’ll test FIGHTER | FREIGHTER | GUNBOAT | CRUISER | TRANSPORT | CAPITAL | MINING.
-
About npc attack.
What I wanted:
my aim was to make so that npcs equipped with torpedoes would attack cruisers and battleships first, and if there is no any capships or after attacking them - attack fighters. And those npcs that have no torps would turn on small ships.How I tested:
in Cambridge system near omega 3 gate I created a zone with corsairs(fighters) and br_navy(fighters and/or capships).
Gave corsair pilots proper jobs.
I also separated system encounters and randommissions encounters, so that I can have almost unlimited amount of npc jobs and loadouts variants.-
First thing I noticed(as fox stated above): npcs behave weird attacking ships that are not FIGHTER or FREIGHTER types, their attacks are not effective, seems like they are attacking solars.
-
Npcs attack ships(and seems like all their targets) in order of their attack_preference.
attack_preference = FIGHTER, 10000, GUNS | GUIDED | UNGUIDED attack_preference = FREIGHTER, 10000, TORPEDO | GUIDED | GUNS | UNGUIDED .........
in this case npcs will attack FIGHTER type ships first, and only after - other types(FREIGHTER types in this case).
attack_preference = FREIGHTER, 10000, GUNS | GUIDED | UNGUIDED attack_preference = FIGHTER, 10000, TORPEDO | GUIDED | GUNS | UNGUIDED .........
in this case npcs will first attack FREIGHTER types first.
So giving torp npcs 2nd case and non-torp npcs 1st variant do the trick(with some side effects).
Proof: I gave fc_c_grp and br_n_grp fighters invulnerable shields, attack preference to attack fighters first, and included 1 br_destroyer(FREIGHTER type ship) into encounter. Result = br_destroyer stayed untouched, fighters were trying to kill each other(with no success 'cos of their shields).
One side effect: those ships that are meant to attack fighters will not attack FREIGHTER types. For some mods it will look strange if npcs will turn on fighters leaving capships untouched.
The following example prevents it.
attack_preference = ANYTHING, 10000, GUNS | GUIDED | UNGUIDED attack_preference = TRANSPORT, 10000, TORPEDO | GUIDED | GUNS | UNGUIDED attack_preference = GUNBOAT, 10000, TORPEDO | GUIDED | GUNS | UNGUIDED attack_preference = CRUISER, 10000, TORPEDO | GUIDED | GUNS | UNGUIDED attack_preference = CAPITAL, 10000, TORPEDO | GUIDED | GUNS | UNGUIDED attack_preference = WEAPONS_PLATFORM, 10000, TORPEDO | GUIDED | GUNS | UNGUIDED attack_preference = SOLAR, 10000, TORPEDO | GUIDED | GUNS | UNGUIDED attack_preference = TRADELANE, 0, GUNS | GUIDED | TORPEDO | UNGUIDED attack_preference = JUMPGATE, 0, GUNS | GUIDED | TORPEDO | UNGUIDED attack_preference = DESTROYABLE_DEPOT, 10000, GUNS | GUIDED | TORPEDO | UNGUIDED
In this case everything is declared in attack preference but FREIGHTER and FIGHTER types, so they will be attacked with equal preference. but one side effect appears: this ANYTHING also includes TLR shield. Npcs will try to take it down(with no success 'cos they will shoot into the centre of the TLR where hp_shield01 is, it looks really weird), and will try forever. So changing hp_shield01 position of TLR may solve this(after shield is down they will fly away).
Those mods that have no tradelanes(like 88Flak) will have no this issue.
Playing with attack_preference order and jobs it’s possible to make npcs with torps turn on capships, and after on solars while other npcs with no torps will take care of fighters.
I guess this is what you are implementing, Fox? hope this will be of some help.
Giving all fighters in npcships.ini same class will result in really random torpds/non torps npc encounters.
Don’t pay attention to my GUNS | GUIDED | TORPEDO | UNGUIDED part
-
-
I don’t know if it well help, but in one of the story missions, one of the early ones, willard research station gets attacked by the rheinlanders. There’s a set of bombers that you have to destroy that are attacking the battleship, they appear to ignore everything else. Might be something in their that helps you out.
-
From pilots story, so they only use torps against capital and solar. Must identify these target groups then (might help with the torpedos if you haven’t seen this already):
[JobBlock]
nickname = story_job_fighter_a_torpedo
wait_for_leader_target = FALSE
maximum_leader_target_distance = 10000
flee_when_leader_flees_style = FALSE
scene_toughness_threshold = HARDEST
flee_scene_threat_style = HARDEST
flee_when_hull_damaged_percent = 0.000000
flee_no_weapons_style = TRUE
loot_flee_threshold = EQUAL
attack_subtarget_order = ANYTHING
field_targeting = ALWAYS
attack_preference = CAPITAL, 5000, GUNS | GUIDED | UNGUIDED | TORPEDO
attack_preference = SOLAR, 5000, GUNS | GUIDED | UNGUIDED | TORPEDO
attack_preference = FIGHTER, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = FREIGHTER, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = TRANSPORT, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = GUNBOAT, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = CRUISER, 5000, GUNS | GUIDED | UNGUIDED
loot_preference = LT_NONE -
Timmy51m wrote:
I don’t know if it well help, but in one of the story missions, one of the early ones, willard research station gets attacked by the rheinlanders. There’s a set of bombers that you have to destroy that are attacking the battleship, they appear to ignore everything else. Might be something in their that helps you out.Since it’s in story mode, it’s probably coded in the mission script that they attack the capships and ignore the fighters.