CustomCommand Demystified!...mostly...sorta

So I’ve spent the last few hours digging and have found a few gold nuggets worth sharing. This isn’t an extensive breakdown of the whole function call, BUT I have found some stuff that will make using it more understandable…

So first let’s take a look at one of the CustomCommand favorites, the drones frigate:

addAbility(NewShipType,"CustomCommand",1,"Drones",1,0,1000,200,0.5,4,0,
"data:Ship/Kus_DroneFrigate/Kus_DroneFrigate.lua","Start_DroneFrigate",
"Do_DroneFrigate","Finish_DroneFrigate","Kus_DroneFrigate",1.15,2,1)

So to start just so you get the bare-minimum understand we should cover the LUA function names.

  • Start_DroneFrigate: Likely to be the start of the ability
  • Do_DroneFrigate: probably a per-update call
  • Finish_DroneFrigate: as the ability’s duration runs out and finishes

The number behind these 3 functions is speculated to be the update frequency.

THE SECOND NUMBER HOWEVER, IS VERY KEY.

                   This one
                       V
Kus_DroneFrigate",1.15,2,1)

That number 2 defines the “index” of the ability. This is how hotkeys are assigned and how in-game command icons are assigned.

So once you know this we need to see how it’s used…

This is a cut from my own PLAYERCFG.LUA :

      {
        174,
        "MainUI_UserEventData( eCustomToggle, 2 )",
        0,
        0,
        "Drones",
        {
          17,
          68,
        },
      },

In this case 174 is the key I’ve selcted (which I thnk was soemthing liek Ctrl Z) and you can see the function call MainUI_UserEventData( eCustomToggle, 2 ) has the 2 in it. But that’s only one part to it.

The place this is all tied together, is with commanduidefines.lua

{
    commandID = INFO_CustomStart + 0,
    activateButtonName = "btnCustomActivate",
    rightClickDisplayName = "$5515",
},
{
    commandID = INFO_CustomStart + 1,
    activateButtonName = "btnGravWellActivate",
    rightClickDisplayName = "$5516",
},
{
    commandID = INFO_CustomStart + 2,
    activateButtonName = "btnDronesActivate",
    rightClickDisplayName = "$5517",
},
{
    commandID = INFO_CustomStart + 3,
    activateButtonName = "btnSpeedActivate",
    rightClickDisplayName = "$5518",
},

Here you can see all the HW1 special commands as they’re defined to associate with their respective UI buttons. If you go and check the grav well and scout’s ability defines you’ll find they have a 1 and 3 respectively in that second to last argument.

If you then go to tb_commandpanel.lua you’ll find where the buttons on the UI are defined:

BTN_CMD_DRONESACTIVATE	        = GetCommandButton(             "btnDronesActivate",	"$2958", 174,	"DATA:UI\\NewUI\\Taskbar\\CommandIcons\\cmd_ico_dronefrigate.dds",		"MainUI_UserEventData( eCustomToggle, 2 );")  
BTN_CMD_SPEEDBOOST		= GetCommandButton(             "btnSpeedActivate",	"$2959", 173,	"DATA:UI\\NewUI\\Taskbar\\CommandIcons\\cmd_ico_speedburst.dds",		"MainUI_UserEventData( eCustomToggle, 3 );")   				
BTN_CMD_GRAVWELL		= GetCommandToggleButton(	"btnGravWellActivate",	"$2957", 170,	"DATA:UI\\NewUI\\Taskbar\\CommandIcons\\cmd_ico_gravewellgenerator.dds",	"MainUI_UserEventData( eCustomActivate, 1 );" , "MainUI_UserEventData( eCustomDeActivate, 1 );")
BTN_CMD_CUSTOM			= GetCommandToggleButton(	"btnCustomActivate",	"$2956", 168,	"DATA:UI\\NewUI\\Taskbar\\CommandIcons\\cmd_ico_specialattack.dds",		"MainUI_UserEventData( eCustomActivate, 0 );" , "MainUI_UserEventData( eCustomDeActivate, 0 );")

You’ll also recognize that 174, 173, and 170 as the default key to use for the ability. I don’t have a list of said keys or how they’re defined, but you can try looking at other commands to get an idea.

That’s about all I got for now, and I have NO idea at all about how the special attacks fro the missile destroyer and heavy corvette work because they don’t have any matching index to go off of.


EDIT: Found the keybindings in the most obvious spot: data/scripts/keybindings.lua

{ 168, eCustomActivate,												INKE_KeyDown, -1, "$5446", { CONTROLKEY, ZKEY } },
{ 169, eCustomDeActivate,											INKE_KeyDown, -1, "$5447", { SHIFTKEY, ZKEY } },
{ 170, eCustomToggle,												INKE_KeyDown, -1, "$5448", { CONTROLKEY, SHIFTKEY, ZKEY } },	-- Gravwell Generator
{ 171, eKamikaze,													INKE_KeyDown, 0, "$5307", { CONTROLKEY, SHIFTKEY, KKEY } },		-- Kamikaze
{ 172, "MainUI_UserEventData2( eSpecialAttack, 0, 7)",				INKE_KeyDown, 0, "$5519", { CONTROLKEY, SHIFTKEY, BKEY } },		-- Burst Attack
{ 173, "MainUI_UserEventData( eCustomActivate, 3 )",				INKE_KeyDown, 0, "$5518", { CONTROLKEY, SHIFTKEY, SKEY } },		-- SpeedBurst
{ 174, "MainUI_UserEventData( eCustomToggle, 2 )",					INKE_KeyDown, 0, "$5517", { CONTROLKEY, SHIFTKEY, DKEY } },		-- Drone Activate

The tricky thing here was that they actually have the name wrong based on what some of the other UI files imply. As far as I can tell, grav well actually isn’t in the list of hotkeys at all. However it still uses the hotkey for “Custom Toggle” just fine.

The key profile is the first number, which is where the 170 came from.

After some extensive experimentation, the game doesn’t like you changing keybindings.lua at all. New entries can’t be found, name changes are ignored, and if you change the ID number on an existing entry, the game will continue to happily use the old ID and still find it somehow.

My conclusion is that keybindings.lua can’t be overridden and will always use its local copy.

The GOOD NEWS, however, is that you can try utilizing one of these un-used “custom” hotkeys for your project. I’ll try making a mod that restores HW1s style of “Z for everything” by simply setting all these abilities to 168 :smile:


Random bonus, some hilarious strings I found in ui.dat

5000	Frilliness
5001	Plain
5002	Slight frills
5003	Lace Trim
5004	Bloomers
5005	Ornate Night Gown
5006	HOW FRILLY YOUR UNDERPANTS MUST BE
5010	Happiness
5011	Depressed
5012	Sombre
5013	Excited
5014	Manic
5015	HOW MUCH YOU WANT TO PLAY THIS GAME

5050	Sauciness
5051	Serious
5052	Aloof
5053	Cheeky
5054	Sarcastic
5055	Annoying
5056	HOW MUCH YOU PLAN TO TRASH TALK
4 Likes

Great post! Does this mean using customcommand a ship can have two or more different player activated “Special Abilities”?

I’ll have to test it, but this seems like a likely possibility. :stuck_out_tongue:

Edit: okay so it didn’t work, I tried added the grav well on top of a drone frigate and it was only able to do the grav well. Seems whichever ability was defined last takes precedence.

Also found that the “1000” argument near the beginning there determines the duration. However the duration on the bar seemed to be completely cosmetic as the drone frigate kept spitting out drones regardless when I set it to a really low number.

Might also have something to do with how the grav well code I added in prevents deactivation of abilities :3 I’ll try again later with a restored-to-default drone frigate.

Kus_GravwellGenerator has 4 numbers at the end of CustomCommand instead of 3. Any idea why?

After many dead Omega Class destroyers, I’m guessing it controls whether the ship lives or dies at the end of it’s ability duration. 1 for explodes, absent (or 0?) for doesn’t explode.

1 Like

SCIENCE.

2 Likes