Advertisement
player2_dz

p2_antiWallCrawl.sqf

Jan 18th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.52 KB | None | 0 0
  1. private ["_isSmkProne","_ogPos","_nearObjects"]; //privatise variables in memory to prevent error...
  2. _isSmkProne = false; _ogPos = []; _nearObjects = []; //create variables we will use later as empty to prevent error...
  3. if (isNil 'P2DZ_AntiWallCrawl') then { P2DZ_AntiWallCrawl = diag_tickTime; }; //if global var doesnt exist then create it(ie first run)
  4. _isSmkProne = [(_this select 1),"smk_urbanprone"] call KRON_strInStr; //check if anim is an urbanprone anim, players current anim = (_this select 1)
  5. //if player is in urban prone anim, exit with the below code
  6. if (_isSmkProne) exitWith {
  7.     _ogPos = position (_this select 0); //get player position at time of entering urbanprone anim and store it as ogPos (original position)
  8.     _nearObjects = nearestObjects [_ogPos, ["All"], 2.5]; //check how many objects are near the player
  9.     //if player is near any objects set them prone with a message and exit early with a message, unless that message was sent already in the last few seconds in which case just exit
  10.     if (count _nearObjects > 1) exitWith { player switchMove "amovppnemstpsraswrfldnon"; if ((diag_tickTime - P2DZ_AntiWallCrawl) > 10) exitWith { P2DZ_AntiWallCrawl = diag_tickTime; systemChat("[ZombZ] Anti-Wall-Crawl: You cannot use this stance near objects."); }; };
  11.     //open a new thread if it didnt just exit, give the new thread the ogPos and player object ((_this select 0)) as input
  12.     0 = [_ogPos,(_this select 0)] spawn {
  13.         private["_ogPos","_isSmkProne","_newPos","_newAnim","_plyr"]; //privatise variables in memory for new thread to prevent error...
  14.         _isSmkProne = false; _ogPos = []; _newPos = []; _newAnim = ""; _plyr2 = objNull; //create variables we will use later as empty to prevent error...
  15.         _ogPos = _this select 0; //grab the ogPos from the thread input
  16.         _plyr2 = _this select 1; //grab player from the thread input
  17.         //wait until: player has moved more than 0.00545 meters OR player is no longer in urban prone
  18.         waitUntil{
  19.             _newAnim = animationState _plyr2; _isSmkProne = [_newAnim,"smk_urbanprone"] call KRON_strInStr; _newPos = position _plyr2; _posDist = _newPos distance _ogPos;
  20.             (((_isSmkProne) && (_posDist > 0.00545)) || (!_isSmkProne))
  21.         };
  22.        
  23.         if (!_isSmkProne) exitWith { }; //if player got out of urban prone without moving, exit without doing below code
  24.         //player moved while in urban prone...
  25.         (_this select 1) switchMove "amovppnemstpsraswrfldnon"; //switch player back to normal prone
  26.         systemChat("[ZombZ] Anti-Wall-Crawl: You cannot move in this stance."); //send a message & exit
  27.     };
  28. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement