[SOLVED] Better memory management

O Ilusionista

Captain 100K
Hello guys, I need to hear from you all some ideas for a problem I will have in the future if I don't plan it ahead,

Right now, my game has 20 playable characters, and each one has at least one aditional model (weapon) and will have another. So we are talking about 60 models just for the playable characters.

With only 2 exceptions, all those alternate models will be used only in two specific stages (which set the wepaon in the level header) and them nowhere on the game. But since weapons are called using LOAD, all those models will be on the memory all the time, eating resources.

So, how you I could handle it better?

I have an idea, let's see if it's good:

- Call all those alternate models as KNOW, not LOAD
- Track the stage number/name storing it on a Global var
- In SELECT animation, check this Global Var and use a script to load the alternate model - loadmodel(name).
- After the stage end, unloads all the alternate models (probably, using endlevel.c). I know we have a function to "loadmodel", but do we have a function to "unloadmodel" by script?

Any other idea?
Thanks

EDIT: Oh wait, There is a configuration which could help me
weapon {name} {bi} Give this spawned enemy {name} as a weapon to start with. The enemy will wield this weapon and attack with it.

~If enemy is knocked down or dies, the weapon will be dropped.
~{bi} determines if model stays in memory or not after current level ends.
0 = Model stays in memory.
1 = Model is unloaded when current level ends.

~Make sure the weapon is available before setting this.
This would unload the weapon after the level ends, but I would still need to LOAD it right at the start, which impacts the game loading. I would like to bypass this.


Nevermind, it doesn't works with setweap.
 
If this was a possibility then a 1 on 1 fighting game would not be a problem.

I thought of a work around for that 1 level you could spawn a npc and control it using keyscripts but that maybe a long way around the issue.
 
Per my PM, this is a case where you'd lose more than gain. Those weapon models are likely ~4K at most. Just not worth trying to save - it won't make any performance difference.

In programming, we call that micro-optimization (which I am very often guilty of). Don't waste resources ever, and if there's a way to optimize for free take it. Just don't go out of the way chasing meaningless gains. Often times you might even decrease performance.

DC
 
Back
Top Bottom