Ship Patching - Stage One

Howdy everyone!

As has been discussed MANY times, this patch sees the introduction of a new toolset for Mod authors that don’t want, or even can’t, create their own ships. We call this ‘Ship Patching’, and it essentially allows an author to bolt new Hard-points to a ship, as well as edit existing ones - including hiding them (which harmlessly prevents things from being added to them).

Here’s an example using the Sp_Tanker ship…

In a file under Sp_Tanker\Patches - let’s call it ‘Test.lua’ place this text:

Patch_Priority = 3.0
Patch_Exclusive = 0
Patch_Ops = { 
  hp_def = {        -- force the joints to understand change...
    root = "Root",
    name = "NavLightR6",
    pos = { -132.7466, -14.2374, -240.2300 },
    rot = { 0, 0, 0 },
    axis = { 0, 0, 0 },
  hp_0 = {
    root = "Root",
    name = "Hardpoint_IonBeam1_Position",
    pos = { 0, 13, 280 },
    rot = { 0, 0, 0 },
    axis = { 0, 0, 0 },

  hp_1 = {
    root = "Root",
    name = "Hardpoint_IonBeam2_Position",
    pos = { 0, 13, -207 },
    rot = { 0, 0, 0 },
    axis = { 0, 0, 0 },

Then, in the Sp_Tanker.ship file itself, add these 2 lines:

StartShipHardPointConfig(NewShipType,"Weapon IonBeam 1","Hardpoint_IonBeam1","Weapon","Innate","Damageable","Hgn_BattleCruiserIonBeamTurret","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon IonBeam 2","Hardpoint_IonBeam2","Weapon","Innate","Damageable","Hgn_BattleCruiserIonBeamTurret","","","","","","","","");

As you’ll see - now the Tanker spawns with 2 very formidable ion cannons… which probably makes HW2 a great deal easier :wink:

A few notes:

The ‘Patches’ folders follow the same Rules logic as Tags/Props - meaning you can put them in a sub-folder named for your custom Rules if you want them to be limited to those rules only.

The first HP edit in the example (hp_def) is there to resolve a bug which will be fixed in the next patch - that adding new nodes doesn’t cause the tree to refresh. Editing an existing one (NavLightR6) however does. That won’t be required post-2.1.

So, give it a shot - you can add a buttload of Point Defense guns now, or just go crazy with almost anything else. This isn’t the entire system, but some of it depends on the new HODOR, more complex skills, etc…



Do I have to include the original HOD and other files along with the patch, or will the game retrieve the HOD from the .BIG file automatically? (Assuming the new ship is a replacement using the same name.)

I’m not much of a ship kitter really, but this still makes me really happy! It honestly looks so easy that even I could do it if I wanted to!

Also the Tanker was the PERFECT example ship :wink:. Who hasn’t wanted to militarize that thing?

1 Like

Second question:

Let’s say I want to duplicate a ship. I want a new version of the “vgr_carrier” with two extra production subsystems. The new ship will be named “vgr_carrier_carrieronly”. I want this for my mod, but only when a particular game setting is enabled. I don’t want to break the MAD animations.

How would I go about setting this all up?

or in the case of the pirates mod turned it into a Battle carrier (Strength of Libertatia) with build able weapon subsystems. :smile:

i cant wait to start using this system once i get a feel for the modding structure on HWRM.

1 Like

@mikali you should be able to copy over the madstate to the new ship and just change the ship name in the madstate.

What is a shipmate?

Ship name, stupid autocorrect. :slight_smile:

1 Like

Like this?

VGR_CARRIER_CARRIERONLY_Launched_OnSet = function(ship)
VGR_CARRIER_CARRIERONLY_Docked_OnSet = function(ship)

Assuming your new ship is named VGR_CARRIER_CARRIERONLY, yes.

What about the other files? I have these files now:

They are all copied from “vgr_carrier”. What all do I need to do to get the ship in a working state and patched?

Alongside those files, create a folder called “patches” and put your hardpoints.lua file in there and the follow the example file contents in the first post.

Other than that, do I need to edit any other files? I see that “vgr_carrier_carrieronly.lua” has some stuff in it that might need to be renamed. As well as the “addCustomCode” stuff in the .ship file.

Also, in the hardpoints.lua file, do I need the “NavLightR6” item, or do I need to replace it with something else? How do I determine “what else”?

Here’s the ship I am working on:

It is still in the old HOD format, which is why I’m trying to update it.

Wait, you can’t patch old hods with this system, only new HWR 2.0 hods.

Also yes, anywhere the ship name is referenced in a code relevant manner would need to be updated to match the new ship name.

I meant, I am trying to reproduce the ship using the new HODs. Otherwise I would not need to do any work and could just keep using the old HODs.

I have an idea to make ship patching more useful… We have Load (load the model), and LoadShared (use an already loaded model, or load it the first time but allow re-use from the correct place)… which isn’t friendly with patching (because there is only 1 instance of that data, you can’t edit it twice). So I think I can add LoadAliased - where you load from someplace else, but as ‘your’ model, a brand new instance. It will cause the mesh/structure to be duplicated in RAM, but most of the textures will be the same name and not dupe. That way, you can do what you are asking without actually having to copy that other HOD.


Your example shows a “Hardpoint_IonBeam1_Position” node. But what about “Hardpoint_IonBeam1_Direction” and “Hardpoint_IonBeam1_Rest”? How do you enter those into the table? Are they direct children of root too?

1 Like

If Direction and Rest are in their default positions (up and forward respectively), you don’t have to add them, and HWR will auto generate them now.

The NavLightR6 item is to “dirty” the HOD and get the game to start re-calculating the joint trees. That requirement may already be removed in the public beta though.

1 Like

The engineer that setup the joint and weapons loading logic did a ■■■■ job - including in some cases actually incorrectly defaulting data if something was missing. Once we started moving all turrets to sub-systems I personally hit that code hard. You don’t have to declare stuff that you aren’t using any longer - which has the added benefit of making new Hardpoints via ship patching much, much easier.