Custom launcher problem: inherit

Freeform discussion about anything related to modding Transcendence.
Post Reply
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

The code below is part of an attempt to create a launcher that can choose missiles from whatever is made available through extensions and mods. This would be useful in creating a launcher that can be manufactured during the game to shoot a custom list of missiles.

Right now, I'm trying to do something simpler: get it to shoot every missile in the game. I've used typCreate to successfully make the launcher. The problem is that when I try to add missiles to it, the XML parser gives me an error because some missiles don't have [ type = "missile" ] inside of their <Missile> element.

I've tried grabbing the XML for those missiles, but typGetXML only works for vanilla UNIDs and doesn't pull anything up for Corporate Command and mod UNIDs.

I've also tried various ways to pull the data I need out of the missiles using other functions without any success. For example, I can get a missile's speed using typGetDataField, but this successfully gets speed for all missiles, even ones like SmartCannon rounds that don't have [ type = "missile" ] inside of their <Missile> tags.

If I could turn the XML parser off, that might solve my problems, since the game seems to know everything it needs to know about SmartCannon rounds to actually fire them. The information is actually stored inside of a <Missile ammoID = [ UNID of ammo ] ..... > tag inside of the SmartCannon weapon itself. The game seems to be able to pull the information it needs out of the SmartCannon weapon and gives me the speed of the ammo when I ask for it. The XML parser, however, gives me an error if I try to make my launcher fire SmartCannon rounds, and the error prevents the launcher type from being created at all.

Now I'm trying to use inherit to make the <Missile> element inside of my launcher. That way, the launcher's missile definitions can simply inherit the information the missiles already have, and I can also override by adding type = "missile" for those missiles where that code is missing.

Unfortunately, this successfully adds all the missiles to the launcher, but none of them actually fires. Ammo disappears when I hold down the tab key, but nothing happens.

This has to be a problem with my attempt to use the new inherit code, since the launcher was able to fire missiles when I was using typGetXML to eliminate missiles from consideration based on the presence of the </missile> end tag. I had to stop using typGetXML for the reasons above, since it was not possible to add Burak missiles or mod missiles to the launcher using that method.

Is this the case because inherit doesn't work for missiles? Alternatively, is it because a missile element can't inherit from another missile element somewhere else if both elements share the same UNID? Or am I doing something wrong in the code itself?

Here's what I have. Thanks if anyone can help!

Code: Select all

		<OnGlobalUniverseCreated>
			(block Nil
				
				; Generate the code for the Pascal launcher's Missile elements
				; First, iterate through all existing missiles
				; Then put together an element for each one and concatenate with the existing code
				; CODE IS NOT WORKING - NEED TO DEBUG!
				(setq missileCode "")
				(enum (itmGetTypes "m") missileUNID 
					(block Nil
					
						; Get the missile's XML code
						(setq missileXML (typGetXML missileUNID))
						
						; Search for the end tag of the Missile element (ignore the first letter to attempt to be case-insensitive)
						; (if (find missileXML "issile>") COMMENTED OUT BECAUSE TYPGETXML DOESN'T WORK FOR NON-VANILLA UNIDS
							; If the Missile element is there, add that missile to the list of missiles this launcher can fire
							; Tried to make 'inherit' work, but it doesn't!
							(setq missileCode (cat missileCode "<Missile ammoID=\"" missileUNID "\" inherit=\"" missileUNID "\" type=\"missile\" />"))
						;	)
						)
					)
			
				; Create the Pascal launcher
				(typCreate &itLauncherI; 
						(subst (typGetStaticData &tmLauncherI; "Template")
							{	itemName : "Pascal launcher"
								missileElements : missileCode
							}
							)
					)
				)
		</OnGlobalUniverseCreated>
User avatar
Xephyr
Militia Captain
Militia Captain
Posts: 857
Joined: Fri Dec 14, 2007 1:52 am
Location: Orion Arm, Milky Way
Contact:

Try including the corporate hierarchy library, you should be able to call from its xmls then.

Code: Select all

<!ENTITY unidCorporateHierarchyVol01	"0x00810000">
Project Renegade (Beta) : "The Poor Man's Corporate Command!"
Real programmers count from 0. And sometimes I do, too.
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Thanks for the suggestion! I still can't pull up the XML, though. Here's what I used:

Code: Select all

(before the TranscendenceExtension tag)
<!ENTITY unidCorporateHierarchyVol01   "0x00810000">

...

(inside the TranscendenceExtension tag)

<Library UNID="&unidHumanSpaceLibrary;"/>
	
<!-- Corporate Command library -->
 <Library unid="&unidCorporateHierarchyVol01;"/>
User avatar
Xephyr
Militia Captain
Militia Captain
Posts: 857
Joined: Fri Dec 14, 2007 1:52 am
Location: Orion Arm, Milky Way
Contact:

Yeah, whoops, you just need to define the library like you did, not with the unid declaration like I posted

Strange that you can't call from their XMLs though
Project Renegade (Beta) : "The Poor Man's Corporate Command!"
Real programmers count from 0. And sometimes I do, too.
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

After looking through the wiki, forums, Transcendence source code, and a number of mods, I haven't found even one example of someone using typGetXML.

It's quite possible that it's supposed to do something other than what I think it does, although it seems not to be very useful if it can only pull up vanilla XML.
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

~ltell gunship* is this still an issue? not sure whether to respond or not https://forums.kronosaur.com/viewtopic.php?f=5&t=7583
RPC - I got your message on IRC a bit late, so I thought I'd respond here.

The problem was that the mod needed usesXML="true" inside of the the TranscendenceExtension tag. The solution is here:

https://forums.kronosaur.com/viewtopic. ... xml#p68727

Thanks for offering to help!
Post Reply