secondary weapon UNID query

Freeform discussion about anything related to modding Transcendence.
Post Reply
relanat
Militia Commander
Militia Commander
Posts: 345
Joined: Tue Nov 05, 2013 9:56 am

secondary weapon UNID query

Post by relanat » Thu Dec 08, 2016 3:50 am

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.

User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2572
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Re: secondary weapon UNID query

Post by digdug » Mon Dec 12, 2016 11:35 pm

you get get/set a secondary weapon property using:

(objGetItemProperty obj item 'secondary) -> True or Nil

(objSetItemProperty obj item 'secondary) -> True if successful.

relanat
Militia Commander
Militia Commander
Posts: 345
Joined: Tue Nov 05, 2013 9:56 am

Re: secondary weapon UNID query

Post by relanat » Tue Dec 20, 2016 12:56 am

Thank you. I'm a bit busy ATM but that will help; it's a lot easier than what I was going to try!

NMS
Militia Commander
Militia Commander
Posts: 349
Joined: Tue Mar 05, 2013 8:26 am

Re: secondary weapon UNID query

Post by NMS » Tue Dec 20, 2016 7:10 am

That checks a specific item on a specific ship. So to get the secondary weapons on a ship you could use this:

Code: Select all

(filter (objGetItems obj 'wI) theWeapon (objGetItemProperty obj theWeapon 'secondary))
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.

relanat
Militia Commander
Militia Commander
Posts: 345
Joined: Tue Nov 05, 2013 9:56 am

Re: secondary weapon UNID query

Post by relanat » Tue Jan 03, 2017 4:47 am

Thanks for that. I had a quick try over Xmas but couldn't quite work out the filtering code. This definitely helps. :)

relanat
Militia Commander
Militia Commander
Posts: 345
Joined: Tue Nov 05, 2013 9:56 am

Re: secondary weapon UNID query

Post by relanat » Fri Feb 03, 2017 11:39 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests