Trigger to Automatically wear eq

Posted by Keith on Sun 10 May 2009 08:28 AM — 26 posts, 102,196 views.

#0
I play a MUD that requires you to wear level eq in order to gain certain stats when you level, and i was wondering if there was a way to set a trigger to automatically wear my level eq when i reach a certain amount of exp.
This is what my prompt looks like:

<100% 100% 100% 3(0) 89%% ESWU>

The number with the 2 %% after it is my EXP and i would like to know how i would get it to set off after i hit about 98%%? is there a way to do it?
#1
Its definitely possible.

I would trigger:
<100% 100% 100% 3(0) 89%% ESWU>

And send it to a script that checks to see if the experience is >= 98%. Have a boolean variable LevelEQ. If that variable is also false have the script wear whatever it is. If the variable is true, do nothing.

Also trigger your level message. Whenever you level reset the variable, and wear your normal equipment.

Pretty simple.
#2
but all my other numbers aren't always at 100% when i level they are always at different numbers, thats why i cant seem to get it to work because my hp could be at 80% or my mana could be low to.
USA #3
Use wildcards.
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5089
#4
Im not really familiar with wildcards so i dont know how i would set them up, i read about them but it just seems kind of confusing to me.
#5
You will want to trigger something like this...
^\<(\d+)\% (\d+)\% (\d+)\% (\d+)\((\d+)\) (\d+)\%\% ESWU\> $

\d means its capturing a digit
+ means your going to capture 1 or more of the previous type
\ is the escape character meaning those strange characters shouldn't be read as regular expression symbols, etc...

Then you'll want to script in some language

check to see if you already changed equipment.
if not, check to see if the 6th wildcard is greater than or equal to 98, remove your current equipment. Wear the other equipment. Store whether or not this has been done in a variable.

then you'll want a similar trigger for whatever the leveling line is... to just remove your leveling equipment and put the other equipment back on. and change the variable that showing what set of equipment you have on to its pre 98% state.
Amended on Mon 11 May 2009 04:22 AM by LupusFatalis
#6
Ok, thank you very much, and since the EWSU is the exits and they are not always the same would i just put in [A-Z]? for that?
Canada #7
if this is your prompt:
<100% 100% 100% 3(0) 89%% ESWU>

make it trigger on:
<*% *% *% *(0) *%% ESWU>

and start a script
if %5 <= 98% remove_normal_eq, wear_leveling_eq

(replace: remove_normal_eq and wear_leveling_eq with the commands)

{CARGO}
Canada #8
oh, if the ESUW is exits and is constantly changing then use a single wild card (*), also I'm just curious but what mud do you play?

{CARGO}
#9
I play a MUD called Tempered Steel, its a Circle MUD.
#10
I think i got the trigger down now, but is there a way to only get it to fire once so i dont keep getting spammed when i reach 98%% exp because it just keeps firing once everytime it comes up.
#11
if the exits are always displayed as letters you can do what you mentioned or use ([A-Z]*) or ([A-Z]+) if a room must have at least one exit.

Beyond that...

The trigger conditions will be recognized every time. Which is why I suggested using an if statement in some scripting language. Along with a variable to tell you if the trigger has already fired or not. That is, the trigger still catches the statement and fires, its just that the effects of it firing are different: only if it hasn't already changed your equipment will it send those commands to the mud.

Maybe there is another way, but that is how I would do it.
#12
Im not really sure how to use scripts and variables though since im really new to all of it when i try to do it i just get confused
#13
download activestate python, get me the text that says you leveled, and when I get a few minutes free I'll see if I can't write you a quick plugin to do the trick.
#14
When i level it says this:

You gained some hit points.
All of a sudden, you hear trumpets and before you know it, there is a feast
honoring you for your accomplishments! You learn that you have risen a level!
You are now level 80! Congratulations!

Thats what it says after i reach a level
#15
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, May 13, 2009, 7:30 PM -->
<!-- MuClient version 4.40 -->

<!-- Plugin "AutoLevelingEquipment" generated by Plugin Wizard -->

<muclient>
<plugin
   name="AutoLevelingEquipment"
   id="3cf0a86995a79034ec87bf1b"
   language="Python"
   save_state="y"
   date_written="2009-05-13 19:29:09"
   requires="4.40"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.pys"/>

<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^You are now level (\d+)\! Congratulations\!$"
   regexp="y"
   script="Leveled"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^\&lt;(\d+)\% (\d+)\% (\d+)\% (\d+)\((\d+)\) (\d+)\%\% ([A-Z]+)\&gt;$"
   regexp="y"
   script="ExperienceCheck"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Variables  -->

<variables>
  <variable name="LevelingEq">0</variable>
</variables>

<!--  Script  -->


<script>
<![CDATA[
LevelingEquipment = ['lItem1', 'lItem2', 'lItem3', 'lItem4', 'lItem5']
NormalEquipment = ['nItem1', 'nItem2', 'nItem3', 'nItem4', 'nItem5']

def ExperienceCheck(TriggerName, Trig_line, wildcards):

	xExp = int(wildcards[5])
	
	xEqState = int(world.GetVariable('LevelingEq'))

	if xEqState == 0:
		if xExp >= 98:
			world.SetVariable('LevelingEq', '1')

			for i in range(0, len(NormalEquipment)):
				world.Send('remove ' + str(NormalEquipment[i]))
		
			for i in range(0, len(LevelingEquipment)):
				world.Send('wear ' + str(LevelingEquipment[i]))

def Leveled(TriggerName, Trig_line, wildcards):
	
	world.SetVariable('LevelingEq', '0')

	for i in range(0, len(LevelingEquipment)):
		world.Send('remove ' + str(LevelingEquipment[i]))

	for i in range(0, len(NormalEquipment)):
		world.Send('wear ' + str(NormalEquipment[i]))
]]>
</script>


</muclient>
Amended on Wed 13 May 2009 11:35 PM by LupusFatalis
#16
This should work. You might need to tweak it some depending on where you get the items from and where you put them, etc...

Replace my lists with your respective items.
#17
Is this gonna put the eq on before i level though?
#18
When you hit 98% or anything greater it will check to see if it has already put on the leveling eq for this level. If it has not it will send the mud.

remove nItem1
...
remove nItemN
wear lItem1
...
wear lItemK

replace the text contained in the lists with your items. If this is not suitable, look at the world.Send function when modifying this code, and you can have it send whatever text you want to the game.

When you level it will do the reverse, removing the leveling stuff, and wearing the normal stuff. (Being defined by the lists.)

Copy your level and prompt lines exactly, and use the game>test trigger function to identify to convince yourself it works. If your prompt appears to be identical but has a space after it, this will need some tweaking, etc... (that is common)

If it were me, I'd make sure it works for one level. Or tweak it, and test it on the next level. But, I'm a bit anal, if I didn't get an extra hp for one level, I might just delete my character and recreate.
#19
it doesnt seem to be working, could it be because I dont have the < > on the outside of the trigger for my prompt?
#20
\0AYou are now level 80! Congratulations!
<100% 100% 100% 3(0) 98%% ESWU>
You are now level 80! Congratulations!
<100% 100% 100% 3(0) 89%% ESWU>\0A

Paste that into the testing of triggers. For the first two lines, it should send the world remove ... and wear ...

for the second it should do nothing visible

Your prompt doesn't have <> or do you mean the trigger is just using the lt and gt codes for it?

You can try replacing them with <>, but it works fine for me. The plugin wizard automatically converted it to those it seems. I would test and make sure your prompt is actually sending a new line at the end. Or if it isn't that it doesn't look more like this:
"<100% 100% 100% 3(0) 98%% ESWU> "
which, as I said is pretty common.

But yeah, if the triggers aren't catching, you'll need to do some tweaking... And most likely with the newline/end of line or some whitespace character.

Someone else can probably help you a bit better there. I still don't know what I'm doing where the packet debugger is concerned.
Amended on Thu 14 May 2009 05:49 PM by LupusFatalis
#21
Ok i figured it out i was setting it wrong, what if i have to get the items from a container what else would i have to add?
#22
You would be altering these lines to do what you want.
	for i in range(0, len(LevelingEquipment)):
		world.Send('remove ' + str(LevelingEquipment[i]))

	for i in range(0, len(NormalEquipment)):
		world.Send('wear ' + str(NormalEquipment[i]))


i.e maybe you want to put the old set in a pack and take the new set out to accomplish the exchange.
	for i in range(0, len(LevelingEquipment)):
		world.Send('remove ' + str(LevelingEquipment[i]))
		world.Send('put ' + str(LevelingEquipment[i]) + ' in pack')

	for i in range(0, len(NormalEquipment)):
		world.Send('get ' + str(NormalEquipment[i]) + ' from pack')
		world.Send('wear ' + str(NormalEquipment[i]))
Amended on Thu 14 May 2009 10:17 PM by LupusFatalis
#23
Ok thank you. For some reason the trigger doesnt seem to go off after i reach 98% exp or more for some reason. but it works when i use it in the test
#24
The script uses a variable so it won't fire more than once per level. This way it doesn't remove and wear equipment every time you change by 1%. But if you should skip from 97% to 99% lets say, it should work just fine. That being said, if you earn enough xp to level from 97% to 100% before you get a prompt somewhere in between, the script obviously won't change your eq. Should you stop playing, change eq, and log off at 98+ % the script won't change your eq when you log back on. Etc... If you want, the addition isn't hard to have it do so, and it would probably be a good learning experience to try and figure out.
#25
it doesnt seem to fire when i reach 98% exp, i cant seem to figure it out, it fires after i level but not before.