Squashing Bug #666 (Partial Fix)

Hmm, can you elaborate a little on your initial question?

How do I disable formations completely in my mod? It may be better just to disable the feature totally if it is broken.

Ah, honestly I don’t remember exactly how. I haven’t fiddled with homeworld in months, and trashed most of the work.

I do remember fiddling with the attack lua files in attempt to allow ships to be in sqauds but not assume and direct formation shape. That way ships could be selected with the number keys are usual, but would attack individual when band selecting.

This ultimately would make the whole appeal to hw2 dogfighting go right out the window. It only partially would solve ship targeting issues when in formations though. I never finished pursuing it.

Anyway, back to your question… take a look into the mothership formation, attack, and .ship files, as they don’t form typical formations when set to do so.

Sorry for resurrecting an old topic, but has anyone tried changing the weapon config for the ships, eg Hgn_KineticAutoGun.wepn for the Hgn_Interceptor? Why I’m asking is StartWeaponConfig has an option <iShootAtSecondaries> and setting this to 1 will allow the weapons to fire at a non-primary target.

I have tested this with the Hgn_Interceptor and all members of the squadron where able to keep attacking the primary target even though they where targeting up to 29 targets. I haven’t put much testing in this at the moment as I don’t have much time to spare.

Just to add, this is the code I used to count the targets of the squad

function Update_Hgn_Interceptor(CustomGroup,Player,ShipId)

  if (SobGroup_GetCurrentOrder(CustomGroup)== COMMAND_Attack) then
    SobGroup_GetCommandTargets("Temp", CustomGroup, COMMAND_Attack)

    if (SobGroup_Count("Temp")> 1) then


I used the addCustomCode function in hgn_interceptor.ship to call the function every 1 second.

The link for a reference on StartWeaponConfig http://hw2bsg.org/wiki.hw2.info/FunctionStartWeaponConfig.html


How big of a performance hit would the game take from a script like this were applied to all ships and groups? Gearbox really did a number on us by not introducing a 64bit execution file.

After a bit more testing, I am a little unsure if changing the variable helps… :frowning:

I tried a different way of doing things and tried using scripts to change the attack targets of both formations and squadrons. While I do suspect it may hurt the performance of the game, I can’t really say by how much.

It you wish to test what I have tried, Mod_Sandbox

About the text on the left as it’s part of a testing mod I’m using to spawn units

FPS is my half-assed attempt at checking performance (Using Rule_Add, so it sticks to ~20)
On Screen is how many ‘spawned’ units there are
Max P/Player is how many ‘spawned’ units for each team

Pressing + or - (Not the numpad) will increase or decrease the Max P/Player
If a unit moves more then a certain distance away from the center, it will be despawned (Default is 10000)
Units will spawn within 100 to 2000 distance from center
CPU players are disabled
Selected units are invulnerable.

There are options in Scripts\Scar\bugSandbox.lua that can be changed.


Tried a different way of doing things, Mod_Sandbox2.zip

There are a few variables in data:scripts/sandbox.lua that can be changed
A new addition is pressing d will either start or stop the “mod” while pressing either h or j will increase or decrease the interval for the “mod”.

There isn’t much to the “mod” and is in data:scripts/strikeGroup.lua and is called using strikeGroup_INIT() (Currently this is done from MPRestrict() in data:scripts/scar/restrict.lua.

Admittedly, I am a little concerned on how it will effect performance as every interval (at an interval of 0.05 [default], that is 20 times per second) it will scan every ship for every player . Using the spawner, I have tested upto ~600 ships from 2 players and haven’t noticed a performance drop from the “mod” but that doesn’t mean there won’t be…


Hmm, 20 times a second might actually be above what is needed. Honestly, having it scan two to five time a second might suffice.

On another note, have you tried this with turreted ships or with the kushan drone frigate? My apologies for not being too involved right now, I’ve more or less given up with Gearbox’s unfinished title. Hats off to the visuals and attempt, but incomplete work from professionals is not acceptable in the my eyes. But hey, it is what it is.

I though about it, and I decided one day that if I had a space navy, small projectiles would more or less be guided. Do you remember the ‘ballistic mods’ that made weapons fire missiles that had no tracking? If someone were to take it a step further and replace missiles for any or every ballistic launcher in the game, we might have a ‘fix’ for a lot of issues, but the underlying problem would still remain. Also, defense fighters would work as intended from the original game.


I do applaud your efforts, as I have limited coding knowledge and could never figure something out that would make ships auto-update their targets.

1 Like

For the issue of individual ships targeting different units while in formation, a possible fix for this is editing the strike group files (scripts\strike groups\)

For example, in sg_x.lua there is

StanceGrouping = "Batch"
StanceGroupingAg = "Shape"
StanceGroupingEv = "Subs"

From my understanding, this is used to split the formation when attacking.

If this is changed to

StanceGrouping = "None"
LayoutMode = "Nodes"

Then ships will keep formation (slow units may fall behind slightly) while attack.

Not the best of screen shots
Honestly I don’t know what LayoutMode does :confused: but if set to Sphere it well, makes the formation a sphere

+Changed screenshot

Tried testing to see if squadrons will fire at the same target if similar changes are made to there strike group files… nope, might’ve missed something, but I think they will require a background script to update there targets.
Though, formations see to work good with out a background script changing there targets.

The kushan drone frigate, or more correctly the drones, are set to guard the drone frigate. It’s not a bug per-say, but how the background scripts handle them.

[Edit3] Don’t wish to double post
From my last testing,

  • With the flak frigate, when a cannon can not fire at the primary target, it will fire at a secondary target until the primary target comes back into that cannons firing arc.
  • With batch built squadrons (Vaygr interceptor, etc), they will all shoot at the primary target and not jump between multiple targets.
  • The drones for the drone frigate will shoot at the main target of the drone frigate.
  • Tested with a mixed formation of hiigaran scouts and kushan interceptors, forming an ‘x’ formation is all good (no surprise). When attacking, the formation will separate, but the kushan interceptors will remain in the ‘x’ formation and target who there formations leader is attacking.

Still need more testing, and have to do changes to all the remaining weapon and strike group files.

… Should ask as I am not a HW1 player. What is the correct purpose of the defense fighter? In the lua code, they are set to seek and destroy missiles pretty much.


Now, about your third edit and the x formation, do they still target the same ship after the initial target is shot down?

The targeting issues more or less come into effect once the initial target is killed. For instance, if a squad of interceptors is told to attack another squad of assault fighters, each ship in the interceptor squad will target the same vaygr fighter (five interceptors on one vaygr fighter). Once the vaygr fighter is dead, each interceptor from will then individually acquire a new target. All the interceptors, with luck, might target another fighter in that vaygr squad, or they might target another squad.

The biggest issue with ship targeting is actually mutual re-targeting.

At the very least, we need a script that will make all ships in a group be in agreement on the next target once the initial one is dead, and it has to be within the players selected band box. This is something gearbox probably could have knocked out in a few days or less, sadly.

As for defense fighers, in the original game they could only shoot down ballistic projectiles, not missiles. Because gearbox didn’t know what to do with them, they now have defense fields and missile defense weaponry.

I have a hopefully working script that will keep a group/formation/squadron both targeting the same target after the inital target is downed, and remembering there inital targeting list (bandbox selection).
The issue, if i’m correct, should be easily fixed by gearbox as it appears that the group (that is a formation that splits up to attack)/formation/squadron all agree on a targeting list, that they do keep after the initial target is downed, but when a primary target from that list is chosen as the next target, it is done at a unit level rather then the group/formation/squadron level, resulting in this issue.
I dont believe there is anyway for a unit to attack ballistic weapons in hw2 :acmsad: and if changing all ballistic weapons to unguided missiles (unsure if unguided is possible), there is still the issue of if a unit can differ between unguided and guided missiles to target.


Not really much to say on the fix side of things, changed some more strike group formations (Haven’t done fighter screen, frigate line and capital phoenix). Change all the weapons that where set to shoot at secondaries to now scan as well.

Removed the sandbox scripting from skirmish and started on a new one in ‘Extra Missions’.

Correcting the defense fighters is looking possible

They hiigaran destroyer is firing unguided missiles instead of kinetic projectiles which the defense fighters are destroying.


Changed all weapons that use Kinetic-Large (Hiigaran Destroyer for example) to shoot missiles instead of bullets.
Defense Fighter does shoot down these bullet missiles, but due to being unable to differentiate between these new missiles and other types (torpedo’s), it will still target them as well.


Sweet! Reminds me of a mod way back after launch that did the unguided balliatics.

If the targeting issues can’t be fixed, maybe making guided projectiles for fighters is the way to go.

One problem I ran into before was how taxing the missiles are on the limited engine. A combination of the extra missile hods and explosion effects really ruined performance, worse than vaygr missile corvette spam from multiple players.

Not every ship needs them either, just interceptor and corvette classes, except for laser corvettes. The guided projectiles I planned on fiddling with had a decent sized firing arc with very limited tracking, such that fighter combat would still look and feel the same but without the bug being the winning factor.

The lag is caused by the program I was using to record the video

Showing off that the hw1 interceptors are staying in formation while attacking, also they are keeping the same target.

[Edit] 2nd attempt at a video, also with a better/working bandbox attack

At about ~18 sec, the strikegroup is targeting an attackbomber which was not part of the bandbox selection, that’s why it switches targets (I think it happens at least one other time in the video).


After trying to fix this for a while, I am going to have to throw in the towel. The issue is that the target selection is done on a per ship level, meaning each ship in a squadron/strike group is creating there own targeting list. Upon creating this list, the ship then selects the best target, and if more then one, it will randomly select it’s target.

While fixing HW2 squadrons can be down with scripting, fixing strike groups can not (That is if they are forced to stay in formation while attacking). Most of my earlier results where happening as the units where creating similar targeting lists and I was just getting them to attack the first target in that list. But if there targeting lists differ, then they will attack different targets.

The code to fix squadrons is

Rule_AddInterval("RULE_FixSquadronTargeting", 0.25)

function RULE_FixSquadronTargeting()

  for player = 0, Universe_PlayerCount()- 1 do
    local int,max = 0, SobGroup_Count("Player_Ships"..player)

    while (int < max) do
      SobGroup_FillShipsByIndexRange("temp1", "Player_Ships"..player, int, 1)

      int = int + 1
      int = int +(SobGroup_Count("temp1")- 1)

      if (SobGroup_Count("temp1") > 1) then
        SobGroup_GetCommandTargets("temp1", "temp2", COMMAND_Attack)

        if (SobGroup_Count("temp2") > 0) then
          SobGroup_FillShipsByIndexRange("temp3", "temp2", 0, 1)
          SobGroup_Attack(player, "temp1", "temp3")
  • This does not work with bandbox selection (After the first target is destroyed, a new targeting list is created)

Well thank you for at least trying to fix this on your own time anyway, it is truly very much appreciated! Really shines a bad light on GBX though for leaving the game in this state after creating this issue with the 2.0 patch in the first place. This really doesn’t give me much confidence for any future game in the franchise coming from GBX, which sucks because I love Homeworld :cry:

At this point I should ask if it is possible to create a community patch mod with this and the other fixes that are possible to mod out… Unfortunately I can’t mod. However, I can, and am willing to, do repetitive jobs (provided that someone gives me the raw files and the instructions).

I helped in making a mod localizable, so if there is something similar that I can do, count me in :slight_smile:

I quite enjoy doing scripting for HW2 and would be happy to help, though I can’t be sure as to how much time I can put in as I am meant to be working on a mod for the game.

To show my lack of knowledge, what are the other issues?

If one of the issues is that defense fighter’s don’t shoot down ballistic weapons, that is due to HW2 not having that ability. Changing the ballistic weapons to missiles kinda helps, but there are issues surrounding that. One being that missiles don’t collide with asteroids. Also, while scripting can force a unit to target missiles, it can not distinguish between different types of missiles (fake ballistics, missiles, torpedoes). And if not forcing a unit that can only attack missiles (defense fighter), it will target a ship and not disengage.

If GBX does ever come back to this game, even if not to fix any bugs, I do hope they add 1 function that allows filling a sobgroup with the strikegroup of a selected unit. This is all that is needed for a basic scripting fix for bug 666. But that is just one function of a growing list of functions I wish GBX would add.


I was referring mainly to the thread “2.1 Patch Balance Issues”, but it seems it was removed (you can see a glimpse of it here: Announcement - Public Patch Preview). I don’t know if every issue that was written there is now fixed or not…