Does anyone know if there is an easy way to get the UNID of the secondary weapon of a ship class? typGetProperty - secondaryWeaponUNID doesn't work unfortunately . Possibly 'secondaryWeapon="true"' can be used in a search somehow.
I'm mucking about with the Korolov Enemy Intelligence screens which only show the one (primary) weapon but would like the first secondary weapon to show as well.
Or is it a case of converting to a shipobject then getting the first installed weapon-not primary and reconverting to a UNID? TIA.
secondary weapon UNID query
That checks a specific item on a specific ship. So to get the secondary weapons on a ship you could use this:
That will return a list of items. You can use (itmGetType item) to get the UNIDs.
I think if you want to get this for a ship type, you'll have to create a ship of that type, run that code on it, then destroy it.
Code: Select all
(filter (objGetItems obj 'wI) theWeapon (objGetItemProperty obj theWeapon 'secondary))
I think if you want to get this for a ship type, you'll have to create a ship of that type, run that code on it, then destroy it.
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.
(@ 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.
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;))
)
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!