Target variable attacks

Post Reply
Strachan
Posts: 6
Joined: Wed Jul 26, 2017 6:39 am

Target variable attacks

Post by Strachan »

I'm playing a Diku mud. Often aggressive mobiles attack. I would like to tell my charmed mobiles (as a magic user character) to attack those variable aggresive mobiles, as soon as they attack me. I thought of creating a regex trigger, but don't know how to stop it after the initial command.

For example:

A guard hits you.
The riverman's daughter obliterate you.
The Grip Reaper suddenly appears and totally devastate you with his attack.

Key words would be "hit" or "obliterate" or "devastate". There is quite a lot more, but just to demonstrate.

I would then have a send command to my charmie as a wildcard to attack "guard", or "daughter" or Grim Reaper". The send would look something like: "order f kill .*"

How the actual script look to set this up, and then also not to keep triggering every time i am hit? Any help will be appreciated. Sorry, I know I have a lot to learn. I have looked at quite a few examples already, and am getting some idea of the basics.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Target variable attacks

Post by Vadi »

Try watching the introductory Mudlet videos at https://www.mudlet.org/media - see how far you go? Post your attempts here :)

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Target variable attacks

Post by Belgarath »

This is probably how I would do it...
Code: [show] | [select all] lua
-- capture the last word (ie. guard, daughter, reaper)
local target = matches[2]:match("(%w+)$")

-- add any changes to the target here if necessary
local to_target = {
  ["Reaper"] = "Grim Reaper"
}

target = to_target[target] or target

-- only attack if `attacking` is set to false (or nil)
if not attacking then
  send("order f kill " .. target)
  attacking = true
end
And you could set the attacking variable to false on some generic kill message. Hope this helps.

Post Reply