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

Gammon Software Solutions 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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Iterator   (5 posts)  [Biography] bio
Date Sun 12 Feb 2012 08:56 PM (UTC)  quote  ]
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)  quote  ]
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.


650 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]