KAZESUI'S PROFILE

Doing Super Programming
on Super Computers
for Super Performance
The Curse of Cpt. Lovele...
Nautical-themed cephalopod-pirate-based action-shmup.

Search

Filter

"Good" rm2k3 event coding

@bulma
Sorry, but you're post shows massive lack of understanding of how stuff works.
To suggest that loops should be avoided is stupid, inefficient, tedious and even more bug prone.

Your argument about loops being bad for old computers is downright bullshit. If you don't terminate a loop after you're done with it, or loop without ever stopping it, then yes, of course it's bad. But that's not a fault of the loop, that's a fault of the coder being an idiot.

Good code saves space, but the space saved by conserving rm2k3 variables is utterly trivial. Even if you set the variable array to 9999 you're not even using a single Mega Byte... which pretty much means it's going to have no impact on performance whatsoever, and any other increase in size as a result of this is also totally trivial, so exactly WHY is it so important to be saving variables, when adding a few can make life a lot easier, make stuff more readable, or even add more flexibility to your code, which is argueable far far more important for the code.

As it stands, pointers in combination with loops allow for much more flexibility, which could only be compensated by massive use of branches, which is way way more inefficient. THIS hurts the usage of old computers.

Also, yes, typically, programming languages tell you to avoid using labels, which is a good advice for novices. However, this isn't necessarily worth much if you don't really understand WHY they can end up being bad. Just having read that they are more prone to cause spaghetti code just doesn't cut it.
The problem with labels is that they can make code more unreadable, or even be totally confusing if you abuse them.

However, rm2k3 does not have proper control structures, and if done right, like shown in my examples, or even in the example of Trujin, which isn't bad either, it's not that much spaghetti. It retains readability, sometimes being even more so than whatever alternative you might be facing by trying to just avoid labels, because you don't understand the concept.

Another thing, Common events does not speed up code, it actually slows it down!
in terms of performance, you don't want a million common event calls. You do this for the sake of reuseability, easier maintenance, less bug prone and for keeping it more readable. Also, it can cut down the size of the set of event instruction, which is actually linked to the performance in terms of memory usage... however if you experience a considerable boost because of this, its most likely because you're doing something horribly wrong in the first place.
You should of course use them, but not for performance, and not just for the sake of using them either. If the code isn't reused at any time other than once in that particular event, it's most of the time better to just keep that code there, rather than to move it out to a common event.

And finally, your last example... Having it run as a parallel process just won't cut it for more demanding real time systems.
if you need to do 60 iterations in a loop, it would take A FULL SECOND for the loop to finish. That's just not acceptable. If you're doing lot of hit collision checks by this kind of loop, you'd get all kind of faulty data, because what happens on the screen will never be checked in time in the actual event. Not to speak of how immensely unecessary it is to have an event which does absolutely nothing except cost cpu time be running. If anything, you'd want to only let that common event be active when a switch is set ON.

All in all, you're primarily listing up bad advice, rather than good ones.

[DynRPG]Blending Modes

Could prove tricky, as there's no easy way to do it right off the bat given the how the SDK is at the moment. It lacks a callback for when battle animations are being drawn, as well as data on the actual battle animations themselves, and locating this data is not a trivial issue.

So... you probably won't see blending for battle animations in near future

"Good" rm2k3 event coding

You are of course very right, there's a lot of personal flavour going here, this having been written more in my flavour of course. That said, my looping style isn't just based on preference, it's actually slightly more efficient than yours as well (in rm2k3 that is, which is an important distinction here).
In rm2k3 it costs one instruction cycle less. The bigger the content of the loop, the more negligible that one instruction cycle becomes, but for tiny loops with lots of iterations, it can become rather noticeable. Of course, this will rarily be a problem unless you're working on some heavy system (a moderately complex real time system, like an advanced ABS for example).

Among the goals of my little article/tutorial here was to combine some coding style with efficiency, not so much about merits of different styles. If I was focusing more on how to code to keep it readable, clean and organized, I probably would have drawn some comparisons to show how it can be done differently yet still good, which would make quite some sense, considering I used to use your looping approach before as well, before switching to my current style.

pixel movement and terrain collission on rpg maker 2003

The scope of the tutorial was limited to give more of an introduction to pixel based movement and it's implications for doing the most simple and necessary stuff, i.e. terrain collision and event interaction. There are of course lot more issues to address for a proper implementation of pixel based movement.

As for your particular issue, a couple of methods come to mind as to what you can try to resolve it:

a) Combine charsets and pictures. Use charsets for the lower 16x16 pixels of an event, which will never overlap that of the hero anyway, and use pictures for anything above.

b) Make all event graphics into pictures, and change the ID of the pictures according to their y coordinates. This should be done using the PicPointerPatch from cherry too not make a branch hell making the system (event with lowest y coordinate also has the lowest picture ID value, and constantly checking this over a parallel process and switching ID's when one event or hero has gone above another).

option a) is potentially easier to implement, but going to be more tedious, while b) can be more complicated to implement (depending on your skills with pointers), but quite less tedious (preferable I'd say). Either way, you more or less limit the amount of graphics you can use to whatever upper limit of picture ID's you have.

+++ DynRPG - The RM2k3 Plugin SDK +++

@GetName  "NameOfVariable", Hero/Monster/Item/Attribute/Condition, number or Variable
Storing a string like this into another string in the dll isn't that hard. The problem arises when you want to display this string somehow. The easiest solution would probably to have an extra hero as temporary string storage, so that you can access it by \n. "NameOfVariable" is by this probably better changed to ID of the hero used as a string storage.

@ShowMessage "message", NameOfVariable/V1/whatever, "more message"
(Basically, works like a glorified cout. It should use the message
box, (since @text seemed to need a picture, which disqualified it from effective use because battles don't allow pictures)

There's a patch for adding picture support in battles.

@SetInt Hero/Monster/Skill/Item/Attribute/Condition, Value/Range/Etc, VariableNum
I'm not entirely sure what you want to do here. you call it "SetInt" which would imply you want to change a given value (which is at odds with you saying "draw from"). It sounds like you want to store an entire object of type condition/item/whatever, but that only makes sense for further work on it in the dll, otherwise you'd rather extract the relevant values you're interested in.

@CheckCondition Hero/Monster, Value1, Skill/Item/Attribute/Condition, Value2
Given how one of the tutorial patches basically draws icons above the actors showing their different Conditions, this should be fairly possible to do. Again, you'll need a way to read the answer though, requiring you to choose a switch id or something to read the return value.

SkillRandomTarget = SkillNumber1, SkillNumber2, SkillNumber3, SkillNumberEtc (stored in DynRpg.ini)
If the SkillNumbers are referring to ID's of actual skills, this can prove tricky since most data of the skills have not yet implemented into the SDK. Alternatively, you might be able to somehow swap the current action of an actor with a "random one", but I don't know how to do that yet, and it would probably require quite a bit of time in terms of playing around to figure it out, if at all possible.

Zombie effect = ConditionNum (stored in DynRpg.ini)
Again, I don't know exactly. It should be all means be perfectly possible, but the effort and approach required is questionable, and these kind of stuff tend to take a lot longer than anticipated once started on, so yeah..

...Something like RPG::Monster or RPG::Actor getName (), then RPG::getItemName, getSkillName, and getConditionName too. But stored in some kind of container, that can be used later.

This is essentially the same as the first one

+++ DynRPG - The RM2k3 Plugin SDK +++

Depends on the errors. If it's simple syntax errors, compiling it wouldn't take very long, but if it's beyond that, I might not have time for it myself. I have time to make these posts, and take a quick look at the forums every now and then, but beyond that I'm fairly busy myself these days.

Compiling a DLL isn't that different than compiling an executable, and following the tutorial given on the documentation page, pretty much tells everything you need to get it properly running... well aside from the problems with using the right compiler, since Code::Blocks have updated their compiler in the meantime (used to work with the default compiler they were using).
Aside from that, looking at source code given from plugins should be helpful enough to just edit tiny bits of code to do what you want (as long as you're not trying something overly fancy).

but yeah, if you have some fairly "correct" cpp code, I could potentially compile it for you, and send you the dll back.

+++ DynRPG - The RM2k3 Plugin SDK +++

I was assuming you had installed the Code::Blocks version which came with MinGW (the almost 100 mb big binary file). I don't recall there being any separate installation parts using this, and this would give you a MinGW folder inside your Code::Blocks folder (probably located under Program Files). If you merely swap the existing folder there with the one in the link from my previous post, that should magically fix your problems (no additional installation or anything, just a matter of cut and paste).

+++ DynRPG - The RM2k3 Plugin SDK +++

On the assumption that you tried to follow the instructions given on the DynRPG documentation page, and downloaded Code::Blocks and everything, try to download this,
unzip the file and replace the MinGW folder in your Code::Blocks folder with the one given in this link.
If you do this and follow all of the other instructions on the page, it might just fix your compiling problem.

Better than relying on Cherry, who seems to be rather busy these days anyway

+++ DynRPG - The RM2k3 Plugin SDK +++

Well, if you use coding terminology without knowing what it means, then obviously you're going to get different answers than what you expect.

OnComment itself is a callback which is triggered whenever a comment line is "executed" in the maker (given that it has the dynrpg patch). Whatever effect you get out of using a plugin and comment commands is not a callback, neither is getMonsterID for that sake (Does it even exist? Closest thing I can see in the documentation is the DatabaseId member of the Monster Class).
Whatever is supposed to happen once a comment is read is up to the developer of the plugin to decide, so of course you won't find details on this on the documentation page.

getItemName is a "function", which you can only access directly by actually coding a plugin in C++. If you want to use it, the minimum requirement is that you're able to write a few lines of code in C++ and manage to compile it properly into a dll. If you can do that, then it shouldn't be too hard too hard to create a plugin with custom a comment command yourself which pretty much does what you describe.

Looking at some C++ source codes from existing plugins can probably help you in your quest here, in terms of how to utilize the onComment callback to make comment commands.

How can I eliminate lag from this

I find this myth of "add a 0.0 wait at end of parallel processes" somewhat amusing, like it's some kind of magic which decreases lag. To see advice like this in such a case is especially amusing since it's effect is obviously going to be neglible.

Adding a wait in an event decreases lag because it may decrease the load of what the maker has to do within a single frame, and since this tiny event script is only executed once every 1 second, its not really going to do anything, but slow down how often the event is executed.

So yeah, as some people have mentioned couple of times so far, the pictures are probably the problem. You could start by taking the two static pictures out of the update loop. Picture 1 and 6 doesn't ever change, and thus don't need to be updated along with the rest. Move it out of the event, and show them at some other point.

More or less the same with picture 2 and 3. You never change the picture, only the coordinates, so change this to "move picture" with a 0.0 wait and with the "wait until moved" unchecked. This is significantly more effective than using "show picture". Just make sure to show the pictures once first in a separate instance, preferably at the same time as with picture 1 and 6.