The first pass as the wrapper script is now up. Hopefully it is more streamlined and easier to use. Below you will find a brief walkthrough. I will be creating a more in depth one soon that will include all of the options and what they do.
The wrapper script is, as it sounds, a script that wraps around your other scripts in order to provide much more complex options than can currently be found in game. The reason for it's development is two fold;
1. It allows any script writer to provide complex targeting options for their scripts without the need to write all of the code themselves.
2. It allows modders to create more meaningful interactions with custom targeting options and unit based outcomes.
The way the script works is as follows;
Starting with a standard script which adds 500 skill experience to the masonry skill to unit 0
modtools/skill-change -skill MASONRY -mode add -granularity experience -unit 0 -value 500
We can then place this script inside of the wrapper script, at the very basic level you will have
wrapper -sourceUnit 0 -checkUnit -script [ modtools/skill-change -skill MASONRY -mode add -granularity experience -unit SOURCE_UNIT_ID -value 500 ]
As it stands this gives us no extra advantages, however we can now begin adding in the options. The full list of targeting options are as follows
'requiredClass',
'requiredCreature',
'requiredSyndrome',
'requiredToken',
'requiredNoble',
'requiredProfession',
'requiredEntity',
'immuneClass',
'immuneCreature',
'immuneSyndrome',
'immuneToken',
'immuneNoble',
'immuneProfession',
'immuneEntity',
'maxAttribute',
'minAttribute',
'gtAttribute',
'ltAttribute',
'maxSkill',
'minSkill',
'gtSkill',
'ltSkill',
'maxTrait',
'minTrait',
'gtTrait',
'ltTrait',
'maxAge',
'minAge',
'gtAge',
'ltAge',
'maxSpeed',
'minSpeed',
'gtSpeed',
'ltSpeed',
So if you wanted your script to only add experience to the unit if they were between masonry levels 1 and 5 you could add
wrapper -sourceUnit 0 -checkUnit -minSkill MASONRY:1 -maxSkill MASONRY:5 -script [ modtools/skill-change -skill MASONRY -mode add -granularity experience -unit SOURCE_UNIT_ID -value 500 ]
You can add as many or as few of the targeting options as you want into a single wrapper. But you aren't just limited for checking a single unit. Say you wanted to add the experience to all of your units within a given distance of the source unit
wrapper -sourceUnit 0 -checkUnit -radius [ 10 10 2 ] -script [ modtools/skill-change -skill MASONRY -mode add -granularity experience -unit SOURCE_UNIT_ID -value 500 ]
Only 5 units in the radius?
wrapper -sourceUnit 0 -checkUnit -radius [ 10 10 2 ] -maxTargets 5 -script [ modtools/skill-change -skill MASONRY -mode add -granularity experience -unit SOURCE_UNIT_ID -value 500 ]
Only friendly units in the radius?
wrapper -sourceUnit 0 -checkUnit Friendly -radius [ 10 10 2 ] -script [ modtools/skill-change -skill MASONRY -mode add -granularity experience -unit SOURCE_UNIT_ID -value 500 ]
In addition to the many many different targeting options you can come up with, you can also alter the actual scripts being run. For example, say you wanted to add masonry experience to a unit, but you wanted to do it based on how much strength that unit has? It's simple!
wrapper -sourceUnit 0 -checkUnit -value [ source.attribute.strength ] -script [ modtools/skill-change -skill MASONRY -mode add -granularity experience -unit SOURCE_UNIT_ID -value VALUE_1 ]
Average of their strength and toughness?
wrapper -sourceUnit 0 -checkUnit -value [ (source.attribute.strength+source.attribute.toughness)/2 ] -script [ modtools/skill-change -skill MASONRY -mode add -granularity experience -unit SOURCE_UNIT_ID -value VALUE_1 ]
And so on, and so on...
Now, because of the large number of different options I am sure you are bound to find some problems, whether it be that it's not doing anything or it's crashing. There is the option to add -verbose into your wrapper script, this will give you a little bit more information on what is going on.
Lastly, if you look at the script you will see several options that I haven't touched on here. For now consider those options not working (most of them are, but there are still some bugs). Currently the wrapper script only supports checking for units and their relations to other units. The next step will be checking locations, items, projectiles, and more. With these additional checks you will be able to;
1. Have a script that only targets tiles with trees around a unit
2. Have a script that only targets items, or weapons, or silver weapons, or silver short swords
3. Have a script to target corpses
4. Have a script to target projectiles
etc...
Any questions please let me know. And if the targeting options aren't working please let me know that as well. I did test nearly all of them in the arena.