Problem with eventing a heath bar

Status
Not open for further replies.

GothicMonocle

Dearly Departed
Veteran
Joined
Nov 20, 2017
Messages
46
Reaction score
12
First Language
Greek
Primarily Uses
RMMV
**Edit: Problem Solved! You can close this thread now.**

So I use the easiest method of eventing a HUD health bar. Which is the picture zoom method. (basically I call a common event that displays two pictures, one for the HUD frame and the other the HP bar.

To calculate how the health bar is going to decrease, I use the following snippet

Code:
mhp = $game_party.members[0].mhp
hp = $game_party.members[0].hp
calculate = (hp * 100) / mhp
screen.pictures[2].move(0, 0, 0, calculate, 100, 255, 0, 30)
The problem? The x positioning! When the HP becomes too low, the HP bar just glitches out of the HUD box. And I have no idea how to fix this.
When full, it looks like this : )
upload_2019-9-16_12-6-58.png
But when empty it does this : (
upload_2019-9-16_12-6-45.png

Any ideas?
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,297
Reaction score
436
First Language
Dutch
Primarily Uses
RMMV
I use SRD_HUDmaker plugin for it, which works probably better.
but using events, does the picture stays 0? or the you use 1 0 to much,
so you can try (if it doesn't make sense) to (0, 0, calculate, 100, 255, 0, 30)

Im not really sure what the 3 zero's does, I know its x, y , ? .
 

GothicMonocle

Dearly Departed
Veteran
Joined
Nov 20, 2017
Messages
46
Reaction score
12
First Language
Greek
Primarily Uses
RMMV
I use SRD_HUDmaker plugin for it, which works probably better.
but using events, does the picture stays 0? or the you use 1 0 to much,
so you can try (if it doesn't make sense) to (0, 0, calculate, 100, 255, 0, 30)

Im not really sure what the 3 zero's does, I know its x, y , ? .
The code reads as follows: screen.pictures[ID].move(position (top left or center) , x, y, x zoom, y zoom, opacity, blend type, wait)

But that plugin you mentioned sounds interesting. Is it for VX ace (The maker I am using) because I can only find hud makers for MV which are in java and by extent completely useless to my project.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,297
Reaction score
436
First Language
Dutch
Primarily Uses
RMMV
I just see yo uusing VXA, My bad, hud maker is only for MV, while its javascript, vxa use ruby so
making the hud work a bit slightly, I know I saw a tutorial for vxa based regarding HP bar.

Ima look if I can find that part, but it doesn't use scriptcall though, its just placed over.

also, if you using 1 member/1player, you can try $game_player.leader (idk if it does take that though) while its the same
as members[0].
but if its around the same in MV, you can try using () on the end of members, unless thats only javascripts.

Let me find something regarding your issue if i can find it, unless someone is faster than me :)
 

GothicMonocle

Dearly Departed
Veteran
Joined
Nov 20, 2017
Messages
46
Reaction score
12
First Language
Greek
Primarily Uses
RMMV
I just see yo uusing VXA, My bad, hud maker is only for MV, while its javascript, vxa use ruby so
making the hud work a bit slightly, I know I saw a tutorial for vxa based regarding HP bar.

Ima look if I can find that part, but it doesn't use scriptcall though, its just placed over.

also, if you using 1 member/1player, you can try $game_player.leader (idk if it does take that though) while its the same
as members[0].
but if its around the same in MV, you can try using () on the end of members, unless thats only javascripts.

Let me find something regarding your issue if i can find it, unless someone is faster than me :)
Well, I don't think how changing the syntax will help since my issue is with the x position not the syntax itself. And besides, MV and Ace use drastically different terms not just in java script but in the interperter so the only thing it would achieve would be crashing the game completely.

I am just asking if there is a way to fix the x position of the hp bar to move slightly to the right so it doesn't glitch through the hud frame...

amyway thank you for at least trying to help
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,350
Reaction score
332
First Language
German
Primarily Uses
RMMV
Its not only that your Hp Bar is shown to far left, also it seems the Z Level has changed, that indicates that something with the Picture IDs got messed up.
Higher Picture Ids are shown ontop of Pictures with lower IDs.
I hope this helps.

Edit: Or can you show Pictures of the whole Eventpages involved.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,297
Reaction score
436
First Language
Dutch
Primarily Uses
RMMV
did you follow this guide?
it also said not to stay from center image, so 0,0,0 would be in the far top left corner.

in case you follow this tutorial, there is a script said in it (idk if it works) for the snippets he said.
in case you did that, than I got no clue how to fix your issue. But it shouldn't happen that the x-position moved to the left though,
which is really weird.
 

Wavelength

Pre-Merge Boot
Global Mod
Joined
Jul 22, 2014
Messages
4,702
Reaction score
3,963
First Language
English
Primarily Uses
RMVXA
Looking through your "move picture" code, it looks completely solid to me. I'm honestly not sure why it isn't working.

One other approach you could take, though it requires considerably more effort, would be to have a "display HP %' variable that slowly ticks down or up (toward the actual HP variable) after changing the HP variable, and to create like 20 different pictures each representing 5% increments of HP. Which picture to show would depend on the Display HP variable. You'd probably want to have a Switch to determine whether the graphic needs to keep recalculating every couple of frames (and set that switch OFF once the Display HP % is equal to the actual HP %), to keep performance smooth. One extra advantage of this approach is that you can make it so that only the red part of the bar will be shown as Sanity gets low, not a squished Red-Blue bar.

If you have trouble implementing this, quote me or @ me and let me know what eventing you tried and what behavior you're actually seeing.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,826
Reaction score
5,516
First Language
Indonesian
Primarily Uses
RMVXA
Try this in your script call, open up the console window, in which value it started to break
Code:
100.times do |i|
  screen.pictures[2].move(0, 0, 0, 100 - i, 100, 255, 0, 30)
  p 100 - i
  Fiber.yield
end
 

GothicMonocle

Dearly Departed
Veteran
Joined
Nov 20, 2017
Messages
46
Reaction score
12
First Language
Greek
Primarily Uses
RMMV
Its not only that your Hp Bar is shown to far left, also it seems the Z Level has changed, that indicates that something with the Picture IDs got messed up.
Higher Picture Ids are shown ontop of Pictures with lower IDs.
I hope this helps.

Edit: Or can you show Pictures of the whole Eventpages involved.
You just gave me an idea. I think I know what to do. You see, I made the HP bar picture look like this
upload_2019-9-16_19-20-45.png
Whereas to avoid distortion, I should make it something like this and position it myself

upload_2019-9-16_19-21-36.png
It works like a charm now! No overlap, no warping beyond the Frame. Everything is as it should be. (And I learned my lesson to not always depend on the map dimentions for picture positioning...)
 

Attachments

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,297
Reaction score
436
First Language
Dutch
Primarily Uses
RMMV
I wouldn't recommend that big size in png, but if you do, I would suggest to use tinypng to make the size of that png
smaller. but it can happen, it start from the far right instead of the HP bar itself.

but as long it works, it works, but its a little warning though =)
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,175
Reaction score
4,297
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Social distancing extended for another week. Personally I'm cool, but this is depressing.
GOOOOD MOOORNING!
APRIL WILL BE BETTER!
First time I've seen the shelves full in my local shop in a while. Still no soap, though.
RachelTheSeeker wrote on StormyRange's profile.
Hey! Haven't I seen you before? :p Good to see you on a RPG Maker site; am pleasantly surprised. :)
When you really think about it, the Trolley Problem is pretty dumb.

Forum statistics

Threads
95,565
Messages
930,125
Members
125,849
Latest member
poot
Top