^
Login

or


Writing TD Scripts

1. Requirements


For this guide, it is necessary to install the following addons: Rematch, tdBattlePetScript, tdBattlePetScript Rematch. It is assumed that installation and setup are already done, and teams are set or easy to set by you.

2. How it works


Basically the addon selects the required ability following instructions written in the script. E.g.:

use(Dodge:312)
use(Nature's Ward:574) [!self.aura(Nature's Ward:820).exists]
use(Alpha Strike:504)
This set of lines result in the following actions:
round 1: it casts Dodge
round 2: it tries to cast Dodge, but since it is on CD, it goes to the next line and casts Nature's Ward
round 3: it tries to cast Dodge, but since it is on CD, it tries the next line. Since aura Nature's Ward is active, it goes to the next line and casts Alpha Strike, and so on.

To summarize: each line is read sequentially until it finds a command that can be executed. The challenge here is writing scripts able to cast the spells according to the desired strategy.

3. Script creation


3.1 The editor



The easiest way to write a script is when you are doing a pet battle with a team previously saved on Rematch.
After starting the fight, open Rematch, right click over the corresponding team and select 'Write script'.
It will open a new window, the 'Script editor'. During the battle, and while the script editor is active it is possible to write a script using the auto-complete feature.










With the script editor opened and during a fight, start typing the desired action and it will soon show an dropdown list.







After selecting an action (type Enter or click over the action) a new list with the abilities available to the active pet will be shown.






Again, select the desired ability and if needed add the conditions when this action will be executed. Start by typing a bracket '[' followed by the first letter of the condition. Options are a target (self, enemy) or weather.





Anyway, a new list will be shown, it there is any.









In case there are additional required parameters, as with auras, a new list will be shown. As before, select the appropriate option.

Once you are familiar with the commands, you might just type the command followed by a dot to activate the dropdownlist with the available options. Remember to close the condition with a bracket: ']'.


Writing and editing a script is not difficult itself since the addon makes it very easy with the dropdown lists. Good luck!


3.2 Actions


ability/use: casts an ability
change: changes active pets
catch: catches a pet, if possible
standby: pass a round
quit: quits the fight

3.3 Conditions


Conditions are written between brackets ([condition]):
if & endif

3.4 Target


self: checks a condition on your own pets
enemy: checks for a condition on your enemy's pet

3.5 Functions


dead (boolean)
exists (boolean)
hp (compare)
hp.can_explode (boolean)
hp.full (boolean)
hp.high (boolean)
hp.low (boolean)
hpp (compare)
aura.exists (boolean)
aura.duration (compare)
weather (boolean)
weather.duration (compare)
active (boolean)
ability.usable (boolean)
ability.duration (compare)
ability.strong (boolean)
ability.weak (boolean)
ability.type (equality)
round (boolean)
played (boolean)
speed (compare)
speed.fast (boolean)
speed.slow (boolean)
level (compare)
level.max (boolean)
power (compare)
type (equality)
quality (compare)
id (equality)
is (boolean)

4. Pratical examples


Although the script helps a lot with its auto-complete feature, it won't be enough to write good scripts. It is a good idea to choose a fight and play with the script editor until you feel more confident with the commands and becomes able to write more complex scripts. Below there will be some examples taken from pet battlers using specific strategies. It is assumed that the team is loaded, the abilities are the ones mentioned on the strategy guide, and that the recommended pet is being used, not an equivalent.

4.1 Wailing Critters


The Wailing Critters dungeon offers a nice opportunity to start improving your skills. Until you win the last fight the dungeon is repeatable and you might leave the dungeon, heal, and restart. There is also some random pets in the back row, but only a few families and abilities. The first 3 fights require only one pet with a fixed set of abilities, turning it into a nice place to practice your skills. The script might work for most of the fight where the same pet+abilities are being used, making it a very useful script. The link for the strategy is here.
The strategy:
Prio 1: Keep Emerald Presence active
Prio 2: Use Emerald Dream when you drop below ~1000 health
Prio 3: Emerald Bite

use(Emerald Presence:597)
use(Emerald Dream:598)
use(Emerald Bite:525)
As it is written, the script will cast Emerald Presence every time it is available. This ability does not have a CD, so we have to add a condition that prevents it from casting if the aura is already present.
The only conditions available are the 'aura(Emerald Presence).exists' or 'aura(Emerald Presence).duration'. The condition that seems to fit the strategy better is the first one.
After writing it, we would have use(Emerald Presence:597) [self(#1Emerald Proto-Whelp).aura(Emerald Presence).exists], which could be read as "cast Emerald Presence if my Emerald Proto-Whelp has Emerald Presence active".
We want the opposite of that, so deny the condition by using a '!' before the target: use(Emerald Presence:597) [!self(#1Emerald Proto-Whelp).aura(Emerald Presence).exists], translating into "cast Emerald Presence if my Emerald Proto-Whelp does NOT have Emerald Presence active". Yay!

use(Emerald Presence:597) [!self(Emerald Proto-Whelp).aura(Emerald Presence).exists]
Next step: as of now, the script will cast Emerald Dream on CD, which might not be required, specially at the beginning of the fight. Let's add the condition that will cast the ability once your whelp is low on health.

use(Emerald Dream:598) [self(Emerald Proto-Whelp).hp<1000]
You might choose to heal your whelp if it is below an amount expressed in percents, and not a fixed amount:

use(Emerald Dream:598) [self(Emerald Proto-Whelp).hpp<50]
This last condition will cast Emerald Dream if your Whelp is below 50% health.
The final script:

use(Emerald Presence:597) [!self(Emerald Proto-Whelp).aura(Emerald Presence).exists]
use(Emerald Dream:598) [self(Emerald Proto-Whelp).hp<1000]
use(Emerald Bite:525)
If your proto-whelp dies you may change it to another equivalent pet with the same abilities, and the script will keep working. To change pets add the following line: change(#2) [self(#1).dead] (change to pet number 2 if my pet number 1 is dead)

Now, some remarks about the way the script is written.
  • If your team has two Emerald Proto-Whelp, the script might not work as expected if you change pets. To avoid problems, instead of naming it, give it the team position, or just use the 'self' target. This will also allow you to use a different pet with the same skills, like the Dream Whelpling or the Emerald Whelpling
  • Do not use a slot number for abilities. It might cause problems if you use an alternative pet whose abilites are on different slot positions, like the Zandalari pets where the abilites Hunting Party and Black Claw sometimes are on a different tier.
  • Use either the ability's code number or both name and code. Some players might use a localized version of the game, and for them the script will not work if you use only the name of the abilities
  • You might leave only the abilities code number, which will result in a shorter script, but it is not necessary

A suggestion for all scripts (change to the appropriate team slot):

change(#2) [self(#1).dead]
use(Emerald Presence:597) [!self.aura(Emerald Presence:823).exists]
use(Emerald Dream:598) [self.hp<1000]
use(Emerald Bite:525)

4.2 Small fragments


Scripts are written for a specific strategy, but there are many common actions that can be use in many scripts. Adjust them to your needs, checking for the right conditions, and apply them when suitable.
  • Pass on first round:
standby [round=1]
  • Change pet to leveling and back (change slot numbers where appropriate):

change(#2) [self(#1).dead & !self(#2).played]
change(#3) [self(#2).active]
  • Use a dodge ability to block an enemy's ability (in this case, Burrow)

use(Deflection:490) [enemy.aura(Underground:340).exists]
  • Change the use of abilities depending on active enemy pet

If the enemy's pets are the first or second, you pet will cast Breath. Once the third pet enters the fight, your pet will cast Bombing Run on CD and Decoy if your enemy uses Burrow

if [enemy(#3).active]
use(Decoy) [enemy.aura(Underground:340).exists]
use(Bombing Run)
endif
use(Breath)

5. Resources






23 Comments (EN)

Show first:


You must be logged in to vote on comments

0

You must be logged in to vote on comments

Darkironman wrote on 10/18/2020

Is anybody else having issues with writing scripts? I can not open the editor.
You must be logged in to vote on comments

1

You must be logged in to vote on comments

squishy930

wrote on 10/18/2020

I am. At first when I clicked "Write Script" nothing would happen and now the option is gone.
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Frostyuwu

wrote on 09/16/2020

Could someone help me with a code?
use(Life Exchange:277)
use(Amplify Magic:488)
use(Eyeblast:475)
standby
standby
use(Amplify Magic:488)
use(Life Exchange:277)
use(Eyeblast:475)
change(Brilliant Spore:1540)
use(Explode)
change(Jade Owl:845)
use(Hawk Eye:521)
use(Lift-Off:170)

this is for Pearlhusk Krawler
Pearlhusk Crawler (NPC#154914)

1: Mini Mindslayer (1,1,2)
2: Brilliant Spore (1,1,2)
3: Jade Owl (1,2,1)

So at the eyeblast step before changing to spore, sometimes mindlayer dies and sometimes lives, regardless, if you switch to the next pet, and use the abilities stated, it's still a win. However, when i run the code, it doesn't work. If mindslayer lives, I still want to switch to the spore and continue with explode. What happens is that it either doesn't change pets, or the spore is not using the ability assigned, and I don't know how to fix it. Maybe this can't be a code because of the rng? Thanks for the help.

You must be logged in to vote on comments

1

You must be logged in to vote on comments

Threewolves

wrote on 08/01/2020

Can the numerical list of pet families be added here? I'm have trouble finding the numerical indicator for critters/mech/dragonkin, etc.
You must be logged in to vote on comments

2

You must be logged in to vote on comments

DragonsAfterDark

wrote on 08/01/2020

Should be the order they come up in on the Rematch bar.

1: Humanoid
2: Dragonkin
3: Flying
4: Undead
5: Critter
6: Magic
7: Elemental
8: Beast
9: Aquatic
10: Mechanical
You must be logged in to vote on comments

2

You must be logged in to vote on comments

Shenk

wrote on 08/01/2020

it's the order in which the families are listed in rematch
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Threewolves

wrote on 08/02/2020

Thx y'all. Just what I was looking for.
You must be logged in to vote on comments

2

You must be logged in to vote on comments

Zurdo

wrote on 07/15/2020

Script to help farm rare pets

quit [enemy(#1).quality!=4 & enemy(#2).quality!=4 & enemy(#3).quality!=4]
quit [enemy(#1).quality!=4 & enemy(#2).quality!=4 & !enemy(#3).exists]
quit [enemy(#1).quality!=4 & !enemy(#2).exists & !enemy(#3).exists]
test(Rare pet found!)

Will quit on press if no rare found, if found, need to quit manually and battle with team of your choice.

Enjoy hunting (edited)
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Amber1019

wrote on 03/12/2020

How do I find aura spell IDs?
For example, I need the aura ID for "Pumped Up" that striders get after using the ability "Pump" (ID:297).
I'm wanting my moths to use their Cocoon Strike (ID: 506) if "Pumped Up" is found to be an active aura on the enemy team. But Rematch doesn't put abilities IDs in auras/buffs.

Would be great if the TD Script addon could record your moves and create a script for you, somehow. :( lol

Edit/Update: I remembered that wowhead has spell IDs in its URL for spells/auras/etc.
For example, Pumped Up is ID 296, as seen in this URL:
https://www.wowhead.com/pet-ability=296/pumped-up

I'd still appreciate if anyone else knows of ways to get IDs of things Rematch doesn't give. (edited)
You must be logged in to vote on comments

2

You must be logged in to vote on comments

Shenk

wrote on 03/12/2020

usually (!) the ID of an aura comes right before the spell that applies it, like in your pump example.
the easiest way to see the ID is by just using in ingame within a script, since td will give you the auto-fill option that also adds the aura's ID by itself
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Amber1019

wrote on 03/14/2020

Yeah, I've begun to notice that trend with the IDs. Thank you! :)
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Pankracy#2378

wrote on 02/23/2020

Great staff ;))). Yet it's still quite a BLACK MAGIC for me ;(((. For instance, I have completely no idea what should I write the script to swap slot 1 pet to slot 2 carry pet and then slot 3 pet. Also it's still REALLY unclear for me HOW to write, what steps should be used as well as what words should be used (there is nothing about it in this article and, well, sorry but I am NOT programmer, math and physics were always totally understandable for me, so all that staff looks like rocket science and I simply DO NOT understad it ;(((. Can you please PM me full guide STEP BY STEP, what command, brackets, comas, numbers and so on should be used when ??? Thanks in advance (edited)
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Lazey

wrote on 02/23/2020

A good start is to try to understand (and learn from) other peoples' scripts, especially on this page where you see the intended usage of abilities, priorities, pet changes.

If that is not for you, it would be best to link/describe a specific situation/fight that you want to do try to write a script for (or want to understand an existing one). And maybe use the Discord that is linked on the front page, formatting/editing is easier there.
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Pankracy#2378

wrote on 02/27/2020

Thank you so much for quick answer ;). Actually I didn’t look at this from such point of view - simply look at someone else’s script to see how it was written command by command. Will try then, thanks once more, KUDOS !!!!
(edited)
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Theaxx

wrote on 01/25/2020

How do you find the ID of a certain pet?
You must be logged in to vote on comments

2

You must be logged in to vote on comments

Lazey

wrote on 01/25/2020

If you're talking about Species-ID and you're using Rematch, you can find that ID for your own pets on the pet cards if you activated Species-IDs and Ability-IDs in pet card options.

Since we're in the tdBPS section I guess you have it installed, so another easy way (especially for enemy pets) is to start the fight and open the script editor and then start typing something like "if [ enem" and then let the AutoFill do it's magic. If you select the names it should add the Species-ID too. (edited)
You must be logged in to vote on comments

0

You must be logged in to vote on comments

Sally wrote on 09/23/2019

I am working on a script vs Eleanor. He has a deadly charge "Death Bleat", that I want to kick.
I need to use kick on the round after he used "Death Bleat", when the ability has 7 turns cooldown. I have not found anything in the API to check for cooldown left.
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Remte

wrote on 09/24/2019

The cooldown doesn't start until the damage is released, so it'd still be 8 turns (but no risk of repeating that because of an interrupt's cooldown).
You must be logged in to vote on comments

1

You must be logged in to vote on comments

DragonsAfterDark

wrote on 09/24/2019

I'm assuming you mean that Death Bleat is a two-round ability, and you need to Kick on the second part before it can charge?

You can go about that in one of two ways:

ability(Kick:307) [enemy.aura

Using this method, you need to wait until Eleanor has done the first round of Death Bleat. Once they do the first round, and you start typing in aura for the script, it should give you a list of all the auras on Eleanor, and one of them should be whatever comes up for their first round of Death Bleat. It would end up looking like:

ability(Kick:307) [enemy.aura(Whatever the Aura's Name is Here).exists]

Or, as Remte pointed out, if the CD doesn't start until the damage is released, you'd need to do something like this:

ability(Kick:307) [enemy.ability(Death Bleat's Code Here).duration=8]

You'll get the specific code for Eleanor's Death Bleat when you start typing in ability. I only have player pet codes copied down, and not enemy pets, so I can't say what the code will look like.
You must be logged in to vote on comments

-6

You must be logged in to vote on comments

JaneDoe wrote on 03/24/2019

Is it possible to use TD Script WITHOUT that terrible REMATCH?
You must be logged in to vote on comments

3

You must be logged in to vote on comments

Lazey

wrote on 04/12/2019

Maybe No, because Rematch is not terrible at all ;-) And Yes, tdBPS should work standalone too, but far more difficult for selecting saved scripts because all is optimized for the combination of these two addons.
You must be logged in to vote on comments

0

You must be logged in to vote on comments

Hodaress wrote on 03/11/2019

During the script creation, where are the scripts saved to?

That is, which file is modified. I've backed up my teams and thought I was also backing up my scripts. However, during the most recent WoW update, my WTF folder was corrupted and I had to restore from an earlier version I had saved to a different hard drive last month. This WTF folder had all of my saved teams and scripts but although the teams restored, the scripts did not. So, I'm look for where the scripts are stored so I can also back that file up also.

Any suggestions?
You must be logged in to vote on comments

2

You must be logged in to vote on comments

Lazey

wrote on 04/12/2019

World of Warcraft_retail_WTFAccountACCOUNTNAMESavedVariablestdBattlePetScript.lua
You must be logged in to vote on comments

0

You must be logged in to vote on comments

Sarah wrote on 02/17/2019

Yeah.... This is far too complicated for my tiny non-tech-savvy brain. For the life of me, I can't get any of my own TD scripts to work :( I have all my steps/guides typed out in the Notes for each team, but I'm having major trouble actually creating a functional/working script.
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Puny

wrote on 12/30/2019

I'm in the same boat, I have no idea how to get anything working. I just wanted to be able to use the scripts from this site already set up but there is no step by step instructions on how to do that. I really need an idiot's guide.
You must be logged in to vote on comments

1

You must be logged in to vote on comments

DragonsAfterDark

wrote on 12/30/2019

How to use the scripts are on a different page: https://www.wow-petguide.com/index.php?m=UsingTDScripts

:)
You must be logged in to vote on comments

1

You must be logged in to vote on comments

Kiwicat#21513

wrote on 12/04/2018

Thank you so much for this guide and thanks to whoever invented TD script and rematch <3
I created my first script today and it was so satisfying when I finally got it to succeed. In the beginning, all the commands made no sense to me, but now its like I learned a new language ^^