Search the Community
Showing results for tags 'oneachframe'.
Found 4 results
-
Code Optimization: onEachFrame vs WaitUntil vs Draw3D
Leopard20 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello everyone. I have a script that I need to run on each frame. The problem is, it can get too heavy sometimes (it runs some code for each element of an array, and if the array gets too big, the code gets slow), enough to reach 1 ms or longer execution time in code performance. I think I read somewhere that codes that run in scheduled environment (such as those called by waitUntil) have a time limit of 3 ms before being stopped by the engine. What is the best way of balancing performance and making sure the code is executed correctly? 1. Using onEachFrame stacked EH 2. Using Draw3d mission EH 3. Using waitUntil (without sleep) I think the first two methods won't get interrupted if the execution time exceeds 3 ms. But it might also mean that the code will slow down the mission even more. I have tested all three methods but they all appear more or less the same. I'd appreciate any help with this.- 31 replies
-
- optimization
- waituntil
-
(and 1 more)
Tagged with:
-
How can I improve efficiency of "onEachFrame" with BIS_fnc_addStackedEventHandler ?
cklymowsky posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
With additional units on the field the FPS starts to drop. I would like to have the script only calculate the _distance every second instead of on every frame to see how much it improves FBS. Any ideas? I have tried the following with no luck private ["_randomSectorDestination","_revealTime","_enemyArray","_addNew"]; _enemyArray = []; _distance = 0; _displayName = ""; _picture = ""; _icon = ""; _revealTime = 30; _run = missionNamespace setVariable ["Intel",0]; _timer = missionNamespace setVariable ["Timer",time]; fn_Draw3DNEW = { _enemyArray = []; _distance = 0; _displayName = ""; _picture = ""; _icon = ""; _run = missionNamespace getVariable ["Intel",0]; _timer = missionNamespace getVariable ["Timer",0]; {if (((side _x) == AIside) && (isFormationLeader _x)) then {_enemyArray pushBack _x}} forEach allUnits+vehicles+allUnitsUAV; { _text = ""; if ( floor(time-_timer) == _run ) then { _run = missionNamespace setVariable ["Intel",_run + 5]; private ["_private", "_displayName", "_picture", "_icon", "_text", "_distance", "_leaderDestination","_enemyArray"]; if (vehicle _x != _x) then {_x = vehicle _x}; _distance = round (_x distance player); _displayName = getText (configfile >> "CfgVehicles" >> typeOf _x >> "displayName"); }; _text = str(parseText format["%1 men %2m",count units group _x, (str _distance)]); _icon = ""; if ( (_x isKindOf "LandVehicle") or (_x isKindOf "Air") or (_x isKindOf "Ship") ) then { _picture = getText (configfile >> "CfgVehicles" >> typeOf _x >> "picture"); } else { _icon = getText (configFile >> "CfgVehicles" >> typeOf _x >> "Icon"); _picture = getText (configFile >> "CfgVehicleIcons" >> _icon); }; drawIcon3D [ _picture, [1,0,0,1], [(visiblePosition _x) select 0,(visiblePosition _x) select 1,((visiblePosition _x) select 2) + 10], 0.8, 0.5, 0, _text, 0, 0.03, "PuristaMedium" ]; player reveal [_x, 4]; {[_x, 1] showWaypoint "ALWAYS" } forEach allGroups; } forEach _enemyArray; hint format ["_run: %1 \n floor(time-_timer): %2 \n floor(time-_timer) == _run: %3", _run, floor(time-_timer), floor(time-_timer) == _run]; }; _addNew = ["BIS_idNEW", "onEachFrame", "fn_Draw3DNEW"] call BIS_fnc_addStackedEventHandler; sleep (_revealTime); ["BIS_idNEW", "onEachFrame", "fn_Draw3DNEW"] call BIS_fnc_removeStackedEventHandler; _run = missionNamespace setVariable ["Intel",nil]; _timer = missionNamespace setVariable ["Intel",nil]; thanks in advance... -
Help with game FREEZING with onEachFrame script
cklymowsky posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
HI All, I'm creating script to display the wayPoints of all AI groups on the screen using an "onEachFrame" in a stackedEventHandler, in order to figure what their currentWaypoint is and how it works. But, I can't figure out why the framerate goes from 40-50 fps to 1 or 0 after a few minutes when a several (10-20) groups are on screen with the script below: Thanks for any help in advance. -
Hi all, desperate to see that BI don't want to add a SP revive function in Arma 3, I decided to create one for my mission but I can't use the one of Norrin because there is a bug with my mission : my team become invincible x) ! So, I'm almost done with the script but some problems remain : I have four playable units : unit1, unit2, unit3 and unit4. unit1 is the team leader/player. 1 - there is my first script (named "test.sqf") and First problem : I don't know how to apply this script to all the members of my team so for the example, I choose unit3 : _damage = damage unit3; _Hurt = _damage > 0.5; if (_Hurt) then {unit3 execVM "injured.sqf"} else {execVM "test.sqf"}; For this, I want to know how can I get the damages of unit1 to unit4 and check if _damage > 0.5 to execute injured.sqf for all of the units who are hurt. 2 - Injured.sqf, same problem than test.sqf : unit3 allowDamage false; unit3 playMove "AinjPpneMstpSnonWrflDnon_rolltoback"; sleep 3; unit3 playMove "AinjPpneMstpSnonWrflDnon_InhuredHealed"; unit3 DisableAI "MOVE"; unit3 addAction ["Revive", "Heal.sqf", nil, 6, true, true, "", "(_target distance _this) < 2"]; 3 - Heal.sqf - the most Important = First, I don't know if the 3 variables are correct (_wounded = the wounded / _medic = the caller of the action / _revive = the ID of the action); _medic playmove ... seems to do nothing (I think the problem is _medic) and finally, player playmove "animation_name" doesn't work, but work with an AI, do you have an idea ? : _wounded = this select 0; _medic = this select 1; _revive = this select 2; _medic playmove "Acts_TreatingWounded_in"; sleep 3; _medic playmove "Acts_TreatingWounded01"; sleep 5; _medic playmove "Acts_TreatingWounded02"; sleep 8; _medic playmove "Acts_TreatingWounded03"; sleep 9; _medic playmove "Acts_TreatingWounded_Out"; sleep 4; _medic setDamage 0; sleep 2; unit3 playMove "AinjPpneMstpSnonWrflDnon_rolltofront"; sleep 3; unit3 playMove "AmovPpneMstpSrasWrflDnon_AmovPercMstpSrasWrflDnon"; unit3 setCaptive false; unit3 allowDamage true; _wounded removeAction _revive; Thanks for the help ^^ !