|
suprmanmw4 Newbie
Joined: 31 Jul 2007 Posts: 5
|
Posted: Tue Jul 31, 2007 11:53 am
Attempting to convert ZMUD script over to CMUD not successful. |
Perhaps I haven't looked at this closely enough yet, or familiarized myself with the newest changes for CMUD, but every other script I have up and running so far except for this. Likely I am missing large changes in the code change that would allow this to work. Essentially this script keeps track of how long you have left on certain buffs before they run out, and keeps that in a status window. As the buffs tick down they change color from green, to yellow, to red depending on how much time is left. It's a wonderful script and worked beautifully in ZMUD. What am I missing that would allow this to also run in CMUD?
Here is the original ZMUD code.
Quote: |
#CLASS 0
#CLASS {Affects_Script}
#ALIAS Affects {#IF @Affects_Toggle {#VAR Affects_Toggle 0;#ECHO Affects script 'OFF'} {#VAR Affects_Toggle 1;#ECHO Affects script 'ON'}}
#VAR Affects_Toggle {1}
#VAR Affects_List {detect invis|detect hidden|detect good|detect evil|armor|shield|stone skin|bless|frenzy|sanctuary|protect align|haste|water breathing|warcry||pass door|enhanced recovery|giant strength}
#VAR Affects_Times {5|5|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0}
#VAR Protect_Align {}
#VAR Tick_Aff {18}
#VAR CAff1 {@Color_Affect(%1,@Affect_Duration(%2))}
#VAR CAff2 {%if(@Affect_Duration(%2)>0,@Color_Affect(%1,@Affect_Duration(%2))%eval(" @Sep "))}
#VAR Affect_Duration {%if( %eval( %ismember( %1, @Affects_List) & %item( @Affects_Times, %ismember( %1, @Affects_List)) != 0), %eval( %item( @Affects_Times, %ismember( %1, @Affects_List)) - @Tick_Aff), 0)}
#VAR Sep {%ansi( green)|}
#VAR Affects_Window {%cr @CAff1("Sanctuary:",sanctuary)%cr @CAff1("Pro @Protect_Align:",protect align)%cr @CAff1("Bless:",bless)%cr @CAff1("Frenzy:",frenzy)%cr @CAff1("Haste:",haste)%cr @CAff1("Armor:",armor)%cr @CAff1("Shield:",shield)%cr @CAff1("Stone:",stone skin)%cr @CAff1("Det Inv:",detect invis)%cr @CAff1("Det Hid:",detect hidden)%cr @CAff1("Det Good:",detect good)%cr @CAff1("Det Evil:",detect evil)%cr @CAff1("GStrength:",giant strength)%cr @CAff1("ER:",enhanced recovery)%cr @CAff1("Breath:",water breathing)%cr @CAff1("Pass:",pass door)%cr @CAff1("Riot:",riot)}
#VAR Color_Affect {%if( %2 & %2 >= 1, %if( %2 > 6, %ansi( bright, cyan), %if( %2 > 4, %ansi( yellow), %ansi( bright, red)))%1%if( %len( %eval( %2-4)) < 2, %eval( " "))%ansi( white)%eval( %2-4), %ansi( red)%1%ansi( gray)%eval( "--"))}
#TRIGGER {{You are affected by the following spells:|You are not affected by any spells.}$} {#VAR Protect_Align %null;#VAR Affects_Times %concat( "0", %repeat( "|0", %eval( %numitems( @Affects_List)-1)));#VAR Tick_Aff 0;#T+ Affects_Script|Aff}
#TRIGGER {e} {#case sanctuary {@Affects_List}}
#CLASS 0
#CLASS {Affects_Script|Downs}
#TRIGGER {^You no longer see invisible objects.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "detect invis", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^You feel less aware of your surroundings.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "detect hidden", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^The gold in your vision disappears.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "detect good", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^The red in your vision disappears.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "detect evil", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^You feel less armored.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "armor", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^Your force shield shimmers then fades away.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "shield", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^Your skin feels soft again.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "stone skin", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^You feel less righteous.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "bless", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^Your rage ebbs.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "frenzy", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^The white aura around your body fades.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "sanctuary", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^You feel less protected.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "protect align", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^You feel yourself slow down.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "haste", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^You start gasping for air as you can breath normally again!$} {#VAR Affects_Times %replaceitem( "5", %ismember( "water breathing", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^Your fire protection fades away.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "protection fire", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^Your cold protection fades away.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "protection cold", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^You feel solid again.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "pass door", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^You feel the divine vitalization leave your body.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "enhanced recovery", @Affects_List), @Affects_Times);#CW 12}
#TRIGGER {^You feel weaker.$} {#VAR Affects_Times %replaceitem( "5", %ismember( "giant strength", @Affects_List), @Affects_Times);#CW 12}
#CLASS 0
#CLASS {Affects_Script|Aff} {enable}
#TRIGGER {^$} {#T- Affects_Script|Aff}
#TRIGGER {^Spell: ({@Affects_List})[ :] modifies * by * for (%d) cycles} {#VAR Affects_Times %replaceitem( %eval( %2 + 5), %ismember( %param1, @Affects_List), @Affects_Times)}
#TRIGGER {^Spell: protection ({good|neutral|evil})[ :] modifies * by * for (%d) cycles} {#VAR Affects_Times %replaceitem( %eval( %2 + 5), %ismember( protect align, @Affects_List), @Affects_Times);#VAR Protect_Align %1}
#STW @Affects_Window
|
I realize there was a change to the AND OR commands, but the script seems to barely function at all. The @Affects_List Variable seems to be entered into the mud at every tick. Any ideas? |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Jul 31, 2007 5:41 pm |
Did you run the Compatibility Report on this in CMUD? Did it report anything? Without knowing more about what your script is supposed to do, it's hard to help. Nothing obvious jumps out at me (except, like you said, you need to change your & to &&)
|
|
|
|
suprmanmw4 Newbie
Joined: 31 Jul 2007 Posts: 5
|
Posted: Tue Jul 31, 2007 8:58 pm |
I ran the compatibility test both before I made the changes to || and &&, and after, and both times it came up with no errors found. :( Anyways, here is the script running wonderfully in ZMUD to hopefully give you all a better idea of how nice it is, and exactly what it does.
The trigger runs off when you look at what spells are affecting you, and pulls them up into a status window, so if you are unbuffed it looks like so...
and the window will be
Then as you buff up your character with spells, it pulls up the duration of the buffs into the window when you check them the first time like so...
which pulls it in to look like
It then uses the tick timer, which is set to match the natural tick of the mud, to count down the buff durations without constantly having to check the affects...
Not having it work is a real bummer, and I simply do not have the experience anymore to know how to change it. Any help at all would be greatly appreciated, but I understand if no one can see the problem or has the time to help. I'll live, or just go back to ZMUD, haha.
Quick edit: You'll notice the color changes on the Spell Names in the window. It stays Cyan until the spell has only a few ticks left on it, at which time it turns yellow, when it hits 0, the last tick, it turns Red and then goes into the negative timer to remind you it wore off. After going a few ticks into the negative, it goes back to the regular Dark Red. Anyways, thanks again.
Also, I realize it is a far amount of work, but I am certain that more than a few people would benefit from a script like this. :) |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Jul 31, 2007 11:43 pm |
Wow, you sure do like making life difficult for yourself by using a fixed-length stringlist for this. You could use use a data record to keep the data much more easily:
Effects.ProEvil=25
Effects.Armor=25
and then decrement them easily, by name. If you deleted the keys with #delkey after they reach a certain negative value, you could even choose to display only the things that were actually affecting you (which would be made easier with %expanddb).
Really, with that improvement in mind, I'd suggest rewriting the script. You needn't rewrite everything, just the parts that that would change, and then slowly add your functionality back in (like the function to colour the names and durations) until you find something that breaks. It's a lot of work finding tiny bugs in a big script.
That said, you might be best to wait until version 2 of CMUD is released. It's going to include support for real, returning functions and that's probably another feature that your script could really benefit from. |
|
|
|
suprmanmw4 Newbie
Joined: 31 Jul 2007 Posts: 5
|
Posted: Wed Aug 01, 2007 4:30 am |
Unfortunately I am not the original creator of the script. It was made by a friend whom I am no longer in contact with a few years ago. I am fine with simple scripts, but I was hoping for an obvious error on this one that could be quickly fixed to get it back up and working. Since it will obviously take a great amount of work that I cannot do, it looks like I'll either stick with ZMUD, or have to scrap it.
|
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed Aug 01, 2007 11:10 am |
Code: |
#TRIGGER {e} {#case sanctuary {@Affects_List}} |
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Aug 01, 2007 11:33 am |
Ignoring the trigger pattern of doom, is sanctuary even a valid argument for case? I thought it only took numbers :S
|
|
|
|
suprmanmw4 Newbie
Joined: 31 Jul 2007 Posts: 5
|
Posted: Wed Aug 01, 2007 6:01 pm |
Haha, ya, don't ask me. I'm not entirely sure. I'm just going to forget about it, thanks anyways guys.
|
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Thu Aug 02, 2007 4:02 am |
Alright, here's code that should work for you in CMUD. Besides changing '&' to '&&' which Fang pointed out the main problems were that the status windows not getting picked up properly (notice the curly braces around the Affects_Window function) and that CMUD/zMUD represents functions as variables so when you defined them there were evaluated. So variable/functions like CAff1, Caff2 and Affect_Duration were changed so that they correctly called #FUNC instead of #VAR.
I also went ahead with Fang's recommendation and converted this to use a DB variable. As you can see the code is cleaner and smaller and will probably run faster.
I hope this helps
Code: |
#CLASS 0
#CLASS {Affects_Script}
#ALIAS Affects {#IF @Affects_Toggle {#VAR Affects_Toggle 0;#ECHO Affects script 'OFF'} {#VAR Affects_Toggle 1;#ECHO Affects script 'ON'}}
#VAR Affects_Toggle {1}
#VAR Affects_List {detect invis|detect hidden|detect good|detect evil|armor|shield|stone skin|bless|frenzy|sanctuary|protect align|haste|water breathing|warcry|pass door|enhanced recovery|giant strength}
#VAR Tick_Aff {18}
#FUNC CAff1 {@Color_Affect(%1,@Affect_Duration(%2))}
#FUNC CAff2 {%if(@Affect_Duration(%2)>0,@Color_Affect(%1,@Affect_Duration(%2))%eval(" @Sep "))}
#FUNC Affect_Duration {%if(@AffectsDB.%1,%eval(@AffectsDB.%1 - @Tick_Aff),0)}
#VAR Sep {%ansi( green)|}
#FUNC Affects_Window {%null %cr @CAff1("Sanctuary:",sanctuary)%cr @CAff1("Pro "@Protect_Align:,protect align)%cr @CAff1("Bless:",bless)%cr @CAff1("Frenzy:",frenzy)%cr @CAff1("Haste:",haste)%cr @CAff1("Armor:",armor)%cr @CAff1("Shield:",shield)%cr @CAff1("Stone:",stone skin)%cr @CAff1("Det Inv:",detect invis)%cr @CAff1("Det Hid:",detect hidden)%cr @CAff1("Det Good:",detect good)%cr @CAff1("Det Evil:",detect evil)%cr @CAff1("GStrength:",giant strength)%cr @CAff1("ER:",enhanced recovery)%cr @CAff1("Breath:",water breathing)%cr @CAff1("Pass:",pass door)%cr @CAff1("Riot:",riot)}
#FUNC Color_Affect {%if( %2 && %2 >= 1, %if( %2 > 6, %ansi( bright, cyan), %if( %2 > 4, %ansi( yellow), %ansi( bright, red)))%1%if( %len( %eval( %2-4)) < 2, %eval( " "))%ansi( white)%eval( %2-4), %ansi( red)%1%ansi( gray)%eval( "--"))}
#TRIGGER {{You are affected by the following spells:|You are not affected by any spells.}$} {#VAR Protect_Align %null;#VAR Affects_Times %concat( "0", %repeat( "|0", %eval( %numitems( @Affects_List)-1)));#VAR Tick_Aff 0;#T+ Affects_Script|Aff}
#TRIGGER {e} {#case sanctuary {@Affects_List}}
#CLASS 0
#CLASS {Affects_Script|Downs}
#TRIGGER {^You no longer see invisible objects.$} {#ADDKEY AffectsDB "detect invis" 5;#CW 12}
#TRIGGER {^You feel less aware of your surroundings.$} {#ADDKEY AffectsDB "detect hidden" 5;#CW 12}
#TRIGGER {^The gold in your vision disappears.$} {#ADDKEY AffectsDB "detect good" 5;#CW 12}
#TRIGGER {^The red in your vision disappears.$} {#ADDKEY AffectsDB "detect evil" 5;#CW 12}
#TRIGGER {^You feel less armored.$} {#ADDKEY AffectsDB "armor" 5;#CW 12}
#TRIGGER {^Your force shield shimmers then fades away.$} {#ADDKEY AffectsDB "shield" 5;#CW 12}
#TRIGGER {^Your skin feels soft again.$} {#ADDKEY AffectsDB "stone skin" 5;#CW 12}
#TRIGGER {^You feel less righteous.$} {#ADDKEY AffectsDB "bless" 5;#CW 12}
#TRIGGER {^Your rage ebbs.$} {#ADDKEY AffectsDB "frenzy" 5;#CW 12}
#TRIGGER {^The white aura around your body fades.$} {#ADDKEY AffectsDB "sanctuary" 5;#CW 12}
#TRIGGER {^You feel less protected.$} {#ADDKEY AffectsDB "protect align" 5;#CW 12}
#TRIGGER {^You feel yourself slow down.$} {#ADDKEY AffectsDB "haste" 5;#CW 12}
#TRIGGER {^You start gasping for air as you can breath normally again!$} {#ADDKEY AffectsDB "water breathing" 5;#CW 12}
#TRIGGER {^Your fire protection fades away.$} {#ADDKEY AffectsDB "protection fire" 5;#CW 12}
#TRIGGER {^Your cold protection fades away.$} {#ADDKEY AffectsDB "protection cold" 5;#CW 12}
#TRIGGER {^You feel solid again.$} {#ADDKEY AffectsDB "pass door" 5;#CW 12}
#TRIGGER {^You feel the divine vitalization leave your body.$} {#ADDKEY AffectsDB "enhanced recovery" 5;#CW 12}
#TRIGGER {^You feel weaker.$} {#ADDKEY AffectsDB "giant strength" 5;#CW 12}
#CLASS 0
#CLASS {Affects_Script|Aff} {enable}
#TRIGGER {^$} {#T- Affects_Script|Aff}
#TRIGGER {^Spell: ({@Affects_List})[ :] modifies * by * for (%d) cycles} {#ADDKEY AffectsDB %1 (%int(%2) + 5)}
#TRIGGER {^Spell: protection ({good|neutral|evil})[ :] modifies * by * for (%d) cycles} {#ADDKEY AffectsDB "protect align" (%int(%2) + 5);#VAR Protect_Align %1}
#STW {@Affects_Window }
|
|
|
_________________ Asati di tempari! |
|
|
|
suprmanmw4 Newbie
Joined: 31 Jul 2007 Posts: 5
|
Posted: Fri Aug 03, 2007 3:19 am |
Wow, you did some amazing work Tech and I really appreciate. Wasn't expecting this at all. Unfortunately when this was loaded up, the script went crazy and I easily guessed it was that trigger of doom that Fang mentioned.
Quote: |
#TRIGGER {e} {#case sanctuary {@Affects_List}} |
This pretty much forced the @Affects_list to be entered into the mud I connected to every time the mud recognized an e. It wasn't pretty. I deleted the trigger and everything else seems like it is working correctly, but the window isn't updating. I believe the triggers are pulling in the information and storing it in the variables, but the status window itself doesn't update unless I go in and change something in the status window and save it. Then when the window "reloads" so to speak after the save it updates. Any ideas? Maybe that was the intention of that trigger, not positive. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Aug 03, 2007 3:31 am |
The window should be updating itself automatically as the variable changes. I remember something about that being on the buglist, but I don't remember when - it's possible that it's supposedly fixed.
|
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Fri Aug 03, 2007 12:59 pm |
The trigger of doom appears to be an attempt to do some sort of spell-up script that went horribly astray.
Quote: |
#TRIGGER {e} {#case sanctuary {@Affects_List}} |
e in many prompts means that you have equilibrium.
Case takes the following form.
#case Number {command 1} {command 2} {command 3} {command 4}
The Affects_List variable contains the following.
detect invis|detect hidden|detect good|detect evil|armor|shield|stone skin|bless|frenzy|sanctuary|protect align|haste|water breathing|warcry|pass door|enhanced recovery|giant strength
Santuary is not defined above so it is null for our purposes.
So when Cmud attempts to execute the #case command it sees.
#case NULL detect invis|detect hidden|detect good|detect evil|armor|shield|stone skin|bless|frenzy|sanctuary|protect align|haste|water breathing|warcry|pass door|enhanced recovery|giant strength
Which it pretty much pukes back onto the screen.
If you want to see what it probably meant to do enter the following.
#exec {#case 7 %concat("{",%replace(@Affects_List,"|","} {"),"}")}
And the command "stone skin" is entered. If you used an 8 instead of a 7 "bless" would have been entered. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Aug 03, 2007 1:05 pm |
That's a pretty naff way of doing that though :|
#exec %item(@Affects_List,7)
And I really can't judge what on earth someone would trigger on the most common letter in the alphabet for. If it's working fine without it, I guess it's not worth worrying about. |
|
|
|
|
|
|
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
|
|