Substituting output with a variable

Posted by Soleil on Thu 06 Sep 2007 02:04 AM — 4 posts, 18,284 views.

#0
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!
USA #1
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
Amended on Thu 06 Sep 2007 06:53 AM by Shaun Biggs
USA #2
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.
#3
Ah okay...thank you very much! I'll look into this!