[SOLVED] LoadSharedModel

I am creating a new HGN mothership. I am not editing the HOD, so I would like to use the LoadSharedModel command in the new SHIP file instead of LoadModel.

However, the mothership has a bunch of other files in its directory: events, mad, madstate, lua, etc.

Is it safe to omit these extra files?

Yes, they use the HOD, the HOD does not use them.

1 Like

Thanks!

Can I remove lines like this from the SHIP file of the new/duplicate mothership? Or should I leave it alone?

addCustomCode(NewShipType,"data:Ship/Hgn_Mothership/Hgn_Mothership.lua","","Create_Hgn_Mothership","Update_Hgn_Mothership","","Hgn_Mothership",4)

You can remove it, but it’s worth checking what that lua script does. From memory it is something to do with victory conditions or research, so you may want to keep it, depending on how you want your duplicate mothership to behave…

1 Like

Oops, good idea.

Do I need to rename all the custom code files in the duplicate ships? For instance like this?

addCustomCode(NewShipType,"data:Ship/Hgn_NewMothership/Hgn_NewMothership.lua","","Create_Hgn_NewMothership","Update_Hgn_NewMothership","","Hgn_NewMothership",4)

No, by the looks of that custom code it should run fine without the need to duplicate and tweak for your duplicate ships. There is no need to change the line, the path will lead it back to the original script.

1 Like

In the research lists, can I target more than one ship using the TargetName property? Thanks.

	{
		Name =					"ImprovedTorpedo",
		RequiredResearch =		"",
		RequiredSubSystems =		"Research | AdvancedResearch & FrigateProduction",
		Cost = 					1000,
		Time = 					60,
		DisplayedName =			"$7515",
		DisplayPriority =		29,
		Description =			"$7516",
		UpgradeType =			Ability,
		TargetType =			Ship,
		TargetName =			"Hgn_TorpedoFrigate",
		UpgradeName =			"UseSpecialWeaponsInNormalAttack",
		Icon = 				Icon_Ability,
		ShortDisplayedName = 		"$7207",
	},

I believe so, using “&”.

1 Like

Thanks!

I wish subsystems had a LoadSharedModel routine too. Instead, I have to copy the HODs when copying a subsystem.

:frowning:

Shared models appear to work for subsystems too, the Vaygr assault frigate is a good example. Only the bow turret has a specific .hod file while the port and starboard mounts use the function.

LoadHODFile is also listed before the Armour and AttackFamily lines while LoadSharedModel comes after.
This may unimportant but it could be worth considering should any errors appear.

3 Likes

That did work! Thanks.

1 Like

I tested and can confirm that you should NOT do this if you are sharing the model from a different ship. If you want to share models, then you should keep addCustomCode as it was originally and not change it.

I tested and can confirm that this does not work for ships, at the very least.

Perhaps a comma separated list would work? Failing that, if you make a research with zero cost and time that only requires this one, it should be auto-completed the instant you get this research and you could put your extra targets in that way

1 Like

How do I make such a research not appear in the in-game research menu? This is my best guess right now: