Challenge of the events.

@bass2yang You would make CT_Bolt proud
I stayed inside the editor at least, right? No horizontal scrolling and I did use an event command lol.
Here is my entry for Challenge 1: Status bars

1734172051735.png


So far I focused on 1 character, and I ignored states.

Here is how I did it:
1734172384944.png


First I showed the background, which is a single image, that covers the whole screen. So, we place it at coordinates 0, 0.

The second image is the player image. This can be more dynamic, when the player has the option to switch party leaders, but I choose to make it for a game where only 1 character is playable, so there was no need for that. (I plan to do this later, just like the states.)

The third command is the interesting one... The script call.
This call will do the following, line by line:
  1. This looks for the actor ID of the party leader.
  2. This looks for the current HP in %
  3. This looks for the current MP in %
  4. This looks for the current TP (Since max is 100, it is always in %)
  5. This places the HP bar
  6. This places the MP bar
  7. This places the TP bar
So, basically what happens is: I show 3 images (one for each bar), and the height of those images are always 100%, but the width in % is equal to the HP, MP or TP in %.

When you have 30%, the bar for HP is only 30% wide, and therefor 70% empty.

This is triggered with a parallel common event that loops 6 times per second. I also trigger it each time a player gets damage on the map (like when bitten by a bat outside of battle), to prevent the bar updating a fraction of a second later. The only reason I made it also parallel is to update it after healing in the main menu (by using a skill or a potion). Of course, I could also have the skill and the potion trigger this common event. Then I don't need a parallel trigger at all.

Here is a the code, so you can copy it over and re-use it if you like:
JavaScript:
var ID = $gameParty.leader().actorId();
var HP = $gameActors.actor(ID).hp * 100 / $gameActors.actor(ID).mhp;
var MP = $gameActors.actor(ID).mp * 100 / $gameActors.actor(ID).mmp;
var TP = $gameActors.actor(ID).tp;
$gameScreen.showPicture(93, 'Bar_HP', 0, 480, 48,  HP, 100, 255, 0);
$gameScreen.showPicture(94, 'Bar_MP', 0, 480, 64,  MP, 100, 255, 0);
$gameScreen.showPicture(95, 'Bar_TP', 0, 480, 80,  TP, 100, 255, 0);

And here are the graphics I used from the pictures folder:
Face.png
Bar_HP.png
Bar_TP.png
Bar_MP.png
Bar_Background.png


You can use everything in your project if you like. Just, replace the face image. 😛 If you want to use my interface, you can scale the face of your party leader to 50% and then crop it into a perfect circle. Place that in the exact center of a 144x144 image, and name it "Face.png". Now my system should work with your game.

Easy peasy right? And if you know how to do a bit of editing, you can make very pretty and cute interfaces surrounding your portait and status bars.
@JohnDoeNews the background could be smaller, why a big file for that?
but it's small, something I do for simplicity (but still neat)

@bass2yang whaáááááát! that is neat and quite working.
1 issue though, your code only works in 1.6.x (not lower) unless > nwjs 0.48
is needed to read them, as "?.destroy" or anything with ?.length = CS6 which
isn't supported in 1.5.x so far I know, but it simplify the code ^^

a way I didn't thought of at all. not with icons like that included.
at least you completed all challenges in 1 😀
@JohnDoeNews the background could be smaller, why a big file for that?
but it's small, something I do for simplicity (but still neat)
Lazyness. Now I didn't have to look up the coordinates and just make it 0, 0. 😛 I know, that is not an excuse. I will adjust that later. 😛

Here is a quick test of the status bars, I suppose. I didn't really follow the prompt and got side tracked with how JS executes and deal with the code. Honestly, I would just make a plugin for this but since we are eventing this, I'll go with script calls and event commands as needed.

I basically just used what was there in the engine and went from there to make it available on the map.

I could add tp too I suppose but I may not even bother with it at this point.

No plugins. 1 script call for the main feature inside a common event that is called with an event on map (about 12 lines condensed to fit in the visible area of the editor so no long trails of code).

Still adding small icon of face making sure the menu doesnt annihilate the new windows added to the Scene Manager.

Can't spend much more time on it since I need to finish other things. Here is the current result. Might update later so I won't bother you with my unoptimized and messy code haha, at least not until I complete the rest of it.

That looks amazing, but to be honest, I have no idea what the javascript does. Would you mind to explain?
@JohnDoeNews the background could be smaller, why a big file for that?
but it's small, something I do for simplicity (but still neat)

@bass2yang whaáááááát! that is neat and quite working.
1 issue though, your code only works in 1.6.x (not lower) unless > nwjs 0.48
is needed to read them, as "?.destroy" or anything with ?.length = CS6 which
isn't supported in 1.5.x so far I know, but it simplify the code ^^

a way I didn't thought of at all. not with icons like that included.
at least you completed all challenges in 1 😀
Thanks! Made some changes for this time around and updated my post. Yeah the optional chaining (?.) is for a later nwjs. Usually, you would do if (variable && variable.property) so you don't run the second part. The optional chaining returns undefined if there isn't anything there.

Should be fine now. Appreciate it!

@JohnDoeNews I'll walk through it a bit. I updated my post to reflect this and the new stuff - should cover all the goals presented.

Updated Post - Status Bars

Thanks!

Here is my entry for Challenge 1: Status bars

View attachment 325605

So far I focused on 1 character, and I ignored states.

Here is how I did it:
View attachment 325607

First I showed the background, which is a single image, that covers the whole screen. So, we place it at coordinates 0, 0.

The second image is the player image. This can be more dynamic, when the player has the option to switch party leaders, but I choose to make it for a game where only 1 character is playable, so there was no need for that. (I plan to do this later, just like the states.)

The third command is the interesting one... The script call.
This call will do the following, line by line:
  1. This looks for the actor ID of the party leader.
  2. This looks for the current HP in %
  3. This looks for the current MP in %
  4. This looks for the current TP (Since max is 100, it is always in %)
  5. This places the HP bar
  6. This places the MP bar
  7. This places the TP bar
So, basically what happens is: I show 3 images (one for each bar), and the height of those images are always 100%, but the width in % is equal to the HP, MP or TP in %.

When you have 30%, the bar for HP is only 30% wide, and therefor 70% empty.

This is triggered with a parallel common event that loops 6 times per second. I also trigger it each time a player gets damage on the map (like when bitten by a bat outside of battle), to prevent the bar updating a fraction of a second later. The only reason I made it also parallel is to update it after healing in the main menu (by using a skill or a potion). Of course, I could also have the skill and the potion trigger this common event. Then I don't need a parallel trigger at all.

Here is a the code, so you can copy it over and re-use it if you like:
JavaScript:
var ID = $gameParty.leader().actorId();
var HP = $gameActors.actor(ID).hp * 100 / $gameActors.actor(ID).mhp;
var MP = $gameActors.actor(ID).mp * 100 / $gameActors.actor(ID).mmp;
var TP = $gameActors.actor(ID).tp;
$gameScreen.showPicture(93, 'Bar_HP', 0, 480, 48,  HP, 100, 255, 0);
$gameScreen.showPicture(94, 'Bar_MP', 0, 480, 64,  MP, 100, 255, 0);
$gameScreen.showPicture(95, 'Bar_TP', 0, 480, 80,  TP, 100, 255, 0);

And here are the graphics I used from the pictures folder:
View attachment 325608View attachment 325609View attachment 325611View attachment 325610View attachment 325612

You can use everything in your project if you like. Just, replace the face image. 😛 If you want to use my interface, you can scale the face of your party leader to 50% and then crop it into a perfect circle. Place that in the exact center of a 144x144 image, and name it "Face.png". Now my system should work with your game.

Easy peasy right? And if you know how to do a bit of editing, you can make very pretty and cute interfaces surrounding your portait and status bars.
Nicely done - very neat too. (Sorry, double post. DELETE OR COMBINE... plz halp. haha.)
Nicely done - very neat too.
You too. Even though that is a higher level of javascript than I will understand any time soon. 😛
My best guess is you could "solve" it using variables and pictures, but in no way would the bars be "accurate" since you'd need a new picture for basically every single pixel and then do a bunch of math.
If you have a simple bar that can extend 'indefinitely' (such as a vertical gradient on a horizontal bar or just a white line), you could probably just use Width in Move Picture to 'shrink' the bar inside the border. That's extremely annoying (at least in MV) because you can't assign a variable to Width. A tricksy way of doing that is to instead push the bar off screen to emulate it shrinking, which only works if your bar border can fully hide it.

Typing all this out makes me want to try this now.
If you have a simple bar that can extend 'indefinitely' (such as a vertical gradient on a horizontal bar or just a white line), you could probably just use Width in Move Picture to 'shrink' the bar inside the border. That's extremely annoying (at least in MV) because you can't assign a variable to Width. A tricksy way of doing that is to instead push the bar off screen to emulate it shrinking, which only works if your bar border can fully hide it.
You can with a script call. That is what I did.

Typing all this out makes me want to try this, now.
What stops you? 😛
You can with a script call. That is what I did.
True, I was more thinking without a script call.

What stops you? 😛
I already ran into some issues, apparently Control Variables doesn't let you choose TP.
Yeah, without a script call, that is a tough one.
Hey all! I kinda hoped there would be more participants, like before, but that is okay. 2 entrees and one of them is even my own. 😛 So far, that is. The challenges will be open forever, so who knows what kind of entrees we get in the future.

But we won't wait for that, right? We go to the next challenge for Januari. I'll add it to the main post in a few days (on januari first) but I can let you guys know what the new challenge will be: A character selection screen. Details come soon, when the challenge is officially starting.
pure eventing with pictures 😛 easy peasy, but low time.
but always welcome to learn more XD

Original thread: https://forums.rpgmakerweb.com/threads/challenge-of-the-events.173841/