Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Tue Sep 06, 2016 5:48 am   

Need help figuring this out.
 
trying to create an alias that simply put creates two aliases with same name but in differant classes

makebot <arg>
Code:

#VA Bot %1 "3K_BOT"
#VA BotName {%concat(@Bot"bot")} "3K_BOT"
#VA ProperName {%proper(@Bot)} "3K_BOT"
#VA BotLoop {%concat(@ProperName"_Loop")} "3K_BOT"
#ALIAS @BotName {#T+ NoBot;#STOP @BotLoop;#STEP;BotStatus = COMPLETE;#T- Bot;#T- akill;#T- walk} "Bot"
#ALIAS @BotName {#T+ Bot;#T+ walk;#T+ akill;#SLOW @BotLoop;#PAUSE;BotStatus = ACTIVE;#T- NoBot} "NoBot"


for the most part it works... untill it gets to the #STEP/#SLOW portions where it doesn't create the aliases with the @BotLoop value but @BotLoop itself... and an extra space.[/code]
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Tue Sep 06, 2016 1:12 pm   
 
I see a syntax issue in your %concats:

%concat(@Bot"bot")

should be

%concat(@Bot, "bot")

Looks like you have a series of variables already and you want to reference one of those on the fly?
I am not sure why you would need to be creating new aliases on the fly though.
That will seriously clutter things up, eventually.
Are you ever going to have more than one bot running at a time to need to be able to turn them on and off individually?
The use of one master variable suggests not.
Perhaps you can explain what you are doing?
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Tue Sep 06, 2016 11:03 pm   
 
well when i tried to nest the fucntions into one simple string and a single variable it would do pretty much the same thing

%concat(%proper(@BotName),"Bot") ... This one worked and made "templebot"

%concat(%proper(@BotName),"_Loop") ... this ont would #SLOW %concat(%proper(@BotName),"_Loop") instead of "#SLOW Temple_Loop"

yes I was attempting to just create dual aliases to turn the bot on/off don't exactly need a new one for each area but it lets me keep it organized in my head.
If it will work to just create a master on/off alias that only requires the <path> arg then awesome.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Wed Sep 07, 2016 12:15 pm   
 
I would just call the two aliases 'botting' and not keep redefining them over and over. (Since they all do the same code anyway)

Also #STOP and #STEP one after the other doesn't do much, there is nothing left for the #STEP to reference after you #STOP
By the same token, if you immediately #PAUSE after starting the #SLOW.... you must have another trigger that handles individual steps.
Ideally #STEP is used to continue after you #PAUSE.

Code:
#ALIAS botting {
  #T+ NoBot
  #STOP @botloop
  BotStatus = COMPLETE
  #T- Bot
  #T- akill
  #T- walk
} "Bot"

#ALIAS botting {
  #T+ Bot
  #T+ walk
  #T+ akill
  #SLOW @BotLoop
  #PAUSE
  BotStatus = ACTIVE
  #T- NoBot
} "NoBot"

#ALIAS makebot {
  $bot=%proper(%1)
  #VA BotName {%concat($bot, "bot")} "3K_BOT"
  #VA BotLoop {%concat($bot, "_Loop")} "3K_BOT"
}


I am curious as to why there are 4 classes that are all getting toggled, but that's beside the point.
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Wed Sep 07, 2016 9:17 pm   
 
I have never created a bot before so this is kind of an excersize in abiltiy, plus its been ages since I've worked with cmud so alot of the command structure is rusted in my noodle. :)

Mostly the bot is based off of this post .. http://forums.zuggsoft.com/forums/viewtopic.php?t=17006 .. with some major re-edits to get some features to work with more current version of cmud.
I have also included two new classes "Bot" and "NoBot" which essentially house duplicate triggers, with specialized values... "You killed.." example NoBot version doesn't include the toggles for #T+/- akill, walk as listed in that post.

It works great so far, and a few of my friends are interested in using it, so I was just trying to make a few extra QoL tweaks and ease of use/setup items... hince this alias i'm having trouble with.

tried your blurb above and works perfectly... Thank you!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Thu Sep 08, 2016 11:35 am   
 
Instead of duplicate settings, why not an #IF statement in a single trigger to decide which route to take?
Based off your @BotStatus variable perhaps.
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Thu Sep 08, 2016 5:59 pm   
 
Already using more nested #IF's then I probably should safely be using, after a certain point it gets a touch complicated to debug 3-4 layers in.

Although I do like that idea... reviewing what I can and will attempt to trim down as much as possible. I'd offer to show the XML for any advice but rather cover thins bit by bit.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Fri Sep 09, 2016 1:23 am   
 
If you are nesting them, you are likely better off with a #SWITCH.
Show me an example and we can see if we cant make it more simple.

Also, if your named triggers are running of an #IF on a variable value, or if they are inside the #CLASS (folder) that gets disabled, you wouldn't have to turn them off individually.
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Fri Sep 09, 2016 2:23 am   
 
as per request... this one is a tad complex to explain ...
@PlayerPresent's state is determined by a seperate trig that uses %ismember(@PName,@Whitelist) true if NOT on that list False if player is on list (and thus safe to bot around)
rest of it should be easy to figure out. (i think this is the worst of my nesting) ** class/guild I play has a sever vulnerabilty to Mind dmg, and Dolphins do that, hince the #IF for them.
Code:
#T- walk
#SUSPEND a1
#IF (@PlayerPresent == 1) {
    #ALARM a1 {+2} {
      #STEP
      #PAUSE
    }
    #ALARM pause {+1} {#T+ akill}
    PlayerPresent = 0
  }
  {
    #IF (@Monster == Dolphin) {
      #ALARM a1 {+2} {
        #STEP
        #PAUSE
      }
      PlayerPresent = 0
      #T+ walk
      #ALARM pause {+1} {#T+ akill}
      }
      {
        k %lower(@Monster) 1
      }
  }
#T- akill
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Fri Sep 09, 2016 12:25 pm   
 
Not the ugly nested #IF i was expecting

@playerPresent is getting redefined as 0 in both halves of your #IF statement.
As such it could be moved outside the #IF altogether and be down at the bottom with the #T-

Also, your #ALARM syntax is not as tight as it could be, the ID portion is best wrapped in double quotes.
also #ALARMS with a + number pattern will only ever fire once, not much need to #SUSPEND them, especially as you don't have a #RESUME anywhere

I see no logical errors, but possible oversights may include:
You don't {#T+ walk} when there is @playerPresent.
You don't seem to account for more than one @playerPresent

Code:
#T- walk
#T- akill
#IF ((@PlayerPresent>0) OR (@Monster == Dolphin)) {
  #ALARM "a1" {+2} {
    #STEP
    #PAUSE
    }
  #ALARM "pause" {+1} {#T+ akill}
  PlayerPresent = 0
  #T+ walk
  } {k %lower( @Monster) 1}
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Fri Sep 09, 2016 9:48 pm   
 
Well I kinda realised its not the bot IF's that are terribly nested but some of my GUI/HUD triggers which are just cosmetic really and fairly unimportant for this topic.

Let me clean out a few personalized settings and i'll export the bot to xml and send it as an attachment in PM if you wish, and only if you wish.

accounting for multiple players is something I hadn't yet consideredand I belive I can account for it fairly easily... maybe
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Sat Sep 10, 2016 12:26 am   
 
Little note for this bit of code
Code:
#SUSPEND a1
#T- walk
#T- akill
#IF ((@PlayerPresent>0) OR (@Monster == Dolphin)) {
  #ALARM "a1" {+2} {
    #STEP
    #PAUSE
    }
  #ALARM "pause" {+1} {#T+ akill}
  PlayerPresent = 0
  #T+ walk
  } {k %lower( @Monster) 1}


and in testing it triggers the kill portion then immediately #steps mid combat. **fixed it by re-adding the <#SUSPEND a1> command**
the only reason I have the "pause" alarm is to re-enable akill if player or dolphin is detected.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sat Sep 10, 2016 3:44 am   
 
I don't see why "a1" would be firing mid-combat.
..unless "akill" or another setting is also issuing #STEP commands, so that "a1" is lingering over from a previous room when combat starts.
In which case is a redundancy/timing issue.
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Sat Sep 10, 2016 4:52 am   
 
look at the link to the post, that I based the bot on. I've essentially used that setup, with edits to each trigger based on monsters for specifc mud... as well as the "you killed" trigger
other then that... very minor tweaks. only running the bot off of the one alias you provided previously, but having to keep 3-5 areas primed for botting due to kill speed, mob count, and other players if its a public area verses an instanced area.

upon entering a room or "look" command is issued from "You killed..." trigger
Code:
PATTERN
^(?: >)\sThere ?:is|are .* obvious ?:exit|exits\:*

VALUE
#ALARM a1 {+2} {
  #STEP
  #PAUSE
  }
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sat Sep 10, 2016 1:16 pm   
 
Instead of redefining a1 all the time, why don't we turn into a permanent alarm {-2}
Then you just need to make sure the room is empty on the post-kill aspect and #RESUME it.
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sat Sep 10, 2016 2:42 pm   
 
Something like this would only fire when you are botting, and your #PATH has not yer finished:

#ALARM "botWalker" {-2} {#IF ((@BotStatus = ACTIVE) AND (%nextdir)) {#STEP;#PAUSE}}
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Sat Sep 10, 2016 9:11 pm   
 
Just so I fully understand, that line will negate all other #ALARM's for "a1" and will no longer require the 'walk' class ?

so when "You killed" fires it will 'look' and see nothing to attack and allow alarm to continue...

as it stands it's working, just not wanting to make changes that i don't fully comprehend incase i mess up. I do make backps before changing anything to be safe.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sun Sep 11, 2016 1:49 am   
 
That was the idea yes.
And no one is forcing you to change it.
It was just an idea.

The obvious exit trigger might still be useful, to reset your @monster and @playerPresent variables, depending on if that line comes before the living things or not.
But no need for it to be in that one specific class.
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Sun Sep 11, 2016 2:24 am   
 
I'm totally willing to make the changes that clean up and stream line the bot concept.
Plus it is teaching me and expanding my code knowledge greatly.

I really do appreciate the help in this regard.
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Sun Sep 11, 2016 7:40 am   
 
As a side topic, Hope you understand regex cause I am failing to figure this one out... I previously stated one of my trigs/regex as the following

^There ?:is|are .* obvious ?:exit|exits\:*

based on my understanding the above should pattern match the two following possible lines of text.

There is one obvious exit: direction DOESN'T MATCH
-or-
There are * obvious exits: direction, direction, direction, etc MATCHES
* could be two|three|four|five|etc

just assuming I don't know enough about regex or i'm doing something horribly wrong.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sun Sep 11, 2016 11:31 am   
 
I was never good at doing regex patterns myself, but i can convert it easily enough.

Code:
#TR {There {is|are} %w obvious exit{s|}:} {
  playerPresent=0
  monster=""
  #IF (@BotStatus = ACTIVE) {
    #SUSPEND botWalker
    #ALARM "emptyChecker" +2 {#IF (@monster=%null) {#RESUME botWalker}
  }
}


This gives two seconds for other triggers to be able to populate @monster, before rechecking its value.
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sun Sep 11, 2016 8:20 pm   
 
Of course, you could just as easily substitute #PAUSE for #SUSPEND and #STEP for #RESUME and bypass the need for "botWalker" at all.
You might want to put the mapper into safe mode first, so it doesn't throw the entire #PATH to the game at once.
_________________
Discord: Shalimarwildcat
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Sep 12, 2016 12:14 am   
 
If you want to use a regex the correct one would be
^There (?:is|are) \w+ obvious exits?:

Modifiers like plus, asterisk, and question mark operate on the symbol directly before them so 's?' makes the 's' optional and '\w+' make the '\w' builtin group repeat one to infinite times. Parenthesis normally mark the beginning or end of a capture group but a question mark as the first symbol stops the group from being a capture and begins other special option like look-ahead, look-behind, or a simple alternation group.

Naked alternation like you had is the term for an alternation not contained in a grouping and creates alternation on the whole pattern level. Your pattern would have matched either of these lines:
^There ?: is
are .* obvious ?:exit
exits\:*

Meaning "There:is" would match as well as "There :is" but " There:is" would not. There anchor is not carried to the alternates the last alternate would have matched "exits:::::::::::::::" as well as "exits" at any point in the line.

If you want to capture the directions for use in the script, which you are not currently doing:
^There (?:is|are) \w+ obvious exits?: (.*)$
Some MUDs can also have rooms with no obvious exits "There are no obvious exits.":
^There (?:is|are) \w+ obvious exits?[:\.]
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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