 |
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Mon Jan 01, 2007 5:44 pm
Squint Targeting |
Hi, I have a new archery script nearly done in Achaea. What I want to do is squint in all directions and capture the player names in all directions if they are on my enemy list. The enemy list and targeting commands all work well but The squint alias gives more than I need. It essentially has something like:
"Room description. Prefix Title Name Lastname SuffixTitle is here. She wields blablabla. Prefix Title Name Lastname SuffixTitle is here. He wields blablabla and is riding a Blablabla."
It seems the words "is here" are always there and that is probably the key. The prefix title, last name, and suffix title may or may not be there. All I need to capture is the actual name and if it ismember of my enemy list variable other things will happen. I need to sift through the information somehow to get only the names for the rest of my system to work. I'm sure I will not have too much trouble collecting the squint direction into a variable when an enemy is there. When done the enemy names and directions will all go into a set of buttons that act as a queue and when one is pressed I will aim and shoot at my selected target. Please help me. |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Jan 02, 2007 12:00 am |
#alias squint {#forall n|ne|e|se|s|sw|w|nw|up|down|in|out {~squint %i};#t+ SquintEnemies;#alarm +1 {#t- SquintEnemies}}
#trig "SquintEnemies" {{@EnemyList}} {do whatever you want having found an enemy}
The problem, as you say, is that the enemy names could (though it's unlikely since your enemies aren't going to have names like "is here" or "she is wielding a big broadsword") appear somewhere else in the pattern. It's possible, I think, using regex to match more than one word and create a regex trigger with a pattern something like this:
{. ((\w+) )*(@EnemyList)((\w+) )* is here.}
to match an enemy name with any number of preceding or following words. Someone who knows more about regex syntax might be able to shed some more light. I'm not sure how well this example would work since the most likely place for an enemy's name to appear is in someone else's title, not in the other items in the room, and that'll still match no matter what you do. For example:
Mia, Worshipper of Herod
would both match the above Regex with both Mia AND Herod, which isn't what you want at all. |
|
|
|
 |
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Tue Jan 02, 2007 2:06 am |
I'll try that but to simplefy for my level of scripting, can I do something like:
#alias squinting {#forall n|ne|e|se|s|sw|w|nw|up|down|in|out {~squint %i};
#Trigger {. ((\w+) )*(@PossibleEnemy)((\w+) )* is here.}
#IF (%ismember( @PossibleEnemy, @EnemyList)) {
#cw red,white
EnemyT = @EnemyS
DirT = @DirS
EnemyS = @EnemyR
DirS = @DirR
EnemyR = @EnemyQ
DirR = @DirQ
EnemyQ = @EnemyP
DirQ = @DirP
EnemyP = @EnemyO
DirP = @DirO
EnemyO = @EnemyN
DirO = @DirN
EnemyN = @EnemyM
DirN = @DirM
EnemyM = @EnemyL
DirM = @DirL
EnemyL = @EnemyK
DirL = @DirK
EnemyK = @PossibleEnemy
DirK = "%i"
}
Example: #Button @EnemyN {Target = @EnemyN; Direction = @DirN; aim @Target @Direction; Shoot @Target @Direction}
The long script just moves the names up the queue until they drop off. There is a button for each. I'm assumong that the %i holds the direction. I realize this is probably messed up somewhat syntax wise and would appreciat any help I can get. Thanks. |
|
|
|
 |
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Wed Jan 03, 2007 1:04 am |
I was only able to capture one name with that trigger out of about 10 people I was able to squint at. Does anyone know of a more general trigger to use??
|
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Jan 03, 2007 1:19 am |
The idea is that @EnemyList is a stringlist of all your enemies. If it was Bob|Harry|Ted for example, the trigger would become
(Bob|Harry|Ted)
Which will match any members from the list. Once it's found one, it'll do whatever you want it to do. It'd be much easier, I think, to use a database variable than many different variables to hold your enemies and the direction that they're in. Forexample, @Enemies.N=Bob|Harry and @Enemies.NW=Ted. Look up the #addkey command for more on that.
The problem is that %i only works during the #forall command. Once the #forall has finished (which is before any of the squint information is received by your client) then %i won't work any more. You'll have to have a trigger on "You squint (%d)" to set which direction you're currently squinting. So:
#trig {You squint (%d)} {#var SquintDir %1}
#trig {({@EnemyList})} {#addkey Enemies @SquintDir %additem(%1,@{Enemies.@SquintDir})}
Which adds the item that matched the trigger to the list already in @Enemies.Direction and then makes the key equal that string. |
|
|
|
 |
Rolly Wanderer
Joined: 16 Oct 2006 Posts: 62
|
Posted: Fri Jan 05, 2007 12:05 am |
I really appreciate all this help but I am very new to REGEX coding so please bear with me. I see how it has matched a name to @EnemyList and can capture the direction of the triggered name to a DB. I do not see how this actually captures that particular name into a variable I can use to target the character. Essentially I need the different variables so that I have a series of names in a row of buttons that once pressed will make that name and direction my target. As things move on and I squint again these variables can travel down the row of buttons and finally drop off the bottom. Perhaps it would be better to test all text displayed on my squints for a match to my @EnemyList variable with an %ismember statement and simply turn on and off a class just to do the squint. Testing to see if a name is there and actually capturing the name into a vaiable are two different things. I'm sure thiat REGEX does it somehow but I can not see how it works and do not think i can easily troubleshoot it. Do I need some code to pull it out of the data base as soon as it goes in and if so, why not avoid the DB alltogether and put the name directly into the variable? This posting is probably making me look pretty ignorant but I would really appreciate some help getting this to work.
|
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Jan 05, 2007 2:27 am |
The very last example I gave wasn't a regex, it was a normal trigger. I'm not sure what you mean by "turning off a class just to do the squint", though. There's no need to compare using an %ismember statement when the trigger already does the same thing, as far I can see.
The point of the database is that besides your KLMNOPQRS syntax being a bit confusing, it doesn't allow for long lists of enemies. If the script detects more than nine enemies when you squint (arena battle maybe?) then you'll lose some. A database never will. The other strength of the database is that the direction the enemy's in is linked simply and clearly with its direction. That way you can show only enemies in a direction, or enemies sorted by direction, or a compass made out of buttons that display enemies, or anything you like, with no extra sorting of the list.
You can use %item in the button label and script to get the values out. For example:
%if(%null(@Enemies.North),%item(1,@Enemies.North,"[...]")
as the button label. You could create something to present you with a list of enemies if you don't have enough room for many buttons. Either through MXP with a <send> tag and a list of them, or perhaps a <send> with a right-click menu. I don't use buttons a great deal so I don't know how versetile they are and if you could create a drop-down menu button with a variable number of entries. Then you could have a button for each direction, and a list of enemies in that direction that drops down.
Regardless, even if you decide to stay with a nine-enemy hard limit because of the button space requirements, the db lets you sort by direction easily, which is useful. |
|
|
|
 |
|
|
|