Got it. I was trying to get a weapon list off of a UNID and that didn't work. Thank you both.
Final code that gives us 'secondaryWeaponUNID'. The screen needs this to display the weapon's name.
This is inserted into a copy of the Korolov ship information screen code to add the secondary weapon to the display.
Code: Select all
;Here we insert code to allow the dockscreen to display the name of the secondary weapon if there is one.
(setq createdShip (sysCreateShip (@ gSelect 0) Nil (typGetProperty (@ gSelect 0) 'defaultSovereign)))
(setq secondaryWeaponList (filter (objGetItems createdShip 'wI) theWeapon (objGetItemProperty createdShip theWeapon 'secondary)))
(objDestroy createdShip)
(setq secondaryWeapon (@ secondaryWeaponList 0))
(setq secondaryWeaponUNID (int (itmGetType secondaryWeapon)))
(if (eq weaponUNID secondaryWeaponUNID)
(setq secondaryWeaponUNID 0)
)
(if (eq classUNID &scHeliotropeGunship;)
(setq secondaryWeaponUNID (int &itTurbolaserCannon;))
)
(if (eq classUNID 0x001B3004)
(setq secondaryWeaponUNID (int &itMicronukeCannon;))
)
(@ gSelect 0) is a ship UNID taken from a StaticData table.
The three 'if's at the end are
1: to stop the screen displaying the secondary weapon twice in ships if the primary weapon is a launcher.
2 and 3: the Heliotrope Gunship and Tundra don't have the property 'secondary' on either of their weapons so their second weapon doesn't get filtered into the secondary weapon list. This cheats and adds it manually.
I might do different code to count installed weapons and add them to the list if there isn't a secondary weapon one day.
Stupid code. Do what I want, not what I typed in!