I am interested. Looks like I have it in as
feature request #89
Oh. Must have overlooked that.
I'll upload a patch at sf.
A quick explanation for everyone interested in using this:
The new tag works much like the other Spell tags regarding python: it must get a python expression, instead of a function. I'll give an example:
CvSpellInterface.py in the component:
Code:
def canCast(argsList):
pCaster, eSpell = argsList
spell = gc.getSpellInfo(eSpell)
return eval(spell.getPyRequirement())
...
def getSpellHelp( argsList ) :
eSpell, ePlayer, leUnits = argsList
pSpell = gc.getSpellInfo( eSpell )
pPlayer = gc.getPlayer( ePlayer )
lpUnits = []
for eUnit in leUnits :
lpUnits.append( pPlayer.getUnit( eUnit ) )
return eval( pSpell.getPyHelp() )
CIV4SpellInfos.xml
Code:
<SpellInfo>
<Type>SPELL_EXPLORE_LAIR_AIFON_ISLE</Type>
...
<PyRequirement>reqExploreLair(pCaster)</PyRequirement>
<PyHelp>helpExploreLair(lpUnits, True)</PyHelp>
...
</SpellInfo>
<SpellInfo>
<Type>SPELL_EXPLORE_LAIR_BARROW</Type>
...
<PyRequirement>reqExploreLair(pCaster)</PyRequirement>
<PyHelp>helpExploreLair(lpUnits, False)</PyHelp>
...
</SpellInfo>
canCast() evaluates the expression given in the PyRequirement tag. That expression can use all variables defined in canCast before eval(), namely pCaster, eSpell and spell (although AFAIK only pCaster is used and intended to be used).
PyHelp works the same way, but is has different variables. lpUnits holds all selected units that can cast the spell. The reason why I chose to consider a list of units rather than just one (the first selected), is that when you click on a spell button while having more than one unit selected, all valid units will cast that spell. So getting only information about one could be misleading.
Also note the call of helpExploreLair in <PyHelp>, with the second argument being True or False. It determines whether the lair is epic or not. This way you can use the same function for epic and non-epic lairs instead of having two separate functions.
On a side node, you, tholal, could possibly add extra information in the DLL, since now the list of possibly casting units is available for the respective GameTxtMgr function. I was thinking of something like "number of units able to cast", although that might be tricky, since, after the first one cast a spell like haste, the other casters might be unable to also cast that spell (the hasted promotion is already there), so the number of casters would be effectively 1.