Circle derivatives such as Nukefire provide a lot of information in the results of the ‘score’ command. Nukefire adds ‘afx’ which will be discussed separately.
In order to build a heal bot, it’s important to know the max and current hitpoints of the character. This excercise handles the max stats part and demonstrates how other information can be retrieved at the same time for use by other scripts.
The first line of a successful response to the score command reports the name of the character. A large number of data lines follow. We will pick out only the data lines we’re interested in and detect the end of the command either via the last data line (movement points) or a timeout in the case of failure. As for other configuration commands, recognizing individual possible failure messages isn’t as critical because this check should only be run when there’s no pressure.
The patterns for the first and last lines of a success are:
^Name[:] (a-zA-Z)+
^[[][| ]*\] - move[ ]+([0-9]+)[/]([0-9]+)
We’re also interested in the hitpoints, mana, and cash on hand:
^[[][| ]*\] - hit[ ]+([0-9]+)[/]([0-9]+)
^[[][| ]*\] - mana[ ]+([0-9]+)[/]([0-9]+)
^[[ ]+Con[:][ ]+[0-9]+[ ]+\] [[] Kills[:][ ]+[0-9]+ \] \[ Credits[:][ ]+[$][ ]+([0-9]+) \]
We’ll only be storing the maximum values (the second in each pattern) because the current values are constantly updated in the prompt.
The result for CMUD and Nukefire is very similar to that we arrived at for the practice command:
#ALIAS {configscore} {#T+ configscore;#VAR configscoreresult 0;#ALARM {+5} {endconfigscore};score}
#TRIGGER {^Name[:] (a-zA-Z)+} {#VAR configscoreresult 1;#VAR charname %1} "configscore" "regex"
#TRIGGER {^[[][| ]*\] - move[ ]+([0-9]+)[/]([0-9]+)} {#VAR configmaxmove %1;#VAR configscoreresult 1;endconfigscore} "configscore" "regex"
#TRIGGER {^[[][| ]*\] - hit[ ]+([0-9]+)[/]([0-9]+)} {#VAR configmaxhit %1} "configscore" "regex"
#TRIGGER {^[[][| ]*\] - mana[ ]+([0-9]+)[/]([0-9]+)} {#VAR configmaxmana %1} "configscore" "regex"
#TRIGGER {[ Credits[:][ ]+[$][ ]+([0-9]+) \]} {#VAR configcash %1} "configscore" "regex"
#ALIAS {endconfigscore} {#IF (@configscoreresult == 0) {#PRINT "CONFIG SCORE FAILED"};#T- configscore;#VAR configscoreresult 0} "configscore"
#T- configscore
Upon running the alias configscore, this script will populate variables named configmaxhit, configmaxmana, configmaxmove, and configcash if it succeeds. A warning is printed on the screen if it fails.