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>