|
kent Beginner
Joined: 03 Apr 2006 Posts: 29
|
Posted: Fri May 12, 2006 11:01 pm
flee, backstab |
hello again i am trying to make and (If.....else) here is how it should go i back stab a creature but i missed so i flee (this part works)
#alias bs {@backstab = %1;backstab %1}
#trigger {You attempt to stab %1 in the back with *, but miss.} {#if (%1 = @backstab) {
#IF (%lastcom2=s) {@lastdir = south} {#if (%lastcom2=n) {@lastdir = north} {#if (%lastcom2=e) {@lastdir = east} {#if (%lastcom2=w) {@lastdir = west} {#if (%lastcom2=ne) {@lastdir = northeast} {#if (%lastcom2=nw) {@lastdir = northwest} {#if (%lastcom2=se) {@lastdir = southeast} {#if (%lastcom2=sw) {@lastdir = southwest}}}}}}}}};
#IF (@lastdir=south) {@lastdir = north} {#if (@lastdir=north) {@lastdir = south} {#if (@lastdir=east) {@lastdir = west} {#if (@lastdir=west) {@lastdir = east} {#if (@lastdir=northeast) {@lastdir = southwest} {#if (@lastdir=northwest) {@lastdir = southeast} {#if (@lastdir=southeast) {@lastdir = northwest} {#if (@lastdir=southwest) {@lastdir = northeast}}}}}}}}};flee @lastdir;{#IF (@lastdir=south) {@lastdir = north} {#if (@lastdir=north) {@lastdir = south} {#if (@lastdir=east) {@lastdir = west} {#if (@lastdir=west) {@lastdir = east} {#if (@lastdir=northeast) {@lastdir = southwest} {#if (@lastdir=northwest) {@lastdir = southeast} {#if (@lastdir=southeast) {@lastdir = northwest} {#if (@lastdir=southwest) {@lastdir = northeast}}}}}}}}};@lastdir;bs @backstab}
This part is where i am lost i tried #Cond in place of the #trigger but not working
#trigger {You stab %1 in the back with *} {#if (%1 = @backstab) {
#IF (%lastcom2=s) {@lastdir = south} {#if (%lastcom2=n) {@lastdir = north} {#if (%lastcom2=e) {@lastdir = east} {#if (%lastcom2=w) {@lastdir = west} {#if (%lastcom2=ne) {@lastdir = northeast} {#if (%lastcom2=nw) {@lastdir = northwest} {#if (%lastcom2=se) {@lastdir = southeast} {#if (%lastcom2=sw) {@lastdir = southwest}}}}}}}}};
#IF (@lastdir=south) {@lastdir = north} {#if (@lastdir=north) {@lastdir = south} {#if (@lastdir=east) {@lastdir = west} {#if (@lastdir=west) {@lastdir = east} {#if (@lastdir=northeast) {@lastdir = southwest} {#if (@lastdir=northwest) {@lastdir = southeast} {#if (@lastdir=southeast) {@lastdir = northwest} {#if (@lastdir=southwest) {@lastdir = northeast}}}}}}}}};flee @lastdir;{#IF (@lastdir=south) {@lastdir = north} {#if (@lastdir=north) {@lastdir = south} {#if (@lastdir=east) {@lastdir = west} {#if (@lastdir=west) {@lastdir = east} {#if (@lastdir=northeast) {@lastdir = southwest} {#if (@lastdir=northwest) {@lastdir = southeast} {#if (@lastdir=southeast) {@lastdir = northwest} {#if (@lastdir=southwest) {@lastdir = northeast}}}}}}}}};@lastdir;bs @backstab} |
|
|
|
Arcane_of_Discworld Wanderer
Joined: 29 Jan 2002 Posts: 99 Location: UK
|
Posted: Sat May 13, 2006 2:38 am |
It would be much easier if you actually mentioned what you wanted the scripts to do and showed actual output from the mud within code tags such as:
Code: |
[code]outout from the mud
more outout from the mud
outout from the mud
outout from the mud[/code] |
As you haven't I have a couple of questions if you will indulge me:
Why are you converting the short directions you send to the mud into long directions (e.g. #IF (%lastcom2=s) {@lastdir = south})?
In the second trigger after a successful backstab do you want to flee the room and then return to backstab again?
I would also like to make a few suggestions as to how to tidy up your existing code:
It surprises me that your first script works because of the way you are trying to set variables. When setting a variable as you do in the bs alias you will get better results leaving out the '@' therefore setting of the variable backstab would become backstab=%1. The same applies throughout your code for the setting of all variables.
To minimise the possibility of others being able to set off your triggers may I suggest when possible that you use the ^ character at the beginning of trigger patterns to lock the pattern to the start of a line. I see that you assign the targetted NPC/Mob the the backstab variable and check it in your code as some measure of prevention however it is still possible for for somone in the same room as you to say 'You attempt to stab [NPCyourattacking] in the back with [anythingatall], but miss.' which will cause your trigger to fire.
I notice that you use %lastcom2() as a method to check the last direction that you moved in which probably works fine most of the time however doesn't allow for times when you may enter a room and do something else such as look at an object or NPC after the movement phase. I would suggest using an #ONINPUT trigger instead set to only fire when a valid direction is input (either from the numberpad, command line or via a script). The %t used in the following example matches any direction as specified within the Pattern Matching portion of the Help>Reference file.
Code: |
#ONINPUT {^(%t)$} {Direction=%1} |
This may be a more appropriate location to also do any conversions from direction format (e.g: short to long) and determine the reverse direction, please see below.
You have used multiple nested #IF commands to convert the short directions into long, may I suggest an alternative method using nested %replace() functions instead. The one caveat with using this method for direction conversion is that the conversion of 'e' to 'east' must be the innermost function otherwise it will replace the 'e' within 'west', e.g:
Code: |
LongDirection=%replace(%replace(%replace(%replace(@ShortDirection, "e", "east"), "w", "west"), "n", "north"), "s", "south") |
The same method can also be used to convert long directions to short if you ever need to keeping in mind that in this conversion the 'e' to 'east' facet must be the outermost function.
I note that you have used another group of nested #IF commands to obtain the reverse direction, this can be more quickly achieved by ose of the %reversedir() function such as:
Code: |
ReverseDir=%reversedir(@Direction) |
I have spent far longer on this than I intended but I hope I have given you some idea on different methods to achieving your goals. |
|
|
|
kent Beginner
Joined: 03 Apr 2006 Posts: 29
|
Posted: Sat May 13, 2006 5:24 pm |
okay here is what i am asking about
when i backstab the creature i want to flee the way i came and then return and do it again, until the moster is more manageable
in the basic we had if...then...else statements which are the conditional variables in the application i am not sure what statements to use i tried what it said in the #trigger <cond> #cond but i guess i am not doing something correctly
#VAR backstab {@backstab}
#TRIGGER {You attempt to stab %1 in the back with *, but miss.} {}
#IF (%1 = @backstab) {#IF (%lastcom2=s) {@lastdir = south} {#IF (%lastcom2=n) {@lastdir = north} {#IF (%lastcom2=e) {@lastdir = east} {#IF (%lastcom2=w) {@lastdir = west} {#IF (%lastcom2=ne) {@lastdir = northeast} {#IF (%lastcom2=nw) {@lastdir = northwest} {#IF (%lastcom2=se) {@lastdir = southeast} {#IF (%lastcom2=sw) {@lastdir = southwest}}}}}}}}};#IF (@lastdir=south) {@lastdir = north} {#IF (@lastdir=north) {@lastdir = south} {#IF (@lastdir=east) {@lastdir = west} {#IF (@lastdir=west) {@lastdir = east} {#IF (@lastdir=northeast) {@lastdir = southwest} {#IF (@lastdir=northwest) {@lastdir = southeast} {#IF (@lastdir=southeast) {@lastdir = northwest} {#IF (@lastdir=southwest) {@lastdir = northeast}}}}}}}}}
#COND {You stab %1 in the back with *.} {#IF (%1 = @backstab) {#IF (%lastcom2=s) {@lastdir = south} {#IF (%lastcom2=n) {@lastdir = north} {#IF (%lastcom2=e) {@lastdir = east} {#IF (%lastcom2=w) {@lastdir = west} {#IF (%lastcom2=ne) {@lastdir = northeast} {#IF (%lastcom2=nw) {@lastdir = northwest} {#IF (%lastcom2=se) {@lastdir = southeast} {#IF (%lastcom2=sw) {@lastdir = southwest}}}}}}}}};#IF (@lastdir=south) {@lastdir = north} {#IF (@lastdir=north) {@lastdir = south} {#IF (@lastdir=east) {@lastdir = west} {#IF (@lastdir=west) {@lastdir = east} {#IF (@lastdir=northeast) {@lastdir = southwest} {#IF (@lastdir=northwest) {@lastdir = southeast} {#IF (@lastdir=southeast) {@lastdir = northwest} {#IF (@lastdir=southwest) {@lastdir = northeast}}}}}}}}}
You stab a giant arachnid in the back with the dagger of death.
A giant arachnid is jabbed on the thorax with your pierce causing giant damage.(D-Sp 19491)
A giant arachnid begins attacking you!
A giant arachnid has some very significant wounds and scratches.
|||||||||||||||||||| 70%
You panic, and attempt to flee.
also if miss I it will flee.
#alias bs {@backstab = %1;backstab %1}
#trigger {You attempt to stab %1 in the back with *, but miss.} {#if (%1 = @backstab) {
#IF (%lastcom2=s) {@lastdir = south} {#if (%lastcom2=n) {@lastdir = north} {#if (%lastcom2=e) {@lastdir = east} {#if (%lastcom2=w) {@lastdir = west} {#if (%lastcom2=ne) {@lastdir = northeast} {#if (%lastcom2=nw) {@lastdir = northwest} {#if (%lastcom2=se) {@lastdir = southeast} {#if (%lastcom2=sw) {@lastdir = southwest}}}}}}}}};
#IF (@lastdir=south) {@lastdir = north} {#if (@lastdir=north) {@lastdir = south} {#if (@lastdir=east) {@lastdir = west} {#if (@lastdir=west) {@lastdir = east} {#if (@lastdir=northeast) {@lastdir = southwest} {#if (@lastdir=northwest) {@lastdir = southeast} {#if (@lastdir=southeast) {@lastdir = northwest} {#if (@lastdir=southwest) {@lastdir = northeast}}}}}}}}};flee @lastdir;{#IF (@lastdir=south) {@lastdir = north} {#if (@lastdir=north) {@lastdir = south} {#if (@lastdir=east) {@lastdir = west} {#if (@lastdir=west) {@lastdir = east} {#if (@lastdir=northeast) {@lastdir = southwest} {#if (@lastdir=northwest) {@lastdir = southeast} {#if (@lastdir=southeast) {@lastdir = northwest} {#if (@lastdir=southwest) {@lastdir = northeast}}}}}}}}};@lastdir;bs @backstab} |
|
|
|
edb6377 Magician
Joined: 29 Nov 2005 Posts: 482
|
Posted: Sun May 14, 2006 2:16 am |
Quick answer to a question since this script came from a few of us.
Quote: |
Why are you converting the short directions you send to the mud into long directions (e.g. #IF (%lastcom2=s) {@lastdir = south})? |
This is done because if i am wearing a seashell helm and i type flee se there was a bug that would say this isnt a valid direction if you typed flee se instead of southeast and because the BUTTONS directions are set short and we turn them into long based on the last input made.
This was a messy fix to a problem in the mud that i believe has been corrected as none of the updated scripts have that in it at all. We have completely recoded the direction tracking so its less intensive.
Additional notes
Quote: |
In the second trigger after a successful backstab do you want to flee the room and then return to backstab again?
|
Yeah on MM you can flee backstab a monster until he reaches 75% health at which time it gives you a message that he is too hurt.
Quote: |
[
It surprises me that your first script works because of the way you are trying to set variables. When setting a variable as you do in the bs alias you will get better results leaving out the '@' therefore setting of the variable backstab would become backstab=%1. The same applies throughout your code for the setting of all variables.
|
doing backstab = %1 tends to recreate variables since many of us keep our variables in the script folder. I.E. {MMSYSTEM|fleebs} as such doing #VAR backstab %1 will update the variable where as backstab=%1 creates a new backstab variable in the root folder each time its called. We do this for easy package addition and removal. Shared variables are in a VARIABLES class folder.
The reasoning for not having ^ always in front of it is more because it seems that on occasion it ends up lining up with the prompt i.e.
Code: |
<1278hp 1556sp 1476st> You stab a shabby-looking citizen in the back with an iron stiletto.
AND
<1278hp 1556sp 1476st>
You stab a shabby-looking citizen in the back with an iron stiletto.
|
The first one wont fire because its not a new line
The second one will. However if you take off the ^ both fire. That was the fix for that problem and realizing that the commands are turned off in ours at this point unless you specifically enable the alias keeps people from abusing it. |
|
|
|
edb6377 Magician
Joined: 29 Nov 2005 Posts: 482
|
Posted: Sun May 14, 2006 3:17 am |
Here is the script that we had rewritten. Kent you should if you can either ask where you originally got the script or the author who wrote it. Updated scripts sometimes exist but havent been posted on sites yet for one reason or another but usually things can be resolved pretty quick. You are using a version of the script that required excess garbage to get around a MUD BUG which is an exception that unless they know about will have a hard time understanding certain scripts. Not that by any means its perfect but its as far updates as i have gone with it
Type wimpy first time you install it so that you have your emergency settings. wimpy will automatically update this any time you run just the wimpy command I SUGGEST ADDING THIS TO THE MUD CONNECTION SCRIPT SO IT UPDATES EVERYTIME YOU LOGON.
#TRIGGER {^Materia Magica is brought to you by Ingenii Interactive Co.} {set refuse-summon on;wimpy} for example
Code: |
#CLASS {MMSystem|fleebs} {enable}
#ALIAS fbs {
#VARIABLE backstab %1
#T+ {MMSystem|fleebs|commands}
#T+ {MMSystem|fleebs|fleechecks}
#CR
backstab %1
}
#VARIABLE lastdir {} {}
#VARIABLE emergencystop {490} {100}
#ONINPUT {^(%t)$} {#VARIABLE lastDir %1} "" {notrig}
#TRIGGER {You pant and gasp, trying to catch your breath.$} {#IF (@emergencystop>%mud.hp) {
#T- {MMsystem|fleebs|commands}
#T- {MMsystem|fleebs|fleechecks}
} {#NOOP}}
#TRIGGER {^You have (%d) hit points. A suggested wimpy setting would be %d~% of that, or ~[%d~].$} {#MATH emergencystop ((%1*25)/100)}
#CLASS 0
#CLASS {MMSystem|fleebs|commands} {disable}
#TRIGGER {You attempt to stab %1 in the back with *, but miss.$} {
flee %reversedir( @lastdir)
@lastdir
fbs @backstab
}
#TRIGGER {You stab %1 in the back with *.$} {
flee %reversedir( @lastdir)
@lastdir
fbs @backstab
}
#TRIGGER {Not while you are in combat.$} {
flee %reversedir( @lastdir)
@lastdir
fbs @backstab
}
#CLASS 0
#CLASS {MMSystem|fleebs|fleechecks} {disable}
#TRIGGER {A %1 is hurt and suspicious - you can't sneak behind {her|him|it}.$} {
#T- {MMsystem|fleebs|commands}
#T- {MMsystem|fleebs|fleechecks}
}
#TRIGGER {You aren't wielding a proper weapon.$} {
#T- {MMsystem|fleebs|commands}
#T- {MMsystem|fleebs|fleechecks}
}
#CLASS 0
|
|
|
|
|
Arcane_of_Discworld Wanderer
Joined: 29 Jan 2002 Posts: 99 Location: UK
|
Posted: Sun May 14, 2006 3:28 am |
Thanks for clearing that up edb6377, it is always much easier to code for Muds you actually play.
|
|
|
|
kent Beginner
Joined: 03 Apr 2006 Posts: 29
|
Posted: Sun May 14, 2006 4:20 pm |
thank you it works beautifully and i can use my macros keys for something else
|
|
|
|
edb6377 Magician
Joined: 29 Nov 2005 Posts: 482
|
Posted: Mon May 15, 2006 7:07 am |
Glad to hear it worked for you.
|
|
_________________ Confucious say "Bugs in Programs need Hammer" |
|
|
|
|
|