Status
Not open for further replies.

Speedvore

RPG Making since RM95!
Veteran
Joined
Oct 3, 2015
Messages
39
Reaction score
12
First Language
English
Primarily Uses
RMMZ
Hello, I'm working on a custom battle system that is made through events and not using any of the built-in battles or plugins in RPG Maker MZ. I just finished creating a health bar that is controlled with a variable.

Here's a video of it working in-game.

My next task is that I'd like the bar to be able to follow the event on the screen as it moves. For some reason, the move picture commands I've been trying haven't exactly been working. Instead, the picture just doesn't move at all.

Here's my code for showing the picture, based on the variable:
JavaScript:
$gameScreen.showPicture(3, $gameVariables.value(97), 0, ($gameVariables.value(81) - 100), ($gameVariables.value(82) - 225), $gameVariables.value(98), 100, 255, 0);

And then here's a breakdown of what the above variables are referring to:
JavaScript:
$gameScreen.showPicture(3, // Picture #3
$gameVariables.value(97), // Picture File Name is stored in this variable
0, // 0 Upper Left
($gameVariables.value(81) - 100), // X-Position of the Event (with an offset)
($gameVariables.value(82) - 225), // Y-Position of the Event (with an offset)
$gameVariables.value(98), // Width stored in this variable
100, 255, 0); // Height, Opacity, Blend Mode

Now, for the Move Picture command, I got this code from the rmmz_objects.js file:
JavaScript:
Game_Screen.prototype.movePicture = function(
    pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, duration,
    easingType
)

So I tried to convert that into what I could use for my game.

Currently in my event, here's what I have:
◆Set Movement Route:Ally1
: :◇Move Down
◆Control Variables:#0081 A1 HP X = Screen X of Ally1
◆Control Variables:#0082 A1 HP Y = Screen Y of Ally1
JavaScript:
$gameScreen.movePicture(3, 0, ($gameVariables.value(81) - 100), ($gameVariables.value(82) - 225), $gameVariables.value(98), 100, 255, 0, 60, 0);

And then it loops back up to my code for showing the picture.

I'm sure it's just a slight coding issue that's causing it to not move, but I haven't received any error messages, it just simply doesn't move. Does anyone have any ideas on what I might be doing wrong here?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,043
Reaction score
1,519
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!

Well, I'm not sure why it is not working, I can't figure out what you are trying to do. Maybe a screenshot of the event can help more.
But I tried a solution for you, thinking about what you want to do, that moves the picture with the event.

So maybe, instead of calling the move picture command, you can use just that(In a parallel event):
JavaScript:
$gameScreen.picture(id)._x = $gameVariables.value(81) - 100
$gameScreen.picture(id)._y = $gameVariables.value(82) - 225

Don't know if you want to use plugins, but I have a plugin that makes it easier to manipulate pictures:
Eli_EnhancedPictures.js
 

Speedvore

RPG Making since RM95!
Veteran
Joined
Oct 3, 2015
Messages
39
Reaction score
12
First Language
English
Primarily Uses
RMMZ
Hi Eliaquim, thanks so much for your response!

Don't know if you want to use plugins, but I have a plugin that makes it easier to manipulate pictures:
Eli_EnhancedPictures.js
This plugin is amazing, and makes looking at the Show/Move Pictures code so much easier. Thank you, I definitely do think that'll be good to use going forward!

So after using the plugin and updating some of my move route event commands (that were previously set to wait), I got it to mostly work moving one way, which is progress!

Basically, I'm going to have events move on a map and I just want the health bar to follow that event. So right now the variable bar moves up with the event, but when it moves back down, it stutters and flies upwards. I'm noticing now that it kind of doesn't move as far as the event on the way up, so that might be part of what's causing the issue for when it moves back down. I think at this point it's probably something with the logic of how it's written though, but I can't quite seem to find what it is.

Here's a gif of what it looks like right now:
HealthBar.gif

And then my Event is fairly long for a single screenshot, so I've transcribed the whole thing into text here (with comments on what each part is doing):
◆Text:None, None, Window, Bottom
: :Health Bar appear!
◆Comment:Starts with Green color (name of the image file)
◆Control Variables:#0097 Health Color = "Health_Green"
◆Comment:Sets the event's HP to 100
: :(this won't be a static number in the end, just 100 for testing)
◆Control Variables:#0098 Health Amount(TEST) = 100
◆Comment:Set Health Label is just for this Event to make it loop
◆Label:Set Health
◆Comment:Gets the Screen position of the event (X and Y)
: :and stores that into 2 variables
◆Control Variables:#0081 A1 HP X = Screen X of Ally1
◆Control Variables:#0082 A1 HP Y = Screen Y of Ally1
◆Comment:Show Empty Healthbar under
◆Plugin Command:EliMZ_Pictures, Show Picture
: :Picture name = Health_Empty
: :Picture Id = 2
: :Origin = UpperLeft
: :Position X = ($gameVariables.value(81) - 100)
: :Position Y = ($gameVariables.value(82) - 225)
: :Scale Width = 100
: :Scale Height = 100
: :Opacity = 255
: :Blend mode = Normal
◆Comment:Shows Colored Healthbar Picture above the event's head
◆Plugin Command:EliMZ_Pictures, Show Picture
: :Picture name = $gameVariables.value(97)
: :Picture Id = 3
: :Origin = UpperLeft
: :Position X = ($gameVariables.value(81) - 100)
: :Position Y = ($gameVariables.value(82) - 225)
: :Scale Width = 100
: :Scale Height = 100
: :Opacity = 255
: :Blend mode = Normal
◆Set Movement Route:Ally1
: :◇Move Up
◆Control Variables:#0081 A1 HP X = Screen X of Ally1
◆Control Variables:#0082 A1 HP Y = Screen Y of Ally1
◆Plugin Command:EliMZ_Pictures, Move Picture
: :Picture Id = 3
: :Origin = UpperLeft
: :Position X = ($gameVariables.value(81) - 100)
: :Position Y = ($gameVariables.value(82) - 255)
: :Scale Width = $gameVariables.value(98)
: :Scale Height = 100
: :Opacity = 255
: :Blend mode = Normal
: :Duration = 15
: :Easing = Constant speed
◆Plugin Command:EliMZ_Pictures, Move Picture
: :Picture Id = 2
: :Origin = UpperLeft
: :Position X = ($gameVariables.value(81) - 100)
: :Position Y = ($gameVariables.value(82) - 255)
: :Scale Width = 100
: :Scale Height = 100
: :Opacity = 255
: :Blend mode = Normal
: :Duration = 15
: :Easing = Constant speed
◆Text:None, None, Window, Bottom
: :ATTACK!
◆Comment:=======================================================
: :
: : ----- This part isn't currently working -----
: : | |
: : V V
◆Set Movement Route:Ally1
: :◇Move Down
◆Control Variables:#0081 A1 HP X = Screen X of Ally1
◆Control Variables:#0082 A1 HP Y = Screen Y of Ally1
◆Plugin Command:EliMZ_Pictures, Move Picture
: :Picture Id = 3
: :Origin = UpperLeft
: :Position X = ($gameVariables.value(81) - 100)
: :Position Y = ($gameVariables.value(82) - 255)
: :Scale Width = $gameVariables.value(98)
: :Scale Height = 100
: :Opacity = 255
: :Blend mode = Normal
: :Duration = 15
: :Easing = Constant speed
◆Plugin Command:EliMZ_Pictures, Move Picture
: :Picture Id = 2
: :Origin = UpperLeft
: :Position X = ($gameVariables.value(81) - 100)
: :Position Y = ($gameVariables.value(82) - 255)
: :Scale Width = 100
: :Scale Height = 100
: :Opacity = 255
: :Blend mode = Normal
: :Duration = 15
: :Easing = Constant speed
◆Comment:^ ^
: : | |
: : ----- This part isn't currently working -----
: :
: :=======================================================
◆Control Variables:#0098 Health Amount(TEST) -= 20
◆Comment:Just checks the health amount and changes image
: :variable based on that
◆If:Health Amount(TEST) ≤ 0
◆Erase Picture:#2
◆Erase Picture:#3
◆Jump to Label:Dead

:Else
◆If:Health Amount(TEST) ≤ 25
◆Control Variables:#0097 Health Color = "Health_Red"

:Else
◆If:Health Amount(TEST) ≤ 50
◆Control Variables:#0097 Health Color = "Health_Yellow"

:End

:End

:End
◆Wait:60 frames
◆Control Self Switch:D = ON
◆Jump to Label:Set Health
◆Label:Dead
◆Text:None, None, Window, Bottom
: :You win!

But here's a screenshot of the part of the Event, in particular, that's not working as intended (from the above code):
Event.png

So maybe, instead of calling the move picture command, you can use just that(In a parallel event):
JavaScript:
$gameScreen.picture(id)._x = $gameVariables.value(81) - 100
$gameScreen.picture(id)._y = $gameVariables.value(82) - 225
I also tried out this suggestion of adding this in a parallel event and unfortunately it didn't change anything for me. I also tried to make this event (linked in the above spoiler tags) be parallel process, and still no luck. I'm not sure, maybe some of the parts of this event could be in a separate event and it might help though?

So I feel like it's getting mostly there, and it's at least moving now, it's just a matter of where and how it moves. This is my first time moving pictures using code, so I could also just be missing something in this process. Or maybe there's a method that's even easier that I haven't found yet, I'm not sure.

If you have any ideas, I'd love a second pair of eyes on this!
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,043
Reaction score
1,519
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi!
Glad you liked the plugin and that it can be able to help you ^^

I really think that will be best for you if you keep updating the picture position and scale width in another event. Possible, a parallel one.
With that, the picture has a better chance of moving smoothly with the event.


I can't see the problem with your event, so I made a little project to show you how I will do it.
Download

Let me know if you manage to download it.
 

Speedvore

RPG Making since RM95!
Veteran
Joined
Oct 3, 2015
Messages
39
Reaction score
12
First Language
English
Primarily Uses
RMMZ
I really think that will be best for you if you keep updating the picture position and scale width in another event. Possible, a parallel one.
With that, the picture has a better chance of moving smoothly with the event.


I can't see the problem with your event, so I made a little project to show you how I will do it.
Download

Thank you so much for this, it works perfectly now!! I used the code you wrote in your project as a guide to implementing it all back into my original project and now it all works smoothly.

I think my issue was that I wasn't including the right parts in the parallel event when I was trying it out, and I think the loop I created was messing with some of the move picture events. But with how you laid out this code, it was very clear when converting it all over and helped me figure out how to make it work now.

Thanks again for all of your help, and for making this plugin as well, I really appreciate it! :)
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,743
Reaction score
5,766
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.

Latest Threads

Latest Posts

Latest Profile Posts

Made a Mapping Tutorial on Adding Lighting/Shadows using Tileset

Currently working on a playlist of songs that have inspired my work on revamping Battle Castle, and making sure they flow decently from one to the next. I will be posting it whenever I upload my next demo.
This is the first song in the playlist.
Artists out there, is there something RPG maker related you wish your graphics software had but doesn't? (Something like automatically transform a wall tile into a cylindrical tower). I want to give a boost to WecTools, but I'm dry of ideas right now...

Forum statistics

Threads
113,909
Messages
1,078,348
Members
148,016
Latest member
Kenu
Top