Jump to content
JohnKalo

Modules Lag when Mission does not

Recommended Posts

By placing it all in a trigger it indeed worked. The lag however although slightly less was there . It still lagged when the bis_fnc_infoText function does not for some reason.

 

About the mission tasks lagging it is indeed true that that mission has a few more scripts than the others but they are only called at certain times and for a certain and limited amount of time. It is scripts which give effects like explosions and such. The number of AI units is the same or even lesser than the other missions. So although most AI units follow scripts so as to patrol even when they are stationed in houses, there should not be an issue. Maybe because the units are in one BIG town and not in different villages. Even then the tasks lagging cannot be fixed.

Share this post


Link to post
Share on other sites
On 9/9/2018 at 11:34 AM, JohnKalo said:

10.] Sometimes I use safety triggers because the mission refuses to place playable units in vehicles. I just place the same trigger 2 or 3 times and all good..

 

So you have multiple triggers doing the same thing?

Are you using other practices similar to this one?

 

Other than that try build stuff from the ground up and see when those "lags" start to show up.

Vanilla first, add mod units/vehicles when the framework for the mission does what it should.

Then add fancy stuff like video playback, music etc.

 

Cheers

Share this post


Link to post
Share on other sites

 @Grumpy Old Man

  • I use 3 triggers instead of one only in one incident. It is the trigger which places all units in a plane at the start of the mission. For some reason if there are not 2 or 3 triggers some units stay out of the plane and the whole mission ends before it starts.
  • Nope, no other similar practices. 
  • Yep, that can be done. For the next mission :) Cannot build this one again since I will anyways build more missions. Although in general the more I advance the mission the more the modules lag. Triggers do not lag at all. And it is not just the task modules. A module unlocking a simple door lags too  :scratchchin:

 

Maybe I should try using script generated tasks and not modules to see if those lag. Hard since the mission is all set but it would be nice to see if the script tasks lag. And most online tutorials are for using modules. I found an example but the thread is all in german. I do not know so many german so can you please send me an MP example in scripting tasks?

 

 

Share this post


Link to post
Share on other sites
39 minutes ago, JohnKalo said:

Maybe I should try using script generated tasks and not modules to see if those lag. Hard since the mission is all set but it would be nice to see if the script tasks lag. And most online tutorials are for using modules. I found an example but the thread is all in german. I do not know so many german so can you please send me an MP example in scripting tasks?

 

I already posted some basic examples on how to tackle simple task scripting in these forums:

 

 

 

Check the demo mission in the second one.

 

Cheers

  • Thanks 1

Share this post


Link to post
Share on other sites

@Grumpy Old Man Ok thanks! Just one question for now. Since it is an MP mission, I will place the code in the init.sqf and call it via a trigger (_runTasks = [] spawn GOM_fnc_linearTasks;) but what will I type in this param:

 

_taskOwner = player;

like blue0, blue1, blue2; or [blue0, blue1, blue2]; or something like players;?

Share this post


Link to post
Share on other sites
36 minutes ago, JohnKalo said:

@Grumpy Old Man Ok thanks! Just one question for now. Since it is an MP mission, I will place the code in the init.sqf and call it via a trigger (_runTasks = [] spawn GOM_fnc_linearTasks;) but what will I type in this param:

 


_taskOwner = player;

like blue0, blue1, blue2; or [blue0, blue1, blue2]; or something like players;?

init.sqf is executed for the server and for every player that joins, so that would be a bad idea.

You can use named units, or handle adding players to tasks via initPlayerLocal.sqf, probably worth its own thread to not further derail this one.

 

Cheers

  • Thanks 1

Share this post


Link to post
Share on other sites

@Grumpy Old Man Just to post the results:

 

I used the mission of yours and a few wiki Arma pages and I managed to make all tasks via a script called through the initPlayerLocal.sqf. The results were that tasks' lag still existed. Before it was about a minute. Now it is 1-2 seconds!!! The tasks location does not lag at all. Only the screen showing task assigned or task succeeded and such lags. On my end and I am on a laptop so it might not lag at all when on a computer. Now if it is MP compatible? Well where it said player I used west as stated in the wiki so it should be.

 

As for the text, using the bis text functions meant no lag!!! And here is the weird thing. The bis function showing the letters to appear one by one lags like it does in the script while the other text functions do not lag. Whatevs. Issue overridden :thumbsup: 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, JohnKalo said:

@Grumpy Old Man Just to post the results:

 

I used the mission of yours and a few wiki Arma pages and I managed to make all tasks via a script called through the initPlayerLocal.sqf. The results were that tasks' lag still existed. Before it was about a minute. Now it is 1-2 seconds!!! The tasks location does not lag at all. Only the screen showing task assigned or task succeeded and such lags. On my end and I am on a laptop so it might not lag at all when on a computer. Now if it is MP compatible? Well where it said player I used west as stated in the wiki so it should be.

 

As for the text, using the bis text functions meant no lag!!! And here is the weird thing. The bis function showing the letters to appear one by one lags like it does in the script while the other text functions do not lag. Whatevs. Issue overridden :thumbsup: 

What exactly does lag? The animation that pops up mid screen? That's nothing you can avoid except not using the animation, seems to be odd that there's some kind of internal delay in the animation, I usually tend to add 5 seconds sleep before adding another task to make sure the current task hint animation is completed. Otherwise the animation of the new task gets played, followed by the animation of the previously completed task, pretty odd if you ask me.

 

Still sounds like there's something odd going on, since slowed down info text functions can be the result of something clogging up the scheduler.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

@Grumpy Old Man Yep, that animation is the one lagging. I also use sleep 5 normally but in this case it does not delay anything. It shows task completed and then task assigned almost immediately. Without waiting for the first animation to be over. It did that one with the modules too. Maybe it is because the animation showing task completed lags while the animation showing new task assigned does not as much. Not making much sense since the animation lag is not 5 seconds! And I should point out that the task animation lagging only happened on the host and not on the clients.

 

What is that scheduler thing? Plus only one text function lags. The others do not and so I use them. And in general, after replacing all the triggers and modules and syncing with the script generated task, the mission seems to be optimized too. It goes even smoother. I might even replace all campaign missions task modules with the script ones. Will take time but I believe it is worth the while.

Share this post


Link to post
Share on other sites

So I followed the thread's advise and I found the culprit! In the new mission I am making I firstly entered the tasks and then I tried placing everything else. Once I placed this one script the tasks started to lag. It is a script I activate via eaches unit init line like this:

 

guard = [this] execVM "HousePatrol.sqf"

and the script which is not mine is this one:

 


 

/*===========================================================================================
    Random House Patrol Script v2.2 for Arma 3
    by Tophe of Östgöta Ops [OOPS]

    Contact & bugreport: BIS forums

=============================================================================================
HOW TO USE:
Place unit close to a house and put this in the init field:  
guard = [this] execVM "HousePatrol.sqf"


OPTIONAL SETTINGS:

guard = [this, MODE, STAND TIME, EXCLUDED POS, STARTING POS, DEBUG] execVM "HousePatrol.sqf"

* BEHAVIOUR - set unit behaviour.
    guard = [this,"COMBAT"] execVM "HousePatrol.sqf"
    
    Options: CARELESS, SAFE, AWARE, COMBAT, STEALTH
    Default: SAFE

* STAND TIME - Set maximum amount of seconds the unit will wait before moving to next waypoint.
    guard = [this,"SAFE",50] execVM "HousePatrol.sqf"
        
    Options: Any value in seconds. 0 = continuous patrol.
    Default: 30

* EXCLUDED POSITIONS - exclude certain building positions from patrol route.
    guard = [this,"SAFE",30, [5,4]] execVM "HousePatrol.sqf"
    
    Options: Array of building positions
    Default: [] (no excluded positions)
    
* STARTING POS - Some building positions doesn't work well will the setPos command.
    Here you may add a custom starting pos. Negative number means starting pos will be randomized.
    guard = [this,"SAFE",30, [5,4], 2] execVM "HousePatrol.sqf"

    Options: Any available building position
    Default: -1 (random)

* STANCE - Tell the unit what stance to use.
    To keep the unit from going prone you can set this to MIDDLE or UP.
    AUTO will be the standard behaviour and unit will crawl around in combat mode.
    HIGH is the default mode. This is like AUTO but prone position is excluded.
    
    Options: UP, DOWN, MIDDLE, AUTO, HIGH
    Default: HIGH
    
* DEBUG - Use markers and chatlog for mission design debugging.
    guard = [this,"SAFE",30, [], -1, true] execVM "HousePatrol.sqf"     
    
    Options: true/false
    Default: false

===========================================================================================*/

if (!isServer) exitWith {};
sleep random 1;

// Set variables
_unit                 = _this select 0;
_behaviour             = if (count _this > 1) then {toUpper(_this select 1)} else {"SAFE"};
_maxWaitTime         = if (count _this > 2) then {_this select 2} else {30};
_excludedPositions     = if (count _this > 3) then {_this select 3} else {[]};
_startingPos         = if (count _this > 4) then {_this select 4} else {-1};
_stance             = if (count _this > 5) then {toUpper(_this select 5)} else {"HIGH"};
_debug                 = if (count _this > 6) then {_this select 6} else {false};

_position = getPos _unit;
_house = nearestBuilding _unit;
_numOfBuildingPos = 0;
_currentBuildingPos = 0;
_lastBuildingPos = 0;
_waitTime = 0;
_timeout = 0;

_behaviours = ["CARELESS", "SAFE", "AWARE", "COMBAT", "STEALTH"];
_stances = ["UP", "DOWN", "MIDDLE", "AUTO", "HIGH"];

_name = vehicleVarName _unit;


if (isNil _name) then
{
    _name = format["Guard x%1y%2", floor (_position select 0), floor (_position select 1)]
};

// Set behaviour of unit
if (_behaviour in _behaviours) then
{
    _unit setBehaviour _behaviour;
}
else
{
    _unit setBehaviour "SAFE";
};


// Set unit stance
if (_stance == "HIGH") then
{
    _stanceCheck =
    {
        _unit = _this select 0;
        while {alive _unit} do
        {
            if (unitPos _unit == "DOWN") then
            {
                if (random 1 < 0.5) then {_unit setUnitPos "MIDDLE"} else {_unit setUnitPos "UP"};                
                sleep random 5;
                _unit setUnitPos "AUTO";
            };

        };
    };

    [_unit] spawn _stanceCheck;
}
else
{
    if (_stance in _stances) then {
        _unit setUnitPos _stance;
    }
    else {
        _unit setBehaviour "UP";
    };
};


// Find number of positions in building
while {format ["%1", _house buildingPos _numOfBuildingPos] != "[0,0,0]"} do {
    _numOfBuildingPos = _numOfBuildingPos + 1;
};

// DEBUGGING - Mark house on map, mark building positions ingame, broadcast information
if (_debug) then {
    for [{_i = 0}, {_i <= _numOfBuildingPos}, {_i = _i + 1}] do    {
        if (!(_i in _excludedPositions)) then {    
            _arrow = "Sign_Arrow_F" createVehicle (_house buildingPos _i);
            _arrow setPos (_house buildingpos _i);
        };
    };
    player globalChat format["%1 - Number of available positions: %2", _name, _numOfBuildingPos];
    if (count _excludedPositions > 0) then
    {
        player globalChat format["%1 - Excluded positions: %2", _name, _excludedPositions];
    };
    
    _marker = createMarker [_name, position _unit];
    _marker setMarkerType "mil_dot";
    _marker setMarkerText _name;
    _marker setMarkerColor "ColorGreen";
};

// Put unit at random starting pos.
while {_startingPos in _excludedPositions || _startingPos < 0} do {
    _startingPos = floor(random _numOfBuildingPos);
};

if (_startingPos > _numOfBuildingPos - 1) then {
    _startingPos = _numOfBuildingPos - 1
};

if (_numOfBuildingPos > 0) then {
    _unit setPos (_house buildingPos _startingPos);
    _unit setPos (getPos _unit);
};

// DEBUGGING - broadcast starting position
if (_debug) then {
    player globalChat format["%1 - starting at building pos %2", _name, _startingPos]
};

// Have unit patrol inside house
while {alive _unit && (_numOfBuildingPos - count _excludedPositions) > 0} do {

    if (_numOfBuildingPos < 2) exitWith {};
    
    while {_lastBuildingPos == _currentBuildingPos || _currentBuildingPos in _excludedPositions} do    {
        _currentBuildingPos = floor(random _numOfBuildingPos);
    };
    
    _waitTime = floor(random _maxWaitTime);
    _unit doMove (_house buildingPos _currentBuildingPos);
    _unit moveTo (_house buildingPos _currentBuildingPos);
    sleep 0.5;
    _timeout = time + 50;
    waitUntil {moveToCompleted _unit || moveToFailed _unit || !alive _unit || _timeout < time};    
    if (_timeout < time) then {_unit setPos (_house buildingPos _currentBuildingPos)};
    
    // DEBUGGING - move marker to new position
    if (_debug) then {
        _name setMarkerPos position _unit;
        _text = format["%1: moving to pos %2", _name, _currentBuildingPos];
        _name setMarkerText _text;
    };
    
    sleep _waitTime;
    _lastBuildingPos = _currentBuildingPos;
};

// DEBUGGING - Change marker color if script ends
if (_debug) then {
    player globalChat format["%1 - ended house patrol loop", _name];
    _name setMarkerColor "ColorRed";
};

 

Sadly the person who created the script has months to log in to the forums so I cannot ask him directly. So is there something I can do about this? In the script's thread nobody said anything about lag.

Tried placing the script into a spoilers tab but it erased the whole thing. So I just added it like ^^^

  • Like 1

Share this post


Link to post
Share on other sites

A few tips

{format ["%1", _house buildingPos _numOfBuildingPos] != "[0,0,0]"}

->

{!((_house buildingPos _numOfBuildingPos) isEqualTo [0,0,0])}

 

 

 

_unit                 = _this select 0;
_behaviour             = if (count _this > 1) then {toUpper(_this select 1)} else {"SAFE"};
_maxWaitTime         = if (count _this > 2) then {_this select 2} else {30};
_excludedPositions     = if (count _this > 3) then {_this select 3} else {[]};
_startingPos         = if (count _this > 4) then {_this select 4} else {-1};
_stance             = if (count _this > 5) then {toUpper(_this select 5)} else {"HIGH"};
_debug                 = if (count _this > 6) then {_this select 6} else {false};

->
 

params ["_unit", ["_behaviour", "SAFE", [""]], ["_maxWaitTime", 30, [0]], ["_excludedPositions", [], [[]]], ["_startingPos", -1, [0]], ["_stance", "HIGH", [""]], ["_debug", false, [false]]
_behaviour = toUpper _behaviour;
_stance = toUpper _stance;

 

 

 

    _stanceCheck =
    {
        _unit = _this select 0;
        while {alive _unit} do
        {
            if (unitPos _unit == "DOWN") then
            {
                if (random 1 < 0.5) then {_unit setUnitPos "MIDDLE"} else {_unit setUnitPos "UP"};                
                sleep random 5;
                _unit setUnitPos "AUTO";
            };

        };
    };

    [_unit] spawn _stanceCheck;

Why the variable?

    [_unit] spawn {
        _unit = _this select 0;
        while {alive _unit} do
        {
            if (unitPos _unit == "DOWN") then
            {
                if (random 1 < 0.5) then {_unit setUnitPos "MIDDLE"} else {_unit setUnitPos "UP"};                
                sleep random 5;
                _unit setUnitPos "AUTO";
            };

        };
    };

 

 

 

waitUntil {moveToCompleted _unit || moveToFailed _unit || !alive _unit || _timeout < time};

Not that important. But lazy eval

waitUntil {moveToCompleted _unit || {moveToFailed _unit || {!alive _unit || _timeout < time}}};

 

 

Don't see anything that would specifically cause la..... Wait a second...

 

while {alive _unit} do {
    if (unitPos _unit == "DOWN") then {
        if (random 1 < 0.5) then {_unit setUnitPos "MIDDLE"} else {_unit setUnitPos "UP"};                
        sleep random 5;
        _unit setUnitPos "AUTO";
    };
};

If unitPos != DOWN. It will loop forever without any sleep.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks, I will try everything you posted!

 

The script when run causes the modules to lag. As you said, maybe the no sleep script is then one causing the issue.

Share this post


Link to post
Share on other sites

@Dedmen

 

So I placed everything you posted in the script and some errors were encountered.

However since I new what part of the script causes lag I now had a way to fight! So I started erasing everything that seemed excessive. 

It did not work at first because some lines were needed although they seemed fine to remove. After a few more sophisticated attempts however I managed to erase whatever parameter I could and success! Everything worked well and most importantly the task lag was gone!!!!! There even was an increase in the fps entirely. Thought I had changed the mouse's sensitivity but nope ... it was an fps increase! Thanks!!!

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

×