[SOLVED, MAYBE] Missile Targetting

I’ve got ships that have a weapon that’s designed to attack fighters and missiles (the ships have other primary weapons for capital ships). The ships will attack fighters using the anti-missile/fighter cannon while shooting another ship, but when it comes to incoming missiles, the ship won’t try and engage them at all. I’ve added the different missile attack families to the attack priority list in the CanAttack ability. I’ve also added setMissileKiller to the anti-missile wepn file too.

If I tell the ship to force attack missiles the weapon fires perfectly and does exactly what I want, but if I leave the ship to it’s own devices it ignores missiles completely. I know the Defence Fighter uses a script for it’s anti-missile weapons, but I’d rather not add that script (or a variant of it) to all the ships that use anti-missile guns. Any advice?

Read through the tai_defensefighter.lua (located in the same location as the .ship file) and try copying what you need. I’m not too familiar with custom ship luas, but that might be the place to start.

Oh, and make sure you add the .lua to be read in you .ship file, using the tai_defensedighter.ship for reference. Should look something like:

addCustomCode(NewShipType,"data:ship/Tai_DefenseFighter/Tai_DefenseFighter.lua… etc.

Yeah, I thought that might be the solution. I hacked it apart and it works fine for my purposes, except for one thing… the missiles switch targets to other missiles mid flight when the anti missile system turns on and shoots other missiles down. I think I might have to try and find a way to get the ship’s current target in the findAndAttackEnemyMissiles to make sure the ship doesn’t lose it’s original target as well as the missiles. Either that or try and disable the feature where missiles swap target. Shouldn’t be too hard. Otherwise, it works really well.

Wish it was simpler, mind you. Wish it worked like it does for fighters, as in it just does. I guess, even with the changes, it’s still not quite built for attacking missiles.

Hmm. Can you edit your missile weapon file in the weapons folder and give it an accuracy of missiles at 0? Check the hiigaran bc ion weapon and the vgr’s trinity cannon (called something like vgr_bc_forward weapon) and see what the fighter and corvette values are, because those will not shoot at fighters.

Using that, I think you could swap out the fighters with missiles.

So, usually, what I do is to maximize a lot the Munition targeting priority for my ships, doing it that way:

[code]addAbility(NewShipType, “CanAttack”, 1, 1, 0, 0, 0.35, 1.5, “Munition, Corvette, Fighter, Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility”, “Frontal”,
{
Fighter = “MoveToTargetAndShoot”,
},
{
Corvette = “MoveToTargetAndShoot”,
},
{
Munition = “MoveToTargetAndShoot”,
},
{
SubSystem = “BroadSideVsSubSystem”, })

[/code]
IIRC, the numerous commas tend to weight even more the first category when it comes to targeting (the order of the categories defines the priority weight, so get the Munition one first if you want some priority).

Then, check in your weapon files that the parameters for shooting at secondaries and shooting at surroundings are both set up to 1 so your weapon will look for other targets besides the ship’s main one.

And, yep, the Taidan Defence fighter code isn’t good if you want to do anything besides pure missile defence given that it will automatically override the targeting orders to select nearby projectiles to destroy.

1 Like

Ah ha! It works! I’ve learnt something else, too. If the weapon that is meant to shoot down missiles doesn’t have a setBallistics(NewWeaponType,0,whatever) in it, they won’t shoot. Will have to increase the miss cone, the anti missile defences are brutally effective. It’d take missile spam or plain old luck to beat them.

1 Like

What do you mean, missile shooting? The weapon firing the missile or the weapon firing at the missile?__

The weapon firing AT the missile. Probably should have been a bit more clear.

Huh. That’s kinda weird, my turret’s main gun has Ballistics at 1 and seems to shoot at the missiles.

It might just need the setBallistics line in general, and it doesn’t matter how it’s set. I think. I’m still a little unsure. (I think now it doesn’t matter at all)

EDIT: Huh. Now it’s stopped working, and I have no idea why.

DOUBLE EDIT: Gah. I think that there’s a bug in the logic. It turns out that it only works with ships with the minelayer ability. I thought that was fixed.

TRIPLE EDIT: It does work, but if the ship has other weapons and you’re attacking a ship, the anti-missile systems don’t fire. If the ship doesn’t have a target already, then it automatically attacks missiles using the anti-missile guns.

2 Likes

So, this ends up just being a passive ability that stops working when you target a ship? That sucks. Sorry, man.

Small bit of necromancy, but I think it’s useful information for anyone else trying this: If you bandbox force-attack a selection including both missiles and ships with a setup like above, it will engage both targets rather than just ignoring the missiles like when you attack ships normally. However, you do need to reissue the force attack frequently since it won’t acquire new missiles as targets by itself, and naturally this is kind of a crummy solution if you’re in a big battle and risk attacking your own ships by accident.

Edit: Possibly relatively common knowledge since it’s how things were apparently done in PDS, but I think worth stating for anyone searching this topic in the future: The ship will also fight both types of target fairly freely if moving around in combat mode but not given a specific target. Naturally, doesn’t help with focusing fire and it’s hard to teach the AI to play that way, but there it is.

1 Like