|
DragonMudder Newbie
Joined: 14 Oct 2003 Posts: 2
|
Posted: Tue Oct 14, 2003 11:06 pm
Complicated IF statements? |
Hello, I am new to scripting and was wondering how I would create the following scenario:
My status bar line displays the current enemy I am fighting, or "none" for no opponent/combat.
First, I need to capture multiple words to a single variable (I think.) For example, if I am fighting "a simple student" and want that target to be one of the "Allowedenemy", how would I go about doing this? The idea would be to have a list of allowed fighting enemies, and then flee when / if I end up fighting something that I don't want to be fighting. I'm not even sure how to start this up or if it is even possible.
Next, I'm looking to create an #IF statement based on my current HPVar. Something like this : #IF HPVar < 200 AND HPVar > 125, {cast heal}. I would then have IF statements such as IF HPVar < 124 {flee; cast recall} Considering that my HPVar only updates every time I hit enter and recieve a new status line, how would I prevent ZMUD from spamming the server and casting heal or executing the command only once?
Finally, I was looking for a command to get items from the corpses of my slain foes if the items are magical. So let's say there is a
(Magic) a silver tunic
in the corpse, and if the item is magic I want to get it. Since the item has multiple words and doesn't respond to keyword "a", how would I go about autolooting the "a silver tunic" without typing the entire "get a silver tunic"? My mud's code would only understand "get silver" or "get tunic". Perhaps I would set it as a variable (Magic) (%w1) (%w2) (%w3) (%w4) ? and then "get w2" ?
I apologize if I'm not coming across very clear... I'm very new at coding and did some high school pascal programming classes, but that is the limit of my experience with it. Please let me know if I'm off base or wrong with any of my statements, or what I should do to set this up. Thanks in advance! |
|
|
|
Brujah Wanderer
Joined: 13 Nov 2002 Posts: 88 Location: USA
|
Posted: Wed Oct 15, 2003 12:20 am |
anything i would suggest for the first two would be put to shame by the scripting by the people likely to respond to this post.
quote: Finally, I was looking for a command to get items from the corpses of my slain foes if the items are magical. So let's say there is a
(Magic) a silver tunic
cut/paste an example of this so we know what strings to use. is every item you plan on getting following the same basic syntax (a/the/an/etc, adjective *Keyword*, noun *keyword*?) |
|
|
|
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Wed Oct 15, 2003 12:33 am |
#VAR ALLOWEDENEMY name1|name2|name3
#VAR target %null
#trigger {something to let you know you are fighting X mob} {#if (!%ismember(@target, @ALLOWEDENEMY)) {flee;cast recall}}
This would require making a stringlist, and maybe replacing @target with whatever variable you use to store your current target.
I don't know for sure how your MUD names things, so here goes nothing:
#TRIGGER {~(Magic~) {a|an} (%w) *} {get %1}
As for creating a prompt trigger for heals.. I'll let the Guru's figure something out.. something along the lines of #send to force a newline with prompt maybe. |
|
|
|
DMUS Beginner
Joined: 01 Sep 2003 Posts: 19 Location: USA
|
Posted: Wed Oct 15, 2003 1:36 am |
If you're mud consistently shows the format
(Magic) a silver tunic
and this always ends with a keyword, then I think you should be able to use
#TR {~(Magic~) * (%w)$} {get %1} |
|
|
|
DMUS Beginner
Joined: 01 Sep 2003 Posts: 19 Location: USA
|
Posted: Wed Oct 15, 2003 4:20 am |
Here's a thought for your autoheal:
#CLASS autoheal
#VAR canflee 1
#VAR canrecall 1
#VAR canheal 1
#TR {HP~: (%d)} {#IF (%1 > 123) {canflee=1;canrecall=1};#IF (%1 < 124 and @canflee=1) {flee;canflee=0} {#IF (%1 < 200 and @canheal=1) {cast heal;canheal=0}}} Have it trigger on prompt
#TR {you may cast heal again} {canheal=1}
#TR {you failed to flee} {flee}
#TR {you successfully fled} {#IF (@myrecall=1) {cast recall;myrecall=0}}
#CLASS 0
(replace blue italic phrases with actual mud output)
Explanation:
If HP are < 124, you will flee and keep fleeing until successful. Then you will cast recall. Now, I'm assuming your HP will still be < 123, so you don't want it to spam flee/cast recall. That's where the canflee/canrecall VARs come in. They prevent the spamming. Once HP gets > 123, the VARs reset to allow you to flee/cast recall again.
Same for canheal. If HP are < 200, you will cast heal if available and the VAR will goto 0 to prevent spamming.
Now, if your mud doesn't haven't limits on casting, then you can remove the recall & heal VARs. The IFs should be sufficient to prevent spamming. You'll still need the flee VAR, though.
At least that's what I was going for
This is probably rather elementary and archaic.
-Anyone want to proofread this and/or provide a better script? |
|
|
|
DragonMudder Newbie
Joined: 14 Oct 2003 Posts: 2
|
Posted: Wed Oct 15, 2003 2:45 pm |
I was playing around with DMUS' heal script and it works pretty good, thank you for taking the time to do it. My only problem with it is that my status line is the last line the mud sends to me, and often the trigger doesn't kick in until after the status line goes up and becomes old text. Hmm, not sure if I explained that correctly. What I mean is I'll have my status line as
<115hp 152ma 269mv(20991) s: ok 17gp ft: none >
and the MUD will be prompting me for a command at the end of it, so ZMud doesn't recognize the status line yet until it is fully sent. Would there be any way to get around this? |
|
|
|
DMUS Beginner
Joined: 01 Sep 2003 Posts: 19 Location: USA
|
Posted: Wed Oct 15, 2003 11:17 pm |
Make sure that trigger has Prompt selected via the Options tab.
|
|
|
|
|
|