 |
jonesbones Newbie
Joined: 30 Jan 2008 Posts: 3
|
Posted: Wed Jan 30, 2008 8:11 pm
Newbie question: health monitoring and healing. |
Hey, I'm just starting to learn how to build a "system" for a rather simple MUD, but beyond some really basic triggers, straight forward keybindings, and the like, I'm pretty bad.
I'm looking to create something that basically does the following:
If the spam is:
Health: X Mana: Y
and is spammed regularly during combat, how would I go about creating a trigger to use a healing item when the health reached a certain point?
Along a similar vein, if the spam is expressed as a fraction of current/max, is there a way to heal at certain percentages?
Finally, I'd like to make one of those moving health bars I've seen with some more complex systems on other games... is there a place I could be reading up on these? It seems like they might be a bit more complex.
Thanks for humoring me, in advance. |
|
|
 |
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Wed Jan 30, 2008 8:35 pm |
Lets give an example with the "spam" line you provided.
Code: |
#trigger "HealTrig" {Health: (%d) Mana: Y} {#if (%1<=50) {heal;#t- HealTrig}}
#trigger "HealTrig2" {Insert message you see here after a successful heal} {#t+ HealTrig}}
|
EDIT: Given that health/mana values are usually numbers, you have to point it out in your trigger and thats what %d is for, it captures a number value into %1 given that its the first %d in the trigger.
This code creates 2 triggers. First one captures the line from MUD that contains info about your current health, for example. Once the health has reached a certain point (illustrated with "50" here), it does the healing thing descriptive for your MUD and turns the trigger off (to avoid looping). Second trigger catches the line from your MUD that you see after a successful cast/quaff for heal and turns the first trigger back on (given that there is such a message in your MUD).
Thats the basic gist for the whole deal and should be learned before moving on tho, imo.
You can continue with capturing the health data into #VARIABLE and put that on your main screen with #BUTTON. But if your first initiative is to make a little piece of script that does the "automated" healing, you have to understand that part before moving on.
Prog |
|
|
 |
jonesbones Newbie
Joined: 30 Jan 2008 Posts: 3
|
Posted: Wed Jan 30, 2008 9:44 pm |
Thanks! It seems to be working.
I tried to expand on it by making one which detects a percentile level and heals when it reaches a certain percent.
When the MUD gives me:
Health: 500/500 Mana: 500/500
I did this:
Health:(%d)/(%d) Mana:(%d)/(%d)
Which assigns the %d's to variables %1-%4, right?
So then I tried:
#if (%1/%2<=.98) {heal}
and also
#if ((%1/%2)<=.98) {heal}
thinking that it would do the arithmatic using the values of those variables, and respond in the same way as the first bit of code, which works... but it doesn't. What am I doing wrong?
Thanks |
|
|
 |
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Wed Jan 30, 2008 10:02 pm |
Let me get it right. 500/500 = current amount and maximum amount, right?
If so, all you need to do is assign %d to the current one.
Code: |
#trigger "HealTrig" {Health: (%d)/500 Mana: 500/500} {#if (%1<=250) {heal;#t- HealTrig}}
|
I vaguely understand that you want to mess around with percentages, but the line from your MUD you provided doesn't seem to have anything to do with them...
If thats not what you wanted at all, you're welcome to clarify.
EDIT: Unless you meant something like calculating the percentage by calculations with those two numbers and then healing when its the
amount you're after... uh, but why would you want to do something like that in the first place, may I ask? You already have the current amount you can have your heals being based from...
Prog |
|
Last edited by Progonoi on Wed Jan 30, 2008 10:05 pm; edited 1 time in total |
|
|
 |
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Wed Jan 30, 2008 10:02 pm |
Try
#IF (%float(%1)/%2 <= 0.98) {heal}
Or
#IF ((100*%1)/%2 <= 98) {heal} |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
 |
jonesbones Newbie
Joined: 30 Jan 2008 Posts: 3
|
Posted: Wed Jan 30, 2008 10:08 pm |
Yes, I'm aiming for percentages, I'm trying to effectively create one by dividing the current from the maximum, and healing off that. So, in my example, I was trying for 98%.
I'll give Guinn's suggestion a try next time I can log on! Thanks for the input. |
|
|
 |
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Wed Jan 30, 2008 10:27 pm |
Nods, once I saw Guinn's suggestions, I understood.
Point remains though as to why not just heal off the current amount at hand
Prog |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Jan 30, 2008 10:31 pm |
It's a pain updating the value you're comparing with if your max hp changes often (buffs, a fast-levelling MUD with thousands of levels, that sort of thing). I would've done the maths with %1<%2*0.98, but it makes no difference really.
|
|
|
 |
|
|