Custom Combat Script
Basic CCS
A Custom Combat Script (CCS) is a way of instructing mafia how to handle combat, round by round. For example, a simple CCS would be to tell mafia to pickpocket on round 1, then cast entangling noodles on round 2 and finally on rounds 3+ to use shieldbutt. If it is unable to carry out one of those steps, then that step will be skipped. For instance, if the character failed to get initiative, then pickpocket will be skipped and the character will go straight to entangling noodles. That CCS would look like this:
[ default ]
1: try to steal an item
2: skill entangling noodles
3: skill shieldbutt
If you wanted to do treat different monsters differently, that can be accomodated also. For instance, the following CCS will attempt to cast Transcendent Olfaction upon Black Knights while treating all other monsters differently. If the character currently has "On the Trail" then that line will be skipped.
[ default ]
1: try to steal an item
2: skill entangling noodles
3: skill shieldbutt
[ Black Knight ]
1: try to steal an item
2: skill transcendent olfaction
2: skill entangling noodles
3: skill shieldbutt
Consult Scripts
While this may seem reasonably flexible, sometimes you will want to do something too complicated to express in this format. For instance if you want your character to cast a Rave Combo if the character is a Disco Bandit, you'd have to change your CCS every ascension, but a consult script can automatically figure it out.
Example of a Consult Script
This example will attempt to pickpocket if possible. If not successful, then if the character is a Disco Bandit and he has learned the relevant Rave Combo, he will attempt to steal an item with the correct Rave combo.
// Save this as RaveSteal.ash
void main(int initround, monster foe, string url) {
boolean stolen = false;
while(contains_text(url, "form name=steal")) {
url = steal();
if((contains_text(url, "grab something") || contains_text(url, "You manage to wrest")))
return; // Something has been stolen. Job done!
}
if(my_class() != $class[Disco Bandit]) return;
matcher combo = create_matcher("(.+),(.+),(.+)", get_property("raveCombo5"));
if(combo.find())
for i from 1 to 3 {
if(contains_text(url, "You win the fight")) return;
url = use_skill(combo.group(i).to_skill());
}
}
This consult script can then be integrated into a CCS like this:
[ default ]
1: consult RaveSteal.ash
2: attack
Parts of a Combat Consultation Script
As you can see in the above example, a consultation script is called with three parameters.
- The first parameter is the round of combat that the script is called. Sometimes it is important to keep track of the round. This is particularly important to keep from losing the fight by going over 30 rounds.
- The second parameter is the monster that you are fighting. This is important because it enables you to take different actions for different monsters.
- The third parameter is the text of the page. This is important because it enables you to examine every detail of the fight as it is taking place. It can be analyzed for potential actions, damage that you deal to a monster and all other events.
All possible actions you can take in a round of combat are listed under In-combat_Consulting