Author: SerpentSerpent wrote: ↑Sun Jun 23, 2019 12:48 am Funkcja podłączająca zadany parametrem zdalnie sterowany pojazd do możliwe jak najlepszego mechanika. Pod uwagę brana jest ilość już podłączonych pojazdów oraz poziom mechanika. Działa zarówno dla statycznych jak i mobilnych wież kontrolnych.
Code: Select all
Export Function Connect(vehicle); var i, t, mech, tmp, j; begin if not vehicle or not GetControl(vehicle) = control_remote then exit; tmp := FilterAllUnits([[f_side, GetSide(vehicle)], [f_or, [f_btype, b_control_tower], [f_weapon, ar_control_tower]]]); if not tmp then exit; result := []; for i in tmp do begin t := UnitsInside(i); if t then for j in t do result := Insert(result, result+1, j); end; if not result then exit; mech := result[1]; if result > 1 then for i = 2 to result do begin t := GetSkill(result[i], 3) - UnitsLinked(result[i]); if t >= (GetSkill(mech, 3) - UnitsLinked(mech)) then mech := result[i]; end; ComLinkTo(vehicle, mech); End;
Topic: viewtopic.php?f=42&t=6012