Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
hatespyware
Apprentice


Joined: 16 Dec 2002
Posts: 103

PostPosted: Mon Jun 09, 2003 7:54 pm   

Recast trigs
 
I am interested in setting up a spellup system, but am having difficulty planning it and wanted to ask for expert advice.

The ideal setup would cast each of about 10 or so spells all at once and then recast the ones that failed repeatedly until they take. It would maintain information of state on all spells (via. spellup and spelldown messages provided by the mud), so as to ease user burden. It would be fast (casting multiple spells rather than waiting for a response after each cast), and it would never cast a spell that is already active.

The difficulty is that when a spell fails, you get a message like "Your spell failed", which indicates nothing about which spell actually failed. I also cast spells not included in this spellup which may or maynot need to be recast, but also have the same message upon failure. Also, multiple spells wear off at the same time on frequent occasions - this makes recasting difficult. When this happens, all the spelldown messages come in an uninterupted block, followed by a newline.

Please forgive me for making an already flatulant post even longer, but... Here is what I'm currently using. I provide it more for background information than a framework to work from. I do not at all mind scrapping it for something better.
Reply with quote
hatespyware
Apprentice


Joined: 16 Dec 2002
Posts: 103

PostPosted: Mon Jun 09, 2003 8:10 pm   
 
#CLASS {powerup}
this alias should cast all spells not currently up
#ALIAS pu {#FORALL @spells {#if {@{stat%i} = 0} {%i}};;#say %cr"All spells up/cast"}

this alias should tell me which spells are down (easier reading than the inverse provided by the mud)
#ALIAS check {#sayprompt %cr;#FORALL @spells {#if {@{stat%i} = 0} {#say %i is down} {#say %i is up}}}

this alias should synchronize my variables with my current affects, i.e. to be triggered after a dispel magic
#ALIAS pucheck {#t+ pucheck;aff}

these are the spells I would like to wear at all times
#VAR spells {armm|bark|wwm|bwm|de|endm|hastem|pfe|tongues|tower|}

these match the spellup/spelldown messages
#TRIGGER {^Your body and mind return to their normal speed} {#var stathastem 0;hastem}
#TRIGGER {You fear the haters of good once again.$} {#var statpfe 0;pfe}
#TRIGGER {You feel less righteous.$} {#var statblessm 0;blessm}
#TRIGGER {You feel vulnerable to the elements again.$} {#var statendm 0;endm}
#TRIGGER {You lose the courage to walk on water.$} {#var statwwm 0;wwm}
#TRIGGER {You no longer feel as if you can breathe under water.$} {#var statbwm 0;bwm}
#TRIGGER {^Your skin doesn't feel quite so tough anymore} {#var statbark 0;bark}
#TRIGGER {Your ears stop tingling!$} {#var stattongues 0;tongues}
#TRIGGER {The tower of mortal will around you fades.$} {#var stattower 0;tower}
#TRIGGER {You feel less protected.$} {#var statarmm 0;armm}
#TRIGGER {You sense the red in your vision disappear.$} {#var statde 0;de}
#TRIGGER {You feel someone protecting you.$} {#var statarmm 1}
#TRIGGER {Your skin turns into bark!$} {#var statbark 1}
#TRIGGER {You feel righteous.} {#var statblessm 1}
#TRIGGER {You feel as if you can breathe under water!$} {#var statbwm 1}
#TRIGGER {Your eyes tingle.$} {#var statde 1}
#TRIGGER {You feel a shield of energy surround your body.$} {#var statendm 1}
#TRIGGER {You have a righteous feeling!$} {#var statpfe 1}
#TRIGGER {You feel fast!$} {#var stathastem 1}
#TRIGGER {You start glowing.$} {#var stattower 1}
#TRIGGER {You feel very buoyant.$} {#var statwwm 1}


these match against the list of current affects
#TRIGGER {^tower of strength : *Sanc ~]$} {#var stattower 1}
#TRIGGER {^haste*Haste ~]$} {#var stathastem 1}
#TRIGGER {^barkskin *Barkskin ~]$} {#var statbark 1}
#TRIGGER {^bless*NONE]$} {#var statblessm 1}
#TRIGGER {^armor*NONE~]$} {#var statarmm 1}
#TRIGGER {^breathe water*BreatheWater ~]$} {#var statbwm 1}
#TRIGGER {^tongues*Tongues ~]$} {#var stattongues 1}
#TRIGGER {^endure element*EndureElement ~]$} {#var statendm 1}
#TRIGGER {^protection from evil:*ProtEvil ~]$} {#var statpfe 1}
#TRIGGER {^waterwalk*Watwalk ~]$} {#var statwwm 1}
#TRIGGER {^detect evil*DetEvil ~]$} {#var statde 1}
#CLASS 0


this resets all spell states to off, asks the mud to list current effects, and finally casts all affects that are down (the affects listing ends in a blank line)
#CLASS {pucheck}
#TRIGGER {^-----------------$} {#pri {#FORALL @spells {#math @{stat%i} 0}};#TEMP afftrig {^$} {pu;#t- pucheck}}
#CLASS 0


each cast alias looks like this:
#ALIAS blessm {#var lastweave 0;weave 'bless' me}

spells not included in the spellup trigger look like this if they are to be recast on failure,
#ALIAS bless {#var lastweave "'bless' %1";weave @lastweave}

or this if they are not to be recast
#ALIAS i {#var lastweave 0;weave 'icelance' @enemy}

and this should recast on spell failure
#CLASS {autoweave}
#TRIGGER {^Your weave begins to warp and crumbles} {#if {@lastweave != 0} {weave @lastweave};pu}
#CLASS 0
Reply with quote
hatespyware
Apprentice


Joined: 16 Dec 2002
Posts: 103

PostPosted: Mon Jun 09, 2003 8:11 pm   
 
Of course, this setup has several flaws. If multiple spells wear off at once, it is prone to casting the same spell several times. If both spellup and normal casts are queued and the normal cast fails more than once, it may be lost (which is actually OK in most circumstances). It is also wholly inappropriate for mass spellups, since several of the spells fail several times - the loop repeats from the first failure much faster than the remaining spells can be cast.

I realize that this is a complex issue and that there may be no perfect solution, but I know that many of you do some pretty amazing things with zMud and I would very much appreciate any pointers you have to offer. I am, regretfully, not very current w/ zMud and I am fairly ignorant of the new stateful triggers - would they provide an elegant and tasty solution? Or, am I never going to be satisfied due to the lack of meaningful failure messages?

Thanks in advance,
hatespyware
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Jun 10, 2003 2:29 am   
 
I started work on this be a lil while though.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Jun 10, 2003 5:23 am   
 
This script has many of your old triggers in it They are garbage, but I need to go to bed. I was converting them as I went but thought it more important to thouroughly test the script.

#CLASS {SpellUp}
#ALIAS pucheck {#T+ AffCheck;aff}
#ALIAS pu {#LOOPDB @SpellData { #IF (%numitems(%val)=3) {#NOOP Checks to see if record is a spell.;#IF (%item(%val,2)=1) {#NOOP Checks the recast flag for spell record;#IF (%ismember(%item(%val,1),@SpellsActive)=0) {#NOOP Check to see that spell is not active;SpellResult=%key;AddSpell}}}}}
#ALIAS check {#ECHO ---Pending Spells---;#IF (%db(@SpellsPending,"Current")) { #ECHO Currently casting: %replace(%db(@SpellsPending,"Current"),"|"," priority ")};#FORALL @HighestPriority {#ECHO Priority: %i;#ECHO %replace(%expandlist(%db(@SpellsPending,"%i"),%cr),"/"," recast mode: ")}}
#ALIAS AddSpell {SpellAddTemp=%rightback(%concat("000",%item(%db(@SpellData, %word(@SpellResult,1,"_")),3)),3);#ADDITEM HighestPriority @SpellAddTemp;#NOOP Priority list must be maintained as zero-filled number for %sort;#NOOP Expand special targetting code in spell, if it not expanded already.;#IF (%pos("_",@SpellResult)=0) { SpellResult=%concat(@SpellResult,%expand(%word(%item(%db(@SpellData, @SpellResult),1),2,":")),"/",%item(%db(@SpellData,@SpellResult),2))};#IF (%db(@SpellsPending,@SpellAddTemp)) {#NOOP Check for null record so we dont make a null item in the list;#ADDKEY SpellsPending @SpellAddTemp %concat(%db(@SpellsPending,@SpellAddTemp), "|",@SpellResult)} { #ADDKEY SpellsPending @SpellAddTemp @SpellResult};HighestPriority=%sort(@HighestPriority,1)}
#ALIAS CheckSpell {#IF (%db(@SpellsPending,"Current")) {#NOOP Check to see if we are currently casting a spell.;#IF (@SpellResult="*") {#NOOP Check last result for failure status.;SpellResult=%db(@SpellsPending,"Current");#IF (%eval(%item(@SpellResult,2)<%item(@HighestPriority,1))) {SpellResult=%item(@SpellResult,1);#ADDKEY SpellsPending Current {};AddSpell;#NOOP Found that a higher priority spell has been added, shuffle current back in.}}};#IF (%db(@SpellsPending,"Current")="") { #IF (@HighestPriority) {#NOOP Check to make sure a spell is waiting to go to Current;SpellResult=%db(@SpellsPending,%item(@HighestPriority,1));#ADDKEY SpellsPending Current %concat(%word(%pop(SpellResult),1,"/"),"|",%item(@HighestPriority,1));#IF (%numitems(@SpellResult)=0) {#NOOP Last one at this priority, pop it off list and delete pending key.;#DELKEY SpellsPending %pop(HighestPriority)} { #ADDKEY SpellsPending %item(@HighestPriority,1) @SpellResult}}};SpellResult=%item(%db(@SpellsPending,"Current"),1);#IF (@SpellResult) {#NOOP Make sure we are still casting a spell. This was actually done to eliminate a larger amount of redundant code.;weave %word(%item(%db(@SpellData,%word(@SpellResult,1,"_")),1),1,":") %word(@SpellResult,2,"_")}}
#VAR SpellsActive {}
#VAR SpellsPending {Currenthastem|008002blessm/1001pfem/1009blesst_Veroule/0}
#VAR SpellTriggers {Your body and mind return to their normal speed.hastemYou feel fast!-hastemYou fear the haters of good once again.pfemYou feel less righteous.blessmYou feel righteous.-blessmYou have a righteous feeling!-pfemYour weave begins to warp and crumbles*tells you, 'bless'blesstYou have blessed-blesst}
#VAR SpellData {hastem'haste' me|1|8pfem'prot evil' me|1|1blessm'bless' me|1|2blesst'bless' :_%word(%line,1)|0|9}
#VAR HighestPriority {009|002|001}
#VAR SpellAddTemp {009} {}
#VAR SpellResult {blesst_~~Veroule/0} {*}
#TRIGGER {You feel vulnerable to the elements again.$} {#var statendm 0;endm}
#TRIGGER {You lose the courage to walk on water.$} {#var statwwm 0;wwm}
#TRIGGER {You no longer feel as if you can breathe under water.$} {#var statbwm 0;bwm}
#TRIGGER {^Your skin doesn't feel quite so tough anymore} {#var statbark 0;bark}
#TRIGGER {Your ears stop tingling!$} {#var stattongues 0;tongues}
#TRIGGER {The tower of mortal will around you fades.$} {#var stattower 0;tower}
#TRIGGER {You feel less protected.$} {#var statarmm 0;armm}
#TRIGGER {You sense the red in your vision disappear.$} {#var statde 0;de}
#TRIGGER {You feel someone protecting you.$} {#var statarmm 1}
#TRIGGER {Your skin turns into bark!$} {#var statbark 1}
#TRIGGER {You feel as if you can breathe under water!$} {#var statbwm 1}
#TRIGGER {Your eyes tingle.$} {#var statde 1}
#TRIGGER {You feel a shield of energy surround your body.$} {#var statendm 1}
#TRIGGER {You start glowing.$} {#var stattower 1}
#TRIGGER {You feel very buoyant.$} {#var statwwm 1}
#TRIGGER "AutoCast" {({@SpellTriggers})} {SpellResult=%db(@SpellTriggers,"%1");#IF (@SpellResult="*") {#NOOP Failed cast.;CheckSpell} { #IF (%begins(@SpellResult,"-")) {#NOOP Success!;SpellResult=%right(@SpellResult,1);#IF (%item(%db(@SpellData,@SpellResult),2)=1) { #ADDITEM SpellsActive @SpellResult};#ADDKEY SpellsPending Current {};CheckSpell} {#IF (%ismember(@SpellResult,@SpellsActive)) { #DELITEM SpellsActive @SpellResult};AddSpell;#IF (%db(@SpellsPending,"Current")="") {CheckSpell}}}}
#CLASS 0

#CLASS {SpellUp|AffCap}
#TRIGGER {^tower of strength : *Sanc ~]$} {#var stattower 1}
#TRIGGER {^haste*Haste ~]$} {#ADDITEM SpellsActive hastem}
#TRIGGER {^barkskin *Barkskin ~]$} {#var statbark 1}
#TRIGGER {^bless*NONE]$} {#ADDITEM SpellsActive blessm}
#TRIGGER {^armor*NONE~]$} {#var statarmm 1}
#TRIGGER {^breathe water*BreatheWater ~]$} {#var statbwm 1}
#TRIGGER {^tongues*Tongues ~]$} {#var stattongues 1}
#TRIGGER {^endure element*EndureElement ~]$} {#var statendm 1}
#TRIGGER {^protection from evil:*ProtEvil ~]$} {#ADDITEM SpellsActive pfem}
#TRIGGER {^waterwalk*Watwalk ~]$} {#var statwwm 1}
#TRIGGER {^detect evil*DetEvil ~]$} {#var statde 1}
#TRIGGER {^-----------------$} {SpellsActive="";#TEMP afftrig {^$} {pu;#T- AffCap}}
#CLASS 0

Essentially what I did was put all your trigger messages into a record variable (@SpellTriggers). That record indicates success messages with a value of -code, messages requesting a spell be added simply get a value of code, and messages indicating failed cast get a value of *.

Next all codes correlate in @SpellData. The values there are cast command(a few minor tweaks and you could zap wands, drink potions, etc)|recast mode(0 no recast/1 recast...maybe want to add a mode 2 or more, I used to have a script with 5 recast modes)|priority(higher is better, highest priority spell pending is cast first & priority is checked before retrying a failed cast).

On the affect list you will see I modified trigger for the same spells I had adjusted into the data. It should give you the right idea of how transfer everything else.

Hopefully everything imports correctly. I have had problems getting record variables to transfer before so if you need I can always package and email it to ya tommorrow.
Reply with quote
hatespyware
Apprentice


Joined: 16 Dec 2002
Posts: 103

PostPosted: Tue Jun 10, 2003 12:58 pm   
 
That looks really neat, Vijilante, and I will definately give it a try. Thank you very much for helping me.

I actually considered a priority queue at some point, but could not plan one that would successfully meet the criteria of casting multiple spells at once. The mud I play on is very fast-paced and sometimes "spamming" casts is the only way to make sure you get your spell-ups refreshed in the very brief time between battles - espescially when you have a nearly 500ms ping. It also explains the need for the triggers to remember state - the brief moments between battle afford little time to manually check affects.

At any rate, unless the mud I play on adds more descriptive spell failure messages (*pray*), I suppose I'll never really be able to implement a perfect system. Thanks a million for helping me to get one step closer, though!

thanks,
hatespyware
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net