Autocasting

BugReportage

Warlord
Joined
Oct 10, 2008
Messages
143
Autocast feature.
Is it possible that some spells can be autocasted?
Example: A mage sits on a square and casts sanctify indefinitely.
 
Sort of.


One idea I had a while back was to make new spells with the same prereqs as many of the current spells, which did nothing but add an "autocast X" promotion. This promotion would wear off from attacking and casting, and would have a pyPerTurn effect (like the one Crown of Brillance has) that forces the unit to cast the spell once per turn.

Hmm...I just realized that I'm not sure whether this forced casting would remove the promotion. I don't think it does (as it doesn't stop the unit from casting something else), but if it does then there is a problem. It might also be appropriate for the spell to block castinf any spell but another spell that just removed the aurocast promotion, but I'm not sure how to do this without way too many python prereqs.
 
You could do it fairly simply by simulating Spellstaff. Your "Autocast_XXX" promotion would trigger python to cast the designated spell at the start of the turn, which would then mark the caster as "Has Casted" and block casting other spells for the turn. You have a "Remove_Autocast_XXX" spell which has a prereq of ""Autocast_XXX" promotion which ignores HasCasted flag and removes the autocasting promotion.

Though if someone intended to do that for a ton of spells it would be ideal to make it into an XML field of <AutocastSpell> for PromotionInfos, then no python is needed at all.
 
You could do it fairly simply by simulating Spellstaff. Your "Autocast_XXX" promotion would trigger python to cast the designated spell at the start of the turn, which would then mark the caster as "Has Casted" and block casting other spells for the turn. You have a "Remove_Autocast_XXX" spell which has a prereq of ""Autocast_XXX" promotion which ignores HasCasted flag and removes the autocasting promotion.

The problem with that is the PyPerTurn effect doesn't always happen at the start of the turn, so you might be able to get away with casting another spell first. As I said, I'm not quite sure if the forced casting would remove a promotion with the <bRemovedByCasting>1 tag. If not, then this could work fine, as the promotion wouldn't have a chance to be be autocasted if something else was cast first. Otherwise I'd be tempted to make it not be removed, but simply make the python call only work that turn if the unit hasn't cast something already, which would mean it would skip one turn of autocasting but would return to its old task the next turn if it isn't given other orders. It would only be removed by the spell then. It might be possible to have multiple autocasts on (since the xml spells can only remove 3 promotions), but only the first one it gets to would actually do anything.

Though if someone intended to do that for a ton of spells it would be ideal to make it into an XML field of <AutocastSpell> for PromotionInfos, then no python is needed at all.

Since a lot of the python calls I was planning to add basically are spells, many of them xml only, I was thinking this would be good to add anyway. I was also wanting this for <PythonPostCombatLost> and <PythonPostCombatWon>. Maybe the existing tags should just call Civ4SpellInfos.xml instead of CvSpellInterface.py? The xml file could still call the python if needed.


I was planning to add this type of autocasting to my (eventual) modmod for most adept, mage, and priest spells, but not any archmage spells. I'd be happy to have it stolen by FF in the meantime.
 
Yes, your ideal approach would be not to remove the python calls, but to add a <SpellOnDefeat> <SpellOnWin> <SpellStartTurn> <SpellEndTurn> set of tags. And if you were smart you would add them to be variable length lists so you can cast as many different spells as you desire in each set.

The reason I propose you make both a SpellStartTurn and a SpellEndTurn would be so that you can have some spell effects only happen at the end of the turn if you would want to move the caster to an ideal location (like the Crown of Brilliance effect would be MUCH nicer at the end of the turn so you can position yourself close to a lot of enemies). You could even make a "Blank" spell which just consumes the casters ability to use other spells in the StartTurn slot and then maintain the actual functional pieces of a spell in the EndTurn position (since these calls would most likely be made not to care if the unit is allowed to cast a spell)
 
Back
Top Bottom