Variable setup looks fine. Other critique:
Code:
<if TimeGT="05.59" TimeLT="18.00">
<equip when="Resting|idle|aftercast">
<feet lock="yes">Serpentes Sabots</feet>
</equip>
</if>
<else>
<if mode="OR" TimeLT="06.00" TimeGT="17.59">
<equip when="Resting|idle|aftercast">
<hands lock="yes">Serpentes Cuffs</hands>
</equip>
</if>
</else>
The second <if> check is redundant. You've already checked the time, and if it's not in the day period (between 6am and 6pm) it must necessarily be nighttime. You can condense it to:
Code:
<if TimeGT="05.59" TimeLT="18.00">
<equip when="Resting|idle|aftercast">
<feet lock="yes">Serpentes Sabots</feet>
</equip>
</if>
<else>
<equip when="Resting|idle|aftercast">
<hands lock="yes">Serpentes Cuffs</hands>
</equip>
</else>
This entire section is problematic:
Code:
<equip when="Idle|Aftercast" set="Idle" />
<!-- Lock gear when engaged -->
<if status="Engaged">
<equip when="Precast|Midcast|Aftercast|Autoset" set="tp">
<main lock="t" />
<sub lock="t" />
<ammo lock="t" />
</equip>
</if>
<equip when="engaged" set="tp" />
Locking main and sub has already been done if you're engaged, so that's redundant. Locking ammo is pointless since you don't lose TP by changing ammo, only if you equip an item in the ranged slot, and you're not using anything in ranged.
Essentially what you want is:
Code:
<equip when="engaged" set="tp" />
<equip when="idle" set="Idle" />
<if status="Engaged">
<equip when="aftercast" set="tp" />
</if>
<else>
<equip when="aftercast" set="Idle" />
</else>
The rules where you specify SpellTarget are incorrect (as of version 2.20):
Code:
<if validtargets="*Self*" targettype="None" spelltarget="<t>">
<changetarget Target="<me>" />
</if>
SpellTarget used to be synonymous with SpellTargetRaw, which would give you a value such as <t>. It's now synonymous with SpellTargetName, which means you'll get something back like "Lesser Colibri". As such, your checks here will always fail.
The purpose of this code:
Code:
<if spell="Teleport*|Warp*|Recall*">
<return />
</if>
is to prevent gear swapping during aftercast where you may be zoning. However you've placed this rule -after- all the earlier stuff which specified aftercast gear. As such, it fails to achieve its purpose. You need this sort of rule right at the start of the rules section, before you give it any equip sets.
This code:
Code:
<if spell = "Bar*">
<equip set = "Barelement" />
<equip when = "aftercast" set = "idle"/>
</if>
has redundant, and possibly incorrect, aftercast info. Aftercast was specified earlier on; this rule will override that earlier aftercast, putting you in idle gear even if you're engaged. That line should be removed.
These rules:
Code:
<if spell = "Regen*">
<equip when ="precast|midcast|aftercast">
<hands lock="true">Orison Mitts +1</hands>
</equip>
</if>
<if buffactive="Divine Caress">
<equip when="precast|midcast|aftercast">
<hands lock="true">Orison Mitts +1</hands>
</equip>
</if>
Should not specify aftercast in their timing. That will lock in orison mitts following the spellcast, regardless of what your intended set (idle or tp) is. You should only be locking precast and midcast.
This code:
Code:
<!--Tp set--->
<equip when="engaged" set="tp" />
<equip when="Idle|Aftercast" set="Idle" />
Is a duplicate of earlier code (and similarly flawed), and should be removed.
Other flaws: You have a long series of <if> checks. This is bad form. Checks that are exlusive (eg: if you're casting Regen*, you can't possibly be casting a Bar* spell) should be considered in an <if>/<elseif> chain so that additional checks don't have to be compared once you have one that passes. Along with pastebin's formatting issues, it makes it difficult for me to be sure exactly which rules are taking effect each cycle.
Clean that up and then see if you're still having the staff issue.