Help with a MUSHClient Trigger

Posted by Chefmonk on Thu 02 Apr 2020 01:24 AM — 4 posts, 14,449 views.

#0
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!
Australia Forum Administrator #1

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
#2
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
Australia Forum Administrator #3

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