 |
Eul |
Posted: Thu Jul 05, 2007 6:57 pm
Script problems |
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Sun Jul 08, 2007 7:18 pm |
Hey, no problem :)
I am actualy having a problem with the abouce trigger, it works fine until it makes me avoid a rough guard and then it just seems to want to ignore all the NPC's I want to kill. Any ideas? |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Sun Jul 08, 2007 7:30 pm |
Wait, I figred it out :) Something REALLY obvious!
I had forgtten to remove the guard from the moblist and because I had the moblist reset after I kill somthing it would never fire off.
Eul. |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Mon Jul 09, 2007 11:13 am |
Kill stealing, nobody likes it so I don’t really want my script to do it.
The way I figured I would get around this is by making another variable called playerlist, and here is the code I have for it so far:
Code: |
#VAR playerlist= ""
#TRIGGER {Heroes online:*.} {#additem("*",@playerlist) |
Ok, this is designed to add all of the players from "who online" into the data base, assuming that it will capture everything in-between "heroes online:" and "."
I am a little sceptical however of how it will handle this data. The mud output will display them one player at a time in a list, such as “ Heroes online: Bob Sally Jeff. “ Will the above command add them all as one big long string that will be unusable? Or will that depend on how I use the information saved in the playerlist?
Anyway, I think I have come up with a way to update this list every so often so the only real question is if I use this:
Code: |
or %ismember ("*",@playerlist) |
In my alias to scan the room for stuff to kill, will it use the wild card to pick up any individual player names or will it try and match the whole block of text, therefore making the current script usless? :)
EDIT wait, I need to re-think this. I'll edit again in 10 mins.
Ok, since the above was flawed because of how my script scans my moblist for stuff to kill and dose not add players to the list, I thought this would solve the problem.
Code: |
#VAR playerlist= ""
#TRIGGER {Heroes online:*.} {#additem("*",@playerlist)
#TRIGGER {%isamember("*",@playerlist)} {#var moblist %additem("%1",@MOBLIST)} |
I dont even know if this will work to be honest, I would like it to check the player list I have generated to see if there is a player there, and then add him to the moblist. Bah, I think I am way off here actualy.
Eul.
Eul |
|
|
 |
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Mon Jul 09, 2007 12:12 pm |
Yup.
Creating a generic string list from a big list such as you're trying to do is always a pretty tricky business. I'd really need to know the *exact* output your mud has for the "Heroes online" line until I could help any further, though.
Right now, supposing that "*" would do the job, correct syntax would be
Code: |
#trigger {Heroes online: *} {#additem playerlist %1}
|
Least according to helpfile for #additem thats the syntax used for it. As supposedly player names don't duplicate I guess you could use that but I'd myself regardless always use %additem(%1,@list) syntax myself. So
Code: |
#trigger {Heroes online: *} {%additem(%1,@playerlist)}
|
Take notice that in trigger's value part, I changed "*" to "%1".
Now, for your second question. Sort of.
You can try the following.
Code: |
#trigger {({@playerlist})} {%additem(%1,@playerlistcurrent)}
|
That picks up the player's name using the playerlist var within the pattern and adds it to the current list of player, letssay in the same zone you're in.
Now, somewhere in your mob killing part above, you could make a new check.
#if ((@playerlistcurrent!=%null)) {#STEP}
And then where you're resetting the moblist var to %null, you'd also set playerlistcurrent to %null.
Hopefully you understand/understood at least some of what I just wrote.
Prog |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Mon Jul 09, 2007 12:31 pm |
Yes, I understand. You create a list of the players with "who online", then while the script is running it will check to see if anyone on the screen you are standing on is one of those players and add there name to a new list. Then I add a line of code into my killing trigger to check to see if the playerlistcurrent has anything in it, if it dose it will asume that that player has "claimed" the NPC's on the screen and move insted of starting combat.
Thanks, I'll post here when I have had time to go through it all, make it work, and more importantly understand why it works :)
Eul |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Jul 09, 2007 1:29 pm |
Prog is right about the #additem syntax. When you're using %additem, though, you must use the format "#var something %additem(newitem,@something)" or the list won't get updated. %additem returns an updated list, it doesn't affect the variable itself. Calling a function on its own like that is bad practice anyway - use the #call command, so
#trig {something} {%function(whatever)}
becomes
#trig {something} {#call %function(whatever)}
Also, when you want to refer to the contents of a wildcard later, you must surround it with brackets.
Heroes:*
as the pattern won't do what you want, but
Heroes:(*)
will. Furthermore, when you later refer to the wildcard in the script, you use one of the %1-%99 variables like in prog's example. Wildcards are numbered from left to right by the position of their opening bracket:
#trig {this is (%w), it has (%d) days left} {}
If you want to reference the contents of the %w wildcard, you substitute %1 in the script. If you want to reference the %d wildcard, you use %2 and so on.
As for your heroes online list, you'll have to use %replace or %subchar to replace the spaces in the list with pipe characters - | - in order to get the list to format properly. You must also use #forall to populate the list because if you did "#additem something bob|harry|sally|joe|fred" you'd end up with the string "bob|harry|sally|joe|fred" added as a single item in the @something list. The proper script will probably look something like this:
#trig {Heroes Online: (*)} {PlayerList="";#forall %replace(%1," ","|") {#additem PlayerList %i}}
With all this said, though, wouldn't it be much easier to detect if a player, any player, is in the room, and not to have to bother capturing all the names? How are players listed in the room description? |
|
|
 |
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Mon Jul 09, 2007 1:43 pm |
Quote: |
With all this said, though, wouldn't it be much easier to detect if a player, any player, is in the room, and not to have to bother capturing all the names? How are players listed in the room description?
|
*giggle* thats exactly what I'd almost suggested myself but I figured that if he'd want to take a shot with generatic whole list, perhaps thats even easier to manage for future reference. Personally though, if there's a line seen which indicates a player fighting a mob, can easily just go with that line setting playercurrent to 1 and then script will move on by stepping and sets playercurrent back to 0.
Otherwise, I guess just been woken up hit again! * Should have () but I'd personally go with something=%additem(%1,@something) rather than #var something %additem(%1,@something). Seems less messy for me.
Prog |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Mon Jul 09, 2007 1:54 pm |
I had originally tried to see if there was a way to do this but sadly players show up just the same as NPC's do on a screen, they sometimes have extra titles but sometimes don’t. You could literally end up with:
A commoner is standing here.
Bob is standing here.
And while I am not to sure if it shows up any extra text if bob is fighting the commoner it is still bad etiquette to attack an NPC that already has another player in front of it, well, IMO anyway.
I guess I could try to set it up to not start combat if anything not listed in my original moblist "is standing here." I just figured this would be easier.
Eul. |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Jul 09, 2007 2:00 pm |
Well, that method would lead to you skipping some rooms that you could kill stuff in. The bot currently adds everything in the room to the list, right, regardless of whether it's a mob you want to kill or not? If that's the case, why not something like this:
#trig {(*) is here.} {#if (%ismember(%1,@playerlist)) {#var MobList %additem("PLAYER",@MobList)} {#var MobList %additem("%1",@MobList)}}
and then all you need to do is add another %ismember check with your rough guard check, seeing if PLAYER is a member of the list. |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Mon Jul 09, 2007 2:25 pm |
No, it currently dose not add everything to the moblist, just stuff from a predefined list. I am starting to get a little confused with all these different ideas. I am going to take a break before getting stuck back into this , although the above line looks like it would make more sense than my current set up.
Back later with results.
Eul |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Tue Jul 10, 2007 2:05 pm |
Ok, I have had another go at this. I couldent get my head around how to combine these to triggers so I dident bother, so they should both scan the npc list line and one will pull out NPC's and the other any players included in the playerlist.
Code: |
#class {NPClist}
#var playerlist= ""
#TRIGGER {Heroes Online: (*).} {PlayerList="";#forall %replace(%1," ","|") {#additem PlayerList %1}}
#TRIGGER {a(*) standing here.} {#if (%ismember(%1,@playerlist)) {#var MobList %additem("PLAYER",@MobList)} {#DELITEM moblist PLAYER}
#TRIGGER {a(*) ({dog|cat|rat|commoner|guard})* standing here.} {#var moblist %additem("%1",@MOBLIST)}
#class 0 |
And I have rewriten my walking script to keep walking if a player is on the screen when I walk in.
Code: |
#CLASS {walk}
#TRIGGER {^There are * obvious exits:*} {#ALARM {+1} {#if ((@MobList="") or %ismember("Guard",@MobList) or %ismember("Player",@moblist)} {#STEP;#PAUSE} {#ALARM {+1} {kill %item(@moblist,1)}}
#CLASS 0 |
What say you guys, any better? |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Jul 10, 2007 2:18 pm |
Your trigger for players is "a(*) standing here." - but from what you've previously said, the text for players in the room is like "Bob is standing here." - there's no "a" at the start and, furthermore, you'll capture the "is" part into the wildcard, which will prevent the %ismember(%1,@playerlist) from matching. Try this pattern instead:
(%w) is standing here.
Also, %ismember is case sensitive, so you must check for PLAYER and not Player in your walk trigger. |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Tue Jul 10, 2007 2:35 pm |
Yes, you are right. Although my above was an example, as I was not at my computer to give a piece of exact output from the mud. It actualy lists all of the NPC's and players in one line. So ignoring the little errors above (I'll change it in a seccond) I am trying to get the script to capture everything in the last line(s) of text from the mud and examine it to see if it contains a player name. Would I have to change the trigger to something like this;
#TRIGGER {(*) standing here.} {#if (%ismember(%1,@playerlist)) {#var MobList %additem("PLAYER",@MobList)} {#DELITEM moblist PLAYER}
Or is this being too vuage for the program?
One last think, I have come across a new NPC that has a new pose in a room. There is two children on a screen and they appear on the NPC line as "Two children are chasing each other here."
How can I sprerate my #TRIGGER {a(*) ({dog|cat|rat|commoner|guard})* standing here.} to have this extra field? |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Jul 10, 2007 2:49 pm |
The "a(*) ({dog|cat|rat|commoner|guard})* standing here." solution is simple providing that it doesn't cause any false positives - "a(*) ({dog|cat|rat|commoner|guard|children})* here." - assuming that they're actually one mob and the keyword is children, anyway.
As for the playerlist trigger, you really MUST use "(%w) is standing here." Given the line "Bob is standing here", the value of %1 will be "Bob is". "Bob is" will NOT be a member of @playerlist even if "Bob" is a member. You need to match on the name and only the name. I'd also advise against deleting the PLAYER item from the list if the item isn't in the playerlist, because this trigger is generic enough that it's going to fire on other things, like mobs in the room. Just because one specific thing in the room isn't a player doesn't mean that there are NO players in the room. |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Tue Jul 10, 2007 3:21 pm |
Ok, two more questions :)
Is there a way of changing the string to look like this;
Code: |
a(*) ({dog|cat|rat|commoner|guard})* ({standing here.|chasing here.|leaning here.|sitting here.}) |
Just so I can stick with my existing list but change any different positions they might have?
Also I am assuming I could not use;
Code: |
a(*) ({dog|cat|rat|commoner|guard|(%ismember(%1,@playerlist))})* standing here. |
EDIT Wait, you just stated before why that wouldent work. never mind :)
Eul |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Jul 10, 2007 3:44 pm |
In answer to your first question - yes, just like that. But bear in mind that "chasing here" won't match "chasing each other here".
You can probably do what you want with the other one by making it
a(*) ({dog|cat|rat|commoner|guard|@playerlist})* standing here.
but this will work in exactly the same way as the
a(*) standing here.
trigger you had before. So in short, no, you can't use that. |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Fri Jul 13, 2007 8:54 pm |
I have a problem with the below trigger;
Code: |
#TRIGGER {^There are* obvious exits*} {#if (inroom= "") {#step;#pause;#abort 1} {#forall @inroom {#if (%match("guard",%i)) {#step;#pause;#abort 1} {#if (%match({@playerlist},%i)) {#step;#pause;#abort 1} {#if (%match({@npclist},%i)) {#PAUSE;#ALARM {+1} {#additem combat %i;k %i;#abort 1} {#step;#pause;#abort 1}}}}}}} |
it is suposed to check @inroom for anyything, if there is nothing #step or if it matches the name "guard" it will step, or if it sees a player from my playerlist. finally it should check to see if there are any matches with my NPC list and then kill them or step if there are no matches.
It just dosent do anything, any tips please?
Eul |
|
|
 |
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Fri Jul 13, 2007 9:47 pm |
uh,
I understand what you're trying to do but I'm pretty sure #forall isn't the way to obtain it.
#forall is
list=sword|dagger|mace
#forall @list {repair %i}
For the thing you're trying to do, I'd suggest the following.
Code: |
#TRIGGER {^There are* obvious exits*} {#if ((@npclist=%null) or (@unwanted_mob!=%null) or (@playerlist!=%null)) {
#step
#pause
} {
#if ((@npclist!=%null)) {
#pause
#alarm {+1} {killlist=%additem( %1, @killlist)}
}
}
}
|
Now... Let me explain.
I added an additional string list called unwanted_mobs. There you can add mobs like "guard" which you want to avoid at all costs and rather move on. This will work provided that There is a trigger which adds "guard" to the unwanted_mobs list. Say
A guard is here. -> unwanted_mobs=%additem(%1,@unwanted_mobs) Where "guard" would be "%1" in the pattern, Like that
A (%w) is here. - So if %w is %1 and is checked to be guard, it will add it to the above list.
Next thing I did was shortening and simplifying the whole thing. If you want to take a step when either a) npclist is empty b) guard is seen c) player is seen. All you have to do is #if ((@npclist=%null) or (@unwanted_mobs!=%null) or (@playerlist!=%null)).
!= stands for not %null ie they are there.
So, when one of those 3 is happening, thing steps.
But if npclist isn't empty ie !=%null then it adds the mob in question into killlist and starts killing it.
Generally, You don't really have to have alarm for adding tho So you can just remove it.
Though I guess what you wanted to do Was to turn ON alarm that does the fighting. So...
#alarm "MobAttack" {*1} {#if ((@npclist!=%null)) {kill %item(@npclist,1);#t- MobAttack} {disable}
So When the above code reaches the point where npclist isn't empty, you can just do #pause;#t+ MobAttack which checks that list isn't empty and starts to kill first mob in the list by issuing kill (first in the list). Once you're done and room is cleared, You can turn it back off until next time.
EDIT: When you have the line seen when mob dies, you can turn the alarm back on with it. That way the alarm will check for every mob and issues kill if list isn't empty and turns itself back off (added #t- MobAttack to the kill part with Edit, btw).
I hope I made some sense.
Prog |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Sat Jul 14, 2007 6:06 am |
Yes it made sense, but I was using match because I didn’t want to make another list. What I currently have is a trigger that picks everything in the room and ands it to inroom so if there was a commoner there it would add the following;
a|commoner|is|staanding|here
The kill trigger matches key words with @npclist and @playerlist and if it finds a match it will start combat, or #step. If I was to use the revised method I would also have to rewrite how my scrip captures npc's in a room, and I only just finished that :)
Thanks for the feed back though, I will be rewriting this later today, but if you could possibly help make this work with the way my inroom list is generated that would be great :)
Thanks,
EDIT:
I have changed it a little, but it is still not working.
#TRIGGER {^There are* obvious exits*} {#alarm {+1} {#forall @inroom {#if (%match("guard",%i) or %match({@playerlist},%i)) {#step;#pause;#abort 1} {#if (%match({@npclist},%i)) {#PAUSE;#ALARM {+1} {#additem combat %i;k %i;#abort 1} {#step;#pause;#abort 1}}}}}}}
It says there is a error where the red # is, but I am not sure what it is.
Eul. |
|
|
 |
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sat Jul 14, 2007 1:38 pm |
I used quotes because the code tags do not allow you to color your text.
There were two errors. First the } was in the wrong spot.
And the } was an extra.
Arminas wrote: |
#TRIGGER {^There are* obvious exits*} {#alarm {+1} {#forall @inroom {#if (%match( "guard",%i) or %match({@playerlist},%i)) {#step;#pause;#abort 1} {#if (%match({@npclist},%i)) {#PAUSE;#ALARM {+1} {#additem combat %i;k %i;#abort 1}} {#step;#pause;#abort 1}}}}} |
Eul wrote: |
#TRIGGER {^There are* obvious exits*} {#alarm {+1} {#forall @inroom {#if (%match("guard",%i) or %match({@playerlist},%i)) {#step;#pause;#abort 1} {#if (%match({@npclist},%i)) {#PAUSE;#ALARM {+1} {#additem combat %i;k %i;#abort 1} {#step;#pause;#abort 1}}}}}}} |
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Sat Jul 14, 2007 3:02 pm |
Ok, I changed it again:
Code: |
#TRIGGER {^There are* obvious exits*} {#ALARM {+1} {#if ((@inroom="") or %ismember( "Guard", @inroom) or %match( @playerlist,@inroom)) {moblist="";#STEP;#PAUSE} {#forall @inroom {#if (%match({@npclist},%i)) {#PAUSE;#ALARM {+1} {#additem combat %i;k %i;#abort 1}}}}}} |
But now when it moves to kill % it is doing it for everything in the inroom list, like :
kill a
kill commoner
kill is
kill standing
kill here
...is that because of the #forall?
Eul. |
|
|
 |
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sat Jul 14, 2007 7:55 pm |
Yes
Note that I did not fix your script as I have not been reading this thread. I simply fixed a script error. There could be a way to make it work properly by moving the } around. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Sun Jul 15, 2007 8:31 am |
Ok, I tried moving the {} but to no avail, I had it working like this;
Code: |
#TRIGGER {(*) ({standing here|sitting here|lying here|squatting on the ground}).} {#var inroom "";#forall %replace( %replace( %1, ",", " ")%1, " ", "|") {#additem inroom %i}} {#if (%match({@npclist},%i)) {%additem moblist 1%}} |
but It will just keep doing "kill a"
So I have had anothe stab at changing the code and come up with way to bypass this trigger.
Code: |
#TRIGGER {(*) ({standing here|sitting here|lying here|squatting on the ground}).} {#var inroom "";#forall %replace( %replace( %1, ",", " ")%1, " ", "|") {#additem inroom %i;#IF (%match(%i,@playerlist)) {#additem moblist "avoid"}}} |
Sadly, this also dose not work. Could anyone point me in the right direction as I am really fustrated. Everytime I think I have a soulution it turns out to be wrong. the seccond trigger is suposed to scan the room for people "standing there" and then add this to a inroom list. it will them try to %match that with my playerlist, and if it is sucsessfull it will add "avoid" to my moblist.
Eul. |
|
|
 |
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Sun Jul 15, 2007 12:43 pm |
I'm sorry for humming the same tune but using several string lists and different setup would cause less trouble and also be easier to understand for starters.
Code: |
#trigger {(*) {standing here|sitting here|lying here|squatting on the ground}} {#if (%ismember( %1, @avoid_mobs) or %ismember( %1, @playerlist)) {#step} {inroom=%additem( %1, @inroom)}}
|
This is, however, just a really simple example of what I've been trying to point you towards each time.
As you already pointed out last time I wrote, that you understand it but don't wanna use it (I never understood, why), I'll cut it short not to waste your time any longer.
Prog
--- btw, 100th post! |
|
|
 |
Eul Wanderer
Joined: 30 Jun 2007 Posts: 53
|
Posted: Sun Jul 15, 2007 1:06 pm |
The only reason why I dident want to use this method was because I had just rewritten the way the script picks up npcs in the room, I mentioned that before (scrool up if you want to see how it dose it now ). Sorry but I though the new method was better because it was adding everything in the room into a list rather than just picking up stuff that matches the trigger bellow. I guess it is to complicated so I'll just try and take a step back and get this to work the sugested way.
Not waste my time
Thanks for taking the time to nudge me in the right direction again!
Eul. |
|
|
 |
|
|
|
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
|
|