Is it possible to add a new element? if so how?

lounahtic

Chieftain
Joined
Oct 12, 2010
Messages
14
i want to add a script to the unit ability bonus vs mounted units, so that if a mounted unit is damaged by a unit with said ability, the mounted unit is replace with another unit.

i think that i need to add a new element, let call it <AntiMounted>, to the CIV5UnitPromotions.xml and write a script to do whatever it's suppose to do.

Code:
<UnitPromotions_UnitCombatMods>
		<Row>
			<PromotionType>PROMOTION_ANTI_MOUNTED_II</PromotionType>
			<UnitCombatType>UNITCOMBAT_MOUNTED</UnitCombatType>
			<Modifier>100</Modifier>
                        <AntiMounted>true</AntiMounted>
		</Row>
</UnitPromotions_UnitCombatMods>

i have decent knowledge on programing in various languages, so the script itself won't be that much of a problem, i have to find the commands for what is this unit's class or how much damage has the unit taken. what i do not know is whether or not it is even possible to add a new element and if so, where would it calls the script for the new element from.

there is a very good chance that this is quite possible, because you can gift units, update units, promote units and capture units... all of which changes the current unit into something else. and with settlers, the captured unit is a worker. so for certain you can change a unit into something else, just that the condition is changed.

also with the elements like <Pillage> when set to true it allows a unit to pillage an improved tile. where is the script that is activated when this happens? if i can find where this is located then i can add a new element and create a script for it in similar fashion.

so my question is where are the codes for all these elements? i hope it's not hardcode into the game, cause then this is probably undoable... but if you have any ideas, let me know. thanks :D
 
There is a <capture> I think tag for units that sets what unit type you get when capturing, but I dont think it works for combat units.
And you cannot directly edit the actions that the various xml data are controlling, those are in the dll's (I think) which cannot be modified for the time being.

However, what you want can be made quite easily with lua scripts. Look around the wiki for combat and unit functions and check how they are used in the games .lua files. I know that there are ones to monitor damage taken by units (attacker/defender) in a combat phase, and there should be one to check promotions. You can also change a units type. Combine those for a function and call it whenever combat happens.
However I wouldnt actually create a new element in the units.xml, as only your mod will use that. You might as well just add a unit/promotion list to your script.
 
I have noticed that if you add table definitions in xml, the in-game database picks them up. So perhaps adding a new element to an existing table definition will as well.
 
Back
Top Bottom