Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show civilian vehicles markers for killers from the start without requiring teleportation #97

Merged
merged 7 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions addons/killers/functions/fnc_createMarkersForNearbyVehicles.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,29 @@ params ["_position", ["_radius", 1000]];

private _nearbyVehicles = _position nearEntities [["Air", "Car", "Motorcycle", "Tank"], _radius];
private _emptyVehicles = _nearbyVehicles select {
crew _x isEqualTo []
damage _x isEqualTo 0 &&
{crew _x isEqualTo []}
};

{
private _vehicle = _x;
private _marker = createMarkerLocal [format ["vehicle_%1", _vehicle], getPosATL _vehicle];
private _markerName = format ["vehicle_%1", _vehicle];
private _markerExists = getMarkerPos _markerName isNotEqualTo [0, 0, 0];
if (_markerExists) then { continue };

private _marker = createMarkerLocal [_markerName, getPosATL _vehicle];
if (_marker isEqualTo "") then { _marker = _markerName };
_marker setMarkerColorLocal "ColorCIVILIAN";
_marker setMarkerSizeLocal [0.5, 0.5];
_marker setMarkerAlphaLocal 1; // Force just in case marker already exists and should be fully-visible again
_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);
[_marker, 2.5, true] call EFUNC(markers,markerDecay);
} forEach _emptyVehicles;

nil
1 change: 1 addition & 0 deletions addons/killers/functions/fnc_createTeleport.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private _positionID = 0;
[QGVAR(teleportedToStart), [_this select 0]] call CBA_fnc_localEvent;
}, [_destinationPos]];
[_destinationPos, _destinationName] call FUNC(createStartPositionMarker);
[_destinationPos] call FUNC(createMarkersForNearbyVehicles);
// Add for deletion after teleportation
_teleportActionsIDs pushBack _teleportActionID;
_positionID = _positionID + 1;
Expand Down
3 changes: 2 additions & 1 deletion addons/markers/functions/fnc_markerDecay.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ params ["_marker", ["_decayHalfTime", 10], ["_local", false]];

// How much decay will be applied every 15 seconds
private _decayRate = 1/(_decayHalfTime * 4 * 2);
private _currentAlpha = markerAlpha _marker;

[_marker, _decayRate, _local] call FUNC(markerDecayLoop);
[_marker, _decayRate, _currentAlpha, _local] call FUNC(markerDecayLoop);
11 changes: 7 additions & 4 deletions addons/markers/functions/fnc_markerDecayLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@
* Public: No
*/

params ["_marker", "_decayRate", ["_local", false]];
params ["_marker", "_decayRate", ["_previousAlpha", -1], ["_local", false]];

private _currentAlpha = markerAlpha _marker;

if (_currentAlpha isNotEqualTo _previousAlpha && {_previousAlpha isNotEqualTo -1}) exitWith {};
if (_currentAlpha <= _decayRate) exitWith {deleteMarker _marker};

private _newAlpha = (_currentAlpha - _decayRate);

if (_local) then {
_marker setMarkerAlphaLocal (_currentAlpha - _decayRate);
_marker setMarkerAlphaLocal _newAlpha;
} else {
_marker setMarkerAlpha (_currentAlpha - _decayRate);
_marker setMarkerAlpha _newAlpha;
};

[FUNC(markerDecayLoop), [_marker, _decayRate, _local], 15] call CBA_fnc_waitAndExecute;
[FUNC(markerDecayLoop), [_marker, _decayRate, _newAlpha, _local], 15] call CBA_fnc_waitAndExecute;