Zelda Style Heart Bar- how to do?

Topics regarding Scripting with Reality Factory
elussya
Posts: 3
Joined: Mon Dec 17, 2007 11:53 pm

Zelda Style Heart Bar- how to do?

Post by elussya » Mon Dec 17, 2007 11:59 pm

Looking for a tutorial or somesuch for assistance on this- I can't figure out how to
accomplish a zelda style heart bar..

In other words- pick up vial/heart pieces to increase your characters total life
capacity (4 pieces = 1 increase), which would reflect on the players HUD,
in the form of ((base # of hearts/vials)+1 more per 4 pieces found)- in other
words a health bar that looks like a heart bar, but that increases by adding
a "heart" to your bar...

Any zelda fans out there that know how to pull this off? I'd love to use a
a gui like this for my project so that I can actually finish in a realistic time-frame ;-)

Please help :-)

*hugs* Elussya

User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Post by steven8 » Tue Dec 18, 2007 12:17 am

Hello elussya, and welcome to Reality Factory. I'm not sure how to accomplish what you desire, but there is a good section on Heads Up Displays in your RF manual. Find it under Programs>Reality Factory>RF Manual On the left hand menu side, you will find a listing for Heads Up Display. Withing this, is what I believe you need. At the top you find 'Pictures'. That is what I think you may need to use. Let us know if this helps.

Good Luck!!
Steve Dilworth - Resisting change since 1965!

elussya
Posts: 3
Joined: Mon Dec 17, 2007 11:53 pm

Post by elussya » Tue Dec 18, 2007 1:43 am

Hmm... I don't think that the default HUD assistance will work the way I'm hoping.

I'm hoping to be able to pick up more 'hearts' in the style of zelda, and have them
displayed on the HUD health area (while still having them decrease when the player
is hit)

User avatar
Agentarrow
Posts: 1346
Joined: Thu Jun 28, 2007 4:34 pm
Location: Kyiv, Ukraine
Contact:

Post by Agentarrow » Tue Dec 18, 2007 4:40 am

That'd be hard to do, the people of nintendo created their own zelda engine from scratch, it was pretty cool though, it could compile in Gamecube or Wii format. (for twilight princess) Anyway, speaking of Nintendo, My health Bar for Terra Trooper needs to be like in Metroid, with those little energy tanks that store a full health bar... Would that be something I could do from the manual?
AgentArrow Home
The greater good is but a point of view...

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis » Tue Dec 18, 2007 2:01 pm

Allright, so let me get this straight. You want to have a row of hearts on the screen and every time you pick up 4 powerups one heart is added to the row?

You could use a healtbar-style HUD element that has large enough intervals in the attribute that it only shows full hearts. In other words, if you increase the attribute with 1, the health bar will become larger and reveal a full heart (instead of half a heart, or one pixel of the next heart).


First off you need to have two different attributes:

Code: Select all

[heartpieces]
initial = 0
low = 0
high = 4

[hearts]
initial = 1
low = 0
high = 8
Then set up a simple script that will handle the 4 heart pieces becoming one heart:

Code: Select all

{

Spawn[ ()
{
     LowLevel("setup");
} ]

setup[ ()
{
     PawnRender(false);  //Don't render the pawn
     SetNoCollision();      //Don't collide

     self.think = "run";
} ]


run[ ()
{
     self.ThinkTime = 0.1; //execute every 0.1 seconds

     if(GetAttribute("heartpieces","Player") = 4)   // if enough powerups have been collected
     {
          SetAttribute("heartpieces",0,"Player");    // reset the number of the powerups
          ModifyAttribute("hearts",1,"Player");      // add one full heart
     }
} ]

}
Add a pawn with this script into the level. It will be invisible and doesn't collide with anything, so it shouldn't affect the game world in any way.


Next, you need to set up your HUD so that it shows the hearts. Now you should create a bitmap that has a row of hearts (either vertical or horizontal). I'll give an example of how to set up the HUD with a horizontal row of 8 hearts that are 32x32 pixels (So the image size for the HUD element is 256x32):

Code: Select all

[hearts]
type = horizontal
frame = XXX.bmp
framealpha = YYY.bmp
indicator = ZZZ.bmp
indicatoralpha = XYZ.bmp
framex = center
framey = 64
indicatoroffsetx = 0
indicatoroffsety = 0
indicatorwidth = 256
This should create the "health bar" in the top center of the screen.


I hope you get what I mean. I didn't test any of this so if you can't get it to work or get some weird errors feel free to ask questions.


***EDIT***
Oh, and welcome to the forums. :)
Pain is only psychological.

User avatar
paradoxnj
RF2 Dev Team
Posts: 1328
Joined: Wed Mar 01, 2006 7:37 pm
Location: Brick, NJ
Contact:

Post by paradoxnj » Tue Dec 18, 2007 2:03 pm

It's actually not that hard to do. RF might not be able to do it right out of the box, but with a little creativity anything is possible. Here's how you can fake it. Create a HUD item with the maximum amount of heart containers that your player can have. Use script to hide the ones from the player that are not active or have been removed due to damage.
Many Bothans died to bring you this signature....

elussya
Posts: 3
Joined: Mon Dec 17, 2007 11:53 pm

Post by elussya » Tue Dec 18, 2007 8:29 pm

Awesome!! That looks like it'll work, I'll be able to test it tomorrow
once my computer's back from the shop :-)

*hugs*

That's saved alot of head bashing from the last few days :-)

Once it's tested and working with my level I'll be posting some screenshots :-)

This is thus far, definitely the most friendly forum I've been part of :-)

Cheers,

Elussya

User avatar
Agentarrow
Posts: 1346
Joined: Thu Jun 28, 2007 4:34 pm
Location: Kyiv, Ukraine
Contact:

Post by Agentarrow » Wed Dec 19, 2007 2:33 am

welcome to the forums, I forgot to mention that :oops: '-.- anyway, So Juutis, you seem to be good at scripting, could I ask you a favor? a script for a Metroid style health bar? with Energy Tanks and stuff? You don't have to if you don't want to, but it never hurts to ask...
AgentArrow Home
The greater good is but a point of view...

User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Post by steven8 » Wed Dec 19, 2007 4:36 am

elussya wrote:Awesome!! That looks like it'll work, I'll be able to test it tomorrow
once my computer's back from the shop :-)

*hugs*

That's saved alot of head bashing from the last few days :-)

Once it's tested and working with my level I'll be posting some screenshots :-)

This is thus far, definitely the most friendly forum I've been part of :-)

Cheers,

Elussya
That'll be excellent! We love screenshots!!

AA - I've never seen that Metroid health bar. Post a screen, if you can. I did a google search, with no luck. No good shots where the HUD is clear.
Steve Dilworth - Resisting change since 1965!

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis » Wed Dec 19, 2007 11:35 am

Agentarrow wrote:So Juutis, you seem to be good at scripting, could I ask you a favor? a script for a Metroid style health bar? with Energy Tanks and stuff? You don't have to if you don't want to, but it never hurts to ask...
Let's see, so every time the player's health reaches 0 you want to see if there's a full energy tank and if so, fill the health bar and empty one tank?

Shouldn't be too tricky. First you have to find a way to prevent the player from truly dying. RF's built-in player dies when its health reaches 0, so if you don't let it go that low, the player shouldn't die. So, in the attributes:

Code: Select all

[health]
initial = 100
low = 1
high = 100

[energytanks]
initial = 5
low = 0
high = 10
Since 1 is the lowest value 'health' can have, the player can't die. Then a little piece of script:

Code: Select all

{

Spawn[ ()
{
     LowLevel("setup");
} ]

setup[ ()
{
     PawnRender(false);  //Don't render the pawn
     SetNoCollision();      //Don't collide

     self.think = "run";
} ]


run[ ()
{
     self.ThinkTime = 0.1; //execute every 0.1 seconds

     if(GetAttribute("health","Player") = 1)   // if 'health' is 1
     {
          if(GetAttribute("energytanks","Player") > 0)  //if there's at least 1 energy tank
          {
               SetAttribute("health",100,"Player");   // set player's health to 100
               ModifyAttribute("energytanks",-1,"Player");      // remove one energy tank
          }
          else  // if there are no energy tanks left
          {
               SetAttributeValueLimits("health",0,100,"Player");  //let health reach zero
               SetAttribute("health",0,"Player");  //kill the player
          }
     }
} ]

}
I hope this gets you started.
Pain is only psychological.

User avatar
Agentarrow
Posts: 1346
Joined: Thu Jun 28, 2007 4:34 pm
Location: Kyiv, Ukraine
Contact:

Post by Agentarrow » Wed Dec 19, 2007 9:49 pm

thx!!!
===EDIT===
And Steven, Here:
Image
AgentArrow Home
The greater good is but a point of view...

User avatar
Spyrewolf
Posts: 450
Joined: Tue Jul 05, 2005 4:53 am
Location: Wellington::New Zealand

Post by Spyrewolf » Thu Dec 20, 2007 7:48 am

Hang on didn't Qod do this for his game? the zelda style health bar, I've seen the images,

yep found it in the gallery! look in teh gallery under legend of Okkora, (sorry if the spelling is out quest)

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams » Thu Dec 20, 2007 11:58 am

Although it looks like a Zelda health bar in these screens it was in fact just a normal health bar with alpha maps and didn't work as described above.

User avatar
ArKanuS
Posts: 54
Joined: Wed Jan 23, 2008 7:29 am
Location: Perth, Australia

Re: Zelda Style Heart Bar- how to do?

Post by ArKanuS » Wed Jan 23, 2008 3:58 pm

Hi, Juutis I was wondering if you could make me a script to? :oops:

I would like to have like a shield (like health) which when runs out starts affecting your health but if you wait awhile the shield recharges but your health stays the same?

Thanks, I'm relatively new to RF :oops:

User avatar
Agentarrow
Posts: 1346
Joined: Thu Jun 28, 2007 4:34 pm
Location: Kyiv, Ukraine
Contact:

Re: Zelda Style Heart Bar- how to do?

Post by Agentarrow » Thu Jan 24, 2008 12:44 am

I don't know much about scripting, but you'd want a second health bar underneath the first that runs out before health does.
uhhh... something like:
Open the player.ini file and go under armor, Replace the Initial with probably about half, so about 50. Next put High as 100 and low as 0. Juutis will have to help with the regenerate thing. You might be better off having it set at something like 200 and replenishable by items
AgentArrow Home
The greater good is but a point of view...

Post Reply