diff --git a/addons/killers/XEH_PREP.hpp b/addons/killers/XEH_PREP.hpp index 5a83ef2d..24fb5292 100644 --- a/addons/killers/XEH_PREP.hpp +++ b/addons/killers/XEH_PREP.hpp @@ -1,4 +1,5 @@ PREP(addItemToStash); +PREP(createMarkersForNearbyVehicles); PREP(createStartPositionMarker); PREP(createTeleport); PREP(deleteStartPositionsMarkers); diff --git a/addons/killers/XEH_postInit.sqf b/addons/killers/XEH_postInit.sqf index fe55e67f..0d3d78ef 100644 --- a/addons/killers/XEH_postInit.sqf +++ b/addons/killers/XEH_postInit.sqf @@ -41,3 +41,16 @@ if (hasInterface) then { }] call CBA_fnc_waitUntilAndExecute; }] call CBA_fnc_addClassEventHandler; }; + +[QGVAR(teleport), { + params ["_killer", "_destination"]; + + if (_destination isEqualType objNull) then { + _destination = getPos _destination; + }; + + // Mark nearest vehicles for first couple minutes + [_destination] call FUNC(createMarkersForNearbyVehicles); + + [QEGVAR(common,teleport), [_killer, _destination]] call CBA_fnc_localEvent; +}] call CBA_fnc_addEventHandler; diff --git a/addons/killers/functions/fnc_createMarkersForNearbyVehicles.sqf b/addons/killers/functions/fnc_createMarkersForNearbyVehicles.sqf new file mode 100644 index 00000000..70d42c00 --- /dev/null +++ b/addons/killers/functions/fnc_createMarkersForNearbyVehicles.sqf @@ -0,0 +1,41 @@ +#include "script_component.hpp" +/* + * Author: 3Mydlo3 + * Searches for vehicles in given radius near given position. + * Creates a decaying marker for each vehicle. + * + * Arguments: + * 0: Search position + * 1: Search radius + * + * Return Value: + * None + * + * Example: + * [getPos bob, 500] call afsk_killers_fnc_createMarkersForNearbyVehicles + * + * Public: No + */ + +params ["_position", ["_radius", 1000]]; + +private _nearbyVehicles = _position nearEntities [["Air", "Car", "Motorcycle", "Tank"], _radius]; +private _emptyVehicles = _nearbyVehicles select { + crew _x isEqualTo [] +}; + +{ + private _vehicle = _x; + private _marker = createMarkerLocal [format ["vehicle_%1", _vehicle], getPos _vehicle]; + _marker setMarkerColorLocal "ColorCIVILIAN"; + _marker setMarkerTextLocal getText (configFile >> "CfgVehicles" >> (typeof _vehicle) >> "displayName"); + + private _markerType = if (_vehicle isKindOf "Air") then { + if (_vehicle isKindOf "Plane") then { "loc_plane" } else { "loc_heli" } + } else { "loc_car" }; + _marker setMarkerTypeLocal _markerType; + + [_marker, 2, true] call EFUNC(markers,markerDecay); +} forEach _emptyVehicles; + +nil diff --git a/addons/killers/functions/fnc_createTeleport.sqf b/addons/killers/functions/fnc_createTeleport.sqf index 1eee213e..0ccffe66 100644 --- a/addons/killers/functions/fnc_createTeleport.sqf +++ b/addons/killers/functions/fnc_createTeleport.sqf @@ -24,7 +24,7 @@ private _positionID = 0; private _destinationName = format ["%1 - %2", _positionID, _x]; private _destinationPos = GVAR(startPositions) getVariable _x; private _teleportActionID = _flag addAction [_destinationName, { - [QEGVAR(common,teleport), [_this select 1, _this select 3 select 0]] call CBA_fnc_serverEvent; + [QEGVAR(killers,teleport), [_this select 1, _this select 3 select 0]] call CBA_fnc_localEvent; // Delete all teleport actions and markers call FUNC(deleteStartPositionsMarkers); private _teleportActionsIDs = (_this select 0) getVariable [QGVAR(teleportActionsIDs), []]; diff --git a/addons/markers/functions/fnc_markerDecay.sqf b/addons/markers/functions/fnc_markerDecay.sqf index 5d8114d7..879ecd62 100644 --- a/addons/markers/functions/fnc_markerDecay.sqf +++ b/addons/markers/functions/fnc_markerDecay.sqf @@ -16,9 +16,9 @@ * Public: No */ -params ["_marker", ["_decayHalfTime", 10]]; +params ["_marker", ["_decayHalfTime", 10], ["_local", false]]; // How much decay will be applied every 15 seconds private _decayRate = 1/(_decayHalfTime * 4 * 2); -[_marker, _decayRate] call FUNC(markerDecayLoop); +[_marker, _decayRate, _local] call FUNC(markerDecayLoop); diff --git a/addons/markers/functions/fnc_markerDecayLoop.sqf b/addons/markers/functions/fnc_markerDecayLoop.sqf index ab33f7b4..285dc2b4 100644 --- a/addons/markers/functions/fnc_markerDecayLoop.sqf +++ b/addons/markers/functions/fnc_markerDecayLoop.sqf @@ -16,12 +16,16 @@ * Public: No */ -params ["_marker", "_decayRate"]; +params ["_marker", "_decayRate", ["_local", false]]; private _currentAlpha = markerAlpha _marker; if (_currentAlpha <= _decayRate) exitWith {deleteMarker _marker}; -_marker setMarkerAlpha (_currentAlpha - _decayRate); +if (_local) then { + _marker setMarkerAlphaLocal (_currentAlpha - _decayRate); +} else { + _marker setMarkerAlpha (_currentAlpha - _decayRate); +}; -[FUNC(markerDecayLoop), [_marker, _decayRate], 15] call CBA_fnc_waitAndExecute; +[FUNC(markerDecayLoop), [_marker, _decayRate, _local], 15] call CBA_fnc_waitAndExecute;