Here's George's multiverse post on TypCreate.
Here's a step-by-step manual on how to override XML objects in Transcendence.
Rules:
1. You can only override objects once, in OnGlobalTypesInit. OnGlobalTypesInit is run at the very beginning of the game. If you want to override an object after this time, well the next best option is cloning that item and using TypCreate to create a modified clone while getting rid of the original.
2. Since our new xml* functions rely on finding the UNID of particular objects, we need to be careful on how we find the UNID. Currently the two ways I know of having the UNID of a particular item accessible at OnGlobalTypesInit is
*Knowing the UNID beforehand, manually inputting the hex number in code.
*Using TypFind.
Plan:
1. We stick OnGlobalTypesInit in the <Events> of whatever item or spaceobject that's in our mod.
2. We then look for the unid using TypFind and magical boolean or logic switches.
In addition to the TypFind syntax, we have a couple tricks in our sleeves.
Code: Select all
(typFind criteria) -> list of UNIDs
criteria
a AdventureDesc
b ItemTable
c EffectType
d DockScreen
e SpaceEnvironmenType
f OverlayType
h ShipTable
i ItemType
m Image
n MissionType
p Power
q SystemTable
s ShipClass
t StationType
u Sound
v Sovereign
y SystemType
z SystemMap
$ EconomyType
+/-{attrib} Require/exclude types with given attribute
Code: Select all
(typFind (cat "* +unid:" &scDanu; ))
to find a particular unid without knowing the hex number.
We can also use the knowledge of certain properties to narrow our search.
In this thread, we can enumerate through all the items in the game, then use an if switch to sort out all the items we want, namely weapons
Code: Select all
(eq (itmGetProperty (itmcreate theUNID 1) 'category) "weapon")
Code: Select all
(not (typGetProperty theUNID 'launcher))
Code: Select all
(not (itmHasAttribute (itmCreate theUNID 1) "energyWeapon"))
I have tested that itmEnumTypes and (itmGetTypes "*") do not work in OnGlobalTypesInit in the same thread, so we're left with TypFind as our only option.
3. Now we can use all of our xml* functions to manipulate and create the new xml we want. I can't go over details because everything is a case by case basis but if there are any pressing questions feel free to ask them in this thread.
General tips:
I myself like to build things from the ground up. One useful function for doing that is (xmlAppendSubElement xml xmlToAdd [index]).
The general game plan is this:
*Create a generic template, such as <Ship or <Station
*Then create all the details, such as <Player or <Dockscreens
*Then using xmlAppendSubElement, I can (xmlAppendSubElement genericTemplateXml detailXmlToAdd [index of where I want that detail to be])
If you're having trouble, always know that you can do (PrintTo 'log XML) and check what your XML looks like in the debuglog at various stages in your code.
4. Once you're done creating the right XML, all you have to do is (TypCreate unidoftheitemyouwanttoreplace xmloftheitemyouwantittobe).
Then that's it.
*edit: added link to George's post on multiverse.