NickyP
Active member
So. You want to make an OpenBOR game, do you? Good, because modding is really fun, and we all want new things to play! But even if you know how to make characters/enemies/stages, that's only part of the problem. Creating your own game (in general) requires efficient use of memory management. After all, the better you use your memory, the more you can do with your game! This tutorial is to cover the basics of OpenBOR memory management, and two main techniques that us modders like to use.
Load vs. Know
Load and Know are mandatory commands that are used in Models.txt. Without Load and Know, there would not be an OpenBOR game. To begin, let's look and see what the manual says about these two commands:
In case you can't tell the difference, let me break it down to you like this:
Load will load all code, images, and sound files an entity uses into RAM memory. Load is mandatory for Player characters, as Players must always be in RAM at all times. There are other ways to load Players without bogging down RAM, but that's a more advanced technique for another day.
Know will only load a placeholder of an entity into RAM; in other words, Know won't load all files of an entity, just the entity's name and location. The entity will be loaded into RAM when the game spawns it in a level.
Now that we've covered the basics, let's look at two major approaches to using these commands.
Method #1: Load Everything
Pros:
-Virtually no loading screens in between stages and levels. Game will transition smoothly.
-All possible entities are fully available in memory. So no clever techniques are required to spawn things like hitflashes, projectiles, NPCs, and more.
Cons:
-Depending on how big the game is, the load time before the player sees the title screen can be extremely long.
-Loading all entities into RAM from the get-go can mess up console compatibility. Not everyone plays OpenBOR on PC, so not everyone has a virtually limitless amount of RAM to deal with. For example, the Dreamcast only has 16 mb of RAM, and PSP-1000 ("phat") has 32 mb of RAM. OpenBOR uses RAM to process code and levels as well, so if your game loads more than the amount of RAM a console has, then your game isn't playable.
This method is the easiest. Like the name implies, you simply declare everything in Models.txt with load instead of know. That's it. A lot of OpenBOR modders choose to go this route because it promises smooth transitions between levels in-game. Personally, I don't like this method. But it's up to you.
Method #2: Load Essentials, Know Everything Else
Pros:
-Way better console compatibility. Allows "big mods" to be playable on low-end machines and consoles.
-Smaller initial load time; the player will see the title screen much faster.
Cons:
-Load time in between levels are longer.
-You will need to keep better track of which entity loads what, and this can be confusing for new modders.
This technique is a little tricky. But, if you use it right, then even a game as big as "Knights & Dragons: Endless Quest" can be played on the Dreamcast. This technique will only load things into RAM when they are actually being used. So if there's a Player character with a lot of projectiles, their projectiles won't be in memory unless you play as that character. This helps free RAM space for other things, like enemies and such. More free RAM space = a better chance that the game can be played on your console.
Here's how we set this up. First, load only mandatory entities in Models.txt. Basically, load only playable characters and hitflashes. For everything else, use know. This includes player/enemy projectiles, text entities, NPC summons, you name it. Everything.
Once you do that, you need learn of the other load command. This one is used in an entity's text file, and NOT Models.txt. From the manual:
You're asking, "NickyP, how do I use this?" It's pretty simple. Let's say you have a character that regularly shoots projectiles. In Models.txt, you want to load the Player, and know the projectile. Sometimes it's better to show you how to do all this, instead of just tell you. So, here's an example from my game, "ClaFan." Let's look at the code for the Archer.
In Models.txt:
Here, I'm loading the Archer, and knowing all of her projectiles and special hitflashes. This way, they only take up RAM memory if the player chooses to play as the Archer. So, in the Archer's actual character text file, we have...
I omitted all the stuff that's not important, just to make things clear. See how everything that has know in Models.txt is being loaded in the Archer's text file? Like I said, this means that they will only be put into RAM when you play as the Archer. So, let's say we picked the Archer in the character select screen. All of her projectiles and special hitflashes are loaded in RAM. How do we use them? The same way you'd use anything else!
Again, non-important stuff omitted. Because arc1 is a standard projectile, and I've loaded it into memory, I use it with custknife and throwframe. You can study up on those commands later. The point I'm illustrating here is, with clever use of all these commands, we can manage our memory usage more efficiently.
Alright folks, that's it! Another day I'll be back with some other techniques, like reusing image files to save up on precious RAM space. Or, you guys can post your own memory management tricks. Keeps these two major methods in mind, and have fun modding!
Load vs. Know
Load and Know are mandatory commands that are used in Models.txt. Without Load and Know, there would not be an OpenBOR game. To begin, let's look and see what the manual says about these two commands:
~load {name} {path}
{name} is a name that the game will use to identify the entity.
{path} is the location relative to OpenBoR of the entity's .txt file.
The entity is always loaded when OpenBoR starts and will always be in memory.
~know {name} {path}
{name} is a name that the game will use to identify the entity.
{path} is the location relative to OpenBoR of the entity's .txt file.
These entities are only loaded to memory when actually needed or to be exact when levels load them.
In case you can't tell the difference, let me break it down to you like this:
Load will load all code, images, and sound files an entity uses into RAM memory. Load is mandatory for Player characters, as Players must always be in RAM at all times. There are other ways to load Players without bogging down RAM, but that's a more advanced technique for another day.
Know will only load a placeholder of an entity into RAM; in other words, Know won't load all files of an entity, just the entity's name and location. The entity will be loaded into RAM when the game spawns it in a level.
Now that we've covered the basics, let's look at two major approaches to using these commands.
Method #1: Load Everything
Pros:
-Virtually no loading screens in between stages and levels. Game will transition smoothly.
-All possible entities are fully available in memory. So no clever techniques are required to spawn things like hitflashes, projectiles, NPCs, and more.
Cons:
-Depending on how big the game is, the load time before the player sees the title screen can be extremely long.
-Loading all entities into RAM from the get-go can mess up console compatibility. Not everyone plays OpenBOR on PC, so not everyone has a virtually limitless amount of RAM to deal with. For example, the Dreamcast only has 16 mb of RAM, and PSP-1000 ("phat") has 32 mb of RAM. OpenBOR uses RAM to process code and levels as well, so if your game loads more than the amount of RAM a console has, then your game isn't playable.
This method is the easiest. Like the name implies, you simply declare everything in Models.txt with load instead of know. That's it. A lot of OpenBOR modders choose to go this route because it promises smooth transitions between levels in-game. Personally, I don't like this method. But it's up to you.
Method #2: Load Essentials, Know Everything Else
Pros:
-Way better console compatibility. Allows "big mods" to be playable on low-end machines and consoles.
-Smaller initial load time; the player will see the title screen much faster.
Cons:
-Load time in between levels are longer.
-You will need to keep better track of which entity loads what, and this can be confusing for new modders.
This technique is a little tricky. But, if you use it right, then even a game as big as "Knights & Dragons: Endless Quest" can be played on the Dreamcast. This technique will only load things into RAM when they are actually being used. So if there's a Player character with a lot of projectiles, their projectiles won't be in memory unless you play as that character. This helps free RAM space for other things, like enemies and such. More free RAM space = a better chance that the game can be played on your console.
Here's how we set this up. First, load only mandatory entities in Models.txt. Basically, load only playable characters and hitflashes. For everything else, use know. This includes player/enemy projectiles, text entities, NPC summons, you name it. Everything.
Once you do that, you need learn of the other load command. This one is used in an entity's text file, and NOT Models.txt. From the manual:
load {name}
~This forces engine to load other entity into memory so the entity can be used.
~{name} is name of loaded entity.
~Normally it's used for projectiles but it can be used to load any 'known' entity especially if the entity is never spawned anywhere in level. Useful to load entities which are spawned by commands such as 'throwframe' and 'spawnframe'.
~Before using this, the entity must be declared with 'know' in models.txt.
You're asking, "NickyP, how do I use this?" It's pretty simple. Let's say you have a character that regularly shoots projectiles. In Models.txt, you want to load the Player, and know the projectile. Sometimes it's better to show you how to do all this, instead of just tell you. So, here's an example from my game, "ClaFan." Let's look at the code for the Archer.
In Models.txt:
load Archer data/chars/archer/archer.txt
know arc1 data/chars/archer/arc1.txt
know arc1b data/chars/archer/arc1b.txt
know arc2 data/chars/archer/arc2.txt
know arc3 data/chars/archer/arc3.txt
know ar data/chars/archer/ar.txt
Here, I'm loading the Archer, and knowing all of her projectiles and special hitflashes. This way, they only take up RAM memory if the player chooses to play as the Archer. So, in the Archer's actual character text file, we have...
name Archer
type player
health 150
load arc1
load arc1b
load arc2
load arc3
load ar
I omitted all the stuff that's not important, just to make things clear. See how everything that has know in Models.txt is being loaded in the Archer's text file? Like I said, this means that they will only be put into RAM when you play as the Archer. So, let's say we picked the Archer in the character select screen. All of her projectiles and special hitflashes are loaded in RAM. How do we use them? The same way you'd use anything else!
anim attack1
offset 45 54
bbox 40 34 11 18
custknife arc1
throwframe 2 2
delay 7
frame data/chars/archer/9.png
sound data/sfx/sword.wav
delay 15
frame data/chars/archer/10.png
delay 10
frame data/chars/archer/11.png
Again, non-important stuff omitted. Because arc1 is a standard projectile, and I've loaded it into memory, I use it with custknife and throwframe. You can study up on those commands later. The point I'm illustrating here is, with clever use of all these commands, we can manage our memory usage more efficiently.
Alright folks, that's it! Another day I'll be back with some other techniques, like reusing image files to save up on precious RAM space. Or, you guys can post your own memory management tricks. Keeps these two major methods in mind, and have fun modding!
