collapse

Author Topic: [OpenBOR TUTORIAL] Updating OpenBOR content on-the-fly.  (Read 549 times)

0 Members and 1 Guest are viewing this topic.

Online O Ilusionista

  • Since 1999 and kicking :)
  • IMT Content Architect
  • *
  • Posts: 12459
  • Country: Brazil br
  • Last Login:Today at 11:21:03 AM
  • OpenBOR & Mugen addicted
    • BMT - Brazil Mugen Team
    • Email
[OpenBOR TUTORIAL] Updating OpenBOR content on-the-fly.
« on: July 04, 2020, 04:05:59 PM »
Updating OpenBOR content on-the-fly.
Tutorial by O Ilusionista. With help of Damon Caskey, thanks buddy.

Although I love the engine, there was always something about OpenBOR that bothered me a little - you had to close the game and reload to update the materials with each modification you made. This wasted a lot of time, depending on the size of the game and the amount of items.

However I found that there is a way to update the material while the engine is running (on-the-fly).
It's not perfect, but it worked for me and it might be useful for more people. And it works when using the DATA folder and not compressed in .pak, ok?

STAGES--------
As Damon said some time ago, the contents of the stages (codes and images) are loaded before use and unloaded immediately after use - that is, when the scenario ends.

Then you can update the scenario files with the engine running. Just exit, save your changes and enter the stage again. The engine will load the content again, this time updated

ENTITIES--------
This is a more complicated case, based on the dependencies that each character has (in other words, the models that the entity carries)

For example, I want to update the entity called "bug". Even if I leave the scene and enter again, the entity will not be updated, as it is already in memory - And if you told the engine to load something it already loaded, it ignores it and moves on because the engine knows what it already loaded.

But here is a trick, which answers a question that I and others asked years ago - If the engine ignores when you ask to load something it has already loaded (in the default configuration), what happens if you tell the engine to load a content that is already in memory but changing the loading configuration?

Answer: ENGINE UPDATES THE LOADED MATERIAL!

And how do you change the loading configuration? Using a command in the stage's .txt file:

Quote
load {name} {bi}

~ Used to load a model whose name is {name} in current level.
~ {bi} determines if model stays in memory or not after current level ends.
0 = Nothing. The model is left alone (IOW, remains loaded) and loop moves on. This is the default action.
1 = Unload model only. The model is unloaded, but the sprites are not. Pretty pointless unless the model has a lot of script attached to it.
2 = Unload sprites only. The mode remains loaded, but its sprites are removed from memory.
3 = You'll notice there there is no third option, but because bitwise logic is in play, 3 effectively means "1 and 2" - model and sprites are unloaded.
~ This command is for loading weapons models or other entities which shouldn't be loaded until this command is executed. It's useful for memory usage control.
~ Don't forget to load {name} with 'know' in models.txt!

In my case, I added:
Quote
load bug 3

After updating what I wanted, I left the stage and entered it again - and now the entity was updated.

Note: for any dependency of this entity, such as weapons, projectiles, etc. that you want to be updated as well, it is necessary to place another command in the file. For example, if the "bug" entity has a projectile (knife / bomb / etc) called "missile", you need to add one more line:

Quote
load bug 3
load missile 3

Tip: You can make a simple test scenario that you will use to test entities and use this code.

« Last Edit: July 04, 2020, 04:59:02 PM by O Ilusionista »



Tags:
 


* IMT Facebook

Help us by Donating!

IMT Discord

Join us at our Discord! Click the image below!

* IMT Shoutbox

Sorry, this shoutbox does not exist.

* Recent Posts

* IMT Calendar

April 2024
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 [27]
28 29 30

SimplePortal 2.3.5 © 2008-2012, SimplePortal