Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Help with a MUSHClient Trigger

Help with a MUSHClient Trigger

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Chefmonk   (2 posts)  Bio
Date Thu 02 Apr 2020 01:24 AM (UTC)
Message
Hey all,

I have a large lack of knowledge for any real coding. I've gone through the Help Files from google and tried to find what I'm looking for, though I need further help.

I play a MUSH which has a pretty basic combat system. I want an idle targeting trigger to use while I'm doing stuff on my other screen and following other players. As such, I set up this trigger:

TRIGGER: * prepares for combat with *.
SEND TO WORLD: TARGET %1

(Target is automatically attacking whoever the creature prepares for combat with)

It works great, it will target whichever creature comes up in the MUSH output while following people. The issue I have is that:

1) I don't want it to accidentally target player characters (most NPCs use an L<#> to indicate level, for example, L16 Velociraptor prepares for combat with YOU, so I'd love to have the option for it to ONLY target things with an L<#> in it's name).
2) It fires multiple times very quickly. So let's say there's 2 NPCs in the room, it will trigger on both of them within succession, where I only want it to target ONE of them to start with, then when that one dies, move onto the next in the room.

Here are some of the phrases from the MUSH.

L6 Dilophosaurus prepares for combat with YOU. <- This will always be a tan text, not highlight yellow.

You earn 92.582 experience points for personal combat. <- This is also always in tan yellow, and happens after each creature dies in combat.

So I would love something that would:

L6 attacks, I automatically target and combat is automatic from that point on through the MUSH anyways via combat rounds. Once L6 is dead, I would love for it to scan for other enemies, then automatically target them and move onto combat with them as well.

I'm not completely idle here, I'm generally watching both of my monitors, however, I usually play a graphical game while I'm in a party with people on the MUSH hunting, as it can be kind of boring to sit there and watch text automatically scroll by.

Thanks!
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 02 Apr 2020 02:10 AM (UTC)
Message

The first part is easy, add L to the trigger, eg.

TRIGGER: L* prepares for combat with *.

Or if that doesn’t work perfectly make a regular expression that checks for numbers, eg.

Match: ^(L[0-9]+ .+) prepares for combat with (.*)$

As for the rest you may have to put a bit of work into that.

  • Find the first mob in the room, set an “in combat” flag.
  • If the trigger matches again, either ignore it or add to a table of pending mobs to fight
  • When you detect a fight over, either re-scan the room or pull the next mob out of the table you set up earlier

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Chefmonk   (2 posts)  Bio
Date Reply #2 on Thu 02 Apr 2020 03:11 AM (UTC)
Message
So I'd assume that the other things I want to do (such as setting an "in combat" flag, etc) would be things I need to do as an LUA script, as opposed to just using a wildcard trigger? I'm going to try to learn how to code it in LUA
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 02 Apr 2020 04:36 AM (UTC)
Message

Yes. It’s Lua by the way, not LUA as it isn’t an acronym. :)

Just nit-picking. However Lua is case-sensitive so you may as well get used to concentrating on that.

There are some great tutorials on the web about using Lua. My advice is to think about how you would go about it as a human, before getting bogged down in coding. In other words make a flow-chart or at least write down on paper the conditions you are trying to test for. For example:

  • If I get a message about starting combat:
    • Is combat already started? Is so, do nothing.
    • If not, set a flag to indicate combat has started
    • Change the target variable
  • If I get a message about combat ending:
    • Clear the combat flag
    • See if there is something else to fight

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,733 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.