Since it seems we don't have one of these in the pet forum as yet, I thought I might as well start one up. This thread will be here to post your own custom AIs in, where they will then be reviewed, commented, and improved on.
So in this spirit, I will start with a "basic" magic counter (in this case, fire) script that I recently worked up for my dogs while proceeding through Runda. I have not as yet had a chance to see how the contingencies for anti-ranged and anti-magic hold up under pressure, nor (surprisingly) whether the manually corrected move_against command in the Phase 2b contingency rule (self-preservation against wall advantage) works as it is intended to. As a skeleton buster, however, the script as a whole seems to work quite well--if a little slowly.
The AI is currently designed to respond to stamina and mp shortages by entering defense and approaching the master for protection and resupply, but I've been pleasantly surprised to see that the pets' phenomenal natural recharge rates keep this contingency from being tripped too often.
Known AI faults:
1. The passive aggro rules do not like to respond when a new mob immediately switches to attack status after a weakened mob is finished off, possibly owing to the fact that the old one has not yet disappeared.
2. The AI is single-minded when attacking. If the "go aggressive" rule is triggered and an enemy that is not the original target enters attack mode before smash is completed, the pet will continue to attack the original target instead of switching focus.
And now, the code.
Code:
<rules>
<rule name="Go aggressive">
<conditions>
<condition name="skill_preparable" pet_skill="smash"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="cancel_skill"/>
<cmd name="prepare_skill" pet_skill="smash" try_cnt="0" timeout="5000"/>
<cmd name="melee_attack" timeout="5000"/>
</sequence>
</pattern>
<event name="seek_target"/>
</rule>
<rule name="Go passive 1-Intro to Loop">
<conditions>
<condition name="target_distance" min_distance="200" max_distance="1500"/>
<condition name="skill_preparable" pet_skill="firebolt"/>
<condition name="skill_preparable" pet_skill="counter"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="cancel_skill"/>
<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="5000"/>
<cmd name="chase" chase_target="master" timeout="1000" run="true"/>
<cmd name="prepare_skill" pet_skill="counter" try_cnt="3" timeout="5000"/>
<cmd name="wait" min="10000" max="10000"/>
</sequence>
</pattern>
<event name="targeted" targeting_type="attack"/>
</rule>
<rule name="Go passive 2-Assault">
<conditions>
<condition name="target_distance" min_distance="100" max_distance="200"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="cancel_skill"/>
<cmd name="melee_attack" timeout="5000"/>
</sequence>
</pattern>
<event name="targeted" targeting_type="attack"/>
</rule>
<rule name="Intro into FC loop">
<conditions>
<condition name="skill_preparable" pet_skill="firebolt"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="5000"/>
<cmd name="prepare_skill" pet_skill="defence" try_cnt="0" timeout="5000"/>
<cmd name="chase" chase_target="master" timeout="5000" run="false"/>
</sequence>
</pattern>
<event name="attack" pet_attackable_skill="smash" down="true"/>
</rule>
<rule name="Loop Phase 1-Counter">
<conditions>
<condition name="skill_preparable" pet_skill="counter"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="prepare_skill" pet_skill="counter" try_cnt="0" timeout="5000"/>
<cmd name="wait" min="10000" max="10000"/>
<cmd name="prepare_skill" pet_skill="defence" try_cnt="0" timeout="5000"/>
<cmd name="chase" chase_target="master" timeout="5000" run="true"/>
<cmd name="wait" min="6000" max="6000"/>
<cmd name="cancel_skill"/>
</sequence>
</pattern>
<event name="attack" pet_attackable_skill="firebolt" down="true"/>
</rule>
<rule name="Loop Phase 2-Firebolt">
<conditions>
<condition name="skill_preparable" pet_skill="firebolt"/>
<condition name="target_distance" min_distance="200" max_distance="1500"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="5000"/>
<cmd name="prepare_skill" pet_skill="defence" try_cnt="0" timeout="5000"/>
<cmd name="chase" chase_target="master" timeout="5000" run="false"/>
<cmd name="wait" min="6000" max="8000"/>
<cmd name="cancel_skill"/>
</sequence>
</pattern>
<event name="attack" pet_attackable_skill="counter" down="true"/>
</rule>
<rule name="Loop Phase 2b-Wall Contingency">
<conditions>
<condition name="skill_preparable" pet_skill="firebolt"/>
<condition name="target_distance" min_distance="100" max_distance="200"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="move_against" distance="300" run="true" timeout="5000"/>
<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="5000"/>
<cmd name="prepare_skill" pet_skill="defence" try_cnt="0" timeout="5000"/>
<cmd name="chase" chase_target="master" timeout="5000" run="false"/>
<cmd name="wait" min="6000" max="8000"/>
<cmd name="cancel_skill"/>
</sequence>
</pattern>
<event name="attack" pet_attackable_skill="counter" down="true"/>
</rule>
<rule name="Retaliate, restart loop">
<conditions>
<condition name="skill_preparable" pet_skill="firebolt"/>
<condition name="skill_preparable" pet_skill="counter"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="melee_attack" timeout="5000"/>
<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="5000"/>
<cmd name="prepare_skill" pet_skill="counter" try_cnt="5" timeout="5000"/>
<cmd name="wait" min="10000" max="10000"/>
</sequence>
</pattern>
<event name="defence" defence_enable_skill="all"/>
</rule>
<rule name="If melee, start loop">
<conditions>
<condition name="skill_preparable" pet_skill="counter"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="prepare_skill" pet_skill="counter" try_cnt="3" timeout="5000"/>
<cmd name="wait" min="10000" max="10000"/>
</sequence>
</pattern>
<event name="attack" pet_attackable_skill="basic" down="true"/>
</rule>
<rule name="Take damage - Any">
<conditions>
<condition name="skill_preparable" pet_skill="counter"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="cancel_skill"/>
<cmd name="prepare_skill" pet_skill="counter" try_cnt="3" timeout="5000"/>
<cmd name="wait" min="10000" max="10000"/>
</sequence>
</pattern>
<event name="attacked" master_skill="all" down="true"/>
</rule>
<rule name="Proactive - AntiArchery">
<conditions>
<condition name="skill_preparable" pet_skill="firebolt"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="cancel_skill"/>
<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="5000"/>
<cmd name="melee_attack" timeout="5000"/>
</sequence>
</pattern>
<event name="aimed"/>
</rule>
<rule name="Proactive - AntiMagic">
<conditions>
<condition name="skill_preparable" pet_skill="firebolt"/>
</conditions>
<pattern>
<param_decl/>
<sequence>
<cmd name="cancel_skill"/>
<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="5000"/>
<cmd name="melee_attack" timeout="5000"/>
</sequence>
</pattern>
<event name="target_magic_prepare"/>
</rule>
</rules>