SilentSpike 84 Posted July 15, 2014 I'm working on a mission that I'd like to be able to port between maps by simply renaming the folder and was wondering if anyone knows of a way to retrieve the width and height of the currently played map. I could use these values to effectively search the entire map for spawn locations. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted July 15, 2014 A good and reliable way to achieve this is to either use town locations or the selectBestPlaces command to find suitable spawn locations for almost every kind of mission. Share this post Link to post Share on other sites
SilentSpike 84 Posted July 15, 2014 That's what I'm currently doing, but it only works so well as I'd need to be able to find the middle of the map and get the radius to check in to make it adjust to maps with different dimensions. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted July 15, 2014 That's what I'm currently doing, but it only works so well as I'd need to be able to find the middle of the map and get the radius to check in to make it adjust to maps with different dimensions. Well in that case: _worldcenter = getArray (configfile >> "CfgWorlds" >> worldName >> "centerPosition"); _worldsize = getnumber (configfile >> "CfgWorlds" >> worldName >> "mapSize"); it's all in the config Share this post Link to post Share on other sites
SilentSpike 84 Posted July 15, 2014 Nice, thanks :) Didn't know about CfgWorlds ---------- Post added at 18:10 ---------- Previous post was at 18:01 ---------- Interestingly it seems that some worlds don't have a map size value (VR for example), doesn't seem to be defined in parent classes either so I can only assume that a default map size of 8192 is used. Share this post Link to post Share on other sites
seba1976 98 Posted July 15, 2014 Please notice though, that's been reported that the method is not reliable. In every case I remember, everyone ended up using markers, or simply using known map sizes and centers for every map you plan to port your mission to. Share this post Link to post Share on other sites
SilentSpike 84 Posted July 15, 2014 Do you know what exactly is unreliable about it? Share this post Link to post Share on other sites
seba1976 98 Posted July 15, 2014 Do you know what exactly is unreliable about it? Oh yes, yes I do. The reported center is not, most of the times, the real center, not by a long shot. I don't remember about mapSize to be honest, but I do mostly the kind of thing you want to do, and I ditched the automatic method a long time ago. Hope that helps. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted July 15, 2014 Do you know what exactly is unreliable about it? Like seba said, you'd want to at least look at different community made maps and look at their configs. As for Altis, the center position is 100m above ground. The center position of stratis is 1024m above ground. You get the idea. Share this post Link to post Share on other sites
das attorney 857 Posted July 15, 2014 Agreed. On Stratis, the "centre" of the map is on the hill above the airfield, near the green mil cargo building.... Share this post Link to post Share on other sites
SilentSpike 84 Posted July 15, 2014 (edited) So why not just half the mapsize to get the center? As for the altitude of the center I'm not that bothered about it. ---------- Post added at 18:54 ---------- Previous post was at 18:48 ---------- Well, for what it's worth. Here's some code which seems to be working fine so far: private ["_worldSize","_worldCenter","_locations","_l","_temp","_tempPos","_sideArray"]; // Retrieve world center and size _worldSize = if (isNumber (configfile >> "CfgWorlds" >> worldName >> "mapSize")) then {getNumber (configfile >> "CfgWorlds" >> worldName >> "mapSize");} else {8192;}; _worldCenter = [_worldSize/2,_worldSize/2,0]; _sideArray = [west,east,independent,civilian] call BIS_fnc_arrayShuffle; // Create respawn positions for each side _locations = (nearestLocations [_worldCenter,["NameCityCapital","NameCity","NameVillage","NameLocal"],sqrt(2*((_worldSize/2)^2))]); { for "_l" from 1 to 3 do { if !(_locations isEqualTo []) then { _temp = _locations call BIS_fnc_selectRandom; _tempPos = locationPosition _temp; [_x,_tempPos] call BIS_fnc_addRespawnPosition; _locations = _locations - [_temp]; } else { _temp = true; while {_temp} do { _temp = false; _tempPos = [_worldCenter,floor(random (_worldSize/2)),random 360] call BIS_fnc_relPos; if ((_tempPos isflatempty [15,0,0.7,10,0,false,objNull]) isEqualTo []) then { _temp = true; }; }; [_x,_tempPos] call BIS_fnc_addRespawnPosition; }; }; true } count _sideArray; Ideally I'd shuffle up the array of sides beforehand but I don't have time to do that right now. Edit: God damn what is with this forum and breaking the line breaks in PHP formatting. Edited July 16, 2014 by SilentSpike Share this post Link to post Share on other sites
SilentSpike 84 Posted July 16, 2014 Updated code above to shuffle the array before the loop. Share this post Link to post Share on other sites
lappihuan 178 Posted July 16, 2014 (edited) _path = configfile >> "cfgworlds" >> worldname; _size = getnumber (_path >> "mapSize"); _size = _size / 2; _center = [_size,_size,0]; you can then make: _centerHeight = ATLtoASL _center; to find the height above sea level where _centerHeight select 2 would be the height. Edited July 16, 2014 by Lappihuan Share this post Link to post Share on other sites