SAIL - Connect (podłączanie zdalnie sterowanych pojazdów)

Gotowe kody SAIL'a, informacje na temat moddingu, itd.

Moderator: zoNE

Post Reply
User avatar
zoNE
The Great Uniter & Site Administrator
The Great Uniter & Site Administrator
Posts: 2059
Joined: Fri Feb 17, 2006 3:44 pm
Location: Poland
Contact:

SAIL - Connect (podłączanie zdalnie sterowanych pojazdów)

Post by zoNE »

Serpent 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;
Author: Serpent
Topic: viewtopic.php?f=42&t=6012
Post Reply