Autopractice Skills Spells

From RoDpedia
Revision as of 22:57, 19 April 2018 by Cerf (talk | contribs) (Added auto practice triggers from Zist's archive page.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Getting a character to autopractice skills and/or spells is relatively easy. It only requires one trigger and one alias. The trigger functions to determine when to call the alias, and the alias parses a list of items requiring practice and sends one to the mud. Of course, you have to customize the alias with the skills and/or spells you want to practice. Also note that this particular example is designed to cause a character to autopractice skills and/or spells when fighting. If you simply wish to automate practicing non-fighting skills then add the alias "autoprac" to your ticktimer alias (see the ticktimer section for more details) to cause the autoprac alias to fire every time your ticktimer expires.

Here is the trigger of the autopractice trigger/alias set:

#TRIGGER {^Your} {autoprac} {autop}

This trigger will fire off of the pattern of "^Your", when it fires it calls the autoprac alias, and it is associated with the class name of "autop". So why trigger off of any line that begins with "Your"? Well, when you are fighting (at least on Realms of Despair), whenever you take a swing at a mob the line you see starts with "Your"... For example : "Your kick misses the carrion crawler" or "Your blast brushes Brunhilde the Valkyrie". In this way, fighting styles can be adepted at the quickest speed possible, since styles only go up when you switch between them alot and do damamge to a mob inbetween switching. Casting spells in autopractice when fighting is not generally recommended, because you run out of mana too fast at low levels. However, I have included one spell in the example of the autoprac alias just in case you wanted to use it for that, or wanted to put it in your ticktimer and turn off the trigger to autopractice non-fighting skills and spells.

Here is the alias "autoprac":

#ALIAS autoprac {#var praclist {"kick style-aggressive style-standard cast-'black-hand'"};#var praclistlen %numwords(@praclist);
#if (@pracnum > @praclistlen) {#var pracnum 1};#if (@pracnum < 1) {#var pracnum 1};#var pracitem %word(@biglist,@pracnum);
#var pracitem %replace(@pracitem,"-"," ");@pracitem;#math pracnum @pracnum+1} {autop}

This alias consists of 8 lines of commands. Here they are, one by one:

  • LINE #1 - #var praclist {"kick style-aggressive style-standard cast-'black-hand'"}

--- This sets up the variable @praclist with a list of things to practice. In this example, the first time the alias is called it will enter the "kick" command. The second time will get the "style aggressive" command. The third will get the "style standard" command. The fourth will get the "cast 'black hand'" command. Notice how the commands have dashes in them, but are separated by spaces? This is the format you must use if you want to add more commands or replace the ones here. Any mud command can be placed in this list, provided it has a space before it and has dashes in it instead of the usual spaces. The reason for this will be evident in LINE #2, LINE #5, and LINE #6.

  • LINE #2 - #var praclistlen %numwords(@praclist)

--- This line looks at how many "space delimited words" are in @praclist and sets the variable @praclistlen to the number of "words" it found. Since there are spaces between the commands set in LINE #1, the @praclistlen would be set to the number "4" for the above example. Without spaces between them, the %numwords function would fail to count the correct number of words.

  • LINE #3 - #if (@pracnum > @praclistlen) {#var pracnum 1}

--- This line checks the value of @pracnum against the value of @praclistlen, and if @pracnum larger than @praclistlen then @pracnum is set to the value of "1". The number in @pracnum will be used to select which command is pulled from the list and sent to the MUD. If the @pracnum number is higher than the number of available commands, then it is reset to 1 so that there aren't any errors, and to start the practice cycle over again with the first command.

  • LINE #4 - #if (@pracnum < 1) {#var pracnum 1}

--- This does a simple check to see if @pracnum is smaller than the value "1". If it is, then it is out of range and is set to 1 to avoid any errors. Most often, this is used when the alias is executed for the first time, and keeps it from crashing zmud with invalid values.

  • LINE #5 - #var pracitem %word(@praclist,@pracnum)

--- This line sets the variable @pracitem to a word from @praclist, indexed by @pracnum. So if @pracnum has a value of 1, this line would set @pracitem to contain "kick", the first word in the list. If @pracnum has a value of 2, this line would set @pracitem to contain "style-aggressive", the second word in the list. It simply pulls the word from the list, indexed by the number in @pracnum, and puts that word in @pracitem. For the %word function to work as coded, the "words" in @praclist would have to be separated by spaces. This is another reason that the commands have dashes in them instead of spaces.

  • LINE #6 - #var pracitem %replace(@pracitem,"-"," ")

--- This line takes the command in @pracitem and changes every dash to a space. This "fixes" the command so that it can be sent to the mud without dashes in it. The dashes were needed to keep the commands separate in the list, and now that the command has been isolated, it's dashes are replaced with spaces. This would take the command "cast-'black-hand'" an change it to "cast 'black hand'", as it should be before sending to the mud. This may seem like an extra step, but it actually makes the alias easier to customize and less confusing.

  • LINE #7 - @pracitem

--- This command is just a variable name, on a line by itself. When zMud sees this, it expands (or "replaces") this line with the contents of @pracitem and sends it to the mud. In other words, this takes the command pulled out of the list and sends it to the mud. If the command was "kick" then this line would send "kick" to the mud just as though you had typed kick and hit enter on your command line.

  • LINE #8 - #math pracnum @pracnum+1

--- This line takes the number in @pracnum, adds 1 to it, and saves it back to @pracnum. In other words, it increments @pracnum by 1. If @pracnum had "1" in it, then it has "2" in it when this line is done. In this way, this autoprac alias "cycles through" all of the words in the list, one by one, before it starts over again.