Feature Use Kol Combat Macros in Custom Combat Scripts

Paragon

Member
Ok... so the easy part is calling the combat macro, just
visit_url("fight.php?action=macro&whichmacro=<MacroNumber>",true);

The slightly more difficult part is getting the macro name->macro number mapping... but...
a visit to account_combatmacros.php has some html wrapped around the important bits of html


Code:
<b>Current Macros: </b>
<select name="macroid">
<option value="{macro#1}">{MacroName1}</option>
<option value="{macro#2}">{MacroName2}</option>
.
.
.
<option value="{macro#N}">{MacroNameN}</option>
</select>

Upon logging in, mafia could parse the macro name/id map and store it in our preferences file..
Then in the custom combat scripts a new command "macro" could be added which would accept either a string or a number, and call the macro.. right?

If too much network traffic is a concern, just have a button/option "Update Combat Macros" that loads the map, and only look up the mapping when that button/option is selected.
 
Last edited:

lostcalpolydude

Developer
Staff member
Saving that anywhere is complicated by the fact that any character can be used in macro names (commas, semicolons, tabs), so line breaks are the only sure way to split them up when recording them. That means it would be a separate file probably, rather than a line in charactername_prefs.txt.
 

Paragon

Member
Hm.. I didn't realize that it was so lenient on naming conventions.
Either way though, here are two regexs that would do the trick of finding the info.

.*?<select name="macroid">(.*?)</select>.* <--- Results in group 1 having just the options html, requires the DOTALL flag for dot to mach line breaks...
Something about (?s)... I think adding that at the begining makes the regex a DOTALL regex... so in theory i belive the correct regex would be
(?s).*?<select name="macroid">(.*?)</select>.*


<option value="(\d*)">(.*?)</option> <--- Results in group 1 having the macro id and group2 having the macro name.
 
Last edited:

HasteBro

Member
Wouldn't this feature be redundant, as you can already write KoL macros in the CCS interface? It's probably easier to just copy and paste the macro in the CCS (fixing the few commands that need fixing) than to patch mafia to parse that.
 

Paragon

Member
Kol Combat macros are saved to your account... so no matter which instance on which computer I run KolMafia from, I know that I have macro X available.
Also, I can add Kol Combat Macros to the Combat Action Bar for manual adventuring.
 

HasteBro

Member
I understand that, but it's still redundant. You could run Mafia from a usb device or cloud storage like dropbox. That way you would always have access to the same data files on any computer.

And as for the adding of Macros to the action bar, relay browser has a button that runs whatever CCS you have set, making adding macros to the bar also redundant.

As far as I know, CCS already runs in a macro-ish way, sending all the commands in a single page hit and returning the results in the same way as macros do.
 

slyz

Developer
It's probably easier to just copy and paste the macro in the CCS
It also means that you have to update your macro in two different places wen you want to tweak it.

Also, CCS macros can't be used as an auto-attack.

EDIT: I'm not against the feature. We could parse account_combatmacros.php on logon (or ask for CDM to add the info to api.php), and track any addition/deletion of macros, so that we wouldn't need to store the macro names anywhere except in the session.

The problem is that we don't have a lot of active devs taking up projects like this one. I'm going to try to mess around with Mafia code this weekend, but I only have free times in 5 minutes bits, and I want to look at other things before this. If anyone else wants to post a patch, we will gladly look at it.
 
Last edited:
Top