Posted By
|
Message
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
7th February, 2012 at 02:39:45 -
Thanks for your input. Hopefully a few more people will give their preference so I can get a feel of how I should design the status while in combat.
A while ago I had made a fake counter using two active objects that went from 0 - 999. That's right, that's 1000 events.
While it works, I wonder if there is another way to get the same effect. Like have 100 events that would control numbers 0 - 99. Then using a 2nd active object and 10 more events, have code to control the hundredth place. I vaguely remember someone doing that before... If anyone knows how to do that (in tgf) please explain it.
Once I know the method, it should be a snap to have a 102 pixel wide bar that shows the percentage of health while also displaying the actual current and max HP values.
n/a
|
Jon Lambert Administrator
Vaporware Master
Registered 19/12/2004
Points 8235
|
7th February, 2012 at 04:07:58 -
Originally Posted by tetsuya_shino Well to be honest, the examples listed didn't work.
value( "HP NOW" ) / value( "HP MAX" ) * 100 is vaild but it doesn't do anything.
However, I just messed around with it and..
( value( "HP NOW" ) * 100 ) / value( "HP MAX" ) works perfectly. Very odd, since as far as I can tell they should give them same end result.
Thanks to everyone that offered advice. Although now, I do have a question for everyone. When you are playing an RPG do you prefer seeing a health bar, the actual current/max values, or both? You'll notice that when I posted that, I added things like *1.0 and such, because (at least in MMF2) you have to force the use of floating point calculations by including numbers with decimal points. The reason your edit works is because the first one gives a less-than-1 value that gets rounded down to zero before the multiplication by 100, while your edit gives a greater than 1 value that just gets rounded down to the nearest whole number as opposed to zero.
Sandwich Time!Whoo!
JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
7th February, 2012 at 04:27:39 -
Very interesting... I had tried to use period key as a decimal, but I got a syntax error. What key did you press to get a deciaml point?
n/a
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
19th February, 2012 at 03:06:08 -
I am toying with the idea of 'battle damage'. Basicly I'd like to swap between 3 different active objects based on the current HP% I'll call these actives A, B, and C. If the current HP is between 64% - 100% object A is shown. Between 34% - 66%, B is shown. And 0% - 33% C is shown.
How would I go about coding this? Thanks.
n/a
|
Chris Burrows
Registered 14/09/2002
Points 2396
|
19th February, 2012 at 19/02/2012 23:37:18 -
Exactly like you just said:
If HP > 64 and HP < 100 then:
- set Active Object A to visible
- set Active Object B to invisible
- set Active Object C to invisible
If HP > 34 and HP < 65 then:
- set Active Object A to invisible
- set Active Object B to visible
- set Active Object C to invisible
If HP 0 33 and HP < 33 then:
- set Active Object A to invisible
- set Active Object B to invisible
- set Active Object C to visible
n/a
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
20th February, 2012 at 20/02/2012 00:37:20 -
Oh, well if the max HP was 100, then yeah it would be simple. But what I am trying to do is do the same thing but with percentages. Because you can level up the max HP can be increased beyond 100 (and the starting max HP might be below 100), I can't base the code on actual numbers. But thank you for your post all the same.
n/a
|
Chris Burrows
Registered 14/09/2002
Points 2396
|
20th February, 2012 at 20/02/2012 01:21:00 -
If your max HP is (for example) 195, then 66 percent of 195 is 128.7 (195 x 0.66).
So...
If HP > (HP_MAX x 0.66) and HP < HP_MAX then:
- set Active Object A to visible
- set Active Object B to invisible
- set Active Object C to invisible
If HP > (HP_MAX x 0.34) and HP < (HP_MAX x 0.65) then:
- set Active Object A to invisible
- set Active Object B to visible
- set Active Object C to invisible
If HP > 0 and HP < (HP_MAX x 0.33) then:
- set Active Object A to invisible
- set Active Object B to invisible
- set Active Object C to visible
n/a
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
22nd February, 2012 at 22/02/2012 01:11:55 -
Ah I see now. I'll give it a shot in a moment. Thank you.
n/a
|
Hagar Administrator
Old klik fart
Registered 20/02/2002
Points 1692
|
22nd February, 2012 at 22/02/2012 15:25:26 -
At work at the moment (I will read this thread more thoroughly when I get home) but TGF1 has no floating point support, i.e. all numbers are integers. So your typical percentage calculation “what you got” / “the maximum” * 100 would return either 0 * 100 or 1 * 100 (as there is no decimal point data)
So to do floating point esque calculations do something like this: ( (Current Health * 1000) / Max Health ) / 10
Edit : The above should do if you do wish to try the percentage way of doing things
Edited by an Administrator
n/a
|
|
|