Search the Community
Showing results for tags 'Optimization'.
Found 20 results
-
optimization [SOLVED] 5 lines only. Can you do it with less?
thy_ posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello, folks. Is there any chance you share a faster or more elegant way to write the same result below? Code goal: at the mission starts, search once all named markers and remove all found markers that aren't area markers (rectangles and ellipses), saving the result in a list for further purposes. Pretty sure even the first code line below could be smarter/complete. // Search through all markers on the map with the prefix "mark_" and append them in a list: _areaMarkersOnly = allMapMarkers select {_x find "mark_" isEqualTo 0}; // result example: ["mark_1", "mark_garbage", "mark_2"] but unfortunately including markers with unwanted shapes. { // forEach in _areaMarkersOnly: // It will be needed to identify what will be deleted later: _index = _areaMarkersOnly find _x; // If the marker (_x) is NOT rectangle and is NOT ellipse, so... if ( (markerShape _x != "RECTANGLE") AND (markerShape _x != "ELLIPSE") ) then { // delete this marker from my list: _areaMarkersOnly deleteAt _index; }; } forEach _areaMarkersOnly; SOLVED! Below, you see the code that works for me after the community advice: _acceptableShapes = ["RECTANGLE", "ELLIPSE"]; _prefix = "mark_"; if ( !_debug ) then { // Selecting only relevant markers: _areaMarkersOnly = allMapMarkers select { (_x find _prefix == 0) AND {(markerShape _x) in _acceptableShapes} }; } else { // For debugging purporses, the way to select the relevant markers here it is slightly different. Now selecting all markers shapes: _areaMarkersOnly = allMapMarkers select { _x find _prefix == 0 }; { // forEach _areaMarkersOnly: // _x index in the list, need it to delete _x from the list: _markerIndex = _areaMarkersOnly find _x; // if the marker has no the shapes acceptables, do it: if ( !((markerShape _x) in _acceptableShapes) ) then { // delete the marker from the list: _possibleMinefields deleteAt _markerIndex; // delete the marker from the map: deleteMarker _x; // and print this messages: systemChat format ["DEBUG > Marker '%1' has NO a rectangle or ellipse shape to be considered a area marker.", _x]; }; } forEach _areaMarkersOnly; }; -
Since I got the habit of placing tons of stuff in eden to get terrains to look better for my missions I ended up making a script that makes it much easier are a lot faster. The replaceobjects.sqf replaces whatever (even billboards in the fallujah map) and allows for tuning orientation, probability, randomisation, etc. I am satisfied with the results, but my lack of knowledge does not allow any further improvement. So I am asking for help to optimize the script and make it run in less time. I have no coding skills whatsoever so is highly probable that there are obviously better ways of doing stuff than the ones I used. This script makes it easy to mass replace buildings and other stuff. Here's two pictures of what it can do in two of my favourite maps: fallujah and diyala: This is my script: /* Replaceobjects.sqf by b3lx. This script replaces terrain objects randomly chosen out of a defined array. Good for batch changes in terrains like replacing tree types or houses. The following arguments have to be passed to the script - _pos = the center position of the area to include. - _radius = limits the max search range - _type = (optional) lists the types of objects the script should filter for. if empty it uses classnames passed through _oldobjlist - _oldobjlist = (optional) object classes to replace; only used if _type is empty - _newobjlist = object classes for replacement - _customdir = (optional) leave empty ("") or define aditional rotation angle for new objects. - _hidden = (optional) if true replacing includes hidden objects, default is false; - _percent = (optional) random percentage of matching object to replace, default is 1; - _sizefilter = (optional) array that defines minimum and maximum size values for object to be filtered. Useful when types or classnames don't work or if you want to use diferent replacements for different sized objects. Use [0,100] if you don't want to filter. - _code = (optional) custom code to be executed on each object, default is {}; - _altreplacer = classes to use when terrain slope is greater than 18 degrees (check isflatempty below). IF empty or false its not used. If true uses classes defined below in _altreplacerdefaul, otherwise use an array with desired classes. - _debug = (optional) markers for each replacement and message with number of replacements. Example 1: Replaces all "Land_House_L_6_EP1" houses with two RSO buildings with disabled simulation and rotated 180 degrees, and places debug markers. [player,200,[],["Land_House_L_6_EP1"],["rso_h21","rso_hut3"],180,true,1,[0,100], {_this disableSimulation true},false,true] execVM "replaceobjects.sqf"; Example 2: replaces 20% of houses around player between 0 and 10 size with two RSO buildings or rubble if the terrain is sloped [[worldsize select 0, worldsize select 1], (worldsize select 0) / 2,["house"],[],["rso_h21","rso_hut3"],0,true,0.2,[0,10], {},["Land_Fortress_01_bricks_v1_F"]] execVM "replaceobjects.sqf"; Example 3: replaces all houses around player with two RSO buildings [[player, worldsize,["house"],[],["rso_h21","rso_hut3"]] execVM "replaceobjects.sqf"; Example 4: replaces all billboards in fallujah by empty ones [replacer, radius,[],[], ["Land_Billboard_F"],0,true,1,[6.00263,6.00264]] execVM "replaceobjects.sqf"; List of types that can be filtered by, according to BIS: "TREE", "SMALL TREE", "BUSH", "object", "HOUSE", "FOREST BORDER", "FOREST TRIANGLE", "FOREST SQUARE", "CHURCH", "CHAPEL", "CROSS", "BUNKER", "FORTRESS", "FOUNTAIN", "VIEW-TOWER", "LIGHTHOUSE", "QUAY", "FUELSTATION", "HOSPITAL", "FENCE", "WALL", "HIDE","BUSSTOP", "ROAD", "FOREST", "TRANSMITTER", "STACK", "RUIN", "TOURISM", "WATERTOWER", "TRACK", "MAIN ROAD","ROCK", "ROCKS", "POWER LINES", "RAILWAY", "POWERSOLAR", "POWERWAVE", "POWERWIND", "SHIPWRECK", "TRAIL" */ //shuffle array function from killzonekid KK_fnc_arrayShuffle = { private "_cnt"; _cnt = count _this; for "_i" from 1 to _cnt do { _this pushBack (_this deleteAt floor random _cnt); if _debug then {systemchat format ["%1 randomized", _i]}; }; _this }; private ["_objArray","_filteredArray","_altreplacerdefault","_slctrl","_pos","_radius","_type","_oldobjlist","_newobjlist","_customdir","_hidden","_percent","_sizefilter","_code","_altreplacer","_debug"]; params ["_pos","_radius","_type","_oldobjlist","_newobjlist","_customdir","_hidden","_percent","_sizefilter","_code","_altreplacer","_debug"]; //finds objects according to criteria and puts them in an array _objArray = []; if (count _oldobjlist == 0) then { _objArray = nearestTerrainObjects [_pos, _type, _radius, false, true]; } else { _fullarray = nearestTerrainObjects [_pos, _type, _radius, false, true]; {if (typeOf _x in _oldobjlist) then {_objArray pushback _x}} forEach _fullarray; }; //filters array according to min and max size defined in _sizefilter if (isNil "_filteredArray") then {_filteredArray = []}; if (!isNil "_sizefilter") then { _sizeA = _sizefilter select 0; _sizeB = _sizefilter select 1; {if (((boundingboxREAL _x select 1 select 0) - (boundingboxREAL _x select 0 select 0) > _sizeA) && ((boundingboxREAL _x select 1 select 0) - (boundingboxREAL _x select 0 select 0) < _sizeB)) then { _filteredArray pushback _x}} forEach _objArray; } else { _filteredArray = _objArray; }; sleep 1; //sets default variables if undefined by user if (isNil "_customdir") then {_customdir = 0}; if (isNil "_hidden") then {_hidden = false}; if (isNil "_percent") then {_percent = 1}; if (isNil "_debug") then {_debug = false}; if (isNil "_code") then {_code = {}}; //houses to use if terrain slope is too great for specified ones. default values are used if _altreplacer is set to true _altreplacerdefault = ["Land_Addon_02_b_white_ruins_F"]; _altreplacer = true; if (isNil "_altreplacer" || !_altreplacer) then {_slctrl = false} else { _slctrl = true; if _altreplacer then {_altreplacer = _altreplacerdefault}; }; //randomizes the array using KK function _filteredArray call KK_fnc_arrayShuffle; if _debug then {systemchat "shuffled"}; reverse _filteredArray; sleep 1; _filteredArray resize (floor ((count _filteredArray) * _percent)); _rplcount = 0; //function that replaces the object _replaceobject = { params ["_oldobject", "_replacer"]; private ["_newobject"]; _position = getPosATL _oldobject; _direction = direction _oldobject; _oldobject hideObjectGlobal true; //checks if slope filter is used and selects from which array of objects (normal or for sloped terrain) to create new object if (!_slctrl) then { _newobject = _replacer createVehicle _position; } else { if (position _oldobject isFlatEmpty [-1, -1, 0.4, 1, 0, false] isEqualto []) then { _newobject = (selectRandom _altreplacer) createVehicle _position; _customdir = 0; } else { _newobject = _replacer createVehicle _position; }; }; //positions new created object on floor, adding custom direction and vertical orientation _newobject setPosATL [_position select 0, _position select 1, 0]; _newobject setDir _direction + _customdir; _newobject setvectorUp [0,0,1]; _newobject call _code; _rplcount = _rplcount + 1; //places debug markers if debug is on if (_debug) then { _mrk = createMarker [str _rplcount,_position]; _mrk setMarkerShape "ICON"; _mrk setMarkerType "hd_dot"; }; }; //checks if hidden objects are to be replaced and calls replacement function accordingly //sleep 1; if _hidden then { {[_x, (selectRandom _newobjlist)] call _replaceobject} forEach _filteredArray; } else { { if (!(isObjectHidden _x)) then {[_x, (selectRandom _newobjlist)] call _replaceobject} } forEach _filteredArray; }; if _debug then {systemchat format ["script replaced %1 objects", _rplcount]};
-
Hey guys new to Arma 3, always wanted to play it and this year I bought my first gaming rig - RTX 3070. AMD Ryzen 5 5600X 6-Core Processor 3.70 GHz, 16 gb Ram and 2tb SSD. I installed the game yesterday, ran it and it was horrible 4-7 fps, saw some videos, changed settings, did benchmark tests but nothing is working. Auto detect is telling me to play it on ultra while I get the same 4-7 fps on the lowest settings. Please help me out I don't want to uninstall the game I've been waiting to play all these years of my life.
- 10 replies
-
- perfomance
- low fps
-
(and 1 more)
Tagged with:
-
How do I enable multithreading? ArmA isn't using anywhere close to all of my resources, how can I make it to where it uses more? I am tired of 20 FPS. If anyone could help I would appreciate it.
- 3 replies
-
- performance
- optimize
-
(and 3 more)
Tagged with:
-
createagent [SOLVED] Seamless replacement of AGENTS for normal UNITS via script.
LSValmont posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello Dear Community! So I am using agents for my Civilian needs on a coop mission but the mission also requires that some of those civilian agents rebel and attack players. Since agents are very basic and cannot attack I must find a way to smoothly replace said agent for a REGULAR UNIT when the WITNESS´s rebel state triggers. Here is how I do stuff so far: PS: As you can probably tell by the script I am going for a "as optimized" as posible script since there will be lots of Witnesses and Enemy Units on the map as well as objects so I am tight on frames.- 11 replies
-
- 2
-
- createunit
- script
-
(and 1 more)
Tagged with:
-
Problem with code performance please help
Maffine posted a topic in ARMA 3 - ADDONS - CONFIGS & SCRIPTING
Hello everyone, I am currently doing two addons for myself and I encountered some problem in field test after everything made sense in editor. The mission I used to test involves a virtual arsenal at some point of the mission so that the player can customize their loadouts. However it would just stuck at the loading screen when I try to open the arsenal with the script on. I tried to run the mission without any mods and everything works fine, and when I only enable one script, the arsenal became accessible only that it will take much longer. Therefore my theory is that the while do script runs on each frame even when the loading screen is displayed and somehow severely affect the efficiency of the loading process. The problem is whether this can be avoided. The code structure I used for both addons: [] spawn { _varA = 0.0; _varB = 0.0; ... while {alive player} do { <Some code here> }; }; I understand that there may be a performance issue since my PC is really an old one, but it is obviously more ideal if the addon is more friendly to low-end devices. Thanks for any advice and sorry for my poor English. -
Optimizing holdAction for performance & Multiplayer
LSValmont posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello A3 Community! Since there is no topic on HoldAction optimization and tweaking I wanted to create one so we could perhaps answer some questions and share our findings. I love the holdActions implementation in Arma 3 far better than addAction but there is always the concern about performance and multiplayer compatibility. My first question would be: 1) Are Lazy evaluation/Successive condition check doable and beneficial for holdAction conditions and if so how could I implement it and optimize this example holdAction: The holdAction is added to the players and displayed when the conditions are met. The script that adds the holdAction is executed from init.sqf: nul = [] execVM "vTakeDown.sqf"; The conditions are: I worry that these many conditions might affect performance specially when adding other similar player holdActions but targeting only civilians etc. Question nber 2: How many holdActions can we add to a player before it starts lagging things out for that particular client?- 5 replies
-
- 1
-
- holdaction
- multiplayer
-
(and 1 more)
Tagged with:
-
Prepare Outlanders, at 17:00 CEST there will be server optimization. Some of you may notice disconnections from encounters in post-war Norway. If that will be your case, please a have a little patience. Thank you!
-
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:
-
scripts Centre Turret of Helicopter script [Solved]
PortalGunner posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi there, It's quite annoying when someone else has used the gunner seat of a Heli, offsetting its position, and you later decide to Manual Fire from the pilot's seat and have a misaligned gun. I've been putting a lot of effort into setting up a script that can deal with this via a User Action, however I'm getting a few errors. A few of them are about missing " ) ", " ] ", " ; " (though I have done my best to never leave these out, including using a bracket checker plugin), or invalid variables (which is probably because it's checking a variable before it's set). To summarise, when a player pilot is in an armed Heli, they shall get a user action to centre the turret. This will have either the current AI or a temporary, invisible AI in the gunner seat target a spawned marker in front of the vehicle (if a player is in the seat it won't affect them). I currently have five six files in relation to this. EDIT: Below has been updated to the latest working script - If you get errors make sure there's no invisible characters using Word It requires CBA mission.Malden\init.sqf mission.Malden\description.ext mission.Malden\functions\functions.hpp mission.Malden\functions\fn_centreTurret.hpp mission.Malden\functions\fn_allowCentreTurret.sqf mission.Malden\functions\fn_turretDir.sqf Currently, unit spawning, marker generation and AI watching are working as intended, however the user action does not appear and if i set off turretdir.sqf manually ( [] execVM "turretdir.sqf"; ) it errors. EDIT: All working as intended. I'm not as proficient at SQF scripting as I'd like to be, so I've probably made some very obvious mistakes. Any help setting this up correctly and optimising would be appreciated. I will keep trying in the meantime.- 54 replies
-
scripts Clear Roads Script - Optimization Required
Lemonwired posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi All, First time on these forums. I've created a unoptimized script that clears roads of obstacles to make it easier for AI to navigate past the clutter. It works to clear the roads but takes so damn long to execute. Any ideas here? Basically, the script works by looking for all roads within a radius then obtains all the nearest objects on that road and hides them. //0 = [player,1000,10] execvm "clearroad.sqf"; //here's what to put in the init.sqf //item 1 is the object that will be the center e.g. player //item 2 is the radius where all the roads that will be impacted e.g. 1000m around the player //item 3 is the area of the road that will be cleared e.g. 10 meters of road to be cleared _pos = _this select 0; _radius = _this select 1; _radius2 = _this select 2; _roadList= getpos _pos nearroads _radius; _notobjects = []; _i = 1; _arraycount = count _roadList; while {_i < _arraycount} do { _arr = nearestObjects [getpos (_roadList select _i), [], _radius2]; _arr2 = nearestterrainObjects [getpos (_roadList select _i), [], _radius2]; _notobjects = _notobjects + _arr + _arr2; _i = _i + 1; }; {hideobject _x} foreach _notobjects; kind regards, Lemon -
Code Optimization: Does setting variables to "nil" after usage help performance?
Leopard20 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello everyone. Currently I'm working on a mission which uses lots of "setVariables" for AI, and if a unit dies, it is deleted and a new unit is spawned instead (I have to use setVariable because it's hard to track all these variables using an array or something). That makes me wonder if these variables are now deleted or not. Basically a single unit could spawn a dozen times, and there could be as many as 50+ AI at any time in the game, which means lots of variables are constantly created, and thus slowing down the mission and consuming unnecessary RAM. If that's the case and the variables keep piling up, does setting them to nil (_unit setVariable ["SomeVar", nil]) help circumvent the issue? P.S: The variables are relatively large in size, and most of them are arrays.- 13 replies
-
- 1
-
- optimization
- performance
-
(and 1 more)
Tagged with:
-
Does white space affect performance?
prototype1479 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Does white space affect performance? If yes or no what about in previous BI games like OFP -
So as the title states I'm curious what you all think about efficiency/optimizations when it comes to writing a lengthy script/mod for a mission. My current scripted mod is AC-C4I (Air Craft Command, Contol, Computers, Communications, & Intelligence). It has to do with sensors and targeting. The scripts have a lot of "waitUntil" commands for locking the targeting camera to screenToWorld amongst other functions. What would be the most efficient way to write this/integrate it into a mission. I can write the whole thing in one file and "call compile preprocessFileLineNumbers" on init. I can create a CfgFunctions.hpp and add it to the description.ext, or I could make it an FSM. I'd love to hear from you guys. Thanks.
- 2 replies
-
- optimize
- efficiency
- (and 10 more)
-
Here is what I currently use.... Init.sqf: if ((not (hasInterface)) and (not (isDedicated))) then { [] spawn { waitUntil {!isNull player}; HC_init = (vehicle player); publicVariableServer "HC_init"; }; }; initServer.sqf: missionNamespace setVariable ["HCs",[]]; "HC_init" addPublicVariableEventHandler { _hc_name = (_this select 1); _hc_id = (owner _hc_name); _hcs = (missionNamespace getVariable "HCs"); _hcs set [(count _hcs), [_hc_name,_hc_id]]; missionNamespace setVariable ["HCs",_hcs]; }; as the title says, is there a more efficient way to accomplish this? Thanks.
-
fps 15-35 and lag Especially when many peoples fight will lag Come on playing Battlefield 4 without this problem My specs: 4KUHD Has been adjusted to 1920x1080 Win 10 CPU:Intel(R) core(tm) i7-6820hk cpu @ 2.70GHz GPU:MSI NVIDIA GTX 1080 RAM:DDR4 (64G) 1x M.2 SSD (SATA) 2x M.2 SSD Combo (NVMe PCIe Gen3 x4 / SATA ) SSD 1x 2.5" SATA HDD HDD already update latest nvidia driver material and effect all open to the maximum
-
New command createObject for decorative objects
dr. hladik posted a topic in ARMA 3 - DEVELOPMENT BRANCH
since 134151 there is a new command in dev. version - createObject (will not yet be part of next patch) what is it good for: - will create object, that is based only on shape (no config needed) - object is not simulated, so it will save some performance (no physx, no sounds, not a interesting target for AI,....) - unlike whole vehicle, it needs very little information to synchronize in MP - if you need decorative object that would normally need simulation (vehicles, tables, buckets) what is it not good for: - cannot handle whole animated soldier with uniform and weapon - will not help with objects, that already have very limited simulation (walls) - it cannot destroyed how to use it: decorativeTank = createObject ["a3\armor_f_beta\apc_tracked_01\apc_tracked_01_rcws_f.p3d", position] decorativeTank hideAnimationSelection["zasleh", true]; decorativeTank hideAnimationSelection["zasleh2", true] decorativeTank hideAnimationSelection["clan", true]; decorativeTank animate ["Wheel_podkoloL3", 1 , true]; decorativeTank animate ["Wheel_podkoloL6", 1 , true]; Where do I get full shape name? - through getModelInfo command What is hideAnimationSelection* (new command) good for? - object is not simulated, therefore some parts needs to be hidden manualy Where do I get list of sections, that can be hidden? - there is a new command - objectAnimationSelectionNames* Can it be hidden automatically? - no, as there is no config involved Why is "animate ["Wheel_podkoloL3", 1 , true]" needed? - object is not simulated, so you have to adjust dampers manually. Where do I get list things I can animate? - there is a new command - objectAnimationsNames* How to delete it? - deleteVehicle will work *WARNING - script command names might yet change -
As someone who has learned all he knows about scripting by fannying about in SQF for the past couple of months, I've got a question for the more advanced scripters out there. I was intrigued by this statement in the ACE3 Medical AI notes: I've searched around and found a few nibbles of information here and there (and there's no documentation as yet that I've found on CBA about state machines) but nothing that really provides a decent comparison between an SQF script with a series of looped functions based on lazy evaluation of conditions, and an FSM that does the same. Is there a noticeable difference in performance or are FSMs just a different way of achieving a similar goal? And if there isn't much performance difference between the two, then what is the most efficient way of squeezing performance out of a complex script? Assuming your functions are as clean and fast as they can be, what are your best practices for making them run with minimal impact? I'm referring here to scripts with complex conditions which will run on a number of units or objects repeatedly (for reference, I'm trying to turn this into a full-blown undercover simulation and more efficiency means more responsiveness for more units).
- 27 replies
-
Hi, everyone. I just launched Arma 3 for the first time in a very long time and was pleasantly surprised to find this very cool new launcher that allows us to set memory (can go as high as 32768 now so no longer hard-limited to 2028 apparently), cores, Vram size, etc. What would be the best settings in my case: I have 16GB of G-Skill gaming ram, an M5A99FX PRO with an FX-8350 8 Core CPU (yes, I know AMD is terrible but it's too late), an MSI GTX 970 Gaming and a very fast internet connection. Also, how is the new TCMalloc_bi.dll file (dated Sept 29th) compare to the tbbmalloc.dll one? Do I need to delete one or do I use both? Thanks. :) P.S. If I don't hear back in a reasonable time (2 to 3 days) I'll just post this on Steam and maybe add helpful responses to this post in case others have the same question here.
-
Hi, I usually play in multiplayer but I play single player too, in both Arma 3 goes at 30-40 fps with little players and my video config in low-standard with a resolution of 1280x720. I don't want any fall of fps more, so what video config I must choose? CPU: Intel® Core i5-3470 CPU @ 3.20GHz GPU: GTX 660 RAM: 8 GB OS: Windows 10 Type of OS: Operative system of 64 bits, cpu x64. Motherboard: ASUS P8H61-M LK R2.0 Game version: 1.50
-
- Optimization
- PC
-
(and 3 more)
Tagged with: