Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];
- _newUnit setPos [0, 0, 0];
- [] call NUP_fnc_playerMarkers;
- _newUnit allowDamage false;
- _newUnit enableSimulation false;
- [0, 1, true, false] call NUP_fnc_cinematicBorder;
- // Create camera to focus on the dead body
- _camera = "camera" camCreate (getPosATL _oldUnit);
- _camera cameraEffect ["INTERNAL", "BACK"];
- _camera camPrepareTarget _oldUnit;
- _camera camCommitPrepared 0;
- _camera camPrepareRelPos [0, 0, 3];
- _camera camPrepareFOV 0.5;
- _camera camCommitPrepared 0;
- // Open the RespawnDialog
- createDialog "RespawnDialog";
- // Disable scoring UI
- private _scoreHUD = uiNamespace getVariable "ScoreHUD";
- if (!isNull _scoreHUD) then {
- _scoreHUD closeDisplay 1;
- };
- // Pass variables to the dialog
- private _display = findDisplay 9500; // RespawnDialog display
- // Fetch the map control and set its position to the player's position
- private _map = _display displayCtrl 9501; // Map control (_CT_MAP)
- if (!isNull _map) then {
- _map ctrlMapAnimAdd [0, 0.025, getPosATL _oldUnit]; // Set the map to player's position
- ctrlMapAnimCommit _map;
- };
- // Fetch the dialog controls
- _respawnButton = _display displayCtrl 1050; // Respawn button (_CT_BUTTON)
- _respawnButton setVariable ["NUP_camInstance", _camera];
- _respawnButton setVariable ["NUP_newUnitInstance", _newUnit];
- _respawnButton setVariable ["NUP_oldUnitInstance", _oldUnit];
- // Attach functionality to the Respawn Button
- private _NUP_respawnEH = _respawnButton ctrlAddEventHandler ["ButtonClick", {
- params ["_ctrl"];
- // Retrieve variables from the dialog
- _display = findDisplay 9501;
- _camera = _ctrl getVariable "NUP_camInstance";
- _newUnit = _ctrl getVariable "NUP_newUnitInstance";
- _oldUnit = _ctrl getVariable "NUP_oldUnitInstance";
- diag_log format ["_oldUnit %1, _newUnit %2, _camera %3", _oldUnit, _newUnit, _camera];
- //hintc format ["_oldUnit %1, _newUnit %2, _camera %3", _oldUnit, _newUnit, _camera];
- // Retrieve the new unit's side
- private _playerSide = side _newUnit;
- private _respawnMarker = switch (_playerSide) do {
- case west: { "start_WEST" };
- case east: { "start_EAST" };
- case independent: { "start_INDEP" };
- default { "start_CIVILIAN" };
- };
- private _markerPos = getMarkerPos _respawnMarker;
- // Building search logic
- _buildingClasses = [
- "Land_Cargo_HQ_V1_F", "Land_Cargo_HQ_V3_F", "Land_Medevac_HQ_V1_F",
- "Land_Cargo_House_V1_F", "Land_Cargo_Tower_V1_F", "Land_i_Shed_Ind_F"
- ];
- _nearestBuildings = nearestObjects [_markerPos, _buildingClasses, 100];
- _allBuildingPositions = [];
- {
- _buildingPositions = [_x] call BIS_fnc_buildingPositions;
- _allBuildingPositions = _allBuildingPositions + _buildingPositions;
- } forEach _nearestBuildings;
- // Determine respawn position
- _respawnPos = if (count _allBuildingPositions > 0) then {
- selectRandom _allBuildingPositions
- } else {
- _markerPos
- };
- // Move player to respawn position
- _newUnit allowDamage true;
- _newUnit enableSimulation true;
- _newUnit setPosATL _respawnPos;
- _camera cameraEffect ["TERMINATE", "BACK"];
- camDestroy _camera;
- // Delete the old unit after 60 seconds
- [_oldUnit] spawn {
- sleep 60;
- deleteVehicle _oldUnit;
- };
- // Remove the EH and close the dialog
- _respawnButton ctrlRemoveEventHandler ["ButtonClick", _NUP_respawnEH];
- closeDialog 0;
- }];
- // Add revive action to the dead body
- _oldUnit addAction [
- "Revive Player", // title
- {
- params ["_target", "_caller", "_actionId", "_arguments"]; // script
- _arguments params ["_camera", "_oldUnit", "_newUnit"];
- [_target, _caller, _camera, _oldUnit, _newUnit] call NUP_fnc_revivePlayer;
- },
- _arguments, // arguments
- 1.5, // priority
- true, // showWindow
- true, // hideOnUse
- "", // shortcut
- "side _this == side _target", // condition
- 2, // radius
- false, // unconscious
- "", // selection
- "" // memoryPoint
- ];
- // Set the safezone delay back to false so respawning players at HQ are protected immediately.
- _newUnit setVariable ["NUP_safezoneDelay", false];
- _newUnit setVariable ["NUP_disableCommandChat", true];
- _newUnit setVariable ["vehicle", 0];
- [] call NUP_fnc_playerMarkers;
- // Apply the saved loadout if it exists
- private _savedLoadout = _newUnit getVariable ["NUP_savedLoadout", nil];
- if (!isNil "_savedLoadout") then {
- _newUnit setUnitLoadout _savedLoadout;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement