Search the Community
Showing results for tags 'nearestobjects'.
Found 9 results
-
Moving Objects, and Using nearestObjects variable with getPos and setPos
Cpt.ScottMiller836 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello Guys, I am Really suffering a little bit. There is a small complicated problem where i don't understand how i am going to do this, here is my question: How Can I Activate a Trigger by Going near someone or a unit or Object with distance limit like code: (blablabla) > 5 or (blablabla) < 5; and how to set Position of a unit near Object with distance from him.- 4 replies
-
- nearestobjects
- nearestobject
-
(and 2 more)
Tagged with:
-
HI All, I'm trying to write a script that spawns units in a nearby building (like houses, farms, hangers, anything with a roof and door), but don't want them to spawn on telephone lines or electrical lines or any weird stuff... #1 I thought BIS_fnc_isBuildingEnterable would help filter these type of buildings out, but it didn't...how can I avoid spawn from these types of places? Here is my script. #2 Also, I keep getting a "Error undefined variable in expression: _building" on line 50, whenever my player leaves by 250m, but thought I defined it? Any ideas how to solve these 2 problems? thanks onMapSingleClick "player setPosATL _pos"; _civilianCount = 0; _nearbyLocations = []; _buildingArray = []; _realBuildingArray = []; while {true} do { sleep 3; waitUntil { // find "Building" near player to spawn civilians _buildingArray = nearestObjects [player, ["House"], 250]; { if ([_x, 3] call ) then {_realBuildingArray pushBackUnique _x}; } forEach _buildingArray; // player is near a location _building = objNull; if !(_realBuildingArray isEqualTo []) then { _realBuildingArray = nearestObjects [player, ["House"], 250]; _building = _realBuildingArray select ((floor random (count _buildingArray)) + 1); systemChat format ["_building: %1", typeOf _building]; // create groups of civilians _grp = createGroup civilian; for "_i" from 1 to floor random 6 do { _unit = _grp createUnit ["C_scientist_F", _building, [], 0, "NONE"]; _wp =_grp addWaypoint [position player, 10]; _wp setWaypointType "MOVE"; _wp setWaypointSpeed "LIMITED"; // spawn function for groups to keep moving to player then return then get deleted [_unit, _grp, _wp, _realBuildingArray] spawn { params ["_unit", "_grp", "_wp", "_realBuildingArray"]; waitUntil { sleep 3; // new waypoint for player that moves if ((player distance2D waypointPosition _wp) > 5) then { _wp =_grp addWaypoint [position player, 5]; _grp setCurrentWaypoint _wp; }; ( ((_unit distance2D player) < 10) or ((player distance2D _unit) > 250) ) }; // select building to return to _building = objNull; if !(_realBuildingArray isEqualTo []) then { _building = _realBuildingArray select ((floor random (count _realBuildingArray)) + 1); _wp =_grp addWaypoint [_building, 0]; _grp setCurrentWaypoint _wp; }; // return to building and get deleted waitUntil { sleep 3; (((_unit distance2D waypointPosition _wp) < 2) or ((player distance2D _unit) > 250) ) }; deleteVehicle _unit; }; }; sleep floor random 5; }; }; };
-
scripting [SOLVED]Check Alive nearestObjects
rkemsley posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
I am currently trying to make it so that when a hold action is preformed on a crate, it will put the crate in the back of a non specific Zamak Truck. Currently, it will put the crate in the nearest Zamak Truck (destroyed or alive). I need it to only pick the closest alive Zamak Truck. I've tried loads of different methods, but I'm now quite stuck. Please help! This is my script so far, all working fine. [ this, "Load.", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", {}, {}, { _this call { _ZamakTrans = nearestObjects [ _this select 0, [ "Truck_02_transport_base_F" ], 25 ]; if ( count _ZamakTrans > 0 ) then { target = ( _ZamakTrans select 0 ); _lockIndexes = [ 2, 3, 4, 5, 6, 7 ]; { if ( ( _x select 2 ) in _lockIndexes ) then { moveOut ( _x select 0 ) }; } forEach fullCrew target; { target lockCargo [ _x, true ]; } forEach _lockIndexes; box attachTo [ target, [ 0, 0.25, -0.15 ] ]; box setVectorDirAndUp [ [ 1, 0, 0], [0, 0, 1 ] ]; }; } }, {}, [], 2, Nil, true, false ] remoteExec [ "BIS_fnc_holdActionAdd", 0, this ]; What I need is to pick the closest alive Zamak Truck, not just the closest one. (any advice/criticism on my script will be greatly appreciated.)- 3 replies
-
- arma 3
- nearestobjects
-
(and 2 more)
Tagged with:
-
nearestobjects Problem with code for nearest object
TheTimer8 posted a topic in ARMA 3 - QUESTIONS & ANSWERS
Okay so I need help with coding a helicopter pick up the nearest object that it can like an ATV for example how exactly can that be written into code some examples would be nice but I do need help on this. And also I have yet to find an example to work with to help me with this problem of mine. -
hideObjectGlobal on all buildings of same type
Spatsiba posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hey! I'm trying to remove military objects on Altis using: _towers = nearestTerrainObjects[[worldSize/2,worldSize/2],[ "Land_Cargo_Tower_V2_F", "Land_Cargo_Tower_V1_F", "Land_Cargo_Tower_V3_F", "Land_HBarrier_3_F", "Land_HBarrier_5_F", "Land_HBarrier_Big_F", "Land_HBarrier_1_F", "Land_HBarrierWall_corridor_F", "Land_HBarrierWall_corner_F", "Land_HBarrierWall6_F", "Land_HBarrierTower_F", "Land_HBarrierWall4_F"],worldSize,false]; {hideObjectGlobal _x} forEach [_towers] without luck. (I know the list isn't complete with all objects but desert towers are still there). My question is: Is there even a way to do this in a mission file?- 7 replies
-
- hidobject
- hideobjectglobal
-
(and 1 more)
Tagged with:
-
Create marker for all plane wreck on the map (Tanoa)
Astrama posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hey, so basically I'm looking for creating a marker on the map at the location of all plane wrecks on Tanoa. I have taken this script and changed the class name of the building to match with the plane wreck but this didn't work... Can you help me please? Thank's! _middle = worldSize/2; _spawnCenter = [_middle,_middle,0]; _maxDistance = _middle; _buildingTypes = ["Land_HistoricalPlaneWreck_02_front_F"]; { _buildingType = _x; _building = _spawnCenter nearObjects [_buildingType, _maxDistance]; { _foundBuilding = _x; _pos = _foundBuilding buildingPos 0; _location = getPosATL _foundBuilding; _marker = createMarker [format ["%1", _foundBuilding],_pos]; _marker setMarkerShape "Icon"; _marker setMarkerSize [1,1]; _marker setMarkerType "mil_dot"; _marker setMarkerBrush "Solid"; _marker setMarkerAlpha 0.5; _marker setMarkerColor "ColorRed"; _marker setMarkerText format["%1", _foundBuilding]; }forEach _building; }forEach _buildingTypes;- 1 reply
-
- wreck
- nearestobjects
-
(and 1 more)
Tagged with:
-
Move Unit to NearestObjects of Certain Type, Select 0
aie-boshell posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello, I need a script to allow me to move a unit to the nearest object of a certain type. I believe the answer is nameofunit move {nearestobject [position nameofunit, "land_pencilred_f"]} I tried this with "land_pencilred_f" being the classname of the objects that I'd like my unit to move to the nearest pencil to his current location. No luck so far but any help is much appreciated :-) -
Trying to get a position from arrays of nearestObjects
FederalRazer89 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
As the title suggest i am trying to get some position from arrays of the command "nearestObjects". I want the "nearestObjects" to look for a certain amount of house, so i can identify a village or town with the script and then use the average of all the listed house in the array. That way the position i am after will not be heavily affected by one or two houses caught in the calclated radius. _Center = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition"); _mapsize = (_Center select 0)*2; _RandomStartPos = [_Center, (_mapsize*0.77), (_mapsize*0.78), 3, 1, 20, 0] call BIS_fnc_findSafePos; sleep 1; player moveInCargo [_heli,5]; _enemySpawnPos = [_RandomStartPos, (_mapsize*0.7), _mapsize*0.71, 3, 0, 20, 0] call BIS_fnc_findSafePos; createMarker ["marker2",_enemySpawnPos]; "marker2" setMarkerShape "ELLIPSE"; "marker2" setMarkerSize [500,500]; "marker2" setMarkerText "Enemy resupply line"; "marker2" setMarkerAlpha 0.5; _findhouses = nearestObjects [_enemySpawnPos, "house"", (_mapsize*0.2)]; //small problems on this line _divide = count _findhouses; _fortifiedpos = _findhouses/_divide; //The bigger problem createMarker ["marker3",_fortifiedpos]; "marker3" setMarkerShape "ELLIPSE"; "marker3" setMarkerSize [500,500]; "marker3" setMarkerText "Enemy resupply line"; "marker3" setMarkerAlpha 0.5; I not really sure how should proceed, because i dont think the line "_fortifiedpos" will work, the problem above prevents it from execute. "nearestObjects" contains arrays of the houses and the houses also have arrays, if there isnt a command that would merge the arrays. If anyone have any input that would be nice, arrays are some a bit new to me so this is kind of over my head. -
I'm having a brain-fart with finding all nearest Blufor units around the player within a radius, INCLUDING units INSIDE vehicles. (Whether it be driver, gunner, passenger, etc.) I'm searching for nearby units like this: BLU=["B_Soldier_base_F","MRAP_01_base_F","Truck_01_base_F","MBT_01_base_F","LSV_01_base_F","B_APC_Wheeled_01_base_F","B_APC_Tracked_01_base_F","Heli_Light_01_base_F","Heli_Transport_01_base_F","Heli_Transport_03_base_F","Plane_CAS_01_base_F","Parachute_02_base_F","B_Boat_Transport_01_F","B_Boat_Armed_01_minigun_F","B_SDV_01_F"]; _n=nearestObjects[player,BLU,8192];_c=[]; {if((isAbleToBreathe _x)&&{(alive _x)&&(_x!=player)})then{_c set[(count _c),_x];};}forEach _n; The above code, even if "B_Soldier_base_F" is the only object being searched for, will not return units inside vehicles. It's possible that once a unit enters a vehicle, he is no longer "B_Soldier_base_F" until he dismounts, but I could definitely be wrong and overlooking something... [EDIT] Figured out a possible work around: BLU=["B_Soldier_base_F","MRAP_01_base_F","Truck_01_base_F","MBT_01_base_F","LSV_01_base_F","B_APC_Wheeled_01_base_F","B_APC_Tracked_01_base_F","Heli_Light_01_base_F","Heli_Transport_01_base_F","Heli_Transport_03_base_F","Plane_CAS_01_base_F","Parachute_02_base_F","B_Boat_Transport_01_F","B_Boat_Armed_01_minigun_F","B_SDV_01_F"]; _n=nearestObjects[player,BLU,WS];_c=[];_v=[]; {if((isAbleToBreathe _x)&&{(alive _x)&&(_x!=player)})then{_c set[(count _c),_x];};}forEach _n; {if((count(crew _x)>1)&&{(alive _x)&&(_x!=player)})then{_v set[(count _v),_x];};}forEach _n; _c=_c+_v; _c select 0; I think this should work. Still need to test it more.