Code:
<!-- Variable (currently set to 1.2 seconds) used to determine whether it is worth equipping precast-FastCast gearset or equip potency set right at the beginninh of casting of the spell
ie. for Raise spell you should precast a FastCast set, so it casts faster, but for Stun or Barfira, it is pointless to use FastCast, because it takes about 0.3s for Spellcast to process changing one gear set into another, and you'd end up casting in FastCast gear by the time a fast spell resolves-->
<var name="LongSpell">1.2</var>
<!-- A variable used to determine how long Spoellcast should wait before swapping from precast gear into midcast gear. When this gets set to 0, precast gear is not loaded and Spellcast proceeds directly to equip midcast gear -->
<var name="Delayer">0.6</var>
<!-- A set of variables used to swap a staff appropriate for the spell element. I use variables for Magian Staves for Potency (nuking) and Enfeebling (accuracy), they're not shown in this snippet -->
<var Name="IceStaff">Chatoyant Staff</var>
<var Name="WindStaff">Chatoyant Staff</var>
<!-- A variable that dictates if your gear sets for nuking and enfeebling should use full potency (for non resistant enemies) or toss in some magic accuracy. This can be changed manually or by for example entering a zone. If I enter Legion zone, this get set to "full magic accuracy", if I enter abyssea, this gets set to "full magic attack" etc -->
<var name="ResistRate">0</var>
<!-- A variable one can set that dictates if gear used when engaged should be Haste, Accuracy, PDT, MDT, StoreTP, Refresh etc. Yugl and Monteneten have this part more complicated. Myself, for example, I'd use this variable to either tank something in full PDT gear on RDM, or use Haste gear in Dynamis.
Let's say I have two gear sets Engaged$Tanking: "Engaged0" and "Engaged1". At the end of this snippet you'll find <action type="equip" when="aftercast" set="Engaged$Tanking" /> - a different gear set would get equipped depending on what the variable below is set to.-->
<var name="Tanking">0</var>
<!-- Similarly to Tanking variable, you could set this to equip either Refresh, PDT, MDT gear when not engaged. For pulling in abyssea, you'd want to set this to PDT, for backline curing, a refresh set would get equipped -->
<var name="Kiting">0</var>
<!-- rule below will be processed for all magic, songs and ninjutsu with the exception of Impact -->
<if CommandPrefix="/magic|/ma|/song|/ninjutsu" notSpell="Impact">
<!-- what to do if no ability shortening magic casting time is active -->
<if notBuffActive="Celerity|Alacrity|Spontaneity">
<!-- check if the spell is long enough for it to be worth equipping a FastCast gear before casting or not -->
<if advanced='"%CastTime">"$LongSpell"'>
<!-- check if the spell is of curative type, since those spells get a dedicated CureFastCast gear -->
<if Spell="Cure*|Cura*">
<!-- spell is a Cure with casting time greater than 1.2s => set delay for midcast gearset to 0.4s and equip "FastCastCure" before casting spell -->
<action type="var" cmd="set Delayer 0.4" />
<action type="equip" when="precast" set="FastCastCure"/>
</if>
<!-- spell is not a cure => set delay for midcast gearset to 0.4s and equip "FastCast" before casting spell -->
<else>
<action type="var" cmd="set Delayer 0.4" />
<action type="equip" when="precast" set="FastCast"/>
</else>
</if>
</if>
<!-- thre was an ability active that lowers casting time of a spell. For Spontaneity, Spellcast will proceed to <else> rule below and not load any precast FastCast gear, but load midcast potency gear instead before casting spell -->
<elseif BuffActive="Celerity|Alacrity">
<!-- Celerity/Alacrity shorten casting time of spell by 50% - check if it's worth bothering loading FastCast gear before casting spell. If the spell is shorter than 2.4s/2=1.2s, it will be treated as short spell -->
<if advanced='%CastTime>=($LongSpell*2)'>
<if Spell="Cure*|Cura*">
<action type="var" cmd="set Delayer 0.4" />
<action type="equip" when="precast" set="FastCastCure"/>
</if>
<else>
<action type="var" cmd="set Delayer 0.4" />
<action type="equip" when="precast" set="FastCast"/>
</else>
</if>
</elseif>
<!-- if rules above determine that the spell is going to be cast near-instantenously, variable Delayer will be set to zero and later on cause
'precast' to be skipped and 'midcast' to be loaded instead-->
<else>
<action type="var" cmd="set Delayer 0.0" />
</else>
<if Skill="EnfeeblingMagic">
<action type="midcastdelay" delay="$Delayer" />
<!-- determine what staff to use depending on spell element. If it was an ice spell, variable <var Name="IceStaff">Chatoyant Staff</var> would kick in-->
<action type="equip" when="midcast"><main>$%SpellElementStaff</main></action>
<!-- Determine if spell is LightEnfeeblingMagic or DarkEnfeeblingMagic and check if $ResistRate is set to low(0) or high(1) -->
<action type="equip" when="midcast" set="%Skill%Type$ResistRate" />
</if>
<elseif Skill="DarkMagic">
<!-- Stun, Kaustra and Klimaform use specific gear sets, rest of the spells like aspirs/drains will use generic DarkMagic potency set -->
<if notSpell="Stun|Kaustra|Klimaform">
<action type="midcastdelay" delay="$Delayer" />
<action type="equip"><main>$%SpellElementStaff</main></action>
<action type="equip" when="midcast" set="DarkMagicBlackMagic" />
</if>
<!-- specific rule for Stun. It check if Thunderstorm and Alacrity buffs are active and equips different gear depending on that -->
<elseif Spell="Stun">
<if advanced='(bool)buffactive("Thunderstorm") AND (bool)buffactive("Alacrity")'>
<action type="equip" when="precast" set="Stun-Alacrity" />
</if>
<else>
<action type="equip" when="precast" set="Stun" />
</else>
</elseif>
<!-- specific gear set for Kaustra -->
<elseif Spell="Kaustra">
<action type="midcastdelay" delay="$Delayer" />
<action type="equip" when="midcast" set="Kaustra" />
</elseif>
</elseif>
[.. gearset rules for other types of magic: elemental, healing, divine, songs etc ..]
<!-- Code below determines what to do after the spell is cast. -->
<if notstatus="Engaged">
<action type="equip" when="aftercast" set="Idle$Kiting" />
</if>
<if status="Engaged">
<action type="equip" when="aftercast" set="Engaged$Tanking" />
</if>
</if>
<!-- code below causes Impact spell to be cast automatically. The problem with this spell is, a special cloak needs to be equipped before the spell is cast.
What this code does:
-detect one is trying to cast Impact.
-equip TwilightCloak
-cancel spell casting, since cloak wasn't equipped at the time user wanted to cast the spell
-wait 1.2s for spellcast/game finish changing gear etc. At this point game will allow Impact to be cast.
-cast Impact
-equip Impact accuracy/potency set after 0.5s
-wait 11s for spell to finish casting
-change gear to current idle set-->
<elseif Spell="Impact">
<action type="equip" when="precast" set="Impact-FC" />
<cancelspell/>
<action type="command">wait 1.2;input /raw /ma "Impact" <t>;wait 0.5;sc set Impact;wait 11;sc set Idle$Kiting;</action>
<return/>
</elseif>
[..end of snippet..]