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
JDVyska
Beginner


Joined: 18 Oct 2002
Posts: 13
Location: USA

PostPosted: Sat Nov 23, 2002 7:38 am   

CleanUp work with AutoSpell for AckMUD
 
I've been working on a bit of code that would allow a user to have two lists of spells that would be maintained automatically (two tiers because I have some that are cheap and some that are pricy mana-wise). It's not the prettiest hunk of code, so I was wondering if I could pass it through the hands of some of the heavy coders here so I can add it to the Finished Forum in a lean, clean form.


#CLASS {StatusStuff|Spells}
#ALIAS nextCheckAff {#IF %numItems( @Durations)==0 {#var Temp 300} {#var TempString @Durations;#var TempString %min( %replace( @TempString, "|", ","));#IF @TempString==0 { minutes 1} { minutes @TempString}};#IF @Temp<62 { #var Temp 90} {};#var Temp %concat( +, @Temp);affAlarm <@Temp>}
#ALIAS minutes {#MATH Temp %1*62}
#ALIAS spellCheck {#var Temp 0;#IF @MaintainSpells1 {#FORALL @SelfSpells1 {#IF %db( @Affects, %i)=="" {recast %i;#add Temp 3} {}}} {};#IF @MaintainSpells2 {#FORALL @SelfSpells2 {#IF %db( @Affects, %i)=="" {recast %i;#add Temp 3} {}}} {};#var Temp %concat( +, @Temp);#IF @Temp>0 {affAlarm <@Temp>} {}}
#ALIAS recast {cast '%1' Tulath}
#ALIAS affAlarm {#ALARM AffAlarm %1 {aff} {StatusStuff|Spells}}
#ALIAS updateSpellList {#clr Spells;#var tempList1 "";#var tempList2 "";#var tempList3 "";#win Spells SELF SPELLS - Class 1 SELF SPELLS - Class 2;#win Spells +-----------------------------+------------------------------+;#loopdb @Affects {sortSpell %key %val};#IF %numItems( @tempList1)>%numItems( @tempList2) { #math Temp ((%numItems( @tempList1)) / 2)} { #math Temp ((%numItems( @tempList2)) / 2)};#loop @Temp {#var tempCounter %eval( (%i * 2) - 1);#var tempString "";#IF %len( %item( @tempList1 , @tempCounter))>0 {#var tempString %addItem( %item( @tempList1 , @tempCounter), @tempString);#var tempString %addItem( %item( @tempList1, %eval( @tempCounter + 1)), @TempString)} {#var tempString %addItem( " ", @tempString);#var tempString %addItem( " ", @tempString)};#IF %len( %item( @tempList2 , @tempCounter))>0 {#var tempString %addItem( %item( @tempList2 , @tempCounter), @tempString);#var tempString %addItem( %item( @tempList2, %eval( @tempCounter + 1)), @tempString)} {#var tempString %addItem( " ", @tempString);#var tempString %addItem( " ", @tempString)};logSpell @tempString};#win Spells +-----------------------------+------------------------------+;#IF %len( @tempString3)>0 {#win Spells %cr OTHER SPELLS;#win Spells +-----------------------------+------------------------------+;#loop %eval( (%numItems( @tempList3)) / 2) {#var tempCounter %eval( (%i * 2) - 1);#var tempString "";#var tempString %addItem( %item( @tempList3 , @tempCounter), @tempString);#var tempString %addItem( %item( @tempList1, %eval( @tempCounter + 1)), @tempString);logSpell @tempString};#win Spells +-----------------------------+------------------------------+}}
#ALIAS padRight {#var Result "";#until (%len( %1)=%2) {#var Result %concat( " ", @Result)}}
#ALIAS sortSpell {#IF %ismember( %1, @SelfSpells1) {#var tempList1 %addItem( %1, @TempList1);#var tempList1 %addItem( %2, @TempList1)} { #IF %ismember( %1, @SelfSpells2) {#var tempList2 %addItem( %1, @TempList2);#var tempList2 %addItem( %2, @TempList2)} {#var tempList3 %addItem( %1, @TempList3);#var tempList3 %addItem( %2, @TempList3)}}}
#ALIAS logSpell {#var logSpellString1 %format( "&18s", %item( %1, 1));#var logDurationString1 %format( "&8.0n", %item( %1, 2));#IF ((%len( %item( %1, 3))>0) & !(%item( %1, 3)==" ")) {#var logSpellString2 %format( "&18s", %item( %1, 3));#var logDurationString2 %format( "&8.0n", %item( %1, 4))} {#var logSpellString2 %format( "&18s", " ");#var logDurationString2 %format( "&8s", " ")};#win Spells ~|@logSpellString1~| @logDurationString1 ~|@logSpellString2 ~| @logDurationString2 ~|}
#VAR SelfSpells1 {warcry|armor|bless|barrier|bark skin} {warcry|armor|bless|barrier|bark skin}
#VAR SelfSpells2 {know critical|know weakness|detect hidden|detect invis|giant strength} {know critical|know weakness|detect hidden|detect invis|giant strength}
#VAR Affects {warcry40armor24bless12barrier6bark skin6}
#VAR Durations {40|40|24|12|12|6|6}
#VAR MaintainSpells1 {1} {0}
#VAR MaintainSpells2 {0} {0}
#VAR Temp {5}
#VAR logSpellString1 { bark skin} {0}
#VAR logSpellString2 { } {0}
#VAR logDurationString1 { 6} {0}
#VAR logDurationString2 { } {0}
#VAR tempList1 {warcry|40|armor|24|bless|12|barrier|6|bark skin|6}
#VAR tempList2 {}
#VAR tempList3 {}
#VAR tempCounter {9}
#VAR tempString {bark skin|6| | }
#TRIGGER {Spell: ~'(*)~'* for (%n) hours.} {#ADDKEY Affects {%1} {%2};#var Durations %addItem( %2, @Durations)}
#ONINPUT {aff} {#var Affects {};#var Durations {};#clr Spells;#win Spells Processing Current Affects...;#ALARM +5 {nextCheckAff;spellCheck;updateSpellList}}
#TRIGGER {^~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~* You are affected by: ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*$} {#GAG;#GAGON}
#TRIGGER {^~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*$} {#GAGOFF}
#BUTTON 16 {SelfSpells1} {#untrigger AffAlarm;aff} {} {} {} {@MaintainSpells1} {CIRCLEMUD} {Size} {90} {23} {} {} {} {} {} {} {} "" {Explore} {} {}
#BUTTON 17 {SelfSpells2} {#untrigger AffAlarm;aff} {} {} {} {@MaintainSpells2} {CIRCLEMUD} {Size} {90} {23} {} {} {} {} {} {} {} "" {Explore} {} {}
#CLASS 0


The class location will change, obviously not everyone has a "StatusStuff" they'd want this under. A couple aliases in there prolly need to be pulled out as "neveminds" (padRight was one, I think).

I also want to still add somewhere a time that updates to show you the time until the next update. Haven't thought that one out yet, though.

quote:
Note: I am aware of the following limitations inherent to the beast:
  • This sucker will spend all the mana you've got and keep trying (I figure, if you want it to stop sucking mana, hit the damned buttons)
  • Some spells can't be cast while fighting - kill faster, no problem, right?




Let me know what you guys think,
Jeremy :D
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Nov 23, 2002 4:32 pm   
 
My immediate opinion is that you should edit your post to remove the [ code ] and
[ /code ] tags. I'm not going to bother reading something that's 17 screens wide,
and has to be scrolled sideways on every line. I expect many people will share my reaction.

LightBulb
Senior Member
Reply with quote
JDVyska
Beginner


Joined: 18 Oct 2002
Posts: 13
Location: USA

PostPosted: Sat Nov 23, 2002 6:06 pm   
 
OKey-Doke, but it's hard to read this way too...

J
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Nov 24, 2002 2:46 am   
 
Thanks. The remaining problem towards getting a readable width for the post seems
to be the ~*~*~* trigger, this could be shortened by two methods. Your lists all
appear to have enough two word entries to allow word-wrapping at reasonable widths.
Method one: Use the "verb" (verbatim) option and you can eliminate all the ~'s.
#TRIGGER {^*****************************************************************$} {#GAGOFF} {} {verb}
Method two: Limit it to about half the line. That should be enough to differentiate it
from other lines with lots of *'s:
#TRIGGER {^~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*} {#GAGOFF}
Or, combine both methods:
#TRIGGER {^********************************} {#GAGOFF} {} {verb}

Other than that, what questions did you have?

LightBulb
Senior Member
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