I’ve been messing around with custom subsystems and weapons for the Hiigaran Bc out of boredom, and I’ve been trying to convert the side pulsar weapons to an anti-missile system. The trouble here is I’m trying to make these side defense weapons automatically attack incoming missiles, similar to the Defense Fighter.
Am I missing something? Its possible to make the cruiser force select the missiles, but then all attention is focused away from actual ship targets, which defeats to purpose of an automatic system.
Try looking at the custom code for the defense fighter?
I take it you’ve already enabled “scanforsecondarytargets” and restricted the firing angles and attack families the pulsar will engage?
I have little luck with secondary targets if they are missiles. Any other ship can be targeted without issue.
As for the defense fighter code, I can’t get the ship’s weapons independent from the actual ship’s targeting.
Perhaps a simpler solution would be to make the missiles function as a typical ship when band-boxed, but I haven’t got that working either.
I think you will need custom code like the defense fighter has:
function findAndAttackEnemyMissiles(CustomGroup, playerID, shipID)
local numberEnemyMissiles = 0
if (Selection_GetMissiles("AllMissiles") > 0) then
--get nearby missiles
--...should not attack allied missiles either
if (Selection_FilterExclude("IncomingMissiles", "AllMissiles", "PlayerOwner", ""..playerID, "") > 0) then
local defensePoint = SobGroup_GetPosition(CustomGroup)
local defensePointString = defensePoint..","..defensePoint..","..defensePoint
numberEnemyMissiles = Selection_FilterInclude("IncomingMissiles", "IncomingMissiles", "NearPoint", defensePointString, ""..4500)
--We only attack enemy missiles when the selection of nearby missiles changes.
--Rather than compare the list of local missiles, just cache the number of local missiles.
if (numberEnemyMissiles > 0) then
--print("updateDefenseFighterAttack: shipID "..shipID.." "..numberEnemyMissiles.." missiles nearby")
if (defenseFighterMissileTargets[shipID] ~= numberEnemyMissiles) then
--print("updateDefenseFighterAttack: shipID "..shipID.." attacking "..numberEnemyMissiles.." missiles")
defenseFighterMissileTargets[shipID] = numberEnemyMissiles
SobGroup_AttackSelection(playerID, CustomGroup, "IncomingMissiles", 1)
I found this which was attempted quite some time ago. Looks like I’ll have to try something else.
IIRC, having quite limited arcs of fire helped a lot as the turrets would attempt to track only the targets in said field. I might try to see if I can get some weapons without meshes to be very near one another but different orientations. Though it would multiply the firepower…
EDIT: oh, right, what I also did was to add a common script to every armed unit that repurposes one of the stances. The script detects if your unit has that stance and if so, activates the defender script. That way, you can easily assign a ship or a squadron to missile defence when needed. Of course, it won’t help for AI players unless you can program the stance shift in case of missile attack on their ships.
Something I’ve been working on recently was a missile decoy system. Making enemy missiles change their target is apparently a no-go, but I’ve tinkered, with very limited results, with some sort of “mine” that would attack missiles coming near it and dropped by fighters. I might have to make it a real unit spawned when a missile is detected (via a variant of the defender script) and that would attack only missiles that come close before self-destructing.
You mean defense fighter, right?
Also, if you got the route of spawning a unit instead of a mine, you could take a look at how the drones for the kushan frigate function for formations and such. I’ve played around with them a bit, and there a lot of interesting things you can do with them. Couple that with a missile defense script and it may do nicely.
Yep. And indeed, it could be something fun to work with, for example if you start making invisible and unselectable units or that kind of stuff. Though, as usual, the issue will be the processing power, as I painfully discovered with my automated ship naming script.