Gaming@NINA

Ending IGN's monopoly, one play at a time

Forums · RM2K3- Hp and energy bar coding

lord_morgoth!imx

0 +0

Sep 8 '07

Well, I thought he come back to the forum in style lol

*Note* this was made before by me on 2 other forums, do not claim this as your own. Ask for permission before posting on another forum!

Well. Heres a tutorial on how to make a working HUD for your game i've included all the basics: Health (Credits to Picceta), Ki, XP (May not work for all games...) , etc.

CREDITS TO PICCETA FOR THE HEALTH BAR CODING, KYLE_KATARN FOR THE RIPPED GRAPHICS AND LORD_MORGOTH FOR THE REST
Enjoy  :D

Table of Contents

1. Hud template/basics
2. Health Bar
3. Ki bar
4. XP bar
5. Ending


Section 1: Hud Template/basics

Necessary Knowledge: Variables, Trigger Conditions, Picture usage.
Necessary Resources: Hud template, Hp bars, Ki bars, Xp bars. (Kyle_Katarn made them, Give credit if used)

First off lets set up the basics. Start by going to the Database. To acess this simply go to the top bar and select Tools and selecting Database from the drop down list.

Once you have entered the database select Common events. Once you have entered the common events select an unused slot and name it HUD. Set it as a Call trigger switch and follow this:

<> Show picture:1 (Place the template picture here) 50x16

This is important so that the Template will show and the Bars will not be randomly floating in the air. You must make sure its a Call event or the game will go very slow otherwise and it won't work effectively.

Place a new event on any map. Set to an Auto start with no graphic and name it HUD.

<> Call event HUD

The common event HUD will be changed multiple times to add the other bars.



Section 2: HP bar

Create the following variable: Hero Hp.

Go to the database and select Database. Open up a new common event and name Hero-HUDHP. Set the trigger switch to Call. Now do the following:

<>Branch if (hero) is in party
     <>variable operations: [hero HP] set, (Hero) hp
      <> variable operations: [hero hp] *, 100
      <> variable operations: [hero hp] /, (hero) max hp
      <> Branch if variable [hero hp] is 100 or more
          <> Show picture 2 (The picture of the hp bar 100%) 64x12
      <>els handler

Now set each of the branches to the same number as the picture. EX. branching the variable to 97 if the picture shows the HP bar at 97%.

NOTE: Place this at the moment of damgae calculation when being damaged for the change to show on the bar.

<>Call event hero-HUDHP

also in the common event HUD place this.


Section 3: Ki Bar

Necessary variable: Hero Ki

The Ki bar is very similar to the Hp bar. Go to the database and common events. Name a new event, (hero) ki. Make it a call switch trigger and do the following:

<>Branch if (hero) is in the party
     <>Variable operations: [Hero's ki] set, (heros) mp
      <> Variable Operations: [Hero's ki] *, 100
      <> variable operations: [Hero's ki] /, (heros) max mp
      <> Branch if variable: [hero's ki] is equal to or greater then 100
           <> Show picture 3 (the picture of the ki bar 100%)

Now set each of the branches to the same number as the picture. EX. branching the variable to 97 if the picture shows the kI bar at 97%.

NOTE: Call this event after the hero has used an attack that uses Ki so that it will show the ki that was removed.

<>Call event: hero-HUDKI

Also put the above in the HUD event in common events.



Section 4: XP bar

NOTE: please note that this XP will not work for you if your using the RM2K3 default XP system for your leveling up.

Necessary Variables: Hero Xp, Xp gained.

The XP bar is very basic. It allows you to track how much Xp you have at any time, when the bar fills you level up and it resets.

Go to the database and then common events. Open a new event and name it hero-HUDXP. Make it a call switch.

<>Branch if (hero) is in the party
     <>Variable operations: [Hero's XP] + [XP gained]
      <> Variable operations:[Hero Xp] *, 100
       <> Variable operations:[Hero xp] /,100
        <> Branch if variable [hero's xp] is greater then or equal to 100
             <> Show picture 4 (put the xp bar at 100% here)
              <>Change level: Hero level 1 up
               <> variable operaitons set, 0
                <> Call event: Hero-HUDXP

(The 100% XP bar is the only part that levels up. Do this for the rest of the Percentages)

<>Branch if variable [Hero's XP] is greater then or equal to 97
    <> Show picture 4 (the picture of the XP bar at 97%)


Were not done yet though. Go to an enemy on the map or some event where the hero gains XP. At the part where the hero gains XP do the following:

<>Variable operations:[XP gained] set, (whatever the amount of XP gained is)
<>Call event: hero-HUDXP
<>variable operations:[XP gained] set,0

This get the XP bar to increase and resetting the [xp gained] variable stops you from getting more XP when the event is called for other reasons.

NOTE: On the Common event HUD place this there.

<>Call event: Hero-HUDXP


Section 5: Ending

Now. Go to the common events and the HUD event it should say this:

Call event:

<>Show picture 1: (the picture of the HUD template)
<>Call event:hero-HUDHP
<>Call event:hero-HUDKI
<>call event:Hero-HUDXP

and then an auto start event on the map like this:

<>Call event: HUD
<>Erase Event

Now that will start up the HUD when you enter the map its visible, then the other call events within it will start up the different bars all at once.

If you have any comments or questions go ahead an ask, i'll answer anything I can. Also please don't quote the whole thing, only parts, thanks.

I hope you enjoyed the Tutorial! Don't post it anywhere without permission, and give Credits to where they are due.

(If you see something within this tutorial which you believe to be yours please let me know so I can fix/edit it, thanks)
Rating: 0

universe_jdj!imx

0 +0

Sep 8 '07

Great post! I'm stickying this :)
Rating: 0

lord_morgoth!imx

0 +0

Sep 8 '07

Thanks! Alot of work went into this, The xp coding was made from scratch  ;D

Look out for an abs (Punching outside of a battle) system to be shown in a tutorial soon. Much more updated from the one I posted long ago.
Rating: 0

The Mystic One

0 +0

Sep 8 '07

Great post and neatly organised. Sure it helps out alot :)
Rating: 0

Painless

0 +0

Sep 9 '07

Just remember that too many common events running at the same time can lag your game. I've seen it happen a few times.

A system like this would be alright, but it's just a heads-up.
Rating: 0

lord_morgoth!imx

0 +0

Sep 9 '07

The hud is set as a call event so it doesn't lag.

I've tested this without the call and it lags, but with it it works fine.
Rating: 0