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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Jscript
. . -> [Subject]  Damage Summing Script
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Damage Summing Script

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


Posted by Iterator   (5 posts)  [Biography] bio
Date Sun 12 Feb 2012 08:56 PM (UTC)
Message
Hi everyone. I'm new to MUSH scripting (and scripting in general) but do have a background in Java.

I'm currently playing a mud where a certain ability rages you and you can't see your HP. I'm wanting to have a script that I can call from triggers and have it tally how much damage I've taken.

I've figured out an average of which hit takes how much: very hard, extremely, pulverized, etc. So these triggers would call the script and the script would add this value to the total and some how display this to the user.. or possibly deduct it from that characters total hp and return that.

Is this possible, and if so could someone point me in the right direction?

Thanks!

/iterator
[Go to top] top

Posted by Kyrock   (20 posts)  [Biography] bio
Date Reply #1 on Fri 08 Jun 2012 09:26 PM (UTC)
Message
don't know if you're still wanting an answer.


var rageTracker = {
   hp: 0,
   veryHard: 5,//don't know avg damages so I'm making them up
   extremely: 10,
   pulverized: 20,
   etc: 40,
   init: function(currentHp) {
      this.hp = currentHp;
   }
   //this function treats its argument as a string.
   hpMod: function(gotHit) {
      //replace any white space with no space
      //then make it lower case.
      var hitSeverity = gotHit.replace(" ","").toLowerCase();
      //if passed veryhard then hitSeverity is equal to 5 and etc.
      hitSeverity = this[hitSeverity];
      //hp is modified and then noted in the world
      this.hp = this.hp - hitSeverity;
      world.Note(this.hp);
   }
}


When you log in you'd set your hp with an alias with the code:
rageTracker.init(80)

or what ever your current hp is. then in your triggers...if the message is something like: "you get hit very hard" you'd send to script:
rageTracker.hpMod("very hard");

then you'd get a note saying 75 (80 - 5 = 75)
[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.


2,928 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 FutureQuest]