I’ve waited too long for official documentation or for someone else to crack this nut, so it’s time for me do my best to brain at them. I figured I ought to post my preliminary results as I go, for general collaboration and so the info will be out there if I get distracted by something else.
So first I cracked open the bigs and searched for every instance of custom code, and realized something that had eluded me so far. There are two things at work here. One is a “CustomCommand” option in addAbility, and one is the all-new addCustomCode. Both refer to a lua file outside the .ship for their logic.
Next I’ve copied every instance of these calls I found, grouped them together, and tried to pretty-print them to a point where I could get an idea of their structure. Functions with this many parameters are always a pain to get a handle on without the parameter names…
The sense I get at first glance is that addCustomCode is used to give constant special behavior or properties to a ship, while addAbility-CustomCommand is just for directly player-activated behavior. I focused on CustomCommand first, since there are fewer instances of it.
I trimmed some repeated or not really helpful info from the collected data, and split it into two blocks for readability. For reference, here’s an example of a raw line:
addAbility(NewShipType,“CustomCommand”,1,“Drones”,1,1,1000,0,0.25,2,0,“data:Ship/Kus_DroneFrigate/Kus_DroneFrigate.lua”,“start_dronefrigate”,“do_dronefrigate”,“finish_dronefrigate”,“kus_dronefrigate”,1.03,2,0)
On to the meat…
addAbility(NewShipType,"CustomCommand",1,...
"Drones", 1, 1, 1000, 0, 0.25, 2, 0, "..Kus_DroneFrigate.lua",
"Drones", 1, 0, 1000, 200, 0.25, 2, 0, "..Kus_DroneFrigate.lua",
"$3191", 1, 0, 1000, 500, 0.55, 0.75, 0, "..Kus_GravWellGenerator.lua",
"Speed Burst", 1, 0, 1000, 0, 1, 0.5, 0, "..Kus_Scout.lua",
"$3191", 1, 0, 1000, 500, 0.55, 0.75, 0, "..Tai_GravWellGenerator.lua",
"Speed Burst", 1, 0, 1000, 0, 1, 0.5, 0, "..Tai_Scout.lua",
"Speed Burst", 1, 0, 1000, 0, 1, 0.5, 0, "..Kus_Scout.lua",
So we have name, sometimes localized so it’ll be what’s shown to the player then a bunch of numeric values. I suspect the ones that are only ever 1 or 0 are true/false flags, but what they’re flagging is hard to guess. My best guess for the mess of numbers would be for the power bar, with capacity, delay, recovery rate, that kind of thing. That’s just a best guess, though. I ought to check out the documentation on the predefined power-bar using abilities and compare to see if the parameters for them line up with these. Then there’s a path to the lua containing the logic, which I’ve truncated for brevity. It seems probable that you could have ships using the same ability calling a common lua file somewhere besides their ship dir, but if so I wonder why gearbox didn’t use that for the duplicated abilities.
"start_dronefrigate", "do_dronefrigate", "finish_dronefrigate", "kus_dronefrigate", 1.03, 2, 0)
"Start_DroneFrigate", "Do_DroneFrigate", "Finish_DroneFrigate", "Kus_DroneFrigate", 1.15, 2, 1)
"Start_Kus_GravWellGenerator", "Do_Kus_GravWellGenerator", "Finish_Kus_GravWellGenerator", "Kus_GravWellGenerator", 1.9, 1, 1)
"Start_Kus_Scout", "Do_Kus_Scout", "Finish_Kus_Scout", "Kus_Scout", 1.4, 3, 1)
"Start_Tai_GravWellGenerator", "Do_Tai_GravWellGenerator", "Finish_Tai_GravWellGenerator", "Tai_GravWellGenerator", 1.9, 1, 1)
"Start_Tai_Scout", "Do_Tai_Scout", "Finish_Tai_Scout", "Tai_Scout", 1.4, 3, 1)
"Start_Kus_Scout", "Do_Kus_Scout", "Finish_Kus_Scout", "Kus_Scout", 1.4, 3, 0)
Then there are these parameters, the first three of which are function names in the referenced file. The fourth I’m unsure of, but I presume is passed to the lua. Due to some looking ahead at the addCustomCode parameters, I’m guessing this is entirely cosmetic, but I’ll have to keep an eye out for that in inspecting the lua files.
The function parameters, just from the names, are presumably called at the start of the ability, durring the maintenance of the ability, and at the end of it respectively. It’s also conceivable that the start and end are called at the ship’s creation and destruction, so that’s something to look for context cluse to in the lua files themselves.
Last is three more number parameters. Again, the last one’s only appearing as 1 or 0 makes me think it’s a true/false flag, but that’s only a guess and I have no clue what it controls. The other two I’m similarly clueless about. They could be fed to the functions as parameters, which would be useful if one lua was called by multiple ships, or they could control something about the timing and update rate of the code. Something else to keep an eye out for context clues to.
ed: Xercodo’s findings are that the penultimate parameter is a hotkey and index, referencing Playercfg.lua, commanduidefines.lua, data/scripts/keybindings.lua, and tb_commandpanel.lua. Sastrei noted that gravwell gen in the updated files has an extra parameter that seems to control if something blows up after using it’s ability. :ed
More later. But, here’s the addCustomCode comparison block…
addCustomCode(NewShipType,"data:Ship/shipname/..."
"...Ben_BentusiExchange.lua", "", "", "Update_Ben_BentusiExchange", "", "Ben_BentusiExchange", 30)
"...Kus_DroneFrigate.lua", "", "create_dronefrigate", "update_dronefrigate", "destroy_dronefrigate", "kus_dronefrigate", 1.03)
"...Hgn_Carrier.lua", "", "Create_Hgn_Carrier", "Update_Hgn_Carrier", "", "Hgn_Carrier", 4)
"...Hgn_Mothership.lua", "", "Create_Hgn_Mothership", "Update_Hgn_Mothership", "", "Hgn_Mothership", 4)
"...Kad_Swarmer.lua", "", "createSwarmerFuel", "updateSwarmerFuel", "destroySwarmerFuel", "AdvancedSwarmer", 0.33)
"...Kad_MultiBeamFrigate.lua", "", "", "updateKad_MultiBeamFrigate", "", "Kad_MultiBeamFrigate", 1.25)
"...Kad_Swarmer.lua", "", "createSwarmerFuel", "updateSwarmerFuel", "destroySwarmerFuel", "Swarmer", 0.33)
"...Kus_Carrier.lua", "Load_Kus_Carrier", "Create_Kus_Carrier", "Update_Kus_Carrier", "", "Kus_Carrier", 10)
"...Kus_CloakGenerator.lua", "", "", "Update_Kus_CloakGenerator", "", "Kus_CloakGenerator", 10)
"...Kus_Drone0.lua", "", "", "Update_Drone0", "", "Kus_Drone0", 60)
"...Kus_DroneFrigate.lua", "", "Create_DroneFrigate", "Update_DroneFrigate", "Destroy_DroneFrigate", "Kus_DroneFrigate", 1.15)
"...Kus_GravWellGenerator.lua", "", "Create_Kus_GravWellGenerator", "Update_Kus_GravWellGenerator", "Destroy_Kus_GravWellGenerator", "Kus_GravWellGenerator", 1.9)
"...Kus_Mothership.lua", "Load_Kus_Mothership", "Create_Kus_Mothership", "Update_Kus_Mothership", "Destroy_Kus_Mothership", "Kus_Mothership", 4)
"...Kus_RepairCorvette.lua", "", "Create_Kus_RepairCorvette", "Update_Kus_RepairCorvette", "Destroy_Kus_RepairCorvette", "Kus_RepairCorvette", 15)
"...Kus_ResearchShip.lua", "Load_Kus_ResearchShip", "Create_Kus_ResearchShip", "Update_Kus_ResearchShip", "Destroy_Kus_ResearchShip", "kus_researchship", 2.2)
"...Kus_SensorArray.lua", "", "", "Update_Kus_SensorArray", "", "Kus_SensorArray", 10)
"...Meg_Crate_HW1Container.lua", "", "", "Update_Meg_Crate_HW1Container", "", "Meg_Crate_HW1Container", 5)
"...Meg_Relic_RUGenerator.lua", "", "", "Update_Meg_Relic_RUGenerator", "", "Meg_Relic_RUGenerator", 5)
"...Tai_Carrier.lua", "Load_Tai_Carrier", "Create_Tai_Carrier", "Update_Tai_Carrier", "", "Tai_Carrier", 10)
"...Tai_CloakGenerator.lua", "", "", "Update_Tai_CloakGenerator", "", "Tai_CloakGenerator", 10)
"...Tai_DefenseFighter.lua", "", "", "updateDefenseFighter", "", "DefenseFighter", 1.25)
"...Tai_Destroyer.lua", "Load_Tai_Destroyer", "Create_Tai_Destroyer", "Update_Tai_Destroyer", "", "Tai_Destroyer", 10)
"...Tai_FieldGeneratorDummy.lua", "", "Create_Tai_FieldGeneratorDummy", "Update_Tai_FieldGeneratorDummy", "Destroy_Tai_FieldGeneratorDummy", "Tai_FieldGeneratorDummy", 3/8)
"...Tai_GravWellGenerator.lua", "", "Create_Tai_GravWellGenerator", "Update_Tai_GravWellGenerator", "Destroy_Tai_GravWellGenerator", "Tai_GravWellGenerator", 1.9)
"...Tai_Mothership.lua", "Load_Tai_Mothership", "Create_Tai_Mothership", "Update_Tai_Mothership", "Destroy_Tai_Mothership", "Tai_Mothership", 4)
"...Tai_RepairCorvette.lua", "", "Create_Tai_RepairCorvette", "Update_Tai_RepairCorvette", "Destroy_Tai_RepairCorvette", "Tai_RepairCorvette", 15)
"...Tai_ResearchShip.lua", "Load_Tai_ResearchShip", "Create_Tai_ResearchShip", "Update_Tai_ResearchShip", "Destroy_Tai_ResearchShip", "tai_researchship", 2.2)
"...Tai_SensorArray.lua", "", "", "Update_Tai_SensorArray", "", "Tai_SensorArray", 10)
"...Vgr_Carrier.lua", "", "Create_Vgr_Carrier", "Update_Vgr_Carrier", "", "Vgr_Carrier", 4)
"...Vgr_Mothership.lua", "", "Create_Vgr_Mothership", "Update_Vgr_Mothership", "", "Vgr_Mothership", 4)
I don’t know about you, but I was certainly surprised by some of the names on that list.