-
Content Count
43 -
Joined
-
Last visited
-
Medals
Everything posted by Matthew10_28
-
Control Structure for an on/off toggle - it has to be easier than I'm making it out to be
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Let me restate what I heard to confirm my understanding. Said more generically for an on/off toggle type control structure, you've got to define/or obtain the initial state of some variable and set it. Then let the script alter that and redefine its new value when its done so others can also "push the button" and have it work. As a matter of best practice, do your defining of those variables necessary in the server init.sqf upon start. Then (as before) the addAction in a particular objects init does nothing more than call the script to run on the server thereby performing the action, then redefining the state of the switch so the next guy who tries can "push the button" once and it work. Unique to my particular example, the nearestObject array command could also be performed at start by placing it in the server init.sqf. Based on the function of this particular script, this is a suitable solution as the only reason it would need to be recalculated is if someone added a light via Zeus or something post server start. It is also taxing on the processor, so it's best to run this once. Using this function in the context of something like an ATC radar would not catch newly spawned or created units though post server start. Now, specific to the code - What is the difference between PublicVariable and missionNamespace setVariable? It wasn't clear to me reading the wiki. I've used PublicVariable inside a triggers on acct to gather up the bad guys it finds in its area and pushback as a pushback array and that works on a dedicated server. -
Locality issue: code not working on dedicated server
Matthew10_28 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
After learning a ton beating this code into submission in locally hosted MP via the editor, it broke when I put it on my separate dedicated server. It basically turns on enemy units and objects within an area when the player walks up to a Keyboard object back at base. The intent is to keep an area "clean" and in its default state until the user selects the mission site to turn on. On-Activation box of Independent Present Trigger: RaidArea079124 = []; //sets up an array to grab all the units within the area {RaidArea079124 pushBack _x} forEach thisList; //finds every unit with the area and adds it to the array Keyboard Init: RaidSite079124ObjectList = nearestObjects [HVT1, [], 200]; //finds all the objects like empty vehicles and other "set dressings" within 200m ofthe centrally spawned "HVT1" unit. this addAction ["Spawn Raid Site @ 079124",{{if (isNil compile format ["'%1'", _x]) then {} else {_x hideObjectGlobal false, _x enableSimulation true}} forEach (RaidArea079124 + RaidSite079124ObjectList); }]; //adds and action to the keyboard object that when run, combines both arrays, and the un-hides and enables the units and objects that actually exist (some done't based on their own probability of presence) I've been reading about BIS_fcn_MP and have been reading a ton on public/global variables but I could not modify it appropriately to get it to work on the server. I've tried declaring publicVariables for RaidArea079124, RaidSite079124ObjectList, & HVT1 (the variable name of a bad guy that always spawns) but it doesn't work. I've read about problems with addAction and MP, so I tried using addAction wrapped inside BIS_fcn_MP. That didn't work and oddly duplicated the addAction label attached to the keyboard object. Now I read that hideObjectGlobal and enableSimulationGlobal are MP functions that are called on the server. I must not be understanding how these functions work together. The only thing I can think of is the magic variable _x is local to each bit of code, thereby making the various values that pass through it not actually make it to the server. I've tried basically the following: On-Activation box of Independent Present Trigger: RaidArea079124 = []; {RaidArea079124 pushBack _x} forEach thisList; publicVariable "RaidArea079124"; Keyboard Init: RaidSite079124ObjectList = nearestObjects [HVT1, [], 200]; publicVariable "RaidSite079124ObjectList"; this addAction ["Spawn Raid Site @ 079124",{{if (isNil compile format ["'%1'", _x]) then {} else {_x hideObjectGlobal false, _x enableSimulation true}} forEach (RaidArea079124 + RaidSite079124ObjectList); }]; or RaidSite079124ObjectList = nearestObjects [HVT1, [], 200]; publicVariable "RaidSite079124ObjectList"; [[this, ["Spawn Raid Site @ 079124",{{if (isNil compile format ["'%1'", _x]) then {} else {_x hideObjectGlobal false, _x enableSimulation true}} forEach (RaidArea079124 + RaidSite079124ObjectList); }]],"addAction",true,true] call BIS_fnc_MP; What am I not understanding? -
Locality issue: code not working on dedicated server
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Took me a while to figure out all my syntax mistakes. I had a programming professor tell us once, "The good thing about computers is they do exactly what you tell them to. The bad thing about computers is they do exactly what you tell them to." So true. With the above in place I get error: undefined variable _raidarea at this line: } forEach (_RaidArea + _ObjectList); The _RaidArea that should have been passed to it was RaidArea079124 which was an array created in the On Activation box of an Independent Present trigger: RaidArea079124 = []; {RaidArea079124 pushBack _x} forEach thisList; publicVariable "RaidArea079124"; So it should be passing that array of the units it finds in that trigger area to the script. The units defined within that trigger area have a probability of presence built in which is why the isNil is in place to kick out the ones that never spawned. <smash head on keyboard> :huh: ETA: I'm an idiot and forgot my own variable name. I passed it "RaidSite079124" and it should have been "RaidArea079124" -
Locality issue: code not working on dedicated server
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
In converting this functionality to a script upon previous suggestion, and I'm getting an error: 0 elements provided, 3 expected pointing to line 8 which is the _ObjectList definition. On the keyboard object the player uses. Both "RaidSite079124" and "HVT1" were declared publicVariables in the init lines of their respective objects. ETA: this version does nothing. I apparently don't know how to compile my script or something? and then call that script as a function? this addAction ["Spawn Raid Site @ 079124", {["RaidSite079124","HVT1"] remoteExec ["scripts\RaidSiteActivator.sqf", 2];}]; ETA: Even though its outdated, this makes more sense, and seems to get farther as it looks like the scripts attempts to run but I get the error. this addAction ["Spawn Raid Site @ 079124", {[[[RaidSite079124, HVT1], "scripts\RaidSiteActivator.sqf"], "BIS_fnc_execVM", true] call BIS_fnc_MP;}]; RaidSiteActivator.sqf private ["_RaidArea", "_HVT"]; _RaidArea = _this select 0; _HVT = _this select 1; _ObjectList = nearestObjects [_HVT,[],200]; {if (isNil compile format ["'%1'", _x]) then {} else { {_x hideObjectGlobal false, _x enableSimulationGlobal true} forEach (_RaidArea + _ObjectList) }}; -
Locality issue: code not working on dedicated server
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Wouldn't the arguments in the first if{isserver} then {"stuff in here"} be unnecessary? instead of doing nothing for the nil items it "turns on" something that doesn't exist? On the suggestion of another forum user in a previous post, the trigger was a convenient way to collect all the bad guys in it's area. The group of bad guys may or may not spawn because of probability of presence and the random placement radius I have set on them. The trigger area is shaped appropriately to collect them all no matter what. I learned that the trigger wouldn't collect objects like empty vehicles and things like desks and chairs so that's where I added the nearestObjects. By the nature of a raid site, those objects would be mainly in and around buildings where the bad guys are pushed out much further from there. The intent is there may be some sites that would overlap if they were defined by a simple radius, but by using an irregular trigger shape, I separate two sites a bit easier that may in close proximity. Off to explore making this into a script that I just pass a few global variables from each raid site through. I see now why using a separate scripts is better design. That way I don't have to generate virtually the same bit of code for every raid site. -
Locality issue: code not working on dedicated server
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thank you. What I was seeking first was understanding. Then hopefully I'd be able to fix my code. What you are saying is, everything "to the left of" remoteExec....the stuff "[iN HERE] remoteExec [yadda yadda]" is calculated until completion. So even before it reaches the server, it finishes its thing and returns nil. Then only the nil is passed to the server for it to "call" to everyone so it does nothing. Even then, since I used "call", its looking for the stuff... "[iN HERE] remoteExec [yadda yadda] to match the syntax of "call". Also didn't realize the role of the curly brackets. I can only say duh on the remoteExec needing to be 2 after reading the wiki on it 2 more times. Also, my understanding of the optional JIP needing to be true seems unecessary. I was worried about someone joining the server after everything got unhidden and enabled not seeing everything those who joined prior to the switch. Now I understand, and it makes sense...but now using your code, it breaks when I self host through the editor. I get an error call type array expected code. undefined variable _x :( Shouldn't that work because, although it is sending it to the server, the server and the local player is the same? Going the script route - would that basically mean that the addAction this is centered around does nothing more than call a script of the code I basically came up with to execute instead of trying to do nested in the addAction? The intent is to have multiple raid sites pre-defined in the editor and have the user be able to select one and "turn it on". I'd have to come up with a way of passing the arguments to that script through the addAction right? -
Locality issue: code not working on dedicated server
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
For anyone following, I've replaced BIS_fcn_MP with remoteExec, but once again it doesn't work on a dedicated. When I was self hosting via the editor, it worked, but it spit out a black box error saying there was an undefined variable "_x" yet it still functioned as intended. Is the magic variable _x used in context of forEach where it's not advisable? Even if I did an i=i+1 with a do until, wouldn't that make "i" an undefined variable too? In both cases they are used internally as a vehicle for a loop right? I feel so stuck :unsure: RaidSite079124ObjectList = nearestObjects [HVT1, [], 200]; publicVariable "RaidSite079124ObjectList"; this addAction ["Spawn Raid Site @ 079124", { if (isNil compile format ["'%1'", _x]) then {} else { [{_x hideObjectGlobal false, _x enableSimulationGlobal true;} forEach (RaidArea079124 + RaidSite079124ObjectList)] remoteExec ["call", 0, true]; } } ]; -
Trigger MP locality?
Matthew10_28 replied to jwllorens's topic in ARMA 3 - MISSION EDITING & SCRIPTING
It seemed that how triggers work in a MP environment might be why I was having problems, but I see now that it's just my lack of understanding. -
Trigger MP locality?
Matthew10_28 replied to jwllorens's topic in ARMA 3 - MISSION EDITING & SCRIPTING
So if a trigger is created in the editor, as well as units inside that trigger (already tripping the trigger) that are set to hidden and AI disabled. Does that affect how a connected player might unhide and enable them globally on a dedicated server? They are "there from the start" any synced across all players including JIP assuming they haven't been unhidden and enabled yet, right? Not to hijack, but the core issue here seems to be very closely related to an issue I posed here. -
Trigger MP locality?
Matthew10_28 replied to jwllorens's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thats just it though. I'm very uncertain of what gets executed on the server and what doesn't; even more unsure of how to force something to run on the server. Like the OP, it seems like certain functions have a shared effect. The wiki might say "aG", "eG", "sE" etc, but I for one don't understand how one can control or direct those aspects. -
Trigger MP locality?
Matthew10_28 replied to jwllorens's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I too am interested in getting clarity of how locality works for certain functions. I'm so confused as to the "map" of what gets controlled where when everyone in MP including the server is playing to the same sheet of music (the .pbo for the mission). -
Passing an array or group through hideObjectsGlobal & enableSimulation?
Matthew10_28 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Background Context: I have a group of semi-random enemy at a location on the map. They are divided in to groups and teams with some doing random patrols via 3den enhanced, and others defending via the CBA defend module. Each groups probability of presence is controlled such that each experience will be unique and different for multiplayer. The intent is to have a site to raid that is different each time but also authentically populated and controlled. The intent is to populate the map with many sites like this that the user can selectively activate and attack. The units are hidden via hideObjectsGlobal true and enableSimulation false upon creation so as to not necessarily burden the server and to keep those areas of the map safe and explore-able should the user choose to. The Code Problem(s): I have an addAction on an objecet a player approaches and then activates the bad guys at the raid site but it seems unnecessarily cumbersome. The addAction just serves to switch hideObjectsGlobal to false and enableSimulation to true. First, I don't know of a way to "group" or "collect" all of the objects at a site so that I could just do something like: this addAction ["Spawn All The Things!",{CollcetionOfStuff hideObjectGlobal false, CollcetionOfStuff enablesimulation true}]; Then I though I would just call upon the various group variable ID's as there are "only" 9 to 11 groups (per raid site). It spit an error saying and object was expected for hideObjectsGlobal and it needs a unit. Then I tried creating an array of the individual unit variable names (that I had to go define for all 20ish units) and passing that through hideObjectsGlobal, but it squawked at the array too. Now I'm left with and excel spreadsheet that generates the gigantic addAction code I need based on my typing in every single units variable name. I end up with this monstrosity below. I had to add the conditional ifNil part since its possible that a unit won't even be created to begin with based on the probability of presence. I works as intended and has the desired effect but, there has got to be an easier way to do this. I want to generate groups like this all over the map and have the user scroll through the addAction menu to activate the desired site the player wants to raid. This is going to get ugly if I have to individually assign variable names to everyone at each raid site. this addAction ["Spawn Raid Site",{if (isNil "HVT1") then {} else {HVT1 hideObjectGlobal false, HVT1 enableSimulation true}, if (isNil "HVT2") then {} else {HVT2 hideObjectGlobal false, HVT2 enableSimulation true}, if (isNil "Garrison1Leader") then {} else {Garrison1Leader hideObjectGlobal false, Garrison1Leader enableSimulation true}, if (isNil "Garrison1_1") then {} else {Garrison1_1 hideObjectGlobal false, Garrison1_1 enableSimulation true}, if (isNil "Garrison2Leader") then {} else {Garrison2Leader hideObjectGlobal false, Garrison2Leader enableSimulation true}, if (isNil "Garrison2_1") then {} else {Garrison2_1 hideObjectGlobal false, Garrison2_1 enableSimulation true}, if (isNil "Garrison2_2") then {} else {Garrison2_2 hideObjectGlobal false, Garrison2_2 enableSimulation true}, if (isNil "Garrison2_3") then {} else {Garrison2_3 hideObjectGlobal false, Garrison2_3 enableSimulation true}, if (isNil "Patrol1Leader") then {} else {Patrol1Leader hideObjectGlobal false, Patrol1Leader enableSimulation true}, if (isNil "Patrol1_1") then {} else {Patrol1_1 hideObjectGlobal false, Patrol1_1 enableSimulation true}, if (isNil "Patrol2Leader") then {} else {Patrol2Leader hideObjectGlobal false, Patrol2Leader enableSimulation true}, if (isNil "Patrol2_1") then {} else {Patrol2_1 hideObjectGlobal false, Patrol2_1 enableSimulation true}, if (isNil "Patrol2_2") then {} else {Patrol2_2 hideObjectGlobal false, Patrol2_2 enableSimulation true}, if (isNil "Patrol3Leader") then {} else {Patrol3Leader hideObjectGlobal false, Patrol3Leader enableSimulation true}, if (isNil "Patrol3_1") then {} else {Patrol3_1 hideObjectGlobal false, Patrol3_1 enableSimulation true}, if (isNil "Patrol4Leader") then {} else {Patrol4Leader hideObjectGlobal false, Patrol4Leader enableSimulation true}, if (isNil "Patrol4_1") then {} else {Patrol4_1 hideObjectGlobal false, Patrol4_1 enableSimulation true}, if (isNil "Patrol5eader") then {} else {Patrol5Leader hideObjectGlobal false, Patrol5Leader enableSimulation true}, if (isNil "Patrol5_1") then {} else {Patrol5_1 hideObjectGlobal false, Patrol5_1 enableSimulation true}}]; -
Passing an array or group through hideObjectsGlobal & enableSimulation?
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Well, my theory of grabbing everything and turning everything on works. RaidSite079124ObjectList = nearestObjects [HVT1, [], 200]; {_x hideObjectGlobal false, _x enableSimulation true} forEach RaidSite079124ObjectList; But now its not playing nice when I try to run it in parallel with the existing code in my addAction. I just learned _x is some sort of magic variable so maybe it doesn't play nice since my existing code uses that as well. This works when it's two seperate addActions... this addAction ["Spawn Raid Site @ 079124",{{if (isNil compile format ["'%1'", _x]) then {} else {_x hideObjectGlobal false, _x enableSimulation true}} forEach RaidArea079124; }]; this addAction ["Spawn Raid Objects",{RaidSite079124ObjectList = nearestObjects [HVT1, [], 200]; {_x hideObjectGlobal false, _x enableSimulation true} forEach RaidSite079124ObjectList}]; But this doesn't... this addAction ["Spawn Raid Site @ 079124",{{if (isNil compile format ["'%1'", _x]) then {} else {_x hideObjectGlobal false, _x enableSimulation true}} forEach RaidArea079124; {RaidSite079124ObjectList = nearestObjects [HVT1, [], 200]; {_x hideObjectGlobal false, _x enableSimulation true} forEach RaidSite079124ObjectList}} ]; ETA: Thinking it can't handle the double use of the magic variable _x I tried this but it spits and undefined varialbe for RaidSite079124ObjectList this addAction ["Spawn Raid Site @ 079124",{{if (isNil compile format ["'%1'", _x]) then {} else {RaidSite079124ObjectList = nearestObjects [HVT1, [], 200], _x hideObjectGlobal false, _x enableSimulation true}} forEach (RaidArea079124 + RaidSite079124ObjectList); }]; ETA 2: So moving that definition call prior to the addAction works, but I'm not entirely convinced why it can't work inside of it. RaidSite079124ObjectList = nearestObjects [HVT1, [], 200]; this addAction ["Spawn Raid Site @ 079124",{{if (isNil compile format ["'%1'", _x]) then {} else {_x hideObjectGlobal false, _x enableSimulation true}} forEach (RaidArea079124 + RaidSite079124ObjectList); }]; -
Passing an array or group through hideObjectsGlobal & enableSimulation?
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Bummer. Empty vehicles and objects like desks are treated the same in this set up? If nearestObjects picks up the empty vehicles and desks, then it's just a matter of using a separate trigger meant to just collect those and calling that in parallel with the units in the addAction. It looks like nearestObjects picks up everything, including things baked into the map, but since I'm only using it to flip the hideGlobalObjects off and to enableSimulation, it's not like I'd have to filter the stuff already on the map right? Sure, it will find EVERYTHING but since every item it finds is already "on" it should only turn on the stuff I add right? Otherwise, I have to get creative with wildcard searches for the class names listed here? -
Passing an array or group through hideObjectsGlobal & enableSimulation?
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
It worked. Thank you. But I must not be fully understanding why that format is so picky. The hideObjectGlobal and enableSimulation expects one type of data, but the isNil expects another? Hence, all these suggested methods of changing them? Now I should be able to just copy down my bad guy composition to another sites, create area2, area3, etc, then add more addAction options for each raid site. Now I see why the "area gathering" suggestion is so powerful. I shouldn't have to individually assign variable names to the units right? In much the same way I created the bad guys, now my intent is to create objects like empty parked vehicles, furniture and similar objects in buildings, and barriers on roads. It will be the extra "unknown" site variable. This method should grab those too as I understand it. MUCH better then assigning a variable name to each pen or pencil I place on a desk. -
Passing an array or group through hideObjectsGlobal & enableSimulation?
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I put a big circular trigger around the raid site and I put exactly that code in the On-Activation box that has Independent present as a condition (I'm using the new FIA Bandits to populate my raid site) I used that addAction code, but it says "unexpected variable in expression: _x" -
Passing an array or group through hideObjectsGlobal & enableSimulation?
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Distance triggers aren't ideal in this case. There might be a raid site the player(s) want to play, but they don't wan't to consider adjacent bad guys getting in the way in their infil or exfil. I don't want to force the player(s) to clear out multiple raid sites just to get to the one site they were really interested in. There are also completely separate missions on the maps too (or one day will be). I tried that and it said "unexpected variable" of my low probability HVT2 since it only exists in the first place 15% of the time. I looked at the script option via USPS (ultra simple patrol script) and it didn't fully perform the functions I needed it to like actually garrison intelligently. Also, creating the other raid sites is not just a copy/paste around a new group of buildings. There are minor placement adjustments of the enemy patrols to suit the terrain. It didn't like this either. Same as the str() option. It said "unexpected variable" of my low probability HVT2 since it only exists in the first place 15% of the time. I'm learning so much from all of this. I think I may end up using the "area gathering" methodology suggested and and explicit route for when the sites overlap. Or just convince myself to only pick sites that don't physically overlap. -
Passing an array or group through hideObjectsGlobal & enableSimulation?
Matthew10_28 replied to Matthew10_28's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I like the idea of letting an area definition grab everything in it, but doesn't that necessitate that I would have to maintain sufficient physical separation of these raid sites? In other words if I placed down guys around a group of houses for raid site they could, in theory, blend in with units from another nearby raid site. I've already spotted points on the map where raid site 1 has patrols that may physically intersect with another raid site with the intent being only 1 is active at a time, at least local to that area. Is there a way to sync or group all the units from 1 Raid site into a single thing like a logical and just call the logical Also, I discovered forEach loops. I managed to condense my original code but now it balks at the isNil statement. It says it expects a string. this addAction ["Spawn Raid Site",{_RaidGroup1 = [HVT1, HVT2, Garrison1Leader, Garrison1_1, Garrison2Leader, Garrison2_1, Garrison2_2, Garrison2_3, Patrol1Leader, Patrol1_1, Patrol2Leader, Patrol2_1, Patrol2_2, Patrol3Leader, Patrol3_1, Patrol4Leader, Patrol4_1, Patrol5Leader, Patrol5_1]; for [{_i=0}, {_i < count _RaidGroup1}, {_i=_i+1}] do {if(isNil (_RaidGroup select _i)) then {} else{(_RaidGroup1 select _i) hideObjectGlobal false; (_RaidGroup1 select _i) enableSimulation true;} }}]; and it likes this of course, but then the player will get a black box error that kind of gives away the first unit that didn't spawn because of probability. Kinda spoils it. this addAction ["Spawn Raid Site",{_RaidGroup1 = [HVT1, HVT2, Garrison1Leader, Garrison1_1, Garrison2Leader, Garrison2_1, Garrison2_2, Garrison2_3, Patrol1Leader, Patrol1_1, Patrol2Leader, Patrol2_1, Patrol2_2, Patrol3Leader, Patrol3_1, Patrol4Leader, Patrol4_1, Patrol5Leader, Patrol5_1]; for [{_i=0}, {_i < count _RaidGroup1}, {_i=_i+1}] do { (_RaidGroup1 select _i) hideObjectGlobal false; (_RaidGroup1 select _i) enableSimulation true; }}];