Author Topic: [RELEASE] Ship variant manager v1.0  (Read 2511 times)

0 Members and 1 Guest are viewing this topic.

[RELEASE] Ship variant manager v1.0
Greeting, fellow modders

Mentioned in the parsing script release thread, this script allows modders to change a capship's loadout and a few other characteristics through a single lua call. The idea was that if a ship or a group of ships has a specific set of characteristics (turret loadout, armor type, AI class, etc.) that differentiate that ship from others of the same class, instead of having to manually copy these from mission to mission, and potentially introduce errors in the process, you would define a "ship variant" in a config table file, then only have to copy a single script-eval-block SEXP referencing that variant and the ship you want to apply it to.

While you can probably get similar results by defining different ship templates in your regular ship tables (since I remember reading that they were working again), I personally have several reasons to use that script over that :
  • Ship templates were not working when I started writing it, so I have no idea how to use them
  • The extra variants won't show up in FRED (or use extra table slots, if that's a concern), which is nice when you have several dozen new variants, and plan to introduce more
  • My mission-wide script automates the process even more and is fairly helpful to keep track of each ship's role and presence throughout the campaign


Source code is available here.

How to use it:

Note: REQUIRES parse.lua

Put shipVariant.lua in data/scripts.

In data/tables/init-sct.tbm, under #Conditional Hooks:
Code: [Select]
$On Game Init: [[shipVariant.lua]]
$On Warp In: [setVariantDelayed()]

In data/config/ship_variants.tbl:
Table specification:
  • Each category specifies variants for a ship class (GTC Aeolus, GVCv Sobek, etc.).
  • Each entry defines a variant.
  • Valid attributes:
    • hull: special hit points (note: accepts order of magnitude multipliers, eg. 1M = 1000k = 1000000)
    • armor: hull armor type
    • turret armor: ship-wide turret armor type
    • subsystem armor: ship-wide subsystem armor type
    • team color: change team color
    • ai class: change ai class
  • Valid sub-attributes:
    • armor: armor type
    • RoF: new rate of fire (in percentage)



Example:
Code: [Select]
#SD Ravana
$Name: Battle Destroyer
$hull:  200k
$armor: Shivan Elite Armor
$ai class: General
$turret armor: Shivan Elite Armor
$turret01:LRed
+armor:Hell Armor
$turret02:LRed
+armor:Hell Armor
$turret03:SRed
+Rof:200
+armor:Hell Armor
$turret04:SRed
+Rof:200
+armor:Hell Armor
$turret05:SAAA
$turret06:SAAA
$turret07:Standard Flak
$turret08:SAAA
$turret09:SAAA
$turret10:SAAA
$turret11:SAAA
$turret12:Standard Flak
$turret13:SAAA
$turret14:Standard Flak
$turret15:SRed
$turret16:Standard Flak
$turret17:Standard Flak
$turret18:Standard Flak
$turret19:Piranha#Shivan
$turret20:Standard Flak
$turret21:Standard Flak
$turret22:Standard Flak
$turret23:Standard Flak
$turret24:SAAA
$turret25:SRed
$turret26:Piranha#Shivan
$turret27:SRed
$turret28:SRed
$turret29:SAAA
$turret30:Standard Flak
#End

In FRED:
Code: [Select]
( script-eval-block
"setVariant("
"'ship name',"
"'variant name')"
)

I am open to suggestions, remarks, questions regarding both this script and the way it is presented in this thread (in other words: I'm not sure if I'm explaining things properly here).