Home   Help Search Login Register  

Author Topic: Prevent slight lag when using the createUnit command...  (Read 1597 times)

0 Members and 1 Guest are viewing this topic.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
In a rare opportunity to do some editing for a change I returned to a dynamic base population and patrol script I started a couple of years back, and it's working pretty well. The only real issue is the slight pause the engine makes when creating the loons. I've discovered that the pause is more or less the same when creating a single loon as it is for creating 22 at once. There are no initialisation scripts running for any of these spawned loons, it's just the basic vanilla "loon_type" createunit [_pos, _group] - nothing special.

The question is: would incorporating the spawning of these loons into a function rather than leaving it in the sqs script make any difference to that pause? If I understand functions correctly, since they're pre-processed they work faster - is that even a correct assumption? Has anyone dealt with this before?

I had a look inside MFCTI, since the auto-generation of troops in that is fairly pause-free: it's all sqs though.

I would go ahead and try it, but if someone has already tested this method and it doesn't affect the pause it's going to be a wasted effort and in that case I'd rather not spend more time on it.  :dunno:

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: Prevent slight lag when using the createUnit command...
« Reply #1 on: 21 Sep 2010, 19:44:02 »
In OFP it helped to put all units in the mission with 0% presence.
This way the engine seemed to preload the models already. Maybe it helps.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Prevent slight lag when using the createUnit command...
« Reply #2 on: 21 Sep 2010, 22:13:55 »
I did wonder if it was the models being loaded but I never thought to check. I tried your suggestion with placing the units I use in the spawn scripts on an island with each of them set to 0% probability of presence, but that didn't have any effect. However, I made their probability of presence 100% again, and there is now no pause at all!  :clap:

Fantastic input kju, many thanks. Problem solved.

* bedges wonders why this guy isn't on the OFPEC staff already...

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: Prevent slight lag when using the createUnit command...
« Reply #3 on: 29 Sep 2010, 20:08:35 »
It's because the game will load the data from the Hard Disk Drive.

So if it didn't load it already because it was needed, it will load it during run-time of the mission and therefore you get lag.

As you have found out the solution is to have one present on mission start-up so it will load it up-front.


By the way, a nice way to reduce lag during a cut-scene is to have the screen black at first and have all the objects there and then rotate the camera around. Then fade it in and start the cut-scene. This can make a noticeable difference on my computer at least.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Prevent slight lag when using the createUnit command...
« Reply #4 on: 01 Oct 2010, 13:46:57 »
Write a function that calls the createUnit command.
urp!