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 Goto page 1, 2, 3  Next
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Thu Jul 05, 2007 6:57 pm   

Script problems
 
Here is the some script I have been editing, but there are two bugs I cannot seem to spot myself.

#TRIGGER {^You killed *.} {take coins from corpse;bury corpse;#T+ akill;#T+ walk;look;#ALARM +2 {#RESUME a1}}

#VAR MOBLIST ""
#TRIGGER {a* ({dog|cat|rat|commoner|guard})* standing here} {#var moblist %additem("%1",@MOBLIST)}

#CLASS {akill}
#TRIGGER {^There are * obvious exits:*} { #ALARM "a1" +2 { #if (@MobList="" OR %ismember("Rough Guard",@MobList)) {#walk} {#t- walk;kill %pop(moblist);#t- akill}}} "" {notrig}
#CLASS 0
/// This trigger is saying there is a problem with the part that says {#walk} but I dont understand what, is it suposed to be #step?

#TRIGGER {{^You move in to attack*.|^You powerfully*.|^You swing*.}} {batter %1 with club}
///This trigger is causing a loop, it is designed to preform a special attack when I move to attack/perform a special attack/miss a special attack but anything sent back from the MUD is setting it off and causing a loop. Any ideas?

#CLASS {walk}
#ALARM "a1" +2 {#STEP;#PAUSE} } "" {notrig}
#CLASS 0

Any input would be great, I thought I was making progress, but aparently not.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Jul 05, 2007 7:36 pm   
 
It's supposed to be #step, not #walk, same as the a1 alarm.

In answer to the second question, by default you can't use wildcards in the {one|two} list syntax. But that doesn't matter, because this is a perfect place to apply the golden DRY rule of programming - Don't Repeat Yourself. Your pattern can become "^You {move in to attack|powerfully|swing}*." and match the same thing that it currently does. If you find yourself having to type out the same thing more than once, there's usually a shortcut. Programmers, like mathematicians, are very lazy :P

If that doesn't fix your problem, get back to me.

EDIT: Also, was that script made from an export from zMUD? It's weird that the a1 alarm was listed at the end because it's not supposed to exist unless the bot is running. Was it running at the time?

EDIT2: This forum needs the :ph34r: smiley, prog :P -
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)

Last edited by Fang Xianfu on Thu Jul 05, 2007 7:41 pm; edited 3 times in total
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Thu Jul 05, 2007 7:36 pm   
 
You might try

#TRIGGER {^{You move in to attack|You powerfully|You swing}} {batter %1 with club}


And see if that helps.


EDIT: Pretty much ninjad, I think :P

Prog
Reply with quote
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Thu Jul 05, 2007 8:43 pm   
 
Thanks for the help.

I have changed my special attack trigger back to the way it was as the new one dose not work, but it is still not working 100%

#CLASS {LAUNCH}
#TRIGGER {^You get ready to kill the (*).} {batter %1 with club}
#TRIGGER {^You powerfully *.} {batter %1 with club}
#TRIGGER {^You swing *.} {batter %1 with club}
#CLASS 0

The first trigger will fire off, but any subsequent ones will not, should I try replacing %1 with a value genirated from the MOBLIST?

Also I have ended up with a new class in my triggers named } that contains the code;
#CLASS {}}
#CLASS 0

What part of my original script is making this? Also dose not seem to be adding NPC's to the MOBLIST. Bah, I am tired and will take another look tomorrow. Thanks for all the help so far.
Reply with quote
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Thu Jul 05, 2007 8:48 pm   
 
Fang Xianfu wrote:

EDIT: Also, was that script made from an export from zMUD? It's weird that the a1 alarm was listed at the end because it's not supposed to exist unless the bot is running. Was it running at the time?


The original code was taken from http://forums.zuggsoft.com/forums/viewtopic.php?t=17006

I was not sure of the function of the #class {walk} part, so just left it in rather than delete somthing I know little about atm :)

Eul.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Jul 05, 2007 9:09 pm   
 
Well, you've moved a few things around from the script posted there that'll hinder the bot working. If you take a look at that script again, you'll see that the "you see obvious exits" trigger should be in the walk class and the trigger that adds items to the moblist should be in the akill class.

Your problem with the "#class {}}" means you made a typo somewhere when you posted the script onto the command line. Make sure you have no settings (aliases or triggers or whatever) that're making other settings, and then check each of them to make sure they contain the right code. Delete the extra ones.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Fri Jul 06, 2007 8:22 am   
 
I have editied this script, tell me what you think now :)

Code:
#CLASS {akill}
#VAR MOBLIST ""
#TRIGGER {a* ({dog|cat|rat|commoner|guard})* standing here} {#var moblist %additem("%1",@MOBLIST)} 
#CLASS 0

#CLASS {walk}
#TRIGGER {^There are * obvious exits:*} { #ALARM "a1" +2 {#if(@MobList="" OR %ismember("Rough Guard",@MobList)} {#STEP;#PAUSE} {#WA %random(1000,2000);kill %pop(moblist)}}} "" {notrig}
#CLASS 0

#CLASS {LAUNCH}
#TRIGGER {^You get ready to kill the ({dog|cat|rat|commoner})*.} {#var moblist #ADDITEM("%1",@launch)} {batter %dups(launch) with club}
#TRIGGER {^You powerfully *.} {batter %pop(launch) with club}
#TRIGGER {^You swing *.} {batter %pop(launch) with club}
#TRIGGER {^You killed *.} {#DELITEM %dups(launch)}
#CLASS 0

#TRIGGER {^You killed *.} {#WA %random(1000,2000);take coins from corpse;bury corpse;look;#ALARM +2 {#RESUME a1}}


The last trigger there I dont think it needs anything after it tells it to look, could anyone gimme a hint? :)
EDIT--> infact could you delete that and the a1 alarm part in the #class walk?

Also the revised launch #class is setup to add a NPC to the launch list when I move to engage it and launch a special attack, leaving the NPC still in the launch list. It will then be triggerd to do the same thing again once the initial special attack has landed/missed and remove the NPC from the launch list. I also added a line to remove the NPC from the launch list if it should die for whatever reason before the special happends. I will no doubt change the three alias into one when I am happy that it is working properly in the first place :)

progonoi wrote:

EDIT: Pretty much ninjad, I think :P


Sorry, have I done somthing wrong by using this script as a starting point? I just figured that if I started with this simple combat bot and started to expereming with it and slowly add/change things I would not only learn from it but have a script that would be tailord to the MUD I play.

Should I just start again from scratch? I supose that would be better from the prespective that I would understand it more, but I was starting to think I was making some progress! :)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Jul 06, 2007 11:32 am   
 
By "ninjad" he means that I, with the stealth of a ninja, snuck in and posted while he was still writing his. He's not talking about the script :P

I notice that you've removed the #t- and #t+ commands from the walk trigger. If the bot still works without them, fair enough, but it's something to check.

Also, your syntax "#var moblist #ADDITEM("%1",@launch)" is wrong - I think you mean %additem and not #additem. Your code is also perhaps not doing what you indend it to do since you're changing the "moblist" variable to contain all the values of the list @launch, %1, and nothing else. Perhaps you mean #additem launch {%1}, since later on you use %dups to remove duplicates. But then again, you probably don't mean to use %dups here, because the output of dups looks like this:

@SomeList = harry|bob|fred|john|harry|fred
%dups(@SomeList) = harry|bob|fred|john

So you'll end up sending the command "batter harry|bob|fred|john with club" which probably isn't what you meant. Also, the %pop function also removes the item from the list, which means that each special attack will hit a separate mob. This may also not be what you want.

The main problem is that I don't know what you intend the new logic to be - if you explain, step by step (numbered, even) what you're now expecting the bot to do, we'll be able to advise you how to get that result and what you're currently doing wrong.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Fri Jul 06, 2007 11:43 am   
 
Thanks for you help here. I'll wait until I get home and post what I want the script to do _after_ I have another go at rewriting it. And I removed the #t commands for it wo walk because of the new way that the bot scans the room for stuff to kill/move, so rather than it looking for stuff to kill and then suspending the walk move it dose them both at the same time and has already #paused the #walk. I think?

Also I see what you are saying, I have acidently made the seccond list modlist insted of making a new one, @launch. I'll tweak that too :)

Anyway, hold off posting any new stuff here until I have another go at this! :D

Laters!
Reply with quote
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Fri Jul 06, 2007 1:04 pm   
 
Code:
#CLASS {akill}
#VAR MOBLIST ""
#TRIGGER {a* ({dog|cat|rat|commoner|guard})* standing here} {#var moblist %additem("%1",@MOBLIST)} 
#CLASS 0
1. At this stage I want the script to pick up any mobs in the room from the list I have in the trigger and add them to @moblist

Code:
#CLASS {walk}
#TRIGGER {^There are * obvious exits:*} {#WA 1000;#if(@MobList="" OR %ismember("Rough Guard",@MobList)} {#STEP;#PAUSE} {#WA %random(1000,2000);kill %pop(moblist)}}} "" {notrig}
#CLASS 0
First I want the script here to be triggerd off by seing the exits line of the mud output. Since the NPC's will be shown after this point I have added a 1 seccond wait. Then I am getting the script to see what creatures are in the @moblist and if there are none or a guard it will #step, if not it will proced to wait from 1 - 2 secconds and then kill the first one.

Code:
#CLASS {LAUNCH}
#VAR LAUNCH ""
#TRIGGER {^You get ready to kill the ({dog|cat|rat|commoner})*.} {#var launch #ADDITEM("%1",@launch)} {batter %dups(launch) with club}
#TRIGGER {^You powerfully *.} {batter %pop(launch) with club}
#TRIGGER {^You swing *.} {batter %pop(launch) with club}
#TRIGGER {You killed *|* killed the *} {#DELITEM %dups(launch)}
#CLASS 0
Here when I start combat the mud will echo back that I "get ready to kill whatever" I want it to add the whatever to @launch ONCE and then use it to perform a special attack. When the special attack is exacuted I will get one of two messages back, " You powerfully *" or "you swing *" now I want it to launch another special attack but this time I want the loop to end by using %pop(launch) to remove the NPC from the @launch list. it will also remove the NCP from this list if I kill the NPC or is someone else dose.

Code:
#TRIGGER {^You killed *.} {#WA %random(1000,2000);take coins from corpse;bury corpse;look}
Here the script will wait a random time between 1 - 2 secconds after it see's and then loot the corpse and then look. This should then trigger off {akill} to kill the next mob or start moving.

I hope this helps, I have tweaked the code from the last time with any problems I could find.

Eul.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Jul 06, 2007 1:13 pm   
 
So you can kill each of the mobs you're botting in two special attack hits, or you only want to special attack twice in each combat? You're definitely complicating things, there - you probably don't even need a list variable. The things I'd change:

1) Make the exits trigger reset the moblist variable.
2) Change the "kill %pop(moblist)" to "kill %item(@moblist,1)" and get rid of all those references to @launch. The "You get ready" trigger can just "batter %item(@moblist,1) with club" and then the "powerfully" and "swing" triggers can do the same. The "You killed" trigger will then use #delnitem to delete the first item of the list.
3) Since this is a zMUD script and not a CMUD script, I suggest removing the #wait commands and putting #alarm back in. #wait in its current form shouldn't really be used in triggers (or, indeed, anywhere else that isn't a loop). This is set to change in the next version of CMUD, but for now, I don't advise it.
_________________
Rorso's syntax colouriser.

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


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Jul 06, 2007 1:57 pm   
 
Hmm, may be minor details but.


Code:


#CLASS {walk}
#TRIGGER {^There are * obvious exits:*} {#WA 1000;#if((@MobList="") OR (%ismember("Rough Guard",@MobList)))} {#STEP;#PAUSE} {#WA %random(1000,2000);kill %pop(moblist)}}} "" {notrig}
#CLASS 0



I added "(" and ")" to close in @moblist="" and same to close in %ismember part.

Another thing.

Code:


#TRIGGER {^You get ready to kill the ({dog|cat|rat|commoner})*.} {#var launch #ADDITEM("%1",@launch)} {batter %dups(launch) with club}



Shouldn't it be

Code:


#TRIGGER {^You get ready to kill the ({dog|cat|rat|commoner})*.} {#var launch #ADDITEM("%1",@launch);batter %dups(launch) with club}



instead?

I may be totally off the course though because I haven't completely woken up yet :P


Prog
Reply with quote
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Fri Jul 06, 2007 2:21 pm   
 
Ok, Just another question, how do I get it to clear the moblist?

I am asuming it will be somthing like {#RESET akill} also should I add it into the "You killed" trigger rather than the exits one, as part of the #class launch depends on the data in the moblist.

Eul.
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Jul 06, 2007 2:50 pm   
 
When you use %pop(moblist) together with kill command then each time you issue it, it will take one name off list. Eventually the list will be clear and as you have your script set up to move when moblist="" it will move.

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
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Fri Jul 06, 2007 2:58 pm   
 
So, lets say there is three rats on the screen. Wouldent the current way this script is set up (without the #reset) wouldent it kill one rat, remove it from the moblist, loot & bury it then look again. now it would see 2 rats on the screen and add those two to the moblist making a new total of 4?

Eul.
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Jul 06, 2007 3:30 pm   
 
Picture this.

You enter the room. You see.

Code:


A rat is here.
A rat is here.
A rat is here.



Your mobcapture trigger is set up to activate when it sees a rat. If it does it will moblist=%additem(%1,@moblist)

Then you'll issue kill command with %pop(moblist). %pop will take first item from the list and use kill with it. Thus, it leaves 2 rats to the list.

Now you'll have 2 options. Personally I think using "look" after every mob you kill is pretty pointless. You can set it up like that then when you notice the mobs activekill var goes 1 and each time you kill a mob it goes 0, then you'll make a check that if its 0 you'll turn it to 1 and execute kill %pop(moblist) again. I guess doing look after each kill is easier for starters, though :)

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: Sat Jul 07, 2007 1:15 pm   
 
The reason I suggested not using %pop is because you want to reuse the value later for your "batter whatever with club" triggers. It'd be better just to remove it from the list once you've killed it.

Also, prog, you definitely hadn't woken up, because your #trig syntax there was entirely wrong. It was right before the changes you made. Also, surrounding the different parts of the AND expression with brackets shouldn't make any difference to the way it's processed, since there's nothing to group.

When I say "reset the moblist" I just mean adding a line to the walk trigger that does 'moblist=""'. That'll get around the problem you were talking about with 4 rats in the list, because it'll kill one, then wipe the list and look again. So only two rats will be added.
_________________
Rorso's syntax colouriser.

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


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sat Jul 07, 2007 1:29 pm   
 
Nods, my apologizes for giving wrong info etc. As I'm today pretty zombified as well :P I'd only say that now that I read through your message Fang I realize that using %item instead of %pop is most likely best idea. Though using %delitem in "You killed" line to delete first item in the list is the same as using %pop(list) there, heh.


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
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Sun Jul 08, 2007 9:01 am   
 
I am having a problem with this line here. Zmud is saying that there is a problem with the OR part of the string. Should I look for another command to use insead of OR, or have i missed out a bracket somewhere?


#CLASS {walk}
#TRIGGER {^There are * obvious exits:*} {#ALARM +1;#if(@MobList)="" OR %ismember("Guard",@MobList) {#STEP;#PAUSE} {#ALARM +1;kill %item(@moblist,1)}}} "" {notrig}
#CLASS 0

Also is there a way of making one of my launch triggers a 1 shot trigger until it gets reset? just point me in the right direction :)

EDIT I just adressed a problem with the #alarm being in there twice and not being in there properly, bit is says there is a problem in the highlite red part. Any hints would be nice.

#CLASS {walk}
#TRIGGER {^There are * obvious exits:*} {#if(@MobList)="" OR %ismember("Guard",@MobList) {#STEP;#PAUSE} {#ALARM +1 {kill %item(@moblist,1)}}} "" {notrig}
#CLASS 0

Eul.
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sun Jul 08, 2007 12:31 pm   
 
I *think* it should be like this:

Code:


#TRIGGER {^There are * obvious exits:*}

value:

#ALARM {+1} {#if ((@MobList="") or %ismember( "Guard", @MobList)) {
    #STEP
    #PAUSE
    } {kill %item( @moblist, 1)}}



Now If it sees the exits line, it activates the 1 second temp alarm which checks if moblist is empty or guard is in the room in which case it steps away and pauses. If those 2 conditions are not met, it will issue kill on the first item in the moblist.

EDIT: I just tested it in my own Zmud by making the trig and playing with the value part. It should be correct.



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
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Sun Jul 08, 2007 4:58 pm   
 
Thanks for that, although conviently enough it was slightly wrong so I still had to figure out what the problem was. You needed an extra set of {} on that Smile

Thanks for all you help guys, its been invaluble.

Once I have had this running for a little while and read up more on all the diferant functions I have another idea I would like to implment, so I'll post here when I have a rough sketch of the code and the idea behing it.


Thanks again!
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Jul 08, 2007 5:18 pm   
 
Eul wrote:
You needed an extra set of {} on that Smile

Where? Prog's code looks right to me, even if the spacing is a bit inconsistent Wink

The only thing I'm not sure about is whether or not #alarm accepts braces {} round the time argument.
_________________
Rorso's syntax colouriser.

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


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sun Jul 08, 2007 5:54 pm   
 
Hmm, I have always used {} round time argument for both temp and perm alarms, haven't had any problems with it yet.

As for the code, I can't think of any place where the extra set of {} would go because I pasted it here exactly as I made and checked in Zmud. And it didn't want any extras there for me.

As for the spaces... uh, I don't know :/ Its precicely pasted out of edit trigger box after saving it, heh.


Anyway, I'm glad it helped.


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
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Sun Jul 08, 2007 6:09 pm   
 
Well its working fine now that I changed it too;
{#ALARM {+1} {#if ((@MobList="") or %ismember( "Guard", @MobList)) {#STEP ;#PAUSE} {kill %item( @moblist, 1)}}}

Anyway, thanks again for all the help. It was working fine until I started to change the exits trigger, but I am going to figure it out myself :)

Eul.
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sun Jul 08, 2007 6:20 pm   
 
Heh, I sort of started to figure that those are the extra {}'s you talked about.

The thing is that I did the code in edit trigger box so thats where/how I pasted it here as well, which means that within edit trig box you don't need extra {}'s but if you'd insert the trigger I made from command line, you need to add starting { and ending }.

My mistake again, I guess :P


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
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
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