Feature #32808

More robust player position finder script

Added by Craig_VG over 2 years ago.

Status:Closed Start date:06/14/2012
Priority:High Due date:
Assignee:Craig_VG % Done:

100%

Category:-
Target version:1.0
Affected ArmA II version: BIForumURL:

Description

Basically make the finding of positions more better. :D

    if (CVG_Playerstart == 50) then {
        if (count _towns != 0) then {
            _townnumber = random floor (count _towns);
            _town = _towns select _townnumber;
            _townpos = (position _town);
            _group = createGroup sideLogic;
            _logic = _group createUnit ["Logic",_townpos, [], 100, "NONE"];   
            _newPos = position _logic;
            player setpos _newPos;
            if (CVG_debug == 2) then {
                player sidechat format ["location chosen, %1",_town]
            };
        }
        else
        {
            if ((count buildings) != 0) then {
                _building = (round(random(count buildings)));
                _newpos = position (buildings select _building);
                _newpos = [_newPos,0,50,1,0,20,0] call BIS_fnc_findSafePos;
                player setpos _newpos;
            }
            else
            {
                _things = nearestObjects [player, [], 200000];
                if ((count _things) != 0) then {
                    _thing = (round(random(count _things)));
                    _newpos = position (_things select _thing);
                    player setpos _newpos;
                }
                else
                {
                    _newpos = [(random 1000),(random 1000)];
                    player setpos _newpos;
                };
            };
        };
    };

    if (CVG_playerstart == 100) then {
        _townnumber = floor (random (count _towns));
        _town = _towns select _townnumber;
        _townpos = getpos _town;
        _checkVar = 0;
        _armPos = getArray(configFile >> "CfgWorlds" >> worldName >> "Armory" >> "positionStart");
        _centPos = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition");

        while {_checkVar < 1} do{
            _dist = 1500;
            _dir = random 360;
            _pos = [(_townpos select 0) + (sin _dir) * _dist, (_townpos select 1) + (cos _dir) * _dist, 0];
            _pos = [_pos,0,40,4,0,20,0] call BIS_fnc_findSafePos;
            _check1 = [_pos, _armPos] call arrayCompare;
            _check2 = [_pos,_centPos] call arrayCompare;
            if ((!_check1) && (!_check2) && ((_pos distance (getpos _town)) > 1000)) then { _checkVar = 1};
        };
        player setpos _pos;
        if (CVG_debug == 2) then {player sidechat format ["location chosen, %1",_townpos]};
    };

    if (CVG_playerstart == 150) then {
        _pos= getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
        _group = createGroup sideLogic;
        _logic = _group createUnit ["Logic", _pos, [], 100, "NONE"];
        player setpos (position _logic);
        if (CVG_debug == 2) then {
            player sidechat format ["location chosen, %1",_pos];
        };
    };

Also available in: Atom PDF