Поднимаем поваленные деревья.

Тема в разделе "Редактор", создана пользователем Dimon UA, 14 мар 2015.

  1. TopicStarter Overlay
    Dimon UA
    Оффлайн

    Dimon UA

    System Admin

    Команда форума

    Регистрация:
    15.10.12
    Сообщения:
    2.172
    Симпатии:
    1.164
    Репутация:
    25
    Дополнительная информация:
    Отряд [KPbIM]
    Чтобы не мешали поваленные деревья написал скрипт.
    1. находим массив всех обьектов
    например в радиусе 100 м от игрока
    Код:
    obj = nearestObjects [player,[],100];
    2.отсеиваем из массива деревья, проверяем их на дамаг и поднимаем (восстанавливаем).
    Код:
    obj call fnc_repair_tree;
    fnc_repair_tree

    Код:
    if !(isClass(configFile>>'CfgPatches'>>'cba_main')) then
    {
        fnc_defaultParam = {
            /* ----------------------------------------------------------------------------
            Function: CBA_fnc_defaultParam
    
            Description:
                Gets a value from parameters list (usually _this) with a default.
    
            Example (direct use of function):
            (begin code)
                private "_frog";
                _frog = [_this, 2, 12] call CBA_fnc_defaultParam;
            (end code)
    
            Example (macro):
            (begin code)
                #include "script_component.hpp"
                DEFAULT_PARAM(2,_frog,12);
            (end code)
    
            Parameters:
                _params - Array of parameters, usually _this [Array]
                _index - Parameter index in the params array [Integer: >= 0]
                _defaultValue - Value to use if the array is too short [Any]
    
            Returns:
                Value of parameter [Any]
            ---------------------------------------------------------------------------- */
            _params = _this select 0;
            _index = _this select 1;
            _defaultValue = _this select 2;
          
            private "_value";
    
            if (!isNil "_defaultValue") then {
                _value = _defaultValue;
            };
    
            if (!isNil "_params" && {(typeName _params) == "ARRAY"} && {count _params > _index} && {!isNil { _params select _index }}) then {
                _value = _params select _index;
            };
    
            // Return.
            if (isNil "_value") then {
                nil;
            } else {
                _value;
            };
        };
        fnc_find = {
            /* ----------------------------------------------------------------------------
            Function: CBA_fnc_find
    
            Description:
                Finds a string within another string.
    
            Parameters:
                _haystack - String in which to search [String or ASCII char array]
                _needle - String to search for [String or ASCII char array]
                _initialIndex - Initial character index within _haystack to start the
                search at [Number: 0+, defaults to 0].
    
            Returns:
                First position of string. Returns -1 if not found [Number]
    
            Examples:
                (begin example)
                    _result = ["frog-headed fish", "f"] call CBA_fnc_find;
                    // _result => 0
    
                    _result = ["frog-headed fish", "f", 5] call CBA_fnc_find;
                    // _result => 12
    
                    _result = ["frog-headed fish", "fish"] call CBA_fnc_find;
                    // _result => 12
                (end)
    
            Author:
                Xeno
            ---------------------------------------------------------------------------- */
            _haystack = _this select 0;
            _needle = _this select 1;
            _initialIndex = [_this, 2, 0] call fnc_defaultParam;
            private ["_haystackCount", "_needleCount", "_foundPos",
            "_needleIndex", "_doexit", "_notfound"];
    
            if (typeName _haystack == "STRING") then {
                _haystack = toArray _haystack;
            };
    
            if (typeName _needle == "STRING") then {
                _needle = toArray _needle;
            };
    
            _haystackCount = count _haystack;
            _needleCount = count _needle;
            _foundPos = -1;
    
            if ((_haystackCount - _initialIndex) < _needleCount) exitWith {_foundPos};
    
            _needleIndex = 0;
            _doexit = false;
            for "_i" from _initialIndex to (_haystackCount - 1) do {
                if (_haystack select _i == _needle select _needleIndex) then {
                    if (_needleCount == 1) exitWith {
                        _foundPos = _i;
                        _doexit = true;
                    };
                    if (_haystackCount - _i < _needleCount) exitWith {_doexit = true};
                    _needleIndex = (_needleIndex) + 1;
                    _notfound = false;
                    for "_j" from (_i + 1) to (_i + _needleCount - 1) do {
                        if (_haystack select _j != _needle select _needleIndex) exitWith
                        {
                            _notfound = true;
                        };
                        _needleIndex = (_needleIndex) + 1;
                    };
                    if (_notfound) then
                    {
                        _needleIndex = 0;
                    } else {
                        _foundPos = _i;
                        _doexit = true;
                    };
                };
                if (_doexit) exitWith {};
            };
    
            _foundPos
        };
        // ==========================================================//
        private ["_debug", "_trees"];
        _debug = false;
    
        _trees = [];
        {
            if (([str _x, ": t_"] call fnc_find) > -1 || {([str _x, "palm"] call fnc_find) > -1}) then
            {
                _trees set [count _trees,_x];
              
            };
        } forEach _this;
        if _debug then
        {
            hint str _trees;
            copyToClipboard str _trees;
            {_x setdamage 1;} foreach _trees;
            sleep 5;
        };
        {
            if ((damage _x) > 0) then
            {
                _x setdamage 0;
            };
        } foreach _trees;
    }else{
        private ["_debug", "_trees"];
        _debug = false;
    
        _trees = [];
        {
            if (([str _x, ": t_"] call CBA_fnc_find) > -1 || {([str _x, "palm"] call CBA_fnc_find) > -1}) then
            {
                _trees set [count _trees,_x];
              
            };
        } forEach _this;
        if _debug then
        {
            hint str _trees;
            copyToClipboard str _trees;
            {_x setdamage 1;} foreach _trees;
            sleep 5;
        };
        {
            if ((damage _x) > 0) then
            {
                _x setdamage 0;
            };
        } foreach _trees;
    };    
     

Пользователи просматривающие тему (Пользователей: 0, Гостей: 0)