Page 1 of 1

Fleeing the Kegor Way (CMUD Smart Flee Alias)

Posted: Fri Apr 21, 2023 12:01 am
by Gormal
Save this as an xml file and import through package manager:

Code: Select all

<cmud>
<class name="Flee">
<var name="dirList" type="StringList" sorted="1">
<value>down|east|north|south|up|west</value>
<json>["down","east","north","south","up","west"]</json>
</var>
<alias name="f">
<value>
<![CDATA[ #CLASS Flee #SWITCH (%1 = n) {#VAR fleeDir n} (%1 = e) {#VAR fleeDir e} (%1 = s) {#VAR fleeDir s} (%1 = w) {#VAR fleeDir w} (%1 = u) {#VAR fleeDir u} (%1 = d) {#VAR fleeDir d} {#VAR fleeDir 0} #IF (@fleeDir != 0) { #VAR fleeCommand {%trim(%2 %3 %4 %5 %6 %7 %8 %9 %10)} } { #VAR fleeCommand {%trim(%1 %2 %3 %4 %5 %6 %7 %8 %9 %10)} } #T+ fleeTrig #SEND FLEE #CLASS 0 ]]>
</value>
</alias>
<trigger name="fleeTrig" priority="1" enabled="false">
<pattern>You flee ({@dirList}){ward|}!$</pattern>
<value>
<![CDATA[ #IF (@fleeDir != 0 && @fleeDir != %left(%1, 1)) { #SWITCH (%1 = north) {#SEND s} (%1 = east) {#SEND w} (%1 = south) {#SEND n} (%1 = west) {#SEND e} (%1 = up) {#SEND d} (%1 = down) {#SEND u} #SEND @fleeDir } { #IF (@fleeDir = 0) { #SWITCH (%1 = north) {#SEND s} (%1 = east) {#SEND w} (%1 = south) {#SEND n} (%1 = west) {#SEND e} (%1 = up) {#SEND d} (%1 = down) {#SEND u} #EXEC @fleeCommand } } #T- fleeTrig ]]>
</value>
</trigger>
<var name="fleeCommand" type="String"/>
<var name="fleeDir">n</var>
<alias name="fb">
<value>
<![CDATA[ #CLASS Flee #VAR fleeDir 0 #VAR fleeCommand {%trim(%1 %2 %3 %4 %5 %6 %7 %8 %9 %10)} #T+ fleeTrig #SEND FLEE #CLASS 0 ]]>
</value>
</alias>
</class>
</cmud>