ArmaMan360 94 Posted November 28, 2015 _nearBuildings = _position nearObjects ["House", _rad]; I am choosing this command to find an actual house to put the captive in. But it also sometimes spawns him at piers, or under the ground just where the small bridges start , eg the small small bridges in Agia Marina. Anyway to further filter out purely civilian buildings? Share this post Link to post Share on other sites
Rydygier 1302 Posted November 28, 2015 Perhaps there is some "smarter" way, but for my use (Pilgrimage) sufficient (as long we're talking about vanilla A3 buildings) is this: _minus = nearestObjects [_pos,["PowerLines_Wires_base_F","Lamps_base_F","Piers_base_F","Land_NavigLight"],_radius]; _blds = _pos nearObjects ["House",_radius]; _blds = _blds - _minus; 1 Share this post Link to post Share on other sites
ArmaMan360 94 Posted November 28, 2015 Perhaps there is some "smarter" way, but for my use (Pilgrimage) sufficient (as long we're talking about vanilla A3 buildings) is this: _minus = nearestObjects [_pos,["PowerLines_Wires_base_F","Lamps_base_F","Piers_base_F","Land_NavigLight"],_radius]; _blds = _pos nearObjects ["House",_radius]; _blds = _blds - _minus; Wow nice way. But I also see a different header for piers under cfgVehicles EMPTY, wonder why the system would return it when I call "House". Anyway Thanks Rydy ;) Share this post Link to post Share on other sites
Tankbuster 1733 Posted November 28, 2015 Here's a list of objects I filter out of the nearobjects house_f result. _excludedbuildings = ["Land_TTowerSmall_1_F", "Land_Dome_Big_F", "Cargo_Patrol_base_F", "Cargo_House_base_F", "Cargo_Tower_base_F", "Cargo_HQ_base_F","Piers_base_F", "PowerLines_base_F", "PowerLines_Wires_base_F", "PowerLines_Small_base_F", "Land_PowerPoleWooden_L_F", /*"Lamps_base_F",*/ "Land_Research_HQ_F", "Land_Research_house_V1_F", "Land_MilOffices_V1_F", "Land_TBox_F", "Land_Chapel_V1_F","Land_Chapel_Small_V2_F", "Land_Chapel_Small_V1_F", "Land_BellTower_01_V1_F", "Land_BellTower_02_V1_F", "Land_fs_roof_F","Land_fs_feed_F", "Land_Windmill01_ruins_F", "Land_d_Windmill01_F", "Land_i_Windmill01_F","Land_i_Barracks_V2_F", "Land_spp_Transformer_F", "Land_dp_smallFactory_F", "Land_Shed_Big_F", "Land_Metal_Shed_F","Land_i_Shed_Ind_F","Land_Communication_anchor_F", "Land_TTowerSmall_2_F", "Land_Communication_F","Land_cmp_Shed_F", "Land_cmp_Tower_F", "Land_u_Shed_Ind_F", "Land_TBox_F"]; Share this post Link to post Share on other sites
ArmaMan360 94 Posted November 28, 2015 Here's a list of objects I filter out of the nearobjects house_f result. _excludedbuildings = ["Land_TTowerSmall_1_F", "Land_Dome_Big_F", "Cargo_Patrol_base_F", "Cargo_House_base_F", "Cargo_Tower_base_F", "Cargo_HQ_base_F","Piers_base_F", "PowerLines_base_F", "PowerLines_Wires_base_F", "PowerLines_Small_base_F", "Land_PowerPoleWooden_L_F", /*"Lamps_base_F",*/ "Land_Research_HQ_F", "Land_Research_house_V1_F", "Land_MilOffices_V1_F", "Land_TBox_F", "Land_Chapel_V1_F","Land_Chapel_Small_V2_F", "Land_Chapel_Small_V1_F", "Land_BellTower_01_V1_F", "Land_BellTower_02_V1_F", "Land_fs_roof_F","Land_fs_feed_F", "Land_Windmill01_ruins_F", "Land_d_Windmill01_F", "Land_i_Windmill01_F","Land_i_Barracks_V2_F", "Land_spp_Transformer_F", "Land_dp_smallFactory_F", "Land_Shed_Big_F", "Land_Metal_Shed_F","Land_i_Shed_Ind_F","Land_Communication_anchor_F", "Land_TTowerSmall_2_F", "Land_Communication_F","Land_cmp_Shed_F", "Land_cmp_Tower_F", "Land_u_Shed_Ind_F", "Land_TBox_F"]; Omg thats a handful. Thanks O.O Share this post Link to post Share on other sites
Tankbuster 1733 Posted November 28, 2015 You're very welcome. I used it to find the centre mass of houses in a town with the aim of finding the town outskirts and it's centre, It seems to work well, certainly better than the town radius and location BI give us. Note that I do count lamps_base as houses, they are remarked out of the list of things to be excluded as having them there seemed to improve the results Share this post Link to post Share on other sites
ArmaMan360 94 Posted November 29, 2015 Thank you all. Considering I have got a unit _veh created. How do I put him in a house? I am having trouble adopting this approach in entirety. Any leads please? As per Rydy's example, now what? _minus = nearestObjects [_sidepos,["PowerLines_Wires_base_F","Lamps_base_F","Piers_base_F","Land_NavigLight"],300]; _blds = _pos nearObjects ["House",300]; _blds = _blds - _minus; Share this post Link to post Share on other sites
Rydygier 1302 Posted November 29, 2015 Assuming, position has to be completely random among all possible positions, one way would be: _insideSpots = []; { _bPos = _x buildingPos 0; _insideSpots = []; _ct = 0; while {not ((_bPos select 0) == 0)} do { _insideSpots pushBack _bPos; _ct = _ct + 1; _bPos = _x buildingPos _ct; }; } foreach _blds; _myPos = _insideSpots select (floor (random (count _insideSpots))); _veh setPos _myPos; 1. Gathering all defined positions from all detected houses; 2. Choosing randomly one of these positions; 3. Placing _veh on this spot. Note, in this way all positions have equal chance to be used, so the more positions defined in given building, the bigger chance, _veh will go there. To have instead equal chance for each house, for example something like this instead: _houses = []; { _bPos = _bldg buildingPos 0; if not ((_bPos select 0) == 0) then { _houses pushBack _x } } foreach _blds; _bldg = _houses select (floor (random (count _houses))); _insideSpots = []; _bPos = _bldg buildingPos 0; _insideSpots = [_bPos]; _bPos = _bldg buildingPos 1; _ct = 1; while {not ((_bPos select 0) == 0)} do { _insideSpots pushBack _bPos; _ct = _ct + 1; _bPos = _x buildingPos _ct; }; _myPos = _insideSpots select (floor (random (count _insideSpots))); _veh setPos _myPos; 1. Collect from found buildings only those containing at least one defined position; 2. Choose randomly one of them; 3. Collect all positions in this chosen house; 4. Pick at random one of these positions; 5. Place _veh there. Share this post Link to post Share on other sites
austin_medic 109 Posted November 29, 2015 I made this little script to move a unit inside a house: define this as a function inside your init.sqf e.g AUSMD_fnc_moveIntoHouse = { _unit = _this select 0; _loopCount = 0; _houses = nearestObjects[leader _group,["Building"],50]; if(count _houses isEqualTo 0) exitWith {}; { _loopCount = _forEachIndex; _houseData = [_x,count units _group] call AUSMD_fnc_buildingEnterable; _house = _x; if(_houseData select 0 isEqualTo true) exitWith { { _x doMove (_house buildingPos _forEachIndex); [_x] spawn { _guy = _this select 0; waitUntil{unitReady _guy}; _guy disableAI "MOVE"; }; } forEach units _group; }; } forEach _houses; }; Which needs this function to work: AUSMD_fnc_buildingEnterable _building = [_this, 0, objNull, [objNull]] call BIS_fnc_param; _min = [_this, 1, 1, [0]] call BIS_fnc_param; //Get available positions of the building private "_availablePositions"; _availablePositions = [_building, _min] call BIS_fnc_buildingPositions; //Does this building have at least one position defined? private "_isEnterable"; _isEnterable = count _availablePositions >= _min; //Return [_isEnterable,_availablePositions]; Since it just searches for houses on its own you might need to do some tweaking. Share this post Link to post Share on other sites
ArmaMan360 94 Posted November 29, 2015 Wow thank you both for the detailed explanation. I am thrilled by your expertise Rydy and Austin !! :D Share this post Link to post Share on other sites
ArmaMan360 94 Posted November 30, 2015 Assuming, position has to be completely random among all possible positions, one way would be: _insideSpots = []; { _bPos = _x buildingPos 0; _insideSpots = []; _ct = 0; while {not ((_bPos select 0) == 0)} do { _insideSpots pushBack _bPos; _ct = _ct + 1; _bPos = _x buildingPos _ct; }; } foreach _blds; _myPos = _insideSpots select (floor (random (count _insideSpots))); _veh setPos _myPos; 1. Gathering all defined positions from all detected houses; 2. Choosing randomly one of these positions; 3. Placing _veh on this spot. Note, in this way all positions have equal chance to be used, so the more positions defined in given building, the bigger chance, _veh will go there. To have instead equal chance for each house, for example something like this instead: _houses = []; { _bPos = _bldg buildingPos 0; if not ((_bPos select 0) == 0) then { _houses pushBack _x } } foreach _blds; _bldg = _houses select (floor (random (count _houses))); _insideSpots = []; _bPos = _bldg buildingPos 0; _insideSpots = [_bPos]; _bPos = _bldg buildingPos 1; _ct = 1; while {not ((_bPos select 0) == 0)} do { _insideSpots pushBack _bPos; _ct = _ct + 1; _bPos = _x buildingPos _ct; }; _myPos = _insideSpots select (floor (random (count _insideSpots))); _veh setPos _myPos; 1. Collect from found buildings only those containing at least one defined position; 2. Choose randomly one of them; 3. Collect all positions in this chosen house; 4. Pick at random one of these positions; 5. Place _veh there. Rydy, this isnt working: call compile preprocessfile "SHK_pos\shk_pos_init.sqf"; _sidepos = getMarkerPos "m1"; _side = createCenter west; _groupHVT = createGroup east; _veh = _groupHVT createUnit ["O_officer_F", _sidepos, [], 0, "NONE"]; sleep 0.3; removeAllWeapons _veh; removeAllAssigneditems _veh; removevest _veh; removeHeadgear _veh; _veh setCaptive true; _veh disableAI "move"; _veh switchMove "Acts_SittingWounded_out"; _veh disableAI "ANIM"; sleep 0.4; _minus = nearestObjects [_sidepos,["PowerLines_Wires_base_F","Lamps_base_F","Piers_base_F","Land_NavigLight"],300]; _blds = _sidepos nearObjects ["House",300]; _blds = _blds - _minus; sleep 0.4; _houses = []; { _bPos = _bldg buildingPos 0; if not ((_bPos select 0) == 0) then { _houses pushBack _x } } foreach _blds; _bldg = _houses select (floor (random (count _houses))); _insideSpots = []; _bPos = _bldg buildingPos 0; _insideSpots = [_bPos]; _bPos = _bldg buildingPos 1; _ct = 1; while {not ((_bPos select 0) == 0)} do { _insideSpots pushBack _bPos; _ct = _ct + 1; _bPos = _x buildingPos _ct; }; _myPos = _insideSpots select (floor (random (count _insideSpots))); _veh setPos _myPos; sleep 0.3; It keeps spawning him at the default place. Share this post Link to post Share on other sites
Rydygier 1302 Posted November 30, 2015 Code wasn't tested - in such case some errors are likely, and RPT logs extremely helpful - found the pronblem thanks to them fast: _bPos = _bldg buildingPos 0;//should be _x _bPos = _x buildingPos _ct;//should be _bldg Working code: _sidepos = getMarkerPos "m1"; _side = createCenter west; _groupHVT = createGroup east; _veh = _groupHVT createUnit ["O_officer_F", _sidepos, [], 0, "NONE"]; sleep 0.3; removeAllWeapons _veh; removeAllAssigneditems _veh; removevest _veh; removeHeadgear _veh; _veh setCaptive true; _veh disableAI "move"; _veh switchMove "Acts_SittingWounded_out"; _veh disableAI "ANIM"; sleep 0.4; _minus = nearestObjects [_sidepos,["PowerLines_Wires_base_F","Lamps_base_F","Piers_base_F","Land_NavigLight"],300]; _blds = _sidepos nearObjects ["House",300]; _blds = _blds - _minus; sleep 0.4; _houses = []; { _bPos = _x buildingPos 0; if not ((_bPos select 0) == 0) then { _houses pushBack _x } } foreach _blds; _bldg = _houses select (floor (random (count _houses))); _insideSpots = []; _bPos = _bldg buildingPos 0; _insideSpots = [_bPos]; _bPos = _bldg buildingPos 1; _ct = 1; while {not ((_bPos select 0) == 0)} do { _insideSpots pushBack _bPos; _ct = _ct + 1; _bPos = _bldg buildingPos _ct; }; _myPos = _insideSpots select (floor (random (count _insideSpots))); _veh setPos _myPos; sleep 0.3; "m1" setMarkerPos _myPos; without yours first line. Also added at the very end single line, that moves the marker, where HVT was teleported, so you can check there, how it looks. Or remove the last line ("m1" setMarkerPos _myPos;). One note about this: _minus = nearestObjects [_sidepos,["PowerLines_Wires_base_F","Lamps_base_F","Piers_base_F","Land_NavigLight"],300]; This blacklist is of course suited for my personal use, which was placing loot or civilians for Pilgrimage. You may want to expand the blacklist by adding new classes of buildings, where yours HVT shouldn't be teleported, like all those patios or arbors without walls. Share this post Link to post Share on other sites