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


Joined: 21 Aug 2007
Posts: 29

PostPosted: Tue Sep 18, 2007 9:19 pm   

Need help with 2 stage triggers
 
I have a trigger that I want to create that needs to fire only when I pick up a piece of dragonscale and look at it, but only when I look at dragonscale. The part of the "look" output that I really need to be triggering on is basically the same for all items, but there is a description high up in the "look" output. The description has a line that looks like this:

This medium fragment of material can be crafted into an item.

So, I want to fire the trigger when it sees the line above, except the word medium can be small, medium or large. Then I want it to fire on the following line in the "look" output.

Magic type : A common relic with 0 points of radiation.

The 2 things I am interested in, on this line is common and relic. Relics are a type of item and can be 1 of these 5:

magical, legendary, mythical, relics and artifacts -- with artifacts being the best and magical being the worst.

Where common is in that line can be one of the following: common, uncommon, rare.

So with all of that said, I want to keep all relics and artifacts (common, uncommon and rare) and I want to keep all items (even magical) if they are uncommon or rare. I figure it would look something like this...

#if ( %2 = artifact ) {} {#if ( %2 = relic ) {} {#if (%1 = common) {drop dragonscale} {}}}

Anyone able to help me put this in a 2-step trigger?

Thanks!
Xantharus
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Sep 18, 2007 9:36 pm   
 
Code:
#VAR article {artifact|relic}
#TRIGGER {(%w) type : A (%w) (%w) with %d of radiation} {#IF (%ismember(@article,%3) & %1="Magic" & %2="common") {drop dragonscale}}


I believe my coding is correct in this matter. I don't have zMUD in front of me, but what it'll do is check to see if it's an artifact or relic, magic, and common. If it meets all three requirements, then it'll drop the item. Otherwise, it'll keep it in the inventory.

Charneus
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Tue Sep 18, 2007 9:39 pm   
 
Sounds like something for within lines state trigger.

I'm not very good with 'em but I'm trying to give my best.

Code:


#trigger "Trig1" {This {medium|small|large} fragment of material can be crafted into an item.$} {look}
#cond {Magic type ~: A (%w) (%w) with (%d) points of radiation.$} {#if ((%ismember(%2,@AlwaysKeep) and (%1="common")or(%ismember(%1,@NotCommon)) {#say Always keeping those!;keep dragonscale}} {
#if ((%ismember(%2,@KeepIfRareOr) and (%ismember(%1,@NotCommon)) {#say Meeting the requirements, keeping those, too!;keep dragonscale {#say Either one or none of the reqs were met, droping!;drop dragonscale}} {within|param=1}
#var NotCommon {uncommon|rare}
#var AlwaysKeep {relics|artifacts}
#var KeepIfRareOr {relics|artifacts|magical|legendary|mythical}



If I understood your idea correctly tho, then State trigger would be completely voluntary in this case, imo anyway. You can easily manage the same idea with 2 seperate ones.
Anyway. I tried to work it out while reading your post at the same time so I hope I got it correctly. Basically there are 3 potions of stuff: 1) stuff in %1 that isn't common 2) stuff in %2 that is either relics or artifacts and matches when isn't common 3) stuff in %2 that is everything else but doesn't match for common.

If I completely misunderstood, please correct me!

Prog
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Tue Sep 18, 2007 9:56 pm   
 
Thanks for the quick response, Charneus, however, I don't think you quite captured the essence of what I am trying to do. I can look at a magical boot on my mud and it'll have that same line: Magic type : A rare relic with 777 points of radiation. Anything that is magical will have that exact same line. What I am looking to do is only fire the trigger when I see this line...

This medium fragment of material can be crafted into an item.

The line above is the first line of output when I look at the item I want to trigger on. The last line of output on those dragonscales is the Magic Type line. So, I want to fire on this: ^This %w fragment of material can be crafted into an item.$

Then I want it to take action on this: Magic type : A common relic with 0 points of radiation.

If I don't trigger on that first line, then the trigger will fire on every item I look at. So the trigger, in my mind, must be two stage, so that it doesn't fire on a pair of boots or a morning star I pick up and look at. Let me show you what slots I am interested in...

Magic type : A (%w) (%w) with 0 points of radiation.
Magic type : A common relic with 0 points of radiation.

There can be two slightly different versions of this line...

Magic type : A (%w) (%w) item with 0 points of radiation.
Magic type : A common magical item with 0 points of radiation.

Either way, I only only interested in keeping the item if %1 = anything other than common or %2 = artifact or relic.

I hope I cleared that up and not confused the matter.
Thanks!
Xantharus
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Tue Sep 18, 2007 10:07 pm   
 
Progonoi,
Thanks for the quick followup. I think you generally have the essence.

%1 can be common, uncommon and rare
%2 can be magical, legendary, mythical, relics or artifacts

Obviously the goal is to get rare artifacts, but I I want to keep all artifacts and all relics (doesn't matter what %1 is) and I want to keep anything that is uncommon and rare (doesn't matter what %2 is). That's it.

I know how to set this part up as a trigger. That's not the issue. What I need help with is creating the trigger to fire on a line that identifies the item, then take action on the magic type. If I only set up a trigger to fire on the magic type, then it will fire on every item that I look at.

Hope that helps!
Xantharus
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Tue Sep 18, 2007 10:21 pm   
 
Alright. Now I think I understand it better than first time.

Do I understand you correctly, tho? You issue the "look" Command on your Mud and will get an Item info? If thats the case. then Yes.
2 states trigger with one being the first's condition within one line after the original would be the best way to go.

This is, however, only when these 2 lines you speak about *really* follow each other without having a line either with some other info or blank between each other. If its the latter, I'd need more info about the exact layout after you have typed "look" to most likely add one more conditional.

If its not the case, then the trigger with one conditional as I wrote in my last post, should do it.

As you now clarified the artifacts etc situation a bit better, there should be a change made for the conditional part, though.

Code:

#trigger "Trig1" {This {medium|small|large} fragment of material can be crafted into an item.$} {look}
#cond {Magic type ~: A (%w) (%w) with (%d) points of radiation.$} {#if ((%ismember(%2,@AlwaysKeep) or (%ismember(%1,@NotCommon)) {keep dragonscale} {#say Its not relic, not artifact. Its also common and not uncommon or rare. Thus, droping!;drop dragonscale}} {within|param=1}
#var NotCommon {uncommon|rare}
#var AlwaysKeep {relics|artifacts}


As you can see, once you clarified, the code became a lot more nicer and understandable. I do hope that I understood this time, though.


Prog
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Tue Sep 18, 2007 10:54 pm   
 
OK... yes, there are lines in between. here is the actual "look" output.

You examine a medium blue dragonscale fragment.
-------------------------------------------------------------------------------
This medium fragment of material can be crafted into an item. If you use
it while holding another medium fragment of the same material in the other
hand, you will join the two fragments together into one large fragment. If
you use it while assisting with the other hand, you will split it into two
small fragments.
-------------------------------------------------------------------------------
Skill type : Improvised (no associated Mastery talent).
Usage : One handed, but may also be thrown.
Size/reach : Adds one encumbrance, and has a melee reach of zero feet.
Material : Blue dragonscale (80% durability).
Techniques : 16 (0 mounted, 0 style-specific and 7 behind the scenes).
-------------------------------------------------------------------------------
Condition : Fifty (out of fifty).
Attack : +0 (+0, +0, +0 or +0 depending on condition).
Defence : +0 (+0, +0, +0 or +0 depending on condition).
Damage : +0 (+0, +0, +0 or +0 depending on condition).
Cooldown : 4, 4, 5 or 5 seconds, depending on wielders encumbrance.
-------------------------------------------------------------------------------
Magic type : A common relic with 0 points of radiation.
-------------------------------------------------------------------------------


From that output, the initial trigger could look at a few different lines to show that it is dragonscale and I will list those as follows:

You examine a medium blue dragonscale fragment. -- or --
This medium fragment of material can be crafted into an item. -- or --
Material : Blue dragonscale (80% durability).

Let me know if this helped.
Xantharus
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Tue Sep 18, 2007 11:05 pm   
 
OK. That looks like quite a bit more complicated than it looked at first glace but I was afraid of that! Cool

I have to go right now but Will work on it tomorrow when I'm back home. Unless, of course, someone solves it meanwhile.

Few ideas that pop in mind though.

Oninput trigger which sends look.

1. cond of that trigger which would be the "medium fragment..." line which would be looplines|param=20

2. cond which would be the "magic type" line with the code we already talked about above.

This idea may or may not work. As I already said in my original post, I haven't used state machine very heavily myself so I may easily be doing things incorrectly.

Prog
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Sep 19, 2007 2:40 am   
 
It seems to me like you're making this much more complex than it needs to be. Prog's example above should work with some very minor alterations (some others to keep it simple):

#trigger {This {small|medium|large} fragment of material can be crafted into an item.} {}
#cond {Magic type ~: A (%w) (%w) with %d points of radiation.$} {#if (%1="common" or not (%2="relic" or %2="artifact")) {drop dragonscale}}

You may find that this benefits from having a different line for the first trigger (that one doesn't seem unique enough, but I don't know your MUD). The "You examine" line seems better.

Also, you might find that the trigger gets stuck on the second state - it doesn't match "uncommon magical item", and it'd make the pattern much more complex to include it. It'd probably much more simple just to change the condition to a Within type with a parameter of about 20. That way, if the second line hasn't matched within 20 lines of the first, the trigger will cancel and move back to the first pattern.

If that doesn't appeal, you could replace the second %w with something like {magical item|legendary item|artifact|relic} - I'm sure you get the idea.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Wed Sep 19, 2007 2:59 pm   
 
Thanks Fang... 1 question though... If I change the 2nd %2 with {magical item|legendary item|artifact|relic}, then does this part still work? (%2="relic" or %2="artifact"))

Thanks!
Xantharus
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed Sep 19, 2007 3:22 pm   
 
Actually, since you would be using (%w) for %2, it won't match magical item or legendary item. %w matches for one word. If you're wanting it to match magical item or legendary item as well, then change the second (%w) to (*). However, that would create a change in your trigger.

#var itemtypes {magical item|legendary item|relic|artifact}
#TRIGGER {This {small|medium|large} fragment of material can be crafted into an item.} {}
#COND {Magic type ~: A (%w) (*) with %d points of radiation.$} {#IF (%1="common" or !%ismember(%2, @itemtypes)) {drop dragonscale}}

Or you could skip the #VAR bit and just go with

#TRIGGER {This {small|medium|large} fragment of material can be crafted into an item.} {}
#COND {Magic type ~: A (%w) (*) with %d points of radiation.$} {#IF (%1="common" or not(%2="relic" or %2="artifact" or %2="magical item" or %2="legendary item")) {drop dragonscale}}

I suppose it's all preference, though. And I'm sure if I'm mistaken, someone will correct me on it. :)

By the way, I realized that I had made a slight mistake my first time by the time I got home (and away from a computer). Glad it was able to be sorted out, though. :)

Charneus
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Sep 19, 2007 9:11 pm   
 
Changing it to {legendary item|...etc...} will work as long as you surround it with brackets as well, ({whatever|something}). Using (*) as in Charneus' suggestion works too, but it's less specific. You could also use ([A-Za-z ]).

You probably don't want to add the magical and legendary items to the #if statement as charneus has, because that'll change the logic of the script. The idea with adding the legendary and magical items to the trigger is just to avoid using the within trigger type.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Fri Sep 21, 2007 6:59 pm   
 
So here is what I ended up with? Any tweaks? I decided I only wanted to keep uncommon and rare items and anything of type artifact.

#TRIGGER {This {small|medium|large} (%w) of material can be crafted into an item.} {#var dtype %1} "Crisis_Bot"
#COND {Magic type ~: {A|An} (%w) ({magical item|legendary item|mythical item|relic|artifact}) with 0 points of radiation.$} {#IF ( %1 = "Common" and %2 != "Artifact" ) {drop @dtype}}
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Sep 21, 2007 7:10 pm   
 
At first glance it looks perfect!

However, I'm not sure if #cond will go without any state definition at all. As I've said I'm not very familar with #cond etc usage myself but.

Perhaps add within|param=20 to the Cond to make sure that after the original/main trigger line is catched, it will search 20 upcoming lines for the Cond line.

Just an idea.


Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Sep 21, 2007 7:15 pm   
 
#cond without any options works just like a normal trigger. In fact, single-state triggers can have all the same options as trigger states, though most of them wouldn't be much use.

Adding a within will make sure it'll fail gracefully - if the second line isn't received within 20 lines of the first, it'll abort and move back to waiting for the first pattern. You might see that as a good thing or a bad thing, but if your trigger's set up properly, it shouldn't be needed anyway.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Sep 21, 2007 7:24 pm   
 
I stand corrected :)


Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Fri Sep 21, 2007 7:28 pm   
 
Thanks for all of the feedback. I think I will add a within statement just to be safe. Do you see any reason why it wouldn't drop an uncommon relic? I don't see anything in the code that would cause it to keep that type.
Thanks!
Xantharus
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Sep 21, 2007 10:10 pm   
 
xantharus wrote:

#COND {Magic type ~: {A|An} (%w) ({magical item|legendary item|mythical item|relic|artifact}) with 0 points of radiation.$} {#IF ( %1 = "Common" and %2 != "Artifact" ) {drop @dtype}}


Try changing the #if part to

Code:


#if ((%1="Common") and (%2!="Artifact")) {drop @dtype}



This says that if its either common or not artifact, it will be dropped, otherwise it will be kept. Looks to me, though, that you aren't giving the code the possibility to drop "uncommon" because its nowhere set in the code. Perhaps add

or "Uncommon" to the same part where Common is now.


Prog
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Sep 21, 2007 10:52 pm   
 
You shouldn't need to change the actual expression - prog is right, the logic is wrong. Your script only drops items that are both common and not artifacts. Since an uncommon relic isn't common, it's not dropped.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
xantharus
Beginner


Joined: 21 Aug 2007
Posts: 29

PostPosted: Fri Sep 21, 2007 11:37 pm   
 
ugh... that was my mistake. It wasn't dropping a Common Relic. I am sorry. I've got it now. I made the change suggested by Prog

#if ((%1="Common") and (%2!="Artifact")) {drop @dtype}

That took care of it.
Thanks!
Xantharus
Reply with quote
daemoan
Beginner


Joined: 04 Feb 2008
Posts: 23

PostPosted: Mon Feb 04, 2008 8:13 pm   
 
how would you write a multi trigger variable system to disable a drop command until the check was finshed

Example of my trigger right now and what it does:

#if ((%1 >= 25) AND (%1 <= 35)) {
put @item bag
c id rare
} {
drop @item
c id rare
}

Result:

Your eyes glow bright yellow for a moment.
Object 'ringmail sleeves rare Wraith Arms armor' is type armor, extra flags none.
Weight is 10, value is 0, level is 20.
Armor class is 77.
This item is inset with a powerful jewel.
Affects strength by 35.
put bag
c id rare
Affects intelligence by 5.
drop
c id rare
Affects wisdom by 5.
drop
c id rare
Affects dexterity by 5.
drop
c id rare
Affects constitution by 5.
drop
c id rare
Affects agility by 15.
drop
c id rare
This item has 100 points of magical resistance.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Feb 04, 2008 10:23 pm   
 
It'd be easier to compile a list of all the data like

#trig {Affects (%w) by (%d)} {#addkey Item %1 %2}
#trig {prompt or something} {look at all the values and see if any of them are too low}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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