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


Joined: 02 Jun 2006
Posts: 19

PostPosted: Wed Apr 16, 2008 12:36 am   

My first script - will it work?
 
Alright, I’m trying to make a bot to run this zone for me. I have some code worked out, but wanted to run it past you guys first, because its my first real script and I’m sure its sloppy.

Here is the bot’s purpose. To run in a very small zone (about 15 rooms) back and forth, killing any ‘goblins’ I see. (I have simplified room descriptions and creature descriptions for this example).

So, here is how the code is supposed to work. Basically this zone has two floors, and a hallway that runs east and west on each floor. I have a separate trigger for each room description. I have a set of trigger classes made for when I’m going east-west top, west-east top, east-west bottom, and west-east bottom, so 4 trigger classes. This is done because I will (obviously) pass through the same room depending on which direction I’m heading, and the script needs to know which direction I’m heading in. So, GTL1, GTL2, GTL3 and GTH1 are my four trigger classes. (These stand for 'go to lower one', 'go to lower two', etc) I also had to come up with a way for it to not move immediately when it saw the room description, but go in the appropriate direction after it ‘looked’ for monsters. Therefore, I store the correct direction I want to move in in a variable, which changes every room I enter. I also have a trigger class called ‘looking’ which is switched on and off every time I enter a room. The exits for a room all trigger turning this off and turning on a walking class(GTL1, GTL2, or wherever). The reason I have all of the directions listed, is at least one of those will be in the exit list, and as soon as one turns ‘looking’ class off, that’s all I need.

Allow me to show you some of my code before I describe the method its supposed to work:

#class looking {
#trig {north}{#T- looking;#T+@walktype;@godir}
#trig {south}{#T- looking;#T+@walktype;@godir}
#trig {east}{#T- looking;#T+@walktype;@godir}
#trig {west}{#T- looking;#T+@walktype;@godir}
#trig {up}{#T- looking;#T+@walktype;@godir}
#trig {down}{#T- looking;#T+@walktype;@godir}
#trig {a goblin stands here}{kill gob}
#trig {Alas, a goblin is dead!}{look}
}

I also have a class called “GTL1”. This class contains a trigger for EVERY room description from the top room to the first destination (Which happens to be top west room to top east room). The room description triggers look like this:

#TRIG{Room description 2. This is a cool room, blah blah whatever}{#T-@walktype;#T+looking;#VAR godir=e}

In the above example, I know that when I’m on GTL1, and I enter room 2, that I want to travel east. So, here is my method: I enter the room, the description triggers. It turns off @walktype, which was at the beginning of this script defined as “GTL1”. (Whenever I reach the end of the hallway, @walktype will change to GTL2). Looking turns on immediately, which will either see the goblin or not. If it sees it, it will kill it, and in theory initiate combat before the character ‘moves’ out of the room, and when its dead it will ‘look’ showing the room description and running the trigger again. If it doesn’t see anything, one of the exits from the room will trigger an exit trigger under ‘looking’ class, turn off the looking class, turn on the walking class (in this case GTL1), and then move in the pre-determined direction (in this case east). It will hit the next room description, and repeat this. Once it hits a ‘turning point’ (such as the end of a hallway), it will switch to another walking class (like GTL2 or GTL3, these are hard-coded in at specific rooms) and continue.

So, how does this look? Is there a better way to be doing this? I am absolutely ready to reply with clarification or any questions you may have. Thank you for your time (I know it’s a long post!) I would very much appreciate any advice I can get.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Apr 16, 2008 2:25 am   
 
There're a number of mistakes with your script, chiefly that you're missing spaces between }{s and the #t- and #t+ commands and their parameters. Spaces are very important in zScript syntax and can't be missed out.

There're any number of different ways to do this, and some (perhaps most) of them will be better than what you currently have. However, they'll be much, much more complex. Writing a bot is probably one of the hardest things you can attempt in zScript and most solutions will probably be gobbledegook to you. That'll cause you problems when you try to improve the bot or otherwise edit it, so I suggest you do whatever works for you.

There're many threads on writing bots around. Have a search.
_________________
Rorso's syntax colouriser.

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


Joined: 02 Jun 2006
Posts: 19

PostPosted: Wed Apr 16, 2008 3:02 am   
 
Thank you for your reply.

I will make sure to make the appropriate fixes to my syntax. However, how is the logic? Does the logic of this code work out? I know it is sloppy and there are better/more complex ways to do it, but will the concept work if I get the syntax correct? I would appreciate any constructive help to get this working. If there is a better way to write this bot, perhaps a foundation of code that I can work from?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Apr 16, 2008 12:14 pm   
 
Well yeah, it should walk you around fine in theory - it might be difficult to get it to do anything but walk around, though. Since you're always going to use the same route, it'll probably be more efficient to use zMUD's built-in pathing. That just moves in a series of directions one after the other, and you can pause it at any time. That's what's most of the bots mentioned on the forums use.

Seriously, do a search.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Wed Apr 16, 2008 1:23 pm   
 
I would need to see a LOT more to be able to tell you if the specific script you are using would work.

In theory it could work.

However you are hard coding FAR too much.
This in turn will lead to having to rebuild the script from the ground up for each area you attempt to build.

As Fang mentioned there are plenty of bot examples in the forums. Most of which make use of the Zmud/Cmud
mapper and or paths.

I did build one once long ago that didn't use either, but I no longer possess the code and No I didn't post it.

I'm pretty sure from memory that there are a couple of full bot scripts posted in the forums.
And I gave progonoi a lot of advice on one a while back. In a huge thread containing lots of botting advice.
In fact you should find a few threads where he is doing the helping these days...

As a rule we don't like to post too much help for that as the questions never seem to stop.
That and on most muds botting is illegal.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Wed Apr 16, 2008 1:48 pm   
 
Ohh, I heard my name! Twisted Evil

Yeah, there really is a lot of data lying around what concerns building bots. Just do searches with 'kill bot', 'bot', 'auto kill' etc, etc.

http://forums.zuggsoft.com/forums/search.php

Anyway, there are several ideas which you can use for the movement part.

1) Use built-in Map feature. (Dynamic movement which can be coded to go in circles indefinitely etc)
2) Use paths. (Easy for start definitely, but after a time could end up being too fixed as opposed to dynamical movement, i.e big path from point A to B after each step is confirmed, %pop one direction off list. When list=%null it means path is gone to its end, load the path again (meaning the one from which you %pop from is "temp path" loaded from some general one - temp_path=@general_path) but go reverse from B to A (I think %pathreverse is the command but I have never used Paths myself. I went directly to using Map features).

Whatever you'll use, you have to have msgs from Mud that give you heads up that direction sent is sent successfully, usually Exits line is the best for that. that %pops one direction off. When you kill all the mobs in the room or when there are nothing to kill when you arrive there, next direction is sent. You can do it with #step if you use #path. You can also make a String List with all the directions you're going to. Then you can %pop each direction off after confirmation and then once you end up with nothing in List you'll do %pathreverse(@general_path) or something. You get the gist of it I hope.

I'm posting from school so I may not make any sense at all :P

The point is, there are several ways to skin a cat, its more than true for ZMud (not to speak about CMud if you get yours hands on it)

I hope it helped some.


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


Joined: 06 Mar 2008
Posts: 27

PostPosted: Wed Apr 16, 2008 5:13 pm   
 
heres the bot im working on at mo to give you an idea of whats involed its fully working but im still iron out bugs at mo


Code:
#CLA {MasterControl}
#AL setclasses {
  #CLA AutoPilot 0
  #CLA SemiAutoPilot 0
  #CLA CheckScore 0
  #CLA PracticeTime 0
  #CLA LetsXP 0
}
#AL manual {
  #CLA AutoPilot 0
  #CLA SemiAutoPilot 0
  #SHOW %ansi( bold, white)You take full control!
}
#AL auto {
  #IF (%yesno(Do you really want Autopilot to take control?)) {autopilot} {semiauto}
}
#AL semiauto {
  #CLA SemiAutoPilot 1
  #SHOW %ansi( bold, white)SemiAuto Enabled!
}
#AL autopilot {
  #CLA AutoPilot 1
  #SHOW %ansi( bold, white)FullAuto Enabled, sit back and enjoy the ride!
}
#CLA 0 
#CLA {MasterControl|AutoPilot}
#VAR findranger 0
#VAR findwarrior 0
#VAR findrogue 0
#VAR desttgt 0
#VAR presentlvl 0
#VAR myclass {}
#VAR mypracs 0
#VAR pracneeded 0
#VAR roominuse 0
#AL letsxp {
  #VAR xping 1
  #CLA LetsXP 1
  #MATH nextdest @nextdest+1
  #IF (@nextdest=10) {#VAR nextdest 1} {}
  #IF (@nextdest=1) {walksapplingeast} {}
  #IF (@nextdest=2) {walkeastwood} {}
  #IF (@nextdest=3) {walknorthrdstop} {}
  #IF (@nextdest=4) {walknorthfields} {}
  #IF (@nextdest=5) {walknorthxproute} {}
  #IF (@nextdest=6) {walksaplingnorth} {}
  #IF (@nextdest=7) {walksaplingwest} {}
  #IF (@nextdest=8) {walkwestxproute} {}
  #IF (@nextdest=9) {walksaplingsouth} {}
  #IF (@nextdest=10) {walksouthxproute} {}
}
#AL walkranger {
  #VAR desttgt 3305
  setwalk
}
#AL walkwarrior {
  #VAR desttgt 3575
  setwalk
}
#AL walkrogue {
  #VAR desttgt 3275
  setwalk
}
#AL walkcrier {
  #VAR desttgt 3276
  setwalk
}
#AL walkrent {
  #VAR desttgt 3288
  setwalk
}
#AL walkwater {
  #VAR desttgt 3274
  setwalk
}
#AL walksapplingeast {
  #VAR desttgt 3422
  setwalk
}
#AL walkeastwood {
  #VAR speedroute {.8es10ws4e3n9e3s2enwn2e3s3wsw2n3w}
  #VAR setpath 1
  setwalk
}
#AL walknorthrdstop {
  #VAR desttgt 3268
  setwalk
}
#AL walknorthfields {
  #VAR desttgt 3262
  setwalk
}
#AL walknorthxproute {
  #VAR speedroute {.e4nse3s}
  #VAR setpath 1
  setwalk
}
#AL walksaplingnorth {
  #VAR desttgt 3550
  setwalk
}
#AL walksaplingwest {
  #VAR desttgt 3531
  setwalk
}
#AL walkwestxproute {
  #VAR speedroute {.3ws2ewses2wn}
  #VAR setpath 1
  setwalk
}
#AL walksaplingsouth {
  #VAR desttgt 3700
  setwalk
}
#AL walksouthxproute {
  #VAR speedroute {.2ns2ws2es}
  #VAR setpath 1
  setwalk
}
#AL walkoldbridgesouth {
  #VAR desttgt 3717
  setwalk
}
#AL walkbendnorthrd {
  #VAR desttgt 3257
  setwalk
}
#TR {You gain a level} {
  #CLA lvlcheck 1
  score
}
#TR {Auto Enabled, sit back and enjoy the ride!} {
  #CLA CheckScore 1
  prac
}
#TR {Level checked, (*) practice needed!} {
  #CLA CheckScore 0
  #CLA PracticeTime 0
  #IF (@findranger) {walkranger} {}
  #IF (@findwarrior) {walkwarrior} {}
  #IF (@findrogue) {walkrogue} {}
  #IF (@findranger=0 AND @findwarrior=0 AND @findrogue=0) {letsxp} {}
}
#TR {You need to set a new destination!} {
  #CLA CheckScore 0
  #CLA PracticeTime 0
  #CLA LetsXP 0
  #VAR recheckneeded 0
  #VAR xping 0
  #IF (@nowaterleft) {walkwater} {}
  #IF (@newlvl) {
    #VAR newlvl 0
    #CLA CheckScore 1
    score
  } {}
}
#TR {You have reached your destination!} {
  #IF (@findranger OR @findwarrior OR @findrogue) {
    #CLA PracticeTime 1
    #SHOW %ansi( bold, white)Lets practice!
  } {}
  #IF (@presentlvl=5 AND @numtorches<5) {restock} {}
  #IF (@presentlvl=5 AND @numtorches>=5) {letsstartagain} {}
  #IF (@nowaterleft) {
    #VAR nowaterleft 0
    getwater
  } {}
  #IF (@xping) {letsxp} {}
}
#TR {Practices all finished!} {
  #CLA PracticeTime 0
  #VAR findranger 0
  #VAR findwarrior 0
  #VAR findrogue 0
  #IF (@presentlvl=5 AND @numtorches<5) {restock} {}
  #IF (@presentlvl=5 AND @numtorches>=5) {letsstartagain} {}
  #IF (@nowaterleft) {
    #VAR nowaterleft 0
    #CLA EatDrink 1
    getwater
  } {}
  #IF (@pracneeded=0 AND @presentlvl<5 AND @nowaterleft=0) {letsxp} {}
}
#TR {Level &presentlvl reached!} {
  #CLA lvlcheck 0
}
#CLA 0
#CLA {MasterControl|AutoPilot|lvlcheck}
#TR {This ranks you as (*) ~(Level &presentlvl~)} {
  #IF (@presentlvl=3) {
    #VAR newlvl 1
    #VAR recheckneeded 1
    #SHOW %ansi( bold,white)Level 3 reached!
  } {}
  #IF (@presentlvl=5) {
    #IF (@tgt="sapling") {
      #VAR newlvl 1
      #VAR recheckneeded 1
      disengage
      #VAR roomclear 1
      #VAR enemysonpage {}
      #VAR tgt {}
    } {}
    #SHOW %ansi( bold,white)Level 5 reached!
    stat
    #MATH totallvl @strlvl+@intlvl+@willvl+@dexlvl+@conlvl
    #IF (%yesno(STR @strlvl INT @intlvl WIL @willvl DEX @dexlvl CON @conlvl TOTAL @totallvl   Do you want to continue statting for better?)) {restat} {restat}
  } {}
  #IF (@presentlvl=1) {
    #VAR newlvl 1
    #VAR recheckneeded 1
    #SHOW %ansi( bold,white)Level 3 reached!!!
  } {}
}
#TR {Str:&strlvl Int:&intlvl Wil:&willvl Dex:&dexlvl Con:&conlvl} {
   #SHOW %ansi( bold,white)Stats noted!}
#CLA 0
#CLA {MasterControl|AutoPilot|CheckScore}
#AL practime {
  stat
  #UNTIL (@mudresponse) {#wa 100}
  #IF (@myclass="warrior") {
    #VAR findwarrior 1
    #SHOW %ansi( bold,white)Level checked, Warrior practice needed!
  } {}
  #IF (@myclass="rogue") {
    #VAR findrogue 1
    #SHOW %ansi( bold,white)Level checked, Rogue practice needed!
  } {}
  #IF (@myclass="ranger") {
    #VAR findranger 1
    #SHOW %ansi( bold,white)Level checked, Ranger practice needed!
  } {}
  #IF (@myclass="MC") {
    #VAR findrogue 1
    #SHOW %ansi( bold,white)Level checked, Rogue practice needed!
  } {}
  #IF (@myclass="FC") {
    #VAR findrogue 1
    #SHOW %ansi( bold,white)Level checked, Rogue practice needed!
  } {}
  #VAR mudresponse 0
}
  #IF (@presentlvl=3) {
    practime
  } {}
  #IF (@presentlvl=4) {
    #SHOW %ansi( bold,white)Level checked, no practice needed!
  } {}
  #IF (@presentlvl=5) {
    #VAR findranger 1
    #SHOW %ansi( bold,white)Level checked, Ranger practice needed!
  } {}
  #IF (@presentlvl>5) {
    #SHOW %ansi( bold,white)Level checked, no practice needed!
  } {}
}
#TR {You are a (*) year old male human myclass~.} {
  #VAR mudresponse 1
}
#TR {You have got &mypracs practice sessions left} {
  #IF (@mypracs>4) {score} {#SHOW %ansi( bold,white)Level checked, no practice needed!}
}
#CLA 0
#CLASS {MasterControl|AutoPilot|SomeWhereToGo}
#ALIAS setwalk {
  #IF (@setpath) {
    #VAR fullroute %pathexpand(@speedroute)
    #VAR setpath 0
  } {
    #VAR speedroute %walk( @desttgt, -1)
    #VAR fullroute %pathexpand(@speedroute)
  }
  #VAR howfar %numitems(@fullroute)
  look
  #WHILE (@howfar>0) { 
    #VAR roomloaded 0
    #VAR takeastep %pop(fullroute)
    #VAR roominuse 0
    #IF (@sitting) {
      #UNTIL (!@sitting) {#WA 5000}
    } {}
    @takeastep
    #VAR whereami %roomname(,[])
    #SHOW %ansi( bold,white)you are at @whereami
    #MATH howfar @howfar-1
    #UNTIL (@roomloaded) {#wa 100}
    #IF (@xping)  {
      #UNTIL (@roomclear) {
        #WA 2000
      }
    } {}
    #IF (@howfar=0) {
      #SHOW %ansi( bold,white)You have reached your destination!
          } {}
    #IF (@recheckneeded) {
      #SHOW %ansi( bold,white)You need to set a new destination!
    } {}
  }
}
#TR {^(*) HP:&health MV:&movepoints >} {
  #IF (@movepoints="Full") {
    #VAR mvp 7
  }
  #IF (@movepoints="Fresh") {
    #VAR mvp 6
  }
  #IF (@movepoints="Fresh") {
    #VAR mvp 5
  }
  #IF (@movepoints="Tiring") {
    #VAR mvp 4
  }
  #IF (@movepoints="Winded") {
    #VAR mvp 3
  }
  #IF (@movepoints="Weary") {
    #VAR mvp 2
  }
  #IF (@movepoints="Haggard") {
    #VAR mvp 1
  }
  #IF (@mvp<=2 AND !@sitting) {
    #VAR sitting 1
    sleep
    #Until (@mvp>=4) {
      #WA 50000
      score
    }
    #VAR sitting 0
    wake
    stand
  } {}
}
#TR {^~[ obvious exits: (*) ~]$} {#VAR roomloaded 1}
#TR {It is pitch black~.~.~.$} {
  #MOVE @takeastep
  #VAR roomloaded 1
  #IF (@xping) {
    ti
    #IF (@time>9 AND @mornorafter="pm") {
      #VAR sitting 1
      rest
    }
#IF (@time<7 AND @mornorafter="am") {
      #VAR sitting 1
      rest
    }
  } {}
}
#TR {It is (%d) o'clock (%w)} {
  #VAR time %1
  #VAR mornorafter %2
}
#TR {The sun rises} {
   #IF (@sitting) {
      stand
      look
      #VAR sitting 0
   } {}
}
#TR {The room is cleared of all enemys worth killing!$} {#VAR roomclear 1}
#CLA 0
#CLA {MasterControl|AutoPilot|PracticeTime}
#AL freshstart {
  #VAR findranger 1
  #SHOW %ansi( bold,white)Level checked, Ranger practice needed!
}
#AL pracwarrior {xxxxxxxxxxxxxx}
#AL pracranger {xxxxxxxxxxxxxxx}
#TR {You have got (%d) practice sessions left} {#VAR mypracs %1}
#TR {Lets practice!$} {
  #IF (@presentlvl=1) {
    pr ride
    #WA 50
    pr ride
    #WA 50
    pr ride
    #WA 50
    pr survival
    #VAR firstprac 1
  } {}
  #IF (@presentlvl=5) {
    #IF (@myclass="warrior") {
      #VAR findwarrior 1
      #SHOW %ansi( bold,white)Level checked, Warrior practice needed!
    } {}
    #IF (@myclass="rogue") {
      #VAR findrogue 1
      #SHOW %ansi( bold,white)Level checked, Rogue practice needed!
    } {}
    #IF (@myclass="ranger") {pracranger}
    #IF (@myclass="MC") {
      #VAR findrogue 1
      #SHOW %ansi( bold,white)Level checked, Rogue practice needed!
    } {}
    #IF (@myclass="FC") {
      #VAR findrogue 1
      #SHOW %ansi( bold,white)Level checked, Rogue practice needed!
    } {}
  } {
    #SHOW %ansi( bold,white)Practices all finished!
  }
  #IF (@presentlvl=3) {
    #IF (@myclass="warrior") {pracwarrior} {}
    #IF (@myclass="rogue")  {
      prac
      #WHILE ( @mypracs>0) {
        pr short blades
        pr dodge
        #MATH mypracs @mypracs-2
      }
      #SHOW %ansi( bold,white)Practices all finished!
    } {}
    #IF (@myclass="MC") {pracrogue} {}
    #IF (@myclass="FC") {pracrogue} {}
  } {}
  #IF (@presentlvl=5) {
    #IF (@firstprac) {
      #VAR findrogue 0
      prac
      #WHILE (@mypracs>0) {
        pr short blades
        pr dodge
        pr attack
        #MATH mypracs @mypracs-3
      }
      #SHOW %ansi( bold,white)Practices all finished!
    } {
      pr ride
      #WA 50
      pr ride
      #WA 50
      pr ride
      #WA 50
      pr survival
      #VAR firstprac 1
    }
  } {}
}
#CLA 0
#CLASS {MasterControl|AutoPilot|EatDrink}
#VAR food {meat}
#VAR foodcont {pouch}
#VAR water {flask}
#VAR watercont {belt}
#AL setfood {
  #VAR food %1
  #SHOW %ansi( bold, white)Your food is set as @food
}
#AL setfoodcont {
  #VAR foodcont %1
  #SHOW %ansi( bold, white)Your @food is stored in your @foodcont
}
#AL setwater {
  #VAR water %1
  #SHOW %ansi( bold, white)Your water is kept in a @water
}
#AL setwatercont {
  #VAR watercont %1
  #SHOW %ansi( bold, white)Your @water is stored in your @watercont
}
#AL getwater {
  #IF (@watercont="belt") {
    rem @water
    fill @water winespring
    wear @water
    #SHOW %ansi( bold, white)You have refilled your @watercont
  } {
    get @water @watercont
    fill @water winespring
    put @water @watercont
    #SHOW %ansi( bold, white)You have refilled your @watercont
  }
}
#TR {It's empty~.$} {
  #VAR recheckneeded 1
  #VAR nowaterleft 1
}
#TR {^(*)You cut (*) slices of meat} {
  #CLA FoodCheck 1
  #VAR foodcount 0
  exa @foodcont
}
#TR {You are thirsty} {
  #IF (@watercont="belt") {
    rem @water
    dr @water
    wear @water
  } {
    get @water @watercont
    dr @water
    put @water @watercont
 }
}
#TR {You are hungry} {
  get @food @foodcont
  eat @food
}
#TR {You only had (*) meat you have now restocked your} {
  #CLA FoodCheck 0
}
#TR {You all ready have (*) meat} {
  #CLA FoodCheck 0
}
#CLA 0
#CLA {MasterControl|AutoPilot|EatDrink|FoodCheck}
#TR {(*) meat (*)} {
  #WA 250
  #IF (!@foodcount) {
    #VAR foodcount 1
    get meat
    get meat
    put meat @foodcont
    put meat @foodcont
    #SHOW %ansi( bold, white)You only had @foodcount meat you have now restocked your @foodcont
  }
}
#TR {^(*)~[&foodcount~] (*) meat} {
  #WA 200
  #MATH foodcount @foodcount+1
  #IF (@foodcount<=3) {
    get meat
    get meat
    put meat @foodcont
    put meat @foodcont
    #SHOW %ansi( bold, white)You only had @foodcount meat you have now restocked your @foodcont
  } {
    #SHOW %ansi( bold, white)You all ready have @foodcount meat
  }
}
#TR {You have refilled your} {}
#TR {You eat the meat} {}
#CLASS 0
#CLA {MasterControl|AutoPilot|LetsXP}
#VAR enemysonpage {}
#VAR alloweddangervalue 2
#VAR killvalue 0
#VAR bestsofar 0
#VAR temptgt {}
#VAR minimumkillvalue 0
#VAR chasing 0
#VAR blank {}
#VAR dead {}
#AL idv {
  #MATH alloweddangervalue @alloweddangervalue+1
  #SHOW %ansi( bold, white)Allowed Danger Value set to @alloweddangervalue
}
#AL ddv {
  #MATH alloweddangervalue @alloweddangervalue-1
  #SHOW %ansi( bold, white)Allowed Danger Value set to @alloweddangervalue
}
#AL imkv {
  #MATH minimumkillvalue @minimumkillvalue+1
  #SHOW %ansi( bold, white)Minimum Kill Value set to @minimumkillvalue
}
#AL dmkv {
  #MATH minimumkillvalue @minimumkillvalue-1
  #SHOW %ansi( bold, white)Minimum Kill Value set to @minimumkillvalue
}
#AL bestkillvalue {
  #IF (@bestsofar<@killvalue) {
    #VAR bestsofar @killvalue
    #VAR tgt @temptgt
    #VAR fleename @tempfleename
    #VAR enemysonpage %push( @tgt, @enemysonpage)
  } {
    enemysonpage=%additem( @temptgt,@enemysonpage)
  }
}
#TR {^A (%w) brown deer eyes you nervously} {
  #VAR temptgt %1
  #VAR tempfleename {deer}
  #VAR dangervalue 2
  #VAR killvalue 3
  #IF (!@roominuse AND @dangervalue <= @alloweddangervalue AND @killvalue >= @minimumkillvalue) {bestkillvalue} {}
}
#TR {^A young and strong (%w) is here} {
  #VAR temptgt %1
  #VAR tempfleename %1
  #VAR dangervalue 3
  #VAR killvalue 4
  #IF (!@roominuse AND @dangervalue <= @alloweddangervalue AND @killvalue >= @minimumkillvalue) {bestkillvalue} {}
}
#TR {^A young (%w) begins to thicken with age} {
  #VAR temptgt %1
  #VAR tempfleename %1
  #VAR dangervalue 2
  #VAR killvalue 5
  #IF (!@roominuse AND @dangervalue <= @alloweddangervalue AND @killvalue >= @minimumkillvalue) {bestkillvalue} {}
}
#TR {^A handsome (%w) stands here} {
  #VAR temptgt %1
  #VAR tempfleename %1
  #VAR dangervalue 5
  #VAR killvalue 6
  #IF (!@roominuse AND @dangervalue <= @alloweddangervalue AND @killvalue >= @minimumkillvalue) {bestkillvalue} {}
}
#TR {{A|An|The} (*) (%w) is dead~!(%s)R~.I~.P~.} {
  #VAR dead %2
  #IF (@dead = @fleename) {
    #CLA Butcher 1
    bc
  } {}
  #CLA Butcher 0
  #IF (@dead=@fleename) {
    #IF (@chasing) {
      #PA fleeroute
      #RE fleeroute
      #VAR chasing 0
    } {}
  } {}
  #VAR tgt {}
  #VAR waste %pop(enemysonpage)
  #VAR anyoneleft %numitems(@enemysonpage)
  #IF (@anyoneleft>0) {
    #IF (@recheckneeded) {
      #VAR roomclear 1
      #SHOW %ansi( bold,white)The room is cleared of all enemys worth killing!
    } {}
    #VAR bestsofar 0
    #VAR enemysonpage {}
    look
  } {
    #VAR roomclear 1
    #SHOW %ansi( bold,white)The room is cleared of all enemys worth killing!
  }
}
#TR {(%w) leaves (%w)} {
  #VAR fleeitem %1
  #VAR fleedirection %2
  #IF (@tgt=@blank) {
    #SHOW %ansi( bold,white)Not my target!
  } {
    #IF (@fleeitem=@fleename) {
      @fleedirection
      #IF (!@chasing) {
        #VAR chasing 1
        #MA 
      } {}
    } {}
  }
}
#TR {~[ obvious exits: (*) ~]$} {
  #WA 200
  #VAR anyoneleft %numitems(@enemysonpage)
  #IF (@anyoneleft>=1) {
    k @tgt
    #VAR roomclear 0
  } {
    #VAR roomclear 1
    #SHOW %ansi( bold,white)The room is cleared of all enemys worth killing!
  }
}
#TR {Hit who~?$} {
  #VAR enemysonpage {}
  #VAR bestsofar 0
  #VAR dead {}
  #VAR tgt
  #VAR anyoneleft 0
  l
}
#TR {They aren't here~.$} {
  #VAR enemysonpage {}
  #VAR bestsofar 0
  #VAR dead {}
  #VAR tgt
  #VAR anyoneleft 0
  l
}
#CLASS 0
#CLA {MasterControl|AutoPilot|WhoAreYou}
#VAR gottcha {}
#VAR Char.Name {}
#AL showdetails {
  #SHOW %ansi( bold, white)@gottcha is already using this room
  #VAR roominuse 1
  }
#AL getdetails {
  #VAR Char.Name %addItem(@gottcha, @char.name)
  whois @gottcha
  #VAR roominuse 1
  }
#TR {^(%w) of (*) is standing here} {
  #VAR gottcha %1
  #IF (%ismember(@gottcha, @char.name)) {showdetails} {getdetails}
  }
#TR {^(%w) of (*) is here, fighting a} {
  #VAR gottcha %1
  #IF (%ismember(@gottcha, @char.name)) {showdetails} {getdetails}
  }
#TR {~*(%w)~*}  {
  #VAR gottcha %1
  #IF (%ismember(@gottcha, @char.name)) {showdetails} {getdetails}
  }
#TR {~*(%w)}  {
  #VAR gottcha %1
  #IF (%ismember(@gottcha, @char.name)) {showdetails} {getdetails}
  }
#CLA 0
#CLA {MasterControl|AutoPilot|LetsXP|Butcher}
#VAR weapon {shortblade}
#AL bc {
  #VAR count 0
  #IF (@Weapon="shortblade") {
    butcher corpse
    dropmeat
  } {
    sw
    rw
    draw dagger
    wield dagger
    butcher corpse
    dropmeat
  }
}
#TR {^You don't see that here (*)} {
  #IF (@Weapon="shortblade") {
    #VAR butcherfin 1
  } {
    #VAR butcherfin 1
    sheath dagger
    rem dagger
    dw
    ww
  }
  #ECHO %ansi( bold, white)You cut @count slices of meat
}
#TR {^You have very little idea on how to go about butchering it(*)} {fin}
#TR {^(*)You can't figure (*)} {
  #IF (@Weapon="shortblade") {
    #VAR butcherfin 1
  } {
    #VAR butcherfin 1
    sheath dagger
    rem dagger
    dw
    ww
  }
  #ECHO %ansi( bold, white)You cut @count slices of meat
}
#TR {^(*)You lean over and carve (*)} {
  #MATH count @count+1
  butcher corpse
  drop meat
  }
#CLA 0





Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Apr 16, 2008 5:58 pm   
 
My first thought is "good god, that's an awful lot of code" and a lot of it seems to be repeating itself. If you used aliases and functions rather than repeating the code, you'd save yourself some work making changes. Same if you combine triggers into one.

Also, the only time you need to begin or end a pattern with * is when your trigger is using one of the #sub commands to replace the whole line. Matches can start anywhere on the line and don't need to end at the end of the line, so they're completely superfluous and cause a lot of slowdown. Don't use them.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Wed Apr 16, 2008 7:10 pm   
 
A couple things on first glance.

#IF (@sitting) {#UNTIL (!@sitting) {#WA 5000}} {}
You are not required to actually put the second set of {} if it is blank.
Yes I know that you are up to speed on the fact that (@sitting) is equivalent to (@sitting==1).
It does make code much more readable if you actually spell it out.
It also helps when you do things like (!@sitting).
I know WHY it works but it always scrambles my brain. It would be much easier read as (@sitting!=1).

Next, you have made heavy use of the #until and #wait commands...
While it is the most direct way of thinking about the problem #wait and #until are not the best way to handle a situation when you are waiting.

A better way to handle situations where you have #until (@thing) {#wait}
Is to create a permanent Alarm that contains the remainder of the code within it and an IF statement.

#alarm "waitForStand" .501 {#if (!@sitting) {Go to whatever or do whatever;#T- waitForStand} {}}

Then you would enable the alarm which would check itself every however long and IF @thing is true it then does the rest of the script and disables itself.

#VAR whereami %roomname(,[])
The parser would really prefer you wrote this as below.
#VAR whereami %roomname( )

Just a couple things that I saw but changing them could be a lot of work.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
meyn
Beginner


Joined: 06 Mar 2008
Posts: 27

PostPosted: Wed Apr 16, 2008 7:57 pm   
 
Thanks for the advice guys, im copying and editing to a new file at mo so i'll incorparate changes as i do it.

I've been adding subclasses 1 at a time so i can check them as i add them but the code does get messy so have to keep re-writting every so often to compact it. just need to add code for horses, torches and when to increase decrease danger and minkillvalue and its finished(plus add enemy triggers just got 4 for while im testing)

where there are 2 triggers detecting the same patern, i have done this to cut down active code, not all classes are on a same time I.E #CLA LetsXP is the biggest so while traveling
and not xp'ing i dont want to be wading through the script everytime i change room, meanwhile the other trigger will still actived all travel needs. there is probably lots of doubling that still that i will remove as editing

hadn't looked at functions before they look like they could save a lot of code i'll see what i can do with them. Thought i might try some #CASE statements to get rid of some of the repaeted #IF statments aswell.

I've been looking at the #ALARM recently, i've seen in the forums a few times that its always better to use #ALARM rather than wait. I'm still not quite sure on the proper way to use this function, i'll have a mess around and see what i can do

Thanks agian for all comments :)
Reply with quote
omniwing
Beginner


Joined: 02 Jun 2006
Posts: 19

PostPosted: Wed Apr 16, 2008 11:15 pm   
 
Indeed, thank you for the replies. I will search and try to re-write my bot using the built in pathing as suggested. Thanks again for the feedback!
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