Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Using Percentages in Scripting

4 years ago

What I'm specifically trying to do is make it so that when displaying HP value for enemies, it doesn't display their actual health total, but instead a line of text depending on the health percentage of the target. For example, if their health is full (100%) then on the page it would display something along the lines of "They are completely unharmed"
 And then of course, when their health is low (25% or so) then it would display something like, "They are about to collapse"
 I could just make it display this kind of text with script by just measuring the exact health total of each individual enemy (I've done it before already), but if I could do the percentage thing in scripting, it would make it easier to make a universal script that I could just copy/paste rather than having to measure health totals for each individual enemy.
 What I'm hoping I can do is something along the lines of "If HPVariable is < 50% of HPMaximum then etc."
 In addition, I kind of had an idea to make health display similarly to old Resident Evil, like with Fine, Caution and Danger, all color-coded and what-not. Being able to measure a variable's percentage in scripting would help with doing this.

Using Percentages in Scripting

4 years ago

You could do something like that with some division in the comparison.

IF %HPVARIABLE < (%HPMAXIMUM / 2) THEN ...

Although now this has me thinking about how it would be neat (though niche) if you could access a variable's min, max, and start values through scripting.

Using Percentages in Scripting

4 years ago

Thanks for the help, that works for what I was wanting.

Using Percentages in Scripting

4 years ago
Just do math.

You have 30/40 health = 75%.

3000/40 = 75

Amazing. Such math, much wow.

Using Percentages in Scripting

4 years ago

I could just do math (it's how I had it set up before), but that's mostly why I was asking, to try and avoid having to set it up for each individual enemy what with their varying healthpools. And on top of that, the bigger issue would be of setting the condition monitor for the reader, since their exact health could be different depending on certain stats. In the end though, it's not like it's necessary at all, just an idea I had and I wanted to know if it would be possible.