a3_exile_occupation/scripts/occupationPublicBus.sqf

118 lines
3.7 KiB
Plaintext
Raw Normal View History

if (!isServer) exitWith {};
_logDetail = format ["[OCCUPATION:publicBus]:: Starting @ %1",time];
[_logDetail] call SC_fnc_log;
2016-04-14 08:47:40 +00:00
_position = [ 0, 5000, 1, 500, 500, 200, 200, 200, true, false ] call DMS_fnc_findSafePos;
// Get position of nearest roads
_nearRoads = _position nearRoads 2000;
_nearestRoad = _nearRoads select 0;
_nearestRoadPos = position (_nearRoads select 0);
_spawnLocation = [_nearestRoadPos select 0, _nearestRoadPos select 1, 0];
// Create the busDriver and ensure he doest react to gunfire or being shot at.
_group = createGroup resistance;
_group setCombatMode "BLUE";
"Exile_Trader_CommunityCustoms" createUnit [_spawnLocation, _group, "busDriver = this; this disableAI 'AUTOTARGET'; this disableAI 'TARGET'; this disableAI 'SUPPRESSION'; "];
busDriver allowDamage false;
removeGoggles busDriver;
busDriver forceAddUniform "U_IG_Guerilla3_1";
busDriver addVest "V_TacVest_blk_POLICE";
busDriver addBackpack "B_FieldPack_oli";
busDriver addHeadgear "H_Cap_blk";
busDriver setCaptive true;
// Spawn busDrivers Vehicle
2016-04-11 20:17:34 +00:00
_publicBus = createVehicle [SC_occupyPublicBusClass, _spawnLocation, [], 0, "CAN_COLLIDE"];
SC_publicBusArray = SC_publicBusArray + [_publicBus];
_publicBus setVariable ["SC_assignedDriver", busDriver,true];
2016-04-11 15:39:00 +00:00
_publicBus setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true];
_publicBus addEventHandler ["getin", "_this call SC_fnc_getInBus;"];
_group addVehicle _publicBus;
clearBackpackCargoGlobal _publicBus;
clearItemCargoGlobal _publicBus;
clearMagazineCargoGlobal _publicBus;
clearWeaponCargoGlobal _publicBus;
_publicBus setVariable ["ExileIsPersistent", false];
_publicBus setVariable["vehPos",_spawnLocation,true];
_publicBus setFuel 1;
2016-04-14 08:47:40 +00:00
_logDetail = format['[OCCUPATION:publicBus] Vehicle spawned @ %1',_spawnLocation];
[_logDetail] call SC_fnc_log;
_publicBus addEventHandler ["HandleDamage", { _amountOfDamage = 0; _amountOfDamage }];
busDriver assignasdriver _publicBus;
2016-04-14 08:47:40 +00:00
busDriver moveInDriver _publicBus;
[busDriver] orderGetin true;
2016-04-14 08:47:40 +00:00
_publicBus lockDriver true;
{
_markerName = _x;
_markerPos = getMarkerPos _markerName;
2016-04-11 20:17:34 +00:00
if (markerType _markerName == "ExileTraderZone" OR markerType _markerName == "o_unknown") then
{
_wp = _group addWaypoint [_markerPos, 100];
_wp setWaypointType "MOVE";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointspeed "LIMITED";
};
} forEach allMapMarkers;
// Add a final CYCLE
_wp = _group addWaypoint [_spawnLocation, 100];
_wp setWaypointType "CYCLE";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointspeed "LIMITED";
_busPos = position _publicBus;
_mk = createMarker ["busLocation",_busPos];
2016-04-11 21:07:38 +00:00
"busLocation" setMarkerType "mil_warning";
"busLocation" setMarkerText "Public Bus";
diag_log format['[OCCUPATION:publicBus] Running'];
busDriver = _publicBus getVariable "SC_assignedDriver";
// Make busDriver stop when players near him.
while {true} do
{
_pos = position _publicBus;
_mk setMarkerPos _pos;
2016-04-11 20:17:34 +00:00
_nearPlayers = (count (_pos nearEntities [['Exile_Unit_Player'],25]));
if (_nearPlayers >= 1) then
{
uiSleep 0.5;
_publicBus setFuel 0;
busDriver disableAI "MOVE";
uiSleep 3;
}
else
{
_publicBus setFuel 1;
uiSleep 3;
busDriver enableAI "MOVE";
if(!Alive busDriver) exitWith {};
};
};
2016-04-14 08:47:40 +00:00
{
// Check for nearby missions
_missionPos = missionNamespace getVariable [format ["%1_pos",_x], []];
_missionDistance = _missionPos distance2D _pos;
if (_missionDistance<=500) then
{
// DMS Mission in range
_logDetail = format['[OCCUPATION:publicBus] Vehicle near DMS Mission @ %1 (%2 metres away)',_missionPos,(_missionPos distance2D _pos)];
[_logDetail] call SC_fnc_log;
};
} forEach allMapMarkers;