[RM2K3] CMS QUESTIONS

Posts

Pages: first 12 next last
Edit: Nevermind. Figured this one out on my own. Should mess around a bit longer before making a new thread.
Okay, now I have a legit question.

So, in my game when you open up the menu it shows three bars (one for each party member) which displays their portrait, name, level, class, HP and MP.

I made an event which calculates the current HP of each party member. I haven't inserted it into the actual menu yet, just a test. It works great. Downside is, it's long as hell. I know when making a custom menu you can't avoid having huge event lists, but I wanna optimize this as much as I can.

So basically the question is: Is there any way to do this that takes up less space?

My test event:

Calculating HP:
What I'm doing here: First I store the current HP of a hero into a variable. Then I store that variable inside another variable called Hero Modded HP. Then I do a modulus operator on that variable to find out the different HP digits. Then I store that into three separate variables for each hero. The ones, the tens, and the hundreds. Min HP is 1, max HP is 999.



Drawing the HP with pictures:

This one is a bit convoluted to explain. Basically I'm using the three variables I have. AlexHP(1s) contains only the last digit of his HP. AlexHP(10s) contains the middle and the last digit. AlexHP(100s) contains all digits. Using a shitload of conditional branches, I'm checking each of these variables to find out how high they are, then based on that the game knows which one to execute and which picture to show.

When all is said and done, there's three pictures on the screen, one for each digit.



So as you can see the second event here is already pretty fucking huge. But that's not even all of it. I have that same event for the second and third party member, each one just as long. But that's not all. This is only to calculate the current HP. I also have to one of these events for each party member to find out their max HP.

Right now I only have three playable characters, and no real plans to add many more. But if I do decide to add more playable characters, it means for each one I'm going to have to do this again.

So if anyone was able to follow all this, do you know if there's a way to slim this down a bit? Make it a bit more compact?
Pretty sure that's the only way to do it. I wouldn't even call that a lot of code heh It's about average or low for this kind of custom system. That's why DynRPG is so powerful. It does with 1 line of code, what pages do.

DynRPG has the ability to draw variables on screen as numbers, which is the only way to make this code smaller, I believe.
Yeah I thought it was wishful thinking. I think I'd rather not mess with DynRPG for now. Oh well, at least a lot of this can be copy pasted and slightly modified.
Hi Rob,

This amount of code is very small. You would be able to multiply this amount of code by ten times and it would still complete faster than you would be able to perceive. You can see this for yourself by copying and pasting that block of code 10 times right after itself.

It might be worth noting something that I've noticed: If you ever do encounter lag (which is doubtful), code called from a Common Event runs slower than that called from events on the map. If you have code in a Common Event that needs a boost of speed, and it wouldn't be too tedious to paste it all into map events where it's relevant, it's worth doing.
Not being able to specify pictures by variable is the #1 annoying thing about custom 2k/3 systems. You can put the modulo math in a subroutine common event to save copy/pasting it over and over at least:







And then calling it:






edit: looking at this like 10 years later, it's missing a /1000 in that event but I never displayed up that far.

I also use PicPointerPatch which I recommend to avoid going insane
You can specify pictures by variables in the official version of RPGmaker 2003.
author=Sidewinder
You can specify pictures by variables in the official version of RPGmaker 2003.


So you can. I actually just found out about this. I own the Steam version of Rm2k3, apparently you can specify pictures by adding a numbered suffix at the end which the Show Picture command can use with a variable.

But does this offer an advantage in any way? I'm still going to have to check 1 through 9 for every digit for every hero, right?
Look, you can do this in Show Picture in the retail version of Rm2k3:



Now this saves me a fuckton of space when it comes to displaying the "ones" value (the last digit of a hero's HP). I literally only need one Show Picture and set it to the value that my other event calculated.

But that only works for the ones. When calculating the tens, the result is the second and third digits of the HP. When calculating the hundreds, the result is all three digits of the HP. I don't wanna make 1000 different pictures for each possible value.

Is there any way to do some magic here?
Yes, but the picture drawing is MUCH less coding.

I'd give my firstborn for Events that could receive parameters in RM 2k3...
Your
author=JustRob
Look, you can do this in Show Picture in the retail version of Rm2k3:



Now this saves me a fuckton of space when it comes to displaying the "ones" value (the last digit of a hero's HP). I literally only need one Show Picture and set it to the value that my other event calculated.

But that only works for the ones. When calculating the tens, the result is the second and third digits of the HP. When calculating the hundreds, the result is all three digits of the HP. I don't wanna make 1000 different pictures for each possible value.

Is there any way to do some magic here?


Your modded HP is still saving only one digit, only it represents the digit in the 10s and 100s POSITIONS, not the actual number, no?
No, that's not how it works. It just saves the current HP but shaves off the first digit. So if HP is 514, then it returns 14.

I'm trying to get it where it does return only a single digit. But I dunno how to do that.
author=psy_wombats

^ that event does do the whole digit isolation thing. Your current mod math is on the right track, just once you're done, you need to subtract the lesser digits (eg for 514 you'd have 14 - 4, then 514 - 10 - 4) and then divide by the place you're going for (/1000, /100, /10, etc, so 500/100, 10/10, 4/1). Subtraction probably not necessary but I don't trust RM to round integer division consistently.


@Large you can sort of fake arguments by setting aside some variables for your "function" common event that you call arguments and outputs and then always read/write from those when calling the event (see other post). If you want to be fancy about this and make your events reentrant, you'll have to do some more work and the bottom of this rabbithole ends with writing malloc in rm2k/3 to simulate a stack frame. It's doable and a fun exercise but at some point you have to wonder if it's really worth it
author=JustRob
Is there any way to do some magic here?
Yeah, but I'm really bad at explaining these things. If it helps, I can show you what I'm doing for Psi Dogs.

It's a common event that figures out how many digits a variable has, does all the necessary math to separate them into multiple variables, then runs through a loop and shows all the pictures I need.

So, if I wanted to draw a number, I'd just need to make an event that goes:

NumberToDraw = 8679305
PictureID = 1
Picture X = 160
Picture Y = 120
Call Event: Draw Number
author=psy_wombats
author=psy_wombats
^ that event does do the whole digit isolation thing. Your current mod math is on the right track, just once you're done, you need to subtract the lesser digits (eg for 514 you'd have 14 - 4, then 514 - 10 - 4) and then divide by the place you're going for (/1000, /100, /10, etc, so 500/100, 10/10, 4/1). Subtraction probably not necessary but I don't trust RM to round integer division consistently.


I see what you mean, but I run into a problem here.

I'm calculating the 1s value first, then the 10s, then the 100s. If I add event commands to take the 10s value and subtract 4 from it, then divide it by 10, then yes I will have the second digit of 514 as a singular digit. But then when it's calculating the 100s value, it no longer works because the variable used to calculate the 10s no longer holds the correct value.

Man, it's difficult to even type this up. I don't know if I'm explaining it right.

Order matters -- save your division for the end
author=psy_wombats
@Large you can sort of fake arguments by setting aside some variables for your "function" common event that you call arguments and outputs and then always read/write from those when calling the event (see other post). If you want to be fancy about this and make your events reentrant, you'll have to do some more work and the bottom of this rabbithole ends with writing malloc in rm2k/3 to simulate a stack frame. It's doable and a fun exercise but at some point you have to wonder if it's really worth it


Ugh.

This is what I'm experiencing (sorry to hijack for a sec here):

I'm using official RM 2k3. Cherry wrote on the Changelog:

author=Changelog
The “This Event” target may now also be used in common events and will refer to the last map event in the call stack. (For example: Map event A calls map event B, which calls common event C, which calls common event D, which moves “This Event”. Result: Map event B will be moved.) The “Erase Event” command behaves the same way, erasing the last map event in the call stack.


However, I am getting an error like this: "Event referenced does not exist". So it seems that the behavior described is not applying.

It frustrates me to no end.
Well I've got another question as well.

So I figured out how to draw my hero's HP as separate single digits, but if his HP is below 10 (say 4), I don't want it to display as "004", but as "4". Same with if his HP is below 100. I want "44" instead of "044".

So I made some conditional branches to check if his HP is above 10 and if it's above 100, then I made an event on my starting map that puts his HP at 1, but it doesn't work. I dunno why, his HP is definitely getting reduced, I checked in the default menu.



So what's going on in this picture: The shit at the top is showing my different menu windows and moving them into place. At the comment Current HP, I'm displaying the current HP. Picture 9 is the 100s digit and picture 10 is the 10s digit, and they should not be shown if his HP is below 100 or 10 respectively.

Anyone know what I'm missing here?

Edit: Nevermind, figured it out. Turns out I had a backup copy of my Menu Initialize running without the conditional branches, I forgot to change it from parallel process.
Okay I need some help again.

So in my custom menu I have the option to save just like the regular menu. If you select it, you go to the save screen. Before you go to the save screen, I call the event to close the menu. I do that because otherwise, the saved game is created when the menu is open, and when you reload the game the menu would be open from the start, which would be odd.

However, after showing the save screen now I call the event to open the menu again. After all, if you've just saved your game but keep playing and you go back, it would be annoying if you have to open the menu again.

But for some reason if I call the event to open the menu after showing the save screen, when I reload the game the menu is still open. Even though at the moment the game was saved, the menu had been closed. It shouldn't reopen the menu until after the saving is done and I've left the save screen.

I don't understand why it's doing that.

Here's a picture of my save function, maybe someone knows what's up.



I can also post the open menu and close menu events, but I don't think it impacts this? It's basically just moving the pictures on to the screen and moving them back off, then disabling the switch that toggles functionality.

Edit: I think I know what the problem is, but I have no idea how to fix it. So basically what happens is that when the save menu is called, it saves the game right there. In that specific event, on that line of code. So when I load that savegame, it actually continues the execution of that event and moves on to the next line of code, which is "open menu". That's why the menu opens when the save is loaded.

How do I fix that? I need to open the menu after showing the save screen, because having to open the menu manually again after saving is just stupid. Hmmmmm
Pages: first 12 next last