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.
Entire forum
➜ MUSHclient
➜ General
➜ Trigger / Script Question : Targetting / Auto-Attack
Trigger / Script Question : Targetting / Auto-Attack
|
You need to log onto the forum to reply or create new threads.
Refresh page
Posted by
| Mattrious
(6 posts) Bio
|
Date
| Mon 04 Nov 2024 09:07 PM (UTC) |
Message
| Good afternoon,
I am sure this has been asked a few time over the years, and I can assure you that I've dug through the all forums and posts over the years. Watched some of Nick's videos and exhausted ChatGPT to the point I think they're going to cancel my subscription.
I am trying to figure out to setup a pretty straight forward script where, I set a target and then when I walk into a room with an NPC, the client will issue some sort of attack or other command, etc.
I can get the targetting stuff setup with variables without issue. Though, I am trying to figure out how to setup an auto-attack feature (use a 'charge' or 'kill' etc).
So recalling back to Nick's video back from 2009 -- I easily got the process setup of setting a target, and then easily creating an alias to inititate a command.
My goal, is to take that one step further and as I walk into a room, the client would see <NPC is here> and then if it matches the target, it would attack.
[Exits: north east south west]
There is a goblin here, lazing behind a pile of recently gathered stones.
There is a goblin here, lazing behind a pile of recently gathered stones.
So pasted above is just the exits and then mobs (not the full room name, description or ASCII map).
The goal would be to set goblin as a target, and when my character walked into the room, it would attack the goblin.
Is there a way to do this? I can get triggers and such to work easily with:
You are thirsty.
<drink cup>
I just can not figure out how to get the client to attack a create or mob that I run into while walking. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #1 on Tue 05 Nov 2024 03:19 AM (UTC) |
Message
| Didn't I cover that in the tutorials?
Assuming you have a targetting alias that saves the target into a variable (which is certainly mentioned in the tutorials), say call the variable "target", then make a trigger:
Match on: There is a @target *
Expand variables: checked
Send: kill @target |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Mattrious
(6 posts) Bio
|
Date
| Reply #2 on Tue 05 Nov 2024 09:23 PM (UTC) |
Message
|
Nick Gammon said:
Didn't I cover that in the tutorials?
Assuming you have a targetting alias that saves the target into a variable (which is certainly mentioned in the tutorials), say call the variable "target", then make a trigger:
Match on: There is a @target *
Expand variables: checked
Send: kill @target
If you did, I must have missed it. I watched your relatively straight forward of creating a target and setting up variables -- but couldn't find anything that set upt he autoattacking piece. I'll go back and do a bit more digging a long with what you've provided here. Thank you as always Nick. Hope you're doing well. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #3 on Wed 06 Nov 2024 05:59 AM (UTC) |
Message
| That was what I was talking about ... creating a target variable. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Mattrious
(6 posts) Bio
|
Date
| Reply #4 on Wed 06 Nov 2024 01:19 PM (UTC) |
Message
|
Nick Gammon said:
That was what I was talking about ... creating a target variable.
I understand. I created the variable and had no issue with that. I was just a bit confused on creating a system where a trigger/script would see said target in a room as I am walking and inititate an attack command, such as kill, charge, etc.
I do have one additional question. Is there a way to make the trigger dynamic? So that @target will just fire on a single keyword and not have to see a string like:
A @target is *
The @target *
Something like (?i)\b@target\b
I've been playing around with it and can not get that puiece to work, so I need to edit the @target string for different NPCs that have different short-descriptions, etc. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #5 on Wed 06 Nov 2024 08:34 PM (UTC) Amended on Wed 06 Nov 2024 08:35 PM (UTC) by Nick Gammon
|
Message
|
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="(?i)^There is .* \b@target\b"
regexp="y"
sequence="100"
>
<send>kill @target</send>
</trigger>
</triggers>
|
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
A bit of testing showed that you need to match on more than just the target name, otherwise it will match every time the target appears in the output (eg. "you attack the gnoll", "you punch the gnoll", "the gnoll dies") would all cause the trigger to fire again, unwanted. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Mattrious
(6 posts) Bio
|
Date
| Reply #6 on Thu 07 Nov 2024 02:01 AM (UTC) |
Message
| Awesome! Thank you for this Nick. You're a rockstar -- and much appreciated for all the work you've done with this software over the years. | 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.
502 views.
You need to log onto the forum to reply or create new threads.
Refresh page
top