Need help with a trigger/script.

Posted by Miltazar on Sun 17 Jun 2001 06:38 AM — 9 posts, 30,250 views.

#0
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
#1
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
Australia Forum Administrator #2
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. :)


#3
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
#4
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
Australia Forum Administrator #5
You could match on something like:

*dwarf* leaves *

That would catch "a small dwarf".

#6
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
Australia Forum Administrator #7
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
Amended on Thu 21 Jun 2001 09:27 PM by Nick Gammon
Australia Forum Administrator #8
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.