This might be a bit basic for most of you so many apologies. I was wandering how to set up a targetting system. By this I mean if in a fight and I am currently hitting Bill and I wish to change and hit Benjamin instead. What would be the best method of doing this without having to type: Punch Benjamin, Kick Benjamin and instead maybe type something like t1 = Benjamin to assign the name Benjamin to a variable. Then my aliases would target that variable (t1) allowing me to just type Punch, Kick and the attacks land on Benjamin. Also would I then be able to set up multiple targets and maybe cycle through them? Any ideas?
Targetting
Posted by LindZ on Tue 05 Nov 2002 02:58 PM — 23 posts, 102,180 views.
You can do that with a few aliases. To allow for multiple targets I have done the idea of first setting up your potential targets, and then choosing one.
eg.
t1 = Bill
t2 = Benjamin
t1 (choose target 1)
kick (kicks Bill)
t2 (choose target 2)
kick (kicks Benjamin)
The plugin below allows for up to 9 targets, with "kick", "punch" and "stab" actions. You can add more actions by amending the appropriate alias.
Just copy the stuff below the line and paste into a notepad window. Save as TargetSwitch.xml, and then add that into MUSHclient using the plugins dialog.
eg.
t1 = Bill
t2 = Benjamin
t1 (choose target 1)
kick (kicks Bill)
t2 (choose target 2)
kick (kicks Benjamin)
The plugin below allows for up to 9 targets, with "kick", "punch" and "stab" actions. You can add more actions by amending the appropriate alias.
Just copy the stuff below the line and paste into a notepad window. Save as TargetSwitch.xml, and then add that into MUSHclient using the plugins dialog.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, November 06, 2002, 9:25 AM -->
<!-- MuClient version 3.30 -->
<!-- Plugin "TargetSwitch" generated by Plugin Wizard -->
<!--
See: http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1947
-->
<muclient>
<plugin
name="TargetSwitch"
author="Nick Gammon"
id="2adec0ac37689537f9e3daf2"
language="VBscript"
purpose="Demonstrates switching targets"
save_state="y"
date_written="2002-11-06 09:20:06"
requires="3.23"
version="1.0"
>
<description trim="y">
<![CDATA[
Demonstrates how you can switch targets with a couple of aliases.
Usage
-----
t1 = person (set target 1)
t2 = person (set target 2)
t3 = person (set target 3) ... and so on up to 9 ...
t1 (choose target 1)
t2 (choose target 2)
t3 (choose target 3) ... and so on up to 9 ...
punch (punch target)
kick (kick target)
eg.
t1=Bill (target 1 is Bill)
t2=Benjamin (target 2 is Benjamin)
t1 (choose Bill)
kick (kick Bill)
t2 (choose Benjamin)
kick (kick Benjamin)
t1 (choose Bill again)
punch (punch Bill)
kick (kick Bill)
t2 (choose Benjamin again)
punch (punch Benjamin)
kick (kick Benjamin)
TargetSwitch:help <-- this help
]]>
</description>
</plugin>
<!-- Aliases -->
<aliases>
<alias
script="SetTarget"
match="^t([1-9])\s*\=\s*(.+)$"
enabled="y"
regexp="y"
>
</alias>
<alias
script="ChooseTarget"
match="^t([1-9])$"
enabled="y"
regexp="y"
>
</alias>
<alias
match="^(kick|punch|stab)"
enabled="y"
expand_variables="y"
regexp="y"
>
<send>%1 @target</send>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
sub SetTarget (sName, sLine, wildcards)
dim which, to_whom
which = wildcards (1)
to_whom = wildcards (2)
world.SetVariable "target" & which, to_whom
world.ColourNote "moccasin", "darkgreen", _
"Target " & CStr (which) & " now '" & to_whom & "'"
end sub
sub ChooseTarget (sName, sLine, wildcards)
world.SetVariable "target", _
world.GetVariable ("target" & wildcards (1))
world.ColourNote "moccasin", "darkgreen", _
"Target now '" & _
world.GetVariable ("target") & "'"
end sub
]]>
</script>
<!-- Plugin help -->
<aliases>
<alias
script="OnHelp"
match="TargetSwitch:help"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
World.Note World.GetPluginInfo (World.GetPluginID, 3)
End Sub
]]>
</script>
</muclient>
Thanx for the plugin Nick. Just one more quick question. How would I then use those targets in a trigger? If i have just been punched by Bob and Bob is t3-
Trigger text: Bob punches you.
Send: punch t3
Tried something similar to the above but Bob is not targetted?
Thanx again,
LindZ
Trigger text: Bob punches you.
Send: punch t3
Tried something similar to the above but Bob is not targetted?
Thanx again,
LindZ
Oh and I do realize that I could just do-
Trigger text: * punches you.
Send: punch %1
However this doesn't have the effect I require in all circumstances.
Trigger text: * punches you.
Send: punch %1
However this doesn't have the effect I require in all circumstances.
You need to set the trigger to expand variables, and then have it send: punch %t3
Unfortunately, there is no graphical interface for editing alias, trigger, variable settings for a plugin. You would need to open the trigger's xml file, and manually add the trigger code there.
You can edit the plugin quickly by opening the plugins menu in MUSHclient, selecting the plugin, then pressing the "edit" button.
If you aren't sure how the trigger code should look, you can try creating it in your main world file... Then select it from the list of triggers, click the "copy" button. Next the "remove" button to delete it from your main world. While it's still in 'clipboard' memory, go edit the plugin as described above, and "paste" the trigger code in.
Unfortunately, there is no graphical interface for editing alias, trigger, variable settings for a plugin. You would need to open the trigger's xml file, and manually add the trigger code there.
You can edit the plugin quickly by opening the plugins menu in MUSHclient, selecting the plugin, then pressing the "edit" button.
If you aren't sure how the trigger code should look, you can try creating it in your main world file... Then select it from the list of triggers, click the "copy" button. Next the "remove" button to delete it from your main world. While it's still in 'clipboard' memory, go edit the plugin as described above, and "paste" the trigger code in.
Quote:
You need to set the trigger to expand variables, and then have it send: punch %t3
You need to set the trigger to expand variables, and then have it send: punch %t3
You mean: punch @t3
Make sure "expand variables" is set.
Hi there guys. I tried the Epand variables thing and then sent: punch @t3. However this did not seem to work? As an example of one of the functions I require this to work for. Say I am preparing a spell-
I make an alias for the spell eg. alias name : pf, send : prepare fireball.
This takes a second to prepare and then the text: Fireball spell ready. Appears on screen.
I have created a trigger to pick up on: Fireball spell ready.
The trigger then sends: Cast Fireball @t3.
On the output the text: Cast Fireball appears but no target is designated?
Any ideas why this is and what I can do about it?
I make an alias for the spell eg. alias name : pf, send : prepare fireball.
This takes a second to prepare and then the text: Fireball spell ready. Appears on screen.
I have created a trigger to pick up on: Fireball spell ready.
The trigger then sends: Cast Fireball @t3.
On the output the text: Cast Fireball appears but no target is designated?
Any ideas why this is and what I can do about it?
That should certainly work.
Check you have 'expand variables' set in the "cast fireball" alias.
Also check that t3 variable is set. Look in the world configuration screen, scroll to the very last item "variables" and check it appears there.
Actually, now that I wrote that, I see a possible problem. The variables are "local" to a plugin. That is, if you are using my plugin then t3 in the plugin is not the same as t3 in the world.
One workaround is to take the alias from the main world, and click on the "copy" button, then edit the plugin and paste that alias into the aliases you see there.
ie. just after <aliases>
Then delete the alias from the main world window. That way you have moved it to the plugin. Save the plugin, go to the plugins window, select it and click "reinstall" and it should work.
Check you have 'expand variables' set in the "cast fireball" alias.
Also check that t3 variable is set. Look in the world configuration screen, scroll to the very last item "variables" and check it appears there.
Actually, now that I wrote that, I see a possible problem. The variables are "local" to a plugin. That is, if you are using my plugin then t3 in the plugin is not the same as t3 in the world.
One workaround is to take the alias from the main world, and click on the "copy" button, then edit the plugin and paste that alias into the aliases you see there.
ie. just after <aliases>
Then delete the alias from the main world window. That way you have moved it to the plugin. Save the plugin, go to the plugins window, select it and click "reinstall" and it should work.
Nick, Thanx for all the help. With the advice that you gave me I finally got the trigger to work by adding the triggers I required to the plugin. Easy when you know how huh? Ok well once again, cheers for all the support.
LindZ.
LindZ.
I see what you are doing but the MUD I play has hundreds of players. I am looking for a way to make a targetting system where I just need to type : Targ <name> for example to set the target and then I can set my attacks to reference whatever is currently set as the target.
The MUD I play (www.ACHAEA.com) has a command in game [settarget <var> <name>]to set targets but that is too much to type in the heat of battle. I am trying to find a way to make targetting quick and easy.
Any suggestions?
The MUD I play (www.ACHAEA.com) has a command in game [settarget <var> <name>]to set targets but that is too much to type in the heat of battle. I am trying to find a way to make targetting quick and easy.
Any suggestions?
If you just want to set one target it is a lot easier. Add this to your script file:
Then make a "targ" alias like this:
Then just type "targ Bill" to set your target. To make some use of this use "@target" in other triggers and aliases where you want to refer to the current target (and check "expand variables").
sub SetTarget (sName, sLine, wildcards)
world.SetVariable "target", wildcards (1)
end sub
Then make a "targ" alias like this:
<aliases>
<alias
script="SetTarget"
match="targ *"
enabled="y"
>
</alias>
</aliases>
Then just type "targ Bill" to set your target. To make some use of this use "@target" in other triggers and aliases where you want to refer to the current target (and check "expand variables").
How do I make this so I can use more attcks than just kick punch etc. I would like to use my bop attack with the targeting system.
I'm not sure what the problem is. You can make multiple aliases that all do something like: kick @target
Im not sure how to do that, I am extreamly new to this maybe you could refer me to a good tutorial on scripting, aliases, etc.
Hi,
I copied this code in my script file:
sub SetTarget (sName, sLine, wildcards)
world.SetVariable "target", wildcards (1)
end sub
Now, when I try to reload the script file, I get the following error:
Error number: 0
Event: Compile error
Description: [string "Script file"]:1: `=' expected near `SetTarget'
Called by: Immediate execution
I must say that I have no clue about scripting. But this code was something that I was searching for. And so I enabled scripting in Mushclient and set my script file, but the file is empty except the code above which I copied.
What did I do wrong?
Thanks for your help
Sarah
I copied this code in my script file:
sub SetTarget (sName, sLine, wildcards)
world.SetVariable "target", wildcards (1)
end sub
Now, when I try to reload the script file, I get the following error:
Error number: 0
Event: Compile error
Description: [string "Script file"]:1: `=' expected near `SetTarget'
Called by: Immediate execution
I must say that I have no clue about scripting. But this code was something that I was searching for. And so I enabled scripting in Mushclient and set my script file, but the file is empty except the code above which I copied.
What did I do wrong?
Thanks for your help
Sarah
You have set Lua as your script language (which is recommended), however that little bit of script is for Visual Basic (VBscript).
The Lua version would be:
However the easier thing is to "send to script" which means you don't need to use a script file at all.
To do that, use "send to script" and just do something like this:
The Lua version would be:
function SetTarget (sName, sLine, wildcards)
world.SetVariable ("target", wildcards [1])
end -- function
However the easier thing is to "send to script" which means you don't need to use a script file at all.
To do that, use "send to script" and just do something like this:
<aliases>
<alias
match="target *"
enabled="y"
send_to="12"
sequence="100"
>
<send>SetVariable ("target", "%1")</send>
</alias>
</aliases>
But, if all you want to do is set a variable, you don't need to script at all:
<aliases>
<alias
match="target *"
enabled="y"
variable="target"
send_to="9"
sequence="100"
>
<send>%1</send>
</alias>
</aliases>
Read this post if the XML code is confusing you:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4777
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4777
Many thanks for your help, I took the code in lua and now it works!
Thank you very much!
Greetings
Sarah
Thank you very much!
Greetings
Sarah
hi i have a problem with making a targeting alias. I looked at what you gave to other people and i thought i could just do that, but it seems like it didnt work. I tried
function SetTarget (sName, sLine, wildcards)
world.SetVariable ("target", wildcards [1])
end -- function
but it gave me an error when i was tryng to use the plugin to put this in.
Line 3: Expected '<', got "f" (content not permitted here) (problem in this file) is what it says
p.s i know nothing about scpriting or anything
function SetTarget (sName, sLine, wildcards)
world.SetVariable ("target", wildcards [1])
end -- function
but it gave me an error when i was tryng to use the plugin to put this in.
Line 3: Expected '<', got "f" (content not permitted here) (problem in this file) is what it says
p.s i know nothing about scpriting or anything
What you have there is a bit of script. Can you post the whole plugin? Taken out of context it is hard to see what is happening.
I think the issue is that he is using it as a plugin, and not as a script file. That is my take on the expected < but found f, message. Plugins expect XML, and scripts don't.
-Onoitsu2
-Onoitsu2