Posted By
|
Message
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
5th February, 2012 at 03:30:45 -
Greetings. I have an active object that appears to look like a health bar. There are 101 different animation frames, one for each number (0 & 1 - 100). This object is linked to a hidden counter off screen. I tested it and it works perfectly.
The thing is, I'd like to be able to give the player less or more then 100 HP while still using this same active object bar.
Thanks in advance.
n/a
|
nim
Registered 17/05/2002
Points 7234
|
5th February, 2012 at 04:11:22 -
I'm not sure if this'll work in TGF, but it's worth a try. Works in MMF2.
-Create the counter and change the Display Type to Animation (rather than Numbers or Hidden)
-Create/Edit the animation frames 0 1 2 3 4 5 6 7 8 9 [minus] [plus] [period] e
-Change the Display Type back to Numbers and it'll keep the new animation frames
Edited by nim
//
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
5th February, 2012 at 04:29:52 -
Thanks for trying to help, but that's not quite what I had in mind. Or maybe I didn't explain it well enough. I doesn't want to use a real health bar or counter object because of the layer issue and becasue they can't be moved or made invisible during gameplay. I can do all that with an active object. So thats why I have an active object that appears to be a health bar, only because it's an active object I can change it's location and/or make it invisible at will.
The object uses both different animations and different directions. For example stopped animation is 1 - 32, becasue there are 32 different directions. Walking animation is 33 - 64, you get the idea.
In the event editor I have it set to the hidden counter value (which will be replaced with a global value once testing is done). So.. if hidden counter = 1, then set bar object's animation to stopped and direction to /\. And so on.
The bar object has a max of 100 HP. I'd like to add code in the event editor that would allow me to have more or less then 100 max HP while the bar object remains unchanged visually.
n/a
|
Jon Lambert Administrator
Vaporware Master
Registered 19/12/2004
Points 8235
|
5th February, 2012 at 04:38:01 -
Always (or whenever you have it set the active object frame)
- Set frame to ((current HP*1.0)/(max HP*1.0))*101.0
You're converting it to a percentage and then setting it to be that percentage full.
Sandwich Time!Whoo!
JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364
|
nim
Registered 17/05/2002
Points 7234
|
5th February, 2012 at 04:40:21 -
Thanks for explaining more. Perhaps the Max() and Min() functions could help you. It just sets an upper or lower limit on a value.
Always: Set "Health Bar" to Min("hiddencounter"),100
Even if the hidden counter (the real health value) is over 100, the health bar won't display beyond 100. Hope this helps.
//
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
5th February, 2012 at 04:43:44 -
Thank you both for your help. I'll do some testing in a moment.
Edit: In trying to get this to work I found an different answer I am pleased with. Thanks again.
Edited by tetsuya_shino
n/a
|
Va1entine
Registered 14/12/2003
Points 367
|
5th February, 2012 at 23:20:37 -
If your talking about TGF1 I know you can edit the numbers in the counter, so you could just copy and past the images there right? That's what I've done with my game anyway
n/a
|
Chris Burrows
Registered 14/09/2002
Points 2396
|
6th February, 2012 at 02:37:01 -
You can do this in MMF2. Just switch the "Type" from "Numbers" to "Animation".
And you can also change the position/visibility of counter objects as well.
n/a
|
Jon Lambert Administrator
Vaporware Master
Registered 19/12/2004
Points 8235
|
6th February, 2012 at 06:13:37 -
@Va1entine: that was already suggestes and he already refused that.
@Chris Burrows: he specified TGF1 for a reason
@tetsuya_shino: I'm curious as to what your solution was
Sandwich Time!Whoo!
JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364
|
Chris Burrows
Registered 14/09/2002
Points 2396
|
6th February, 2012 at 09:45:32 -
Hmmmmmm... I wonder what reason?
n/a
|
tetsuya_shino
Registered 12/08/2004
Points 491
|
6th February, 2012 at 14:01:26 -
Well, I think I explained what I was trying to do well enough before, so I won't repeat myself. But for the answer I ended up using was neither JL's or Nim's solutions. (Although they aren't bad and I was thankful to receive them.)
What I did was simply make a smaller health bar. From 100 down to 25. Counting 0, that's only 26 different directions using the Stopped animation. (Remember this is an active object and not a counter object)
Next I played out how the HP improvment system would work. Rather then totally random numbers
there would be different grades of max Hp values. 75, 100, 125, 150, 175, 200. And that's it.
So basicly I am using my first idea, but rather then having 101 different events for 0 & 1 - 100.. I am only using 26 events per HP grade. How much a sliver (a part of the health bar that is 1 pixel high and 3 pixels tall) is worth depends on the current HP grade. If the max HP is 75, then the first sliver denotes 1 - 3 HP. If the max HP is 200, that same sliver denotes 1 - 8 HP.
I got the idea of limiting the max health to 200 from Shadowrun on the snes. (Which is a great game by the way.) As long as I balance the attack and damage values correctly, don't need huge values. The way I am going about this seems really tedious, but I've already done it for one character already. I just need to copy and paste the code for other characters and enemies.
Anyways, thanks again.
n/a
|
The_Antisony At least I'm not Circy
Registered 01/07/2002
Points 1341
|
6th February, 2012 at 18:29:47 -
I think you could have done this a lot simpler if you just used a single active object, one direction; and create 100 counter frames. Create two counters, preferably global. Name one CurrHP (CurrentHP) and one MaxHP (Maximum HP). Since you have 100 counter frames, any counter value can be a percentage of the 100; so you'd only need to find out what % of MaxHP the character's CurrHP is at, then set the active object to display the correct frame.
ActiveCounter:
Change Animation Sequence to "AniName".
Set Direction to "Default Direction".
Force Animation Frame to CurrHP/MaxHP*100.
That way, let's say the player's MaxHP is 999 and CurrHP is 712.
Your counter doesn't have 999 frames, but with the equation,
712/999*100=71. It's 71%, and if you set your frame to 71, it should show correctly.
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
|
Jon Lambert Administrator
Vaporware Master
Registered 19/12/2004
Points 8235
|
6th February, 2012 at 22:51:18 -
Originally Posted by GrimFusion I think you could have done this a lot simpler if you just used a single active object, one direction; and create 100 counter frames. Create two counters, preferably global. Name one CurrHP (CurrentHP) and one MaxHP (Maximum HP). Since you have 100 counter frames, any counter value can be a percentage of the 100; so you'd only need to find out what % of MaxHP the character's CurrHP is at, then set the active object to display the correct frame.
ActiveCounter:
Change Animation Sequence to "AniName".
Set Direction to "Default Direction".
Force Animation Frame to CurrHP/MaxHP*100.
That way, let's say the player's MaxHP is 999 and CurrHP is 712.
Your counter doesn't have 999 frames, but with the equation,
712/999*100=71. It's 71%, and if you set your frame to 71, it should show correctly. The percentage thing is what I suggested (and which has already been rejected, even though it allows arbitrary health values and is arguably easier).
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 01:47:00 -
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?
n/a
|
The_Antisony At least I'm not Circy
Registered 01/07/2002
Points 1341
|
7th February, 2012 at 02:10:47 -
Both, but meters are easier at a glance.
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
|
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
|
|
|