Jump to content
Sign in to follow this  
Kydoimos

Init.SQF Optimization

Recommended Posts

Hey all! Wondering if someone can help me with my frankly noobish scripting. Basically, I'm running an init.sqf that calls a couple of SQF files and contains a 15 second sleep, along with a bundle of animations etc. Now, my problem is, the first time I run the mission in the editor (and only the first time), the mission is sluggish and the OSD text appears later than it should and dialogue is getting delayed. I suspect the init.SQF is getting clogged.

How can I run a series of sqfs for an intro without this happening? Strangely, I've used sqfs and sleeps in other missions, and have not had this problem. Any suggestions? Thanks very much in advance!

---------- Post added at 20:58 ---------- Previous post was at 20:52 ----------

The strangest thing is - it ONLY happens when I load Arma 3 and load the mission the first time! :p

---------- Post added at 21:03 ---------- Previous post was at 20:58 ----------

Scheduled scripts always start with slight delay, subject to engine load.
I wonder if this is my problem?

Share this post


Link to post
Share on other sites

Not sure what the problem is exactly, but you may look into uiSleep. I've used it before in init.sqf and it helped delay map at briefing until everything was loaded. Had to play with exact amount of sleep. The A2 mission in my sig uses it.

Share this post


Link to post
Share on other sites

Interesting! I'll look into that! Thanks!

Share this post


Link to post
Share on other sites

Hi, ROT - no, there's no script errors or anything - thanks for the link!

Share this post


Link to post
Share on other sites

Can you post the mission here or your init.sqf?

Share this post


Link to post
Share on other sites

Hi Grumpy Old Man, I've tried that - yeah, doesn't seem to matter! ZooLoo75, might do that after work today. Thanks for your responses!

Share this post


Link to post
Share on other sites

The issue here is that on the first time you launch the mission the game is loading all the textures and objects for the first time, so the initial load is longer. Unfortunately while it's loading init.sqf has already been called and is executing.

The only nice workaround I can think of right now is to use BIS_fnc_blackOut and BIS_fnc_blackIn;

Try this at the very top of your init.sqf or initPlayerLocal.sqf:

[ "BIS_ScreenSetup", false ] call BIS_fnc_blackOut;
sleep 5;
[ "BIS_ScreenSetup", true ] call BIS_fnc_blackIn;

I actually use this in most of my missions just because it looks nicer anyway. Give it a go.

Share this post


Link to post
Share on other sites

Thanks everyone for your responses - yes, as Azer1234 asks, how exactly can the finishMissionInit be used? That sounds like it might do the trick!

Share this post


Link to post
Share on other sites
The issue here is that on the first time you launch the mission the game is loading all the textures and objects for the first time, so the initial load is longer. Unfortunately while it's loading init.sqf has already been called and is executing.

The only nice workaround I can think of right now is to use BIS_fnc_blackOut and BIS_fnc_blackIn;

Try this at the very top of your init.sqf or initPlayerLocal.sqf:

[ "BIS_ScreenSetup", false ] call BIS_fnc_blackOut;
sleep 5;
[ "BIS_ScreenSetup", true ] call BIS_fnc_blackIn;

I actually use this in most of my missions just because it looks nicer anyway. Give it a go.

Cool thanks.

Share this post


Link to post
Share on other sites

Also, it seems the audio takes a while to process - for instance, the digital text sound on the OSD takes a while to materialise.

Share this post


Link to post
Share on other sites

As a matter of fact, the OSD seems to take a lot of effort to process - even when I pre-process it. Really odd, that!

Share this post


Link to post
Share on other sites

Plus, all the KB conversations are delayed at mission load. It's like there's a pause and then the audio needs to catch up.

Share this post


Link to post
Share on other sites
Thanks everyone for your responses - yes, as Azer1234 asks, how exactly can the finishMissionInit be used? That sounds like it might do the trick!

I am not 100% certain, but my understanding is finishMissionInit is a nullary command, used in the same way one would use "waitUntil {scriptDone _scriptHandle}". It presumably suspends execution of the code until the mission initialisation is complete.

Share this post


Link to post
Share on other sites

---------- Post added at 12:00 ---------- Previous post was at 11:35 ----------

Thanks Ceeeb - that really helpful! Good to know!

Edited by Kydoimos

Share this post


Link to post
Share on other sites

Hi there,

This might be, because the rendering is still being loaded.

Try:

// Add event handler that fires once all systems (rendering, simulation etc) have been loaded and player is in control of character
["BIS_introPreload", "onPreloadFinished", {
// Remove event handler
["BIS_introPreload", "onPreloadFinished"] call BIS_fnc_removeStackedEventHandler;

// Flag
missionNamespace setVariable ["BIS_readyForIntro", true];
}] call BIS_fnc_addStackedEventHandler;

waitUntil {
!isNil { missionNamespace getVariable "BIS_readyForIntro" };
};

// YOUR CODE GOES HERE

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×