
Kod: Zaznacz cały
_p = [p1, p2, p3, p4, p5, p6];
_grp = createGroup east;
_unit = _grp createUnit ["Ins_Soldier_Pilot", position (random _p), [], 0, "FORM"];
[_unit] join _grp;
Moderatorzy: kondor, Inkwizytor
Kod: Zaznacz cały
_p = [p1, p2, p3, p4, p5, p6];
_grp = createGroup east;
_unit = _grp createUnit ["Ins_Soldier_Pilot", position (random _p), [], 0, "FORM"];
[_unit] join _grp;
Kod: Zaznacz cały
_p select (floor (random (count _p)))
Kod: Zaznacz cały
random _p
Kod: Zaznacz cały
_pos = [p1, p2, p3, p4, p5, p6];
_des = [d1, d2, d3, d4, d5, d6];
_grp = createGroup east;
while {true} do
{
_liczba1 = round(random 5);
_liczba2 = round(random 5);
_element1 = (_pos select _liczba1);
_element2 = (_des select _liczba2);
_heli = createVehicle ["Mi17_Ins", position _element1, [], 0, "FLY"];
_unit1 = _grp createUnit ["Ins_Soldier_Pilot", position _element1, [], 0, "FORM"];
_unit2 = _grp createUnit ["Ins_Soldier_Pilot", position _element1, [], 0, "FORM"];
_unit3 = _grp createUnit ["Ins_Soldier_Pilot", position _element1, [], 0, "FORM"];
_unit4 = _grp createUnit ["Ins_Soldier_Pilot", position _element1, [], 0, "FORM"];
[_unit1] join _grp;
[_unit2] join _grp;
[_unit3] join _grp;
[_unit4] join _grp;
_unit1 moveInDriver _heli;
_unit2 moveInGunner _heli;
_unit3 moveInCargo _heli;
_unit4 moveInCargo _heli;
_unit1 doMove position _element2;
sleep 500;
deleteVehicle _heli;
deleteVehicle _unit1;
deleteVehicle _unit2;
deleteVehicle _unit3;
deleteVehicle _unit4;
sleep 5;
};
Tak myślałem, że da się prościej... niestety nie jestem aż tak biegły w skryptach. Może jakiś przykład z tą pentelką?kondor pisze:To, co podałem (oraz funkcja BISu) jest krótsze i bardziej elastyczne, bo liczy długość tablicy i się nie wywali jak odejmiesz lub dodasz element. Poza tym, kod który napisałeś da się zapisać 4 razy krócej używając np pętli for...
Kod: Zaznacz cały
...
_heli = createVehicle ["Mi17_Ins", position _element1, [], 0, "FLY"];
for "_i" from 0 to 3 do
{
_liczba1 = floor (random count _pos);
_liczba2 = floor (random count _des);
_element1 = (_pos select _liczba1);
_element2 = (_des select _liczba2);
_unit = _grp createUnit ["Ins_Soldier_Pilot", position _element1, [], 0, "FORM"];
[_unit] join _grp;
switch (_i)
{
case 0: _unit moveInDriver _heli;
case 1: _unit moveInGunner _heli;
default: _unit moveInCargo _heli;
};
_grp doMove position _element2;
};
sleep 500;
deleteVehicle _heli;
{ deleteVehicle _x } forEach (units _grp);
sleep 5;
Mylisz się bo tam jest podane round a nie floor.kondor pisze:Już widać błąd tego podejścia - liczysz random 5, a masz 6 elementów...
Każdemu się zdarza... właśnie dlatego nie wiem czemu pisałem:kondor pisze:Tak, przeczytałem random zamiast round.
Kod: Zaznacz cały
deleteVehicle _heli;
deleteVehicle _unit1;
deleteVehicle _unit2;
deleteVehicle _unit3;
deleteVehicle _unit4;
Kod: Zaznacz cały
{deleteVehicle _x} forEach (units _grp);
No i niestety nie działa, ale nie ważne. Mam prośbę... Mógłbyś króciutko opisać jak ta pętla działa, bądź jak powinna działać?Poprawiłem poprzedni kod, chociaż i tak nie mam jak przetestować, więc może nie działać.
Kod: Zaznacz cały
for "_i" from 0 to 3 do
{
_liczba1 = floor (random count _pos);
_liczba2 = floor (random count _des);
_element1 = (_pos select _liczba1);
_element2 = (_des select _liczba2);
_unit = _grp createUnit ["Ins_Soldier_Pilot", position _element1, [], 0, "FORM"];
[_unit] join _grp;
switch (_i)
{
case 0: _unit moveInDriver _heli;
case 1: _unit moveInGunner _heli;
default: _unit moveInCargo _heli;
};
_grp doMove position _element2;
};
Kod: Zaznacz cały
_pos = [p1, p2, p3, p4, p5, p6];
_des = [d1, d2, d3, d4, d5, d6];
_grp = createGroup east;
while {true} do
{
_liczba1 = floor (random count _pos);
_liczba2 = floor (random count _des);
_element1 = (_pos select _liczba1);
_element2 = (_des select _liczba2);
_heli = createVehicle ["Mi17_Ins", position _element1, [], 0, "FLY"];
_heli setPosATL [getPosATL _element1 select 0, getPosATL _element1 select 1, (random 500)];
for "_i" from 0 to 4 do
{
_unit = _grp createUnit ["Ins_Soldier_Pilot", position xyz, [], 0, "FORM"];
[_unit] join _grp;
switch (_i) do
{
case 0:
{
_unit moveInDriver _heli;
};
case 1:
{
_unit moveInTurret [_heli,[0]];
};
case 2:
{
_unit moveInTurret [_heli,[1]];
};
default
{
_unit moveInCargo _heli;
};
};
{_x doMove position _element2 && _x setSpeedMode "FULL" && _x flyInHeight (random 500)} forEach (units _grp);
};
sleep 500;
deleteVehicle _heli;
{deleteVehicle _x} forEach (units _grp);
};