Register forum user name Search FAQ

Gammon Forum

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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Substituting output with a variable

Substituting output with a variable

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


Posted by Soleil   (5 posts)  Bio
Date Thu 06 Sep 2007 02:04 AM (UTC)
Message
I am trying to set up a trigger that gags a line and substitutes it with a line including a variable. Here is what I want to do:

ex. attack:

You launch a powerful uppercut at Kairuni.
You connect to the head!

In this MUD each attack does a certain amount of limb damage and I would like to substitute the "You connect to the head!" with something like "HEAD DAMAGE [#/7]" in order to better track damage to each body part. At the very least, I'd like to output something such as this after each attack that connects.

My problem is I'm not sure how to store numbers in variables and increment them based on whether or not I hit the limb or not. I also don't know to send variables as output to the MUD.

To add on to the problem, kicks do 2 points of limb damage and punches do 1 point and each attack combo has 1 kick and 2 punches. Any help would be greatly appreciated!
Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #1 on Thu 06 Sep 2007 06:51 AM (UTC)

Amended on Thu 06 Sep 2007 06:53 AM (UTC) by Shaun Biggs

Message
This requires a bit of scripting, and probably several triggers. I have a quick example in Lua to show here. You pretty much just need a table to hold the various places that something has been damaged. You also need several triggers marking whether an attack is a punch or a kick, and to store that in a variable for use by the next trigger.

<triggers>
  <trigger
   enabled="y"
   match="You launch a powerful uppercut at *."
   name="uppercut"
   send_to="9"
   sequence="100"
   variable="limbattack"
  >
  <send>punch</send>
  </trigger>
  <trigger
   enabled="y"
   omit="y"
   match="You connect to the head!"
   name="limbhit"
   send_to="14"
   sequence="100"
   script="limbhit"
  >
  </trigger>
</triggers>

<aliases>
  <alias
   name="newmob"
   match="kill *"
   enabled="y"
   sequence="100"
   script = "newmob"
  >
  <send>%0</send>
  </alias>
</aliases>


limbs = {}
function limbhit( sTrig, sLine, wildcards )
  limbs[wildcards[1]] = ( limbs[wildcards[1]] or 0 ) + 1
  if GetVariable( "limbattack" ) == "kick" then
    limbs[wildcards[1]] = limbs[wildcards[1]] + 1
  end
  print( string.upper( wildcards[1] ).." DAMAGE ["..limbs[wildcards[1]].."/7]" )
end

function newmob()
  limbs = {}
end

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #2 on Thu 06 Sep 2007 07:07 AM (UTC)
Message
Just in case you are unfamiliar with scripting in Lua, I'll break down what the script does.

limbs = {}

Initializes the 'limbs' variable as an empty table.


  limbs[wildcards[1]] = ( limbs[wildcards[1]] or 0 ) + 1

if limbs[bodypart] is 0, set it to one, else just add one.

  if GetVariable( "limbattack" ) == "kick" then
    limbs[wildcards[1]] = limbs[wildcards[1]] + 1
  end

if the attack was a kick, add another damage counter to make it 2

  print( string.upper( wildcards[1] ).." DAMAGE ["..limbs[wildcards[1]].."/7]" )

print out the line for how much total damage has been done to the affected limb.


function newmob()
  limbs = {}
end

Use this to re-initialize the limb damage counter to an empty table when you move on to a new mob/player.

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Soleil   (5 posts)  Bio
Date Reply #3 on Thu 06 Sep 2007 06:58 PM (UTC)
Message
Ah okay...thank you very much! I'll look into this!
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.


14,108 views.

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

Go to topic:           Search the forum


[Go to top] top

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