[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  Need help with a trigger/script.

Need help with a trigger/script.

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


Posted by Miltazar   (7 posts)  [Biography] bio
Date Sun 17 Jun 2001 06:38 AM (UTC)
Message
I'm trying to do a script where when a mob i'm attacking flee's i follow and re-attack. but not when someone else flees, just someone i'm attacking. so i'm thinkin it'll have to set the enemy name to a variable when i attack, or am attacked, or assist. that way when it flee's it'll know thats the same mob i was attacking and follow. flee msg is on 2 lines:
A dwarven noble panics, and attempts to flee!
A dwarven noble leaves south.

any suggestions on how i could do this? I'm not up to speed on the scripting languages. Any help is appreciated. Thanks.

Miltazar
[Go to top] top

Posted by Miltazar   (7 posts)  [Biography] bio
Date Reply #1 on Sun 17 Jun 2001 06:47 AM (UTC)
Message
Was just thinking, if you use an * in the flee msg you'd need an actual keyword for the mob to initiate combat, so you'd have to parse through the wildcard and get rid of the A and An's and stuff like that, and use the first word. Or some other process...just thought i'd post that just incase. Thanks again for any help anyone provides, i REALLY need to learn more languages...would be a simple task in C or C++. Thanks again:)

Miltazar
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sun 17 Jun 2001 09:36 AM (UTC)
Message
The important thing here is to know what it is you are attacking. One way would be to make an alias, and enter the name in the alias, eg.


Alias: KILL *
Send: kill %1
Script: OnKill



The script routine could look like this:


sub OnKill (thename, theoutput, thewildcards)
world.setvariable "mobname", thewildcards (1)
end sub



Then you could make a trigger to catch the mob leaving:


Trigger: * leaves *
Script: OnMobLeaves


The script routine could look like this:


sub OnMobLeaves (thename, theoutput, thewildcards)
if world.getvariable ("mobname") = thewildcards (1) then
world.send wildcards (2)
end if
end sub


I haven't tested this, and there are probably other ways of doing it, but this is a suggestion to get you started. :)



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Miltazar   (7 posts)  [Biography] bio
Date Reply #3 on Wed 20 Jun 2001 08:28 AM (UTC)
Message
That sounds like it might work. I just started exploring scripts, usually didn't have a use for them. Would you be so kind as to tell me how to implement that? I'm just starting to learn how to script, heh. Thanks, you've been a great help, never woulda figured this out without your help.


Miltazar
[Go to top] top

Posted by Miltazar   (7 posts)  [Biography] bio
Date Reply #4 on Wed 20 Jun 2001 09:14 AM (UTC)
Message
Ok, nevermind. I think i got the hang of this scripting thing. But another question. first- how do i put in that it moves that direct AND kills the mob? and finally how do i make it so that when i type kill dwarf that it will reconize it in "A small dwarf leaves east."? is there a way to alter wildcards to a different word or some other way? If i can just get this altered it'll work. THanks:)

Miltazar
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Wed 20 Jun 2001 11:42 AM (UTC)
Message
You could match on something like:

*dwarf* leaves *

That would catch "a small dwarf".


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Miltazar   (7 posts)  [Biography] bio
Date Reply #6 on Wed 20 Jun 2001 08:43 PM (UTC)
Message
Yah but it would only work on dwarves. is there a way to include variable names within triggers? that way it would be *mobname* leaves *. Otherwise i dunno how to get it to follow a fleeing creature without it following anyone that flees.

Also on another note, in the script you put world.send thewildcards (2). How do you send commands? like kill mobname? sorry for all the trouble, still tryin to get the hang of this.


Miltazar
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Thu 21 Jun 2001 09:25 PM (UTC)

Amended on Thu 21 Jun 2001 09:27 PM (UTC) by Nick Gammon

Message
Quote:

Also on another note, in the script you put world.send thewildcards (2). How do you send commands?


You can type it literally, with the "+" sign to join words, like this:


world.send "kill " + wildcards (2) + " with sword"


Make sure you put spaces inside the quotes like I did above, so the words don't run together. You don't want something like: killdwarfwith sword

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Thu 21 Jun 2001 09:38 PM (UTC)
Message
Quote:

Yah but it would only work on dwarves. is there a way to include variable names within triggers? that way it would be *mobname* leaves *. Otherwise i dunno how to get it to follow a fleeing creature without it following anyone that flees.


You need to do this in two steps.

1. Make an alias to tell it which creature to follow
2. The alias makes a trigger that does the actual following.

Something like this:



Add alias

Alias: chase *
Send:  (nothing)
Label: Chase
Script: OnChase

Add a script function

sub OnChase (thename, theoutput, thewildcards)

' addtrigger flags
'    1 = enabled
' 1024 = replace existing trigger of same name

World.addtrigger "chase", "*" + wildcards (1) + "* leaves *", _
                 "%3", 1024 + 1, -1, 0, "", ""

End Sub



Now you type: chase dwarf

The chase alias sets up a trigger "*dwarf* leaves *" so if the dwarf leaves East you follow it.



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


19,492 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]