The Daily Click ::. Forums ::. Klik Coding Help ::. custom health bar (tgf)
 

Post Reply  Post Oekaki 
 

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
  7233
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

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
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
  7233
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

Has Donated, Thank You!360 Owner
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

GOTW WINNER OCT. 2011
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

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
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

GOTW WINNER OCT. 2011
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

VIP MemberStarSnow
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

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
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

VIP MemberStarSnow
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?
   

Post Reply



 



Advertisement

Worth A Click