Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // loop function to keep player who is mounted unarmed
- ten_fnc_unarmed_loop = {
- params ['_target','_enable'];
- if !(_enable) exitWith {
- if (!isNil 'ten_unarmedLoop') then {
- terminate ten_unarmedLoop;
- ten_unarmedLoop = nil;
- };
- };
- // create the loop and save script handler
- ten_unarmedLoop = _target spawn {
- params ['_target'];
- waitUntil {
- if (
- (isNil '_target' || {isNull _target || {!alive _target || !([_target] call ace_common_fnc_isAwake)}}) ||
- (!alive player || !([player] call ace_common_fnc_isAwake))
- ) exitWith {
- ten_unarmedLoop = nil;
- true
- };
- _target action ['SwitchWeapon', _target, _target, 100];
- (false)
- };
- };
- };
- // loop function for the unit that mounted a unit
- ten_fnc_mounted_loop = {
- params ['_target','_enable'];
- if !(_enable) exitWith {
- if (!isNil 'ten_mounted_loop') then {
- terminate ten_mounted_loop;
- ten_mounted_loop = nil;
- };
- };
- // create the loop and save script handler
- ten_mounted_loop = [_target] spawn {
- params ['_target'];
- waitUntil {
- if (
- (isNil '_target' || {isNull _target || {!alive _target || !([_target] call ace_common_fnc_isAwake) || !((vehicle _target) isEqualTo _target)}}) ||
- (!alive player || !([player] call ace_common_fnc_isAwake) || !((vehicle _target) isEqualTo _target))
- ) exitWith {
- _target call ten_fnc_disMount;
- ten_mounted_loop = nil;
- true
- };
- (false)
- };
- };
- };
- // disable collision function
- ten_fnc_col = {
- params ['_target'];
- private _nil = {
- _x disableCollisionWith _target;
- _target disableCollisionWith _x;
- false
- } count (allUnits + vehicles);
- };
- // mounting function
- ten_fnc_mount = {
- params ['_target'];
- if !(_target inArea [player,5,5,0,false]) exitWith {hint 'failed, too far to mount!';};
- if (!isNil 'ten_ride_car' && {!isNull ten_ride_car}) then {
- deleteVehicle ten_ride_car;
- };
- ten_ride_car = 'O_LSV_02_unarmed_F' createVehicle [0,0,0];
- player moveInTurret [ten_ride_car,[5]];
- ten_ride_car allowDamage false;
- ten_ride_car setMass 0;
- [ten_ride_car,true] remoteExec ['lock'];
- ten_ride_car lockCargo true;
- clearItemCargoGlobal ten_ride_car;
- clearWeaponCargoGlobal ten_ride_car;
- clearBackpackCargoGlobal ten_ride_car;
- clearMagazineCargoGlobal ten_ride_car;
- player disableCollisionWith _target;
- {ten_ride_car disableCollisionWith _x;false}count (allUnits + vehicles);
- [ten_ride_car] remoteExec ['ten_fnc_col'];
- ten_ride_car attachTo [_target,[0.17,0.25,1.35]];
- ten_ride_car setObjectTextureGlobal [0,''];
- ten_ride_car setObjectTextureGlobal [1,''];
- ten_ride_car setObjectTextureGlobal [2,''];
- {ten_ride_car hideSelection [_x,true];false}count (selectionNames ten_ride_car);
- player setVariable ['ten_ride_mounting',true];
- player setVariable ['ten_ride_mountedOn',_target];
- _target setVariable ['ten_ride_mounted',true,true];
- [_target,true] remoteExec ['ten_fnc_unarmed_loop',_target];
- [_target,true] call ten_fnc_mounted_loop;
- };
- // Dismounting function
- ten_fnc_disMount = {
- params ['_target'];
- player setpos (ten_ride_car getpos [1,180]);
- deleteVehicle ten_ride_car;
- player setVariable ['ten_ride_mounting',false];
- _target = player getVariable ['ten_ride_mountedOn',objNull];
- player setVariable ['ten_ride_mounting',false];
- if (isNil '_target' || {isNull _target}) exitWith {};
- _target setVariable ['ten_ride_mounted',false,true];
- [_target,false] remoteExec ['ten_fnc_unarmed_loop',_target];
- [_target,false] call ten_fnc_mounted_loop;
- };
- // add ace interaction to players
- if (hasInterface) then {
- // create action for riding on back
- _ride = [
- "ride_on_back",
- "Ride On Back?",
- "",
- {
- // ace progressbar for getting on
- [
- 3,
- [_target],
- {
- _target = ((_this param [0]) param [0,objNull]);
- player playAction "medicStop";
- _target call ten_fnc_mount;
- },
- {player playAction "medicStop";},
- "Mounting"
- ] call ace_common_fnc_progressBar;
- player playAction "medicStart";
- },
- {!(player getVariable ['ten_ride_mounting',false]) && !(_target getVariable ['ten_ride_mounted',false]) && ((side _target) isEqualTo (side player)) && ((vehicle player) isEqualTo player) && ((vehicle _target) isEqualTo _target)}
- ] call ace_interact_menu_fnc_createAction;
- // add action to all units
- ["CAManBase", 0, ["ACE_MainActions"], _ride, true] call ace_interact_menu_fnc_addActionToClass;
- // get off action for interaction
- _off = [
- "ride_on_off",
- "Get Off",
- "",
- {
- _target call ten_fnc_disMount;
- },
- {(player getVariable ['ten_ride_mounting',false])}
- ] call ace_interact_menu_fnc_createAction;
- // add action to player self interaction for getting off
- ["CAManBase", 1, ["ACE_SelfActions"], _off, true] call ace_interact_menu_fnc_addActionToClass;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement