f3cuk / WICKED-AI

Wicked AI missions for your server
30 stars 59 forks source link

Mines Again #42

Closed nerdalertdk closed 10 years ago

nerdalertdk commented 10 years ago

Just found this code in the Sarge AI. Thought it was better then a minefield ?

AI will lay down mines if there are enemy armour nearby.

//If use statics are enabled leader searches for static weapons near.
            // Tanks enemies are contabiliced
            if ( KRON_UPS_useMines && _Mines > 0 ) then {
                _enemytanksnear = false;    
                {
                    if ( ("Tank" countType [_x] > 0 || "Wheeled_APC" countType [_x] >0 
                        || "Tank" countType [vehicle _x] > 0 || "Wheeled_APC" countType [vehicle _x] >0 ) 
                        && alive _x && canMove _x && _npc distance _x <= _closeenough + KRON_UPS_safedist )
                        exitwith { _enemytanksnear = true; _enemytanknear = _x;};                                                                                   
                } foreach _targets;

                //If use mines are enabled and enemy armors near and no friendly armor put mine.
                if ( _enemytanksnear && !isnull _enemytanknear && alive _enemytanknear ) then {
                    _friendlytanksnear = false;
                    {
                        if (!( alive _x && canMove _x)) then {_friendlytanks = _friendlytanks - [_x]};
                        if (alive _x && canMove _x && _npc distance _x <= _closeenough + KRON_UPS_safedist ) exitwith { _friendlytanksnear = true;}; 
                    }foreach _friendlytanks;    

                    if (!_friendlytanksnear && random(100)<30 ) then {
                        _dir1 = [_currPos,position _enemytanknear] call KRON_getDirPos;
                        _mineposition = [position _npc,_dir1, 25] call MON_GetPos2D;    
                        _roads = _mineposition nearroads 50;
                        if (count _roads > 0) then {_mineposition = position (_roads select 0);};
                        if ([_npc,_mineposition] call MON_CreateMine) then {
                            _Mines = _Mines -1;
                            if (KRON_UPS_Debug>0) then {diag_log format["%1: %3 puting mine for %2",_grpidx,typeof _enemytanknear, side _npc]};                                     
                        };                                                  
                    };              
                };
            };``
f3cuk commented 10 years ago

That is a nice little feature. But it's more resource intensive and it requires the inclusion of the KRON file which is quite a mess to be honest. Also missions are supposed to spawn only after bandits have set up shop, so they would've done things like laying down mines and setting traps.