Jump to content
Sign in to follow this  
CombatComm

How much do triggers and markers lag the in game performance?

Recommended Posts

As I continue to create my mission I have noticed my map becoming extremly cluttered with markers and triggers ALL nessecary for it to work. I also like to create the script in the triggers as it is less time consuming and convenient. My question is, does execVM "script.sqf" as opposed to executing the syntax right there in the trigger make ANY difference in performance or CPU usage? And does the amount of triggers placed in the editor lag the game? I mean the engine dosent have to render it visually anyway so I imagine it wouldent. Thanks

Share this post


Link to post
Share on other sites
My question is, does execVM "script.sqf" as opposed to executing the syntax right there in the trigger make ANY difference in performance or CPU usage?

ther should be no diffrance in performance by doing that.. only reason you want to do it, is to make your life much easyer. espesialy if there is a error in you commands. easyer to look int the script than in the act of the trigger.

does the amount of triggers placed in the editor lag the game?

yes/no. it really depends what they do and how big the trigger area is.

if you have problems with cutter. i suggest you make some of your scripts functons..

then call the function from the trigger instead of execing a script.

example.. in init.sqf put somethign like this for a function file

call compile preprocessFileLineNumbers "my_fnc.sqf";

now in my_fnc.sqf you can have functions.

Myname = 
{
   hint str(name player)
};

test = 
{
   _x = _this;
   _y = 1;
   _res = _x +_y;
  _res //return value.. "no ;"
};

so if you exec a command like call Myname; the player name will be hinted.

if you exec a command like value = [1] call test the result of value will be 2

now if you make a function with a sleep in it. you can not use call. but use spawn instead :)

this helps alot of you have scripts that are executed more than once during gameplay..

hope some this will help you uncutter you mission :p

Share this post


Link to post
Share on other sites

Well, the main performance hit comes from the fact that triggers check for their conditions very often. Even it the trigger is set to execute only once, it will check for its condition every frame until it is satisfied or the trigger is deleted.

Sometimes it helps to only check for the initial condition in a trigger and then launch a script to determine when to execute further action.

If a process is running continuously, it probably should be put into a script because you can control the execution time of a loop with sleep commands.

An advanced method to run complex missions is to only spawn what you need for the next objective via script and perform cleanup when it's done. Even dead bodies affect performance, although mostly graphical lag. However, you really can't place every unit in the editor if your mission is that complex. You can store their exact position in a script or use logic to place them intelligently via script though.

Share this post


Link to post
Share on other sites

I am currently utilizing the spawngroup BIS function only after one objective is complete and so on like u stated. So that should help with performance. However, I am not sure how to clean up dead bodies. I did hear that the garbage module would work with this function well? Sync it or just place it?

Well, the main performance hit comes from the fact that triggers check for their conditions very often. Even it the trigger is set to execute only once, it will check for its condition every frame until it is satisfied or the trigger is deleted.

Sometimes it helps to only check for the initial condition in a trigger and then launch a script to determine when to execute further action.

If a process is running continuously, it probably should be put into a script because you can control the execution time of a loop with sleep commands.

An advanced method to run complex missions is to only spawn what you need for the next objective via script and perform cleanup when it's done. Even dead bodies affect performance, although mostly graphical lag. However, you really can't place every unit in the editor if your mission is that complex. You can store their exact position in a script or use logic to place them intelligently via script though.

Share this post


Link to post
Share on other sites

Instead of placing a lot of triggers at start of mission you could have only a few triggers.

After their job is done they can call a function that creates the next triggers, or better you reuse the old triggers (give them names in the name field and use settriggerX commands).

I don't know if it's possible to delete a trigger. It could be done (but I didn't test it) by setting their activation to once and activating them after.

To delete dead bodies you can simply have an array of groups and have a script check if units are dead for each group.

MYGROUPS = [];

Each time you spawn a group : MYGROUPS = MYGROUPS + <if BIS_spawnGroup returns a group then : BIS_spawnGroup else: group a_spawned_soldier>

then

[] spawn
{
   while {true} do
   {
       {
           if (count units _x == 0) then {deleteGroup _x; MYGROUPS = MYGROUPS - [_x]} else
           {
               {
                   if (! alive _x) then {deleteVehicle _x};
               } forEach units _x;
           };
       } forEach MYGROUPS;
       sleep 1;
   };
};

Edited by d3nn16

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  

×