Configuring SquadronSize the "right" way

Greetings all!

With lots of time available to dig into some of the new modding capabilities of the latest patch (thanks GBX!) this weekend, I thought I would tackle something PDS has been trying to do for a long time: dynamic squadron size. This can be broken down into two capabilities:

  • The ability to select a ‘default’ squadron size for ships from the
    game setup screen*.
  • The ability to dynamically adjust squadron size during the course of a game.

I based a lot of my research from this thread below, @BitVenom thank you for your detailed change logs!

Before we even get to selecting the squadron size in a game setup screen, let’s just try converting the fighters to use values-assigned-by-properties as that’s a great first step. I begin by adding a line to /scripts/rules/deathmatch/props/default.lua

Number_Properties = {
	hgn_attackbomber_squadsize = 6,
	hgn_interceptor_squadsize = 6,

The goal here is to set the default squadron size for all fighter-type ships for this specific gamerule. Eventually, I’d like to try within a single gamerule to have a drop-down setting such as “Number of ships per squadron” and then the player can choose “HW1 Style” or “HW2 Style” for example. This would be a sub-property of the game rule, and to make this work I’d have a SquadronSize_HW1.lua and a SquadronSize_HW2.lua in the rules/<gamerule>/props folder with the same Number_Properties = {...} array in each, but only the correct one loaded by the game rule sub-setting. Any confirmation that this would be the best way to procede? Or how to get the game rule to only execute select .lua files within /props? I think using tags would be the right way to do it, but not sure how.

Moving on, I attempt to get the .ship to use the newly defined gamerule property in defining its own squadron size, trying the following:

NewShipType.SquadronSize = getRulesNum(NewShipType, "hgn_interceptor_squadsize", 1.0)

Here’s where I’ve tried experimenting but get stuck. I don’t quite understand what getRulesNum (or getShipNum, for that matter) is doing behind the scenes. This built exactly one (‘1.0’) interceptor; and I had my doubts it was actually reading from the Number_Properties array. I tried replacing "hgn_interceptor_squadsize" with "junk" and I got the same result, one interceptor per squadron built. I tried replacing the last parameter ‘1.0’ with ‘100’ and of course I got an interceptor squadron with 100 ships in it! :smiley: I tried reversing the parameters, but I could not figure out how getRulesNum() could read the property for squadsize and correctly build that number of ships-per-squadron. So without further ado, here are my questions to the community:

1.) I’d like to just get this working so that I can define squadron sizes for ships in a game rule property, which I think is what GBX wants us to do in the long run (or as a .ship property using getShipNum(), but I got an identical result when trying that method in my simple example above). Anyone have any advice?

2.) When that’s working, I’m hoping to try out some .lua code that will update the Number_Properties array during the course of the match, e.g. a player researching “squadron size upgrade” and then the default squadron size increases by one, for example. Then, my thinking is this would seamlessly influence the properties of any new ship built, but I’m not sure if that’s the intention?

Thanks for any input, and good luck to all the modders out there.


*I know that @Krnt_13 has done an example of this in the brilliant HW: Past and Future mod. This is accomplished by having a separate .ship file where the health, value, buildspeed, and of course squadron size are defined differently across multiple .ship files for each ship. Knowing that the features GBX have implemented are destined to take us in a more efficient direction, I started this thread. Great work my friend and I hope HW: Past and Future can benefit from the discussion here!

Hopefully this thread doesn’t disappear into oblivion - I have continued to do some research on my end regarding .ship properties derived from gamerule .prop files. For PDS, we’ve currently got a prototype of the Building squadrons via Support ships from Hyperspace feature. This was accomplished with some cool new scripting thanks to the power of AddCustomCode() for individual ships. Nonetheless I’m still working on how to do squadron size the right way!

I’ve found that I can’t seem to modify (or even properly query for that matter) a gamerule Number_Property or String_Property. If anyone has any more of a breakdown of what is happening with getRulesNum (specifically what the parameters are) I’d be much obliged!

On a related note, does anyone know how to delete a ship using SobGoup() functions? I was digging around for a SobGroup_Delete() or SobGroup_Clear, _Empty, and _RemoveType() all empty the SobGroup. I’m trying to effectively remove a ship from the match, like retiring it but skipping over the whole retire mechanic. Does such a function exist? I am experimenting with such a feature for dynamic squadron size to see if I can cut the number of ships per squadron when they are docked.

Anyways, thanks to anyone who can provide more insight on gamerule-derived properties, for SquadronSize or anything else for that matter! Cheers;


You can set the health of the contents of a sobgroup to zero, but that’ll probably kill the whole squadron. I don’t actually know if you can do something that’ll affect one ship in the squadron without hitting the whole squadron.

I’m interested in your efforts with gamerule props, and plan on doing some related things, but haven’t gotten there yet. If I do crack the nut, I’ll try to remember this thread and let you know how it went.

Well, I tried my hand at this as well and came up short.


NewShipType.meshRenderLimit = getShipNum(NewShipType, "meshRenderLimit", 14000)

ear_omega.lua (wired in via customcommand)

getShipNum(CustomGroup, "meshRenderLimit", 100)


Number_Properties_Priority = 1.0	-- Default - on conflict higher is used...

Number_Properties = {
	meshRenderLimit = 14000,

String_Properties_Priority = 1.0

String_Properties = {

hwrm.log output

stack traceback:
   1:  function `Do_Jumppoint' at line 6 [string ""] 
 parameter: attempt to call global `getShipNum' (a nil value)