Jump to content
Sign in to follow this  
Guest

Little David Hand - Rapel Help

Recommended Posts

Guest

This will assist you when jumping on a edge.
It was stracted from my mod BRPVP and if some error happens, please post here.

[] spawn {
	//VARS
	_safePos = [0,0,0];
	BRPVP_rapelRapelling = false;
	BRPVP_rapelRope = objNull;

	//FUNCTIONS
	BRPVP_rapelStopRapel = {
		ropeDestroy BRPVP_rapelRope;
		deleteVehicle BRPVP_svCriaVehRetorno;
		(findDisplay 46) displayRemoveEventHandler ["KeyUp",BRPVP_rapelKeyUpEH];
		BRPVP_rapelRapelling = false;
	};
	BRPVP_rapelRopeUnwind = {
		if (!isNull (_this select 0)) then {
			ropeUnwind _this;
			BRPVP_rapelRopeUnwindPV = _this;
			publicVariable "BRPVP_rapelRopeUnwindPV";
		};
	};
	BRPVP_svCriaVeh = {
		BRPVP_svCriaVehEnvio = _this;
		publicVariableServer "BRPVP_svCriaVehEnvio";
	};
	BRPVP_rapelOnDanger = {
		params ["_pP","_rapelHSafe"];
		_onDanger = false;
		_pPA = ASLToATL _pP;
		_lis = lineIntersectsSurfaces [_pP vectorAdd [0,0.2,0.5],_pP vectorAdd [0,0.2,-_rapelHSafe],player,objNull,true,1,"GEOM","NONE"];
		//drawLine3D [_pPA vectorAdd [0,0.2,0.5],_pPA vectorAdd [0,0.2,-_rapelHSafe],[1,0,0,1]];
		if (count _lis == 0) then {
			_lis = lineIntersectsSurfaces [_pP vectorAdd [0.15,-0.15,0.5],_pP vectorAdd [0.15,-0.15,-_rapelHSafe],player,objNull,true,1,"GEOM","NONE"];
			//drawLine3D [_pPA vectorAdd [0.15,-0.15,0.5],_pPA vectorAdd [0.15,-0.15,-_rapelHSafe],[0,1,0,1]];
			if (count _lis == 0) then {
				_lis = lineIntersectsSurfaces [_pP vectorAdd [-0.15,-0.15,0.5],_pP vectorAdd [-0.15,-0.15,-_rapelHSafe],player,objNull,true,1,"GEOM","NONE"];
				//drawLine3D [_pPA vectorAdd [-0.15,-0.15,0.5],_pPA vectorAdd [-0.15,-0.15,-_rapelHSafe],[0,0,1,1]];
				if (count _lis == 0) then {
					_onDanger = true;
				};
			};
		};
		if (!_onDanger) then {
			[false,(_lis select 0 select 0) distance _pP]
		} else {
			[true]
		};
	};

	if (hasInterface) then {
		//PUBLIC VARIABLES EVENTHANDLER CLIENT
		"BRPVP_rapelRopeUnwindPV" addPublicVariableEventHandler {
			if (!isNull (_this select 1 select 0)) then {
				ropeUnwind (_this select 1);
			};
		};
		"BRPVP_svCriaVehRetorno" addPublicVariableEventHandler {
			BRPVP_rapelRope = ropeCreate [_this select 1,[0,0,0],player,[0,0,1],1.5];
		};

		//RAPEL CODE
		waitUntil {
			if (!BRPVP_rapelRapelling) then {
				_pP = getPosASL player;
				_rapelIt = [_pP,3.5] call BRPVP_rapelOnDanger;
				if (_rapelIt select 0) then {
					if (animationState player find "ladder" == -1 && _pP distance _safePos <= 2) then {
						BRPVP_rapelRapelling = true;
						_vel = velocity player;
						_pole = (vectorNormalized _vel) vectorMultiply 0.8;
						_pR = (_pP vectorAdd _pole) vectorAdd [0,0,-0.5];
						[player,["B_static_AA_F",ASLToAGL _pR,[],0,"CAN_COLLIDE"]] call BRPVP_svCriaVeh;
						BRPVP_rapelKeyUpEH = (findDisplay 46) displayAddEventHandler ["KeyUp",{
							params ["_unused","_key","_shift","_ctrl","_alt"];
							_return = false;
							if (!isNull BRPVP_rapelRope) then {
								if (_key == 0x11 && ropeUnwound BRPVP_rapelRope) then {
									_return = true;
									[BRPVP_rapelRope,5,-0.5,true] call BRPVP_rapelRopeUnwind;
								};
								if (_key == 0x1F && ropeUnwound BRPVP_rapelRope) then {
									_return = true;
									_delta = 2 min (((getPos player) select 2) - 0.1);
									[BRPVP_rapelRope,5,_delta,true] call BRPVP_rapelRopeUnwind;
								};
								if (_key == 0x39 && !_shift) then {
									_return = true;
									call BRPVP_rapelStopRapel;
								};
								if (_key == 0x39 && _shift) then {
									_return = true;
									call BRPVP_rapelStopRapel;
									_dir = getDir player;
									player setVelocity [5*sin(_dir),5*cos(_dir),2.5];
								};
								if (_key in actionKeys "Prone") then {_return = true;};
							};
							_return
						}];
					};
				} else {
					_h = _rapelIt select 1;
					if (vehicle player == player && stance player != "PRONE" && _h < 0.25) then {
						_safePos = _pP;
					};
				};
			} else {
				if (!isNull BRPVP_rapelRope) then {
					if !(([getPosASL player,0.5] call BRPVP_rapelOnDanger) select 0) then {
						call BRPVP_rapelStopRapel;
					};
				};
			};
			false
		};
	};
	if (isServer) then {
		//PUBLIC VARIABLES EVENTHANDLER SERVER
		"BRPVP_svCriaVehEnvio" addPublicVariableEventHandler {
			(_this select 1) params ["_p","_param"];
			_veh = createVehicle _param;
			_veh enableSimulation false;
			hideObjectGlobal _veh;
			BRPVP_svCriaVehRetorno = _veh;
			(owner _p) publicVariableClient "BRPVP_svCriaVehRetorno";
		};
	};
};

To install it copy the code to the root of your init.sqf.

Share this post


Link to post
Share on other sites
Guest

This was working to prevent player to go prone while in rope, but not working anymore.

if (_key in actionKeys "Prone") then {_return = true;};

Any help is apreciated.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×