|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Thu Mar 26, 2009 5:51 am
Not sure how to do this. Need help with complicated patterns. |
I've been looking at different Muds lately.
In one of them there are various attacks done that all give different afflictions. The problem is it is all on one line like the following.
Quote: |
With a focused look, Fred strikes at you with a curved executioner’s greataxe. Your left leg is elegantly struck and swept out from under you, knocking you to the ground. |
Both sentences change continually. The first half is different attacks and the second one various afflictions or damages.
Right now I have all the attacks in a list and all the afflictions as separate triggers. However, in testing it is very slow that way. Well not really slow but slow enough to notice.
Like the attacks are in a trigger like this.
Then I have a trigger for each type of affliction, but the problem is I can't anchor that second one so I put a space at the beginning. It's still slow though.
What would be a better way to do this? It would be simple if the second half was on the next line. I'm not sure how to do it. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 26, 2009 7:34 am |
Can't you just use a single trigger, with a list of attacks and a list of afflictions?
^(list|of|attacks). (list|of|afflictions).$ |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Thu Mar 26, 2009 9:59 am |
Probably you know this, but it is faster to anchor at the end of a sentence (too). That is interesting I think, like, how many more sentences you would have to check beginning with the word with, then ending with the word ground? Anyway Fang Xianfu did that.
Maybe in this case, ground is more common, I don't know. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Thu Mar 26, 2009 3:54 pm |
Fang Xianfu wrote: |
Can't you just use a single trigger, with a list of attacks and a list of afflictions?
[tt]^(list|of|attacks). (list|of|afflictions).$ |
Well I thought about that. Would that be even slower having to run through a huge script to test for match on the second sentence to determine which affliction? What is the [tt]?
Quote: |
Probably you know this, but it is faster to anchor at the end of a sentence (too). That is interesting I think, like, how many more sentences you would have to check beginning with the word with, then ending with the word ground? Anyway Fang Xianfu did that.
Maybe in this case, ground is more common, I don't know. |
I know that. My example trigger was a list of all the actual attacks which are the first sentence so I can't anchor the end because it isn't the end of the actual line.
The whole line is ^Someone performs some attack. You are afflicted with some affliction.$
As it is now there are 50 different affliction lines (second sentence), which are all different afflictions not the same affliction, that go with the first sentences which are like a dozen or so various attacks. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 26, 2009 4:05 pm |
The [tt] was me forgetting to close the tag :P It's fixed now. Still pondering solutions to this, it's a knotty problem.
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Thu Mar 26, 2009 4:07 pm |
With a focused look, Fred strikes at you with a curved executioner’s greataxe. Your left leg is elegantly struck and swept out from under you, knocking you to the ground.
could instead end up as...
With a focused look, Fred strikes at you with a curved executioner’s greataxe. Your right leg is struck with an awesome blow and pulverized into a bloody stump.
or as...
Swinging a heavy longsword in an underhand arc, Bob strikes at you. Bob slashes your right leg, striking a major artery that splurts blood in all directions.
or as...
Swinging a heavy longsword in an underhand arc, Bob strikes at you. You are slashed in the belly for a mere scratch.
Each attack does something different but there are only so many attacks but a lot of different afflictions. Otherwise I would have to make a trigger for every single type of attack and affliction and that would be a few hundred just for this skill set. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Thu Mar 26, 2009 8:04 pm |
Perhaps it would help if we knew what you wanted to do with this information. Do you actually need to know that Bob swung a heavy longsword in an underhand arc? What do you want to do with the different afflictions? From what you have given so far, I don't see a need to know the type of attack, and I would focus on simply triggering on the afflictions, assuming I actually wanted to do or record something dependent on the type of affliction. What is it you actually want to do?
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Fri Mar 27, 2009 3:25 am |
Well obviously I do. I also don't want to create 100 triggers that aren't anchored. Why else would I worry about it. I'm just wondering if there is a better way to do it than what I am currently doing, which is having all attacks in a list and making a trigger for that and then all afflictions in separate triggers. So every attack I have two triggers firing instead of one.
Besides setting variable values based upon the affliction given, I also color all attacks and sub the afflictions part of the line so I can easily see what is going on for clarity. The problem with doing "^(?:@attacks)\. (@afflictions)\.$" is I would have a huge switch statement trying to match over 50 lines of text so basically testing for a match twice, once when trigger fired then again to assign variable in script. I'm just asking what you all think would be faster because my current method also seems to be slow. I apologize if the answer to my question should be obvious. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Mar 27, 2009 9:37 am |
Okay, I think this is a pretty simple solution. Here's a test case demonstrating what I'm on about:
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<class name="Testing" copy="yes">
<trigger priority="10" copy="yes">
<pattern>^Some attack line.</pattern>
<value>#say attack
#t+ test</value>
</trigger>
<trigger name="test" priority="20" enabled="false" copy="yes">
<pattern>Some affliction line.$</pattern>
<value>#say afflict</value>
</trigger>
</class>
</cmud> |
Use #say Some attack line. Some affliction line. to test this.
Basically, you can put all your affliction triggers in a class that's disabled. Turn that class on with the attack trigger, and as long as all the priorities of the affliction triggers are higher, they'll still fire on the same line. You can then turn the class back off with each of the triggers. As a failsafe, put an event handler in the class as well, set to run on your prompt, that also turns off the class. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Fri Mar 27, 2009 11:32 pm |
Thanks for the suggestions. That is pretty much the way I am going to do it once i discover ALL of the attack lines. I think I have them all but not sure yet.
|
|
|
|
|
|