/*
Author: Phil
Steam: https://steamcommunity.com/id/xshiragamix/
Description:
Random flyby
Note:
If you using custom code, you need to delete the crew and vehicle by yourself !
Parameter(s):
0 Optional: Classname of the vehicle or Array of Classnems, crew will be created automaticly
Recommend to only use planes or helis
1 Optional: Custom center, Type object
3 Custom code passed as array [{1},{2}]
1) Code on start waypoint
Access the vehicle with _vehicle = param[0];
2) Code on end waypoint
Access the vehicle with _vehicle = param[0];
To only use waypoint end code use [{},{code}]
----------------------------------->
Examples:
o) Basic
[]execVM "fox_ambientFlyby.sqf";
o) Advanced
[
["C_Heli_Light_01_civil_F","B_Plane_CAS_01_F","O_T_VTOL_02_infantry_F"],
false,
[
{
_smoke = "SmokeShellGreen" createVehicle [0,0,0];
_smoke attachTo[_this select 0,[0,0,0]];
},
{
{deleteVehicle _x;} forEach crew (_this select 0);deleteVehicle (_this select 0);
}
]
]execVM "fox_ambientFlyby.sqf";
----------------------------------->
You can copy pasta the code below directly in the 3den debug window to test it.
*/
_vehicleClass = param[0,["C_Plane_Civil_01_F","C_Heli_Light_01_civil_F"]];
_objectCenter = param[1,false];
_customCode = param[2,[{},{}]];
//if Array is passed select a random one
if(( typeName _vehicleClass ) isEqualTo "ARRAY") then{
_vehicleClass = _vehicleClass call BIS_fnc_selectRandom;
};
_center = getArray(configfile >> "CfgWorlds" >> worldname >> "centerPosition");
_mBottomLeft = [0 - 1000,0 - 1000,0];
_mTopLeft = [0 - 1000,( (_center select 0) * 2) - 1000,0];
_mTopRight = [ ( (_center select 0) * 2 ) + 1000,( (_center select 1) * 2 ) + 1000,0];
_mBottomRight = [( (_center select 0) * 2 ) + 1000,0 - 1000,0];
_pos1 = [_mBottomLeft,_mTopLeft] call BIS_fnc_selectRandom;
_pos2 = [_center] call BIS_fnc_selectRandom;
_pos3 = [_mTopRight,_mBottomRight] call BIS_fnc_selectRandom;
_startPos = [_pos1,_pos3] call BIS_fnc_selectRandom;
_endPos = [_pos1,_pos3] - [_startPos];
_veh = createVehicle [_vehicleClass,_startPos, [], 0, "FLY"];
createVehicleCrew _veh;
_centerRandom = _center getPos [((_center select 0) / 2) * sqrt random 1, random 360];
_wp1 = (group _veh) addWaypoint [_startPos, 0];
if(( typeName _objectCenter ) isEqualTo "OBJECT")then{
_wp2 = (group _veh) addWaypoint [getPos _objectCenter, 0];
}else{
_wp2 = (group _veh) addWaypoint [_centerRandom, 0];
};
_wp3 = (group _veh) addWaypoint [_endPos select 0, 0];
//Default code for waypoints
_waypointStartCode = _customCode param[0,{}];
_waypointEndCode = _customCode param[1,{{deleteVehicle _x;} forEach crew (_this select 0);deleteVehicle (_this select 0);}];
if( ( typeName _waypointStartCode ) isEqualTo "CODE")then{
_wp1 setWaypointStatements ["true", format["[vehicle this] call %1",_waypointStartCode]];
};
if( ( typeName _waypointEndCode ) isEqualTo "CODE")then{
_wp3 setWaypointStatements ["true", format["[vehicle this] call %1",_waypointEndCode]];
};
Comments