Search the Community
Showing results for tags 'waituntil'.
Found 15 results
-
Code optimization, multiple threads of waituntil and spawn
Vandeanson posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hiho Gentlemen, for the past weeks I have been looking into improving the FPS impact my Vandeanson's Apocalypse mod has on missions. What does the mod do? (all the below happens server side only, fyi) 1. []spawn "Position finder function": find well suiting locations to spawn sites of interest (small sized composition of structures, things and AI, e.g. a banditcamp) based on a random players location 2. []spawn "Site spawner function":mark that location (as set in #1.) and starts "waituntil {code to check for condition}" with condition that ANY player gets close to the site 3. create the site, enable dynamic simulation, start despawn timer 4.a [] "spawn hideobjectglobal function" that will hide the objects of a site once no player is near that site, but the despawn timer (item. 5 below) has not run out yet 4.b [] "spawn un-hideobjectglobal function" that will UNhide the objects of a site if a player is near again 5. wait for despawn timer to run out (minimum up-time of a site) 6. start "waituntil {code to check for condition}" with condition that no player is near the site 7. delete the site/AI 8. start at #1. I hope its somehow recognizable, that this should allow for a dynamic environement, with least possible performance impact due to the "waituntil" gating. Sites are only up if really needed e.g. a player is nearby to actually see the site. If the sites and AI are spawned, dynamic simulation is enabled. The performance gains compared to previous versions (where assets where spawned in and FPS was only saved by dyn. simulation) are already quite considerable. The performance saving actions happen through distance checks, waituntil, dynamic simulation, hideobjectglobal and despawn of sites that are no longer needed (e.g. noone within 4k meters proxy) However, the question that is bugging me currently is about the performance impact of having multiple (possibly 100+) waituntil and spawn threads up sametime. waituntil: the mod spawns about 10 type of sites, each sites may be spawned up to 10 times. Each creates an own "waituntil" thread. I seem to understand that these waituntils are continuisly eating up performance until the "condition" is met. Until then, the condition is checked every frame. In my case, these are way to many "check" iterations than needed. A check every 5 seconds is fine as well. Hence I changed the waituntil to waituntil {sleep 5; ...code..}; Question: am I correct that this shold have a "considerable" positive impact on performance of waituntil usage? I got this from forum posts so it should atleast have some hand and feets. [] spawns: most functions need to be spawned in a separate thread, I can not use "call" as the calling script can not be halted until the function returns true and since suspension (waituntil) is not allowed for called functions. Where i can use "call", i do that. Hence, in additiona to a lot of waituntils, I also have multiple spawn threads run more or less complex code sametime. I believe that if i put in sleep timers between each bulk of complex code that should help with performance (e.g. first all bandit camps are spawned, then the next site may start to spawn in). Question: this, if the sleep timers are set right, should put additional ease on cpu. Correct? Also, if I place small sleep timers throughtout spawned code, I should ease possible stutters/lags when spawning stuff. I could also add condition checks (uff, more waituntils) between major functions spawns, that only return true once the previous site/code bulk is done. I hope it is somehow understandable what I am trying to do and what the challenges are that I am worried about. A playable test version of the mod can be found here FYI: (it does not include ALL of the performance saving actions yet, but it should give you a fair picture). Why this post? I would like to understand if: - my thought process is correct - if the issues I am looking into are actual issues worth looking into - if more experienced people would take a similar approach or if I am missing knowledge and the issue could be taken on in better ways. The changes I made already show positive results, but I am sure that there are things that I dont know yet. The above conclusions are based on the last 2 years of coding various projects and reading up various topics online (KK's blog, forum posts, code optimisation guides...) I have no professional coding background, hence I might lack basic knowledge. End of wall of text. I appreciate any feedback, input, source of information and so on that I can get;) Thanks! Cheers VD -
Gotcha: player is not for Dedicated Server so I am looking for a way to start a few functions files where the target is the multiplayer/coop through hosted and dedicated servers. Some ideas, but not what I'm looking for (already read!): And this older one (already read!): That said, just to start, this is a init.sqf template I've seen and used: // INIT.SQF HEADER (TARGET IS MISSONS IN HOSTED AND DEDICATED SERVERS / NEVER SINGLEPLAYER): if (!isDedicated) then { // checking player in hosted servers / and avoid JIP issues (?): waitUntil { !isNull player; }; // mission briefing available for all clients: [] call compile preProcessFileLineNumbers "briefing.sqf"; }; if (hasInterface) then { [] spawn { waitUntil { sleep 0.1; !isNull player; // <--------------------------------- It doesnt look right! It should watch for _x of allPlayers, right? }; }; }; // AND CUSTOM CODE HERE... About the code above, shouldn't that be like this one below? // NOT TESTED! if (!isDedicated) then { // checking player in hosted servers / and avoid JIP issues (?): waitUntil { !isNull player; }; // mission briefing available for all clients: [] call compile preProcessFileLineNumbers "briefing.sqf"; }; if (hasInterface) then { [] spawn { waitUntil { sleep 0.5; count allPlayers < 0; systemChat "You're a human player!"; }; }; }; // IF IT HAS PASSED BY ONE OF THOSE LOOPINGS ABOVE, CUSTOM CODE TO BE READED HERE... A model will impact positively in, at least, 18 multiplayer missions I've built in the last 3 years.
-
Hello, I wonder if is there a way of getting out of a waitUntil loop in the case when a script is remoteExec on the server in the init.sqf with player passed as argument and when the player disconnect from the server? I see on my linux server'screen when i disconnect from the server the error " Client: Remote object 4:0 not found " and the diag_log message continuing emmiting each second so the script never end. //init.sqf if (hasInterface) then { waitUntil {!isNull player}; [[player], "test.sqf"] remoteExec ["execVM", 2]; }; // test.sqf params ["_player"]; while {!isNull _player} do { waitUntil { diag_log "!!!!In waitUntil loop!!!!"; sleep 1; /*(condition code)*/ or isNull _player }; if (isNull _player) exitWith {}; //code... // // };
-
Transport Pilot Rewards Script Help
Trenchcoat posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
I am attempting to create a rewards script for transport pilots fulfilling their duties. I have it set up to count the passengers, create a starting marker and ending marker, and calculate it, but my waitUntils do not seem to be functioning properly, causing the script to finalize as soon as the Event handler fires. Are Event handlers able to be suspended? Examples: waitUntil {count fullCrew [_vehicle,"",false] >= 2}; waitUntil { ((getPos (_vehicle) select 2) > 25) && (speed (_vehicle) > 30) }; If it is not suspendable, I guess I will have to make addActions for Transport begin, and Transport ended; but if it gets crazy at the LZ, remembering to do that may be a issue.- 4 replies
-
- eventhandler
- suspend
-
(and 1 more)
Tagged with:
-
Using countSide is resulting in "Error Type Bool, expected Bool"
[GLT] Legislator posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello for years I've been using this code in my init.sqf to check for ingame conditions. if (isServer) then { // Task 1 PATROL [] spawn { waitUntil {((west countSide (list trg1)) > 0)}; nul = ["task1", "Succeeded"] execVM "\glt_core\scripts\tasks\task.sqf"; obj1 = true; publicVariable "obj1"; "patrol1" setMarkerColor "ColorRed"; "patrol1" setMarkerType "mil_objective"; "patrol1" setMarkerText localize "STR_GLT_Task_Goal_Secure_Area"; }; }; Since the last big game update it resulting into this error however: 17:59:27 Error in expression <aitUntil {((west countSide (list trg1)) > 0)}; nul = ["task1", "Succeeded"] exec> 17:59:27 Error position: <> 0)}; nul = ["task1", "Succeeded"] exec> 17:59:27 Error Type Bool, expected Bool I checked the condition ingame using the debugging console: a = west countSide list trg1; Results: a = 0 obj1 = true So apparently the condition is skipped because of the error and the code is executed before it should be. Can anyone confirm if this is an intended behaviour now or a game bug? What can I do to prevent this error? This is a very big issue for me as I'm using this code in more than 80 missions. Thanks to anyone in advance. -
Race Circuit Script (aka learning to count)
wogz187 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
This topic is solved. Clear courses by reaching the next marker. If you're looking for the module it's available here: Drive Link This is the test rig in the demo. Adding new marks and whole new courses is easy. From here on is the original topic, I need to learn how to count. I posted this the other day, with a plea to understand why it works when, in my estimation, it shouldn't really. Regardless. I set about to simplify ring counting. I don't like having one .sqf file for each ring course. I feel like 1 or 2 scripts should be able to do this. One file if somebody helps me to learn how to count. Two if this works: Determine which course and define ring marks with generic titles, ringCOURSE.sqf-- this example shows 2 courses with 3 rings each if (ringCHALL==1) then { ring1=ringMARK1_1; ring2=ringMARK1_2; //first course second mark ring3=ringMARK1_3; rings= []execVM "ringCLEAR.sqf"; }; if (ringCHALL==2) then { ring1=ringMARK2_1; ring2=ringMARK2_2; //second course second mark ring3=ringMARK2_3; rings= []execVM "ringCLEAR.sqf"; }; and then build a switchdo case for each ring, or a waitUntil loop, or... I don't know and that's the question. Keep in mind there is only one ring with one trigger attached to drive the ring clearing script(s). This is what it needs to do, ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination; ringGOAL_1 setpos (getpos currentRING); The real trick in this is how to go from: ring1, ring2, ring3, to set the variable "currentRING" in sequence. Oh, boy! I hope that makes sense! -
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:
-
Help getting two WaitUntil conditions Merged.
LSValmont posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
So my script starts like this: _Join_East = creategroup EAST; call { _changing = allUnits select {(side _x isEqualTo civilian) && (!isPlayer _x) && (_x distance player < 100)}; _changing apply { units _x joinSilent _Join_East; [_Join_East, _Pos_1] call BIS_fnc_taskAttack; // Now all nearby Ai civilians turn hostile to the player! And that works like a charm! What I need is to put this two waitUntil conditions into a single waitUntil with an OR. waitUntil {sleep 1; ({alive _x} count units _Join_East) < 3;}; waitUntil {sleep 1; player distance units _Join_East > 500}; I can't seem to get both to work in an OR format. The final result should be: waitUntil { (The _Join_East group has less than 3 units) OR (The player got 500 meters away from the units in the _Join_East group). Thanks in advanced! -
waitUntil vs (while + sleep) performance cost
ColonelKernel posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi. I was wondering which one of these two commands has a bigger effect on performance: waitUntil { !cond }; or while {cond} do { sleep 0.5; }; Also, does the amount of sleep time matter? What about the condition? For example, if we have to check a series of conditions (e.g {alive _x} foreach Allunits) which one is better? -
Hello c",) first of love this forum, it has really helped me a lot ! . . . well over to my first post in here. Or this is more of a question; how do i get a chopper to wait untill it has been fully loaded before take off?.. "i meen not like if player is in, or if a spesific group is in. I only want a line to make the chopper wait untill every seat is full, or no more space in cargo." Maybe somthing like: waitUntil {heli is full} AND {!isNull player}; or waitUntil {heli fullcargo} AND {!isNull player}; Please help me you see i have made a mission where you must contact, rescue and finally load rescued civilian units on to a waiting chopper. "i started with a dream to count the rescued units onboard the heli, and then give score fore each. But seeing as this was a bit over my skill level i choose to have it only take of when fully loaded and the give a static score. I am using simple shop by HoverGuy i was hoping to give money for each rescued civilian loaded." Hope you are the right person to help me, i have really searched everywhere . . . Best regards RotaMafia.
- 4 replies
-
- waituntil
- fully loaded
- (and 6 more)
-
waituntil with sleep technical question
dlegion posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
hello! i got a huge doubt about waituntil and sleep...here is an example (while (true) its not relevant, i just put it to better give the idea of a looping code): while {true} do { waitUntil {sleep 600;{alive _x} count allPlayers isEqualTo 0}; }; this looping code will wait 600 seconds for 1 single time and then check in loop every 0.5 seconds the "alive players" condition? OR the looping code will wait 600 seconds, check the "alive players" condition, then wait 600 seconds, then check "alive players" condition and so on ? if my ultimate goal is to check a condition every 600 seconds, what i should do ? thanks guys! -
I am executing this code in a .sqf using execVM via a trigger, but waitUntil isn't working. That is, after _cnt == 0 (after I kill all the units in the _ambushers group), the script does not continue. However, if after killing _ambushers, if I reexecute the script via the debug console in-game, then it seems to work just fine - it skips the first titleText and goes right into the code below waitUntil {_cnt == 0}. But the whole point of waitUntil is to NOT have to reexecute anything. What gives? Is it a waitUntil issue, or a count issue? What am I doing wrong? _ambushers = group ambusher; _cnt = count units _ambushers; if (_cnt > 0) then { titleText ["CREWMAN: TOOK YOU LONG ENOUGH! SHOOT THEM!", "PLAIN DOWN", 4]; titleFadeOut 1; }; waitUntil {_cnt == 0}; sleep 2; if (alive crewman) then { toolkitbox addItemCargo ["Toolkit",1]; titleText ["CREWMAN: Whew! Thanks for your help, guys.", "PLAIN DOWN", 4]; titleFadeOut 1; sleep 6; titleText ["CREWMAN: There is a repair kit in my equipment box. Take it for your truck. Just in case.", "PLAIN DOWN", 4]; titleFadeOut 1; sleep 6; ["tsk03","SUCCEEDED"] call BIS_fnc_taskSetState; sleep 3; ["tsk02b","ASSIGNED"] call BIS_fnc_taskSetState; } else { titleText ["PLAYER: He's dead. Looks like we failed.", "PLAIN DOWN", 4]; titleFadeOut 1; sleep 6; ["tsk03","FAILED"] call BIS_fnc_taskSetState; sleep 3; ["tsk02b","ASSIGNED"] call BIS_fnc_taskSetState; };
-
I want to make a trigger which execVM an sqf file and wait until it finishes. But every time it gives me an error or it doesn't wait at all. I tried: myhandle = [] execVM "test.sqf"; waitUntil { scriptDone myhandle }; and it gave me this: waitUntil { |#|scriptDone my.. Generic error in expression also tried: myhandle = [] execVM "test.sqf"; null = [] spawn { waitUntil { scriptDone myhandle }}; then it does not wait at all. The trigger activates before the sqf finish. Inside the sqf, there is a variable at the end: test_sqf_running = nil I also tried: [] execVM "test.sqf"; waitUntil { sleep 1; isNil "test_sqf_running" }; and this happened: waitUntil { |#|sleep 1; is... Generic error in expression. also tried with spawn and it activates before the sql finish. Where is it wrong?
- 5 replies
-
- waituntil
- genericerrorinexpression
-
(and 1 more)
Tagged with:
-
Okey, i dont know if this has been up before, i couldnt find anything. iam trying to check if a marker has changed color.. it is for using EOS with tasks. MapClickEOS_Patrol = { // Create EOS Zone _Size = _this select 0; _groups = _this select 1; _grpSize = _this select 2; _Pos = _this select 3; // Create Marker Zone _m = createMarker [format ["Patrol%1", Random 1000],_pos]; _m setMarkerShape "ELLIPSE"; _m setMarkerSize [_size,_size]; _m setMarkerBrush "Solid"; _m setMarkerColor "ColorRed"; // Close map titletext ["Zone Created",""]; // Create EOS Zone null = [[_m],[0,0],[_groups,_grpSize,100],[0,0],[0],[0],[0,0],[5,0,300,EAST,TRUE]] call EOS_Spawn; sleep 5; waitUntil {sleep 5; getMarkerColor _m == "ColorGreen"}; hint "Area CLEAR"; }; i get expression error no matter what i do :( i know its probably something small but i cant figure it out, everything works as it should except the waituntil....
-
Hi folks I've got an issue with trying to write a script that lets me keep doing an action until the point where I don't want to do the action any longer. A player has a camera in their gear. When they want to take a photo, the script fires up. The script makes them put away their current weapon, and an image of the back of a camera pops up on their screen. picture sharing Now the bit that has me stumped. I want to be able to have the player take as many photos as they want before putting the camera away. The script snippet I have for 'clicking' the camera is this: (The inputAction "Fire" is done by the player holding Left-Ctrl + Left mouse click). This works a treat in my script, but sadly can only be done once at the moment due to my lack of scripting know-how. I then have another script snippet which lets the rest of the script continue, thus closing the camera and letting the player get his weapon out again: (The inputAction "toggleRaiseWeapon" by default is a double tap of the Left-Ctrl key). The other problem here is that the player has to take a photo before the script continues on to the part where the player can put the camera away. What if the player opens the camera, but then decides to put it away without taking any shots. He/she can't in the script's current state. Here's the whole script currently: So in summery, I want the player to be able to point and 'click' the camera as many times and at as many objects as they want, then when they're ready, put the camera away. I hope that all makes sense. Any help with this is appreciated. Thanks heaps. Vapour