Advertisement
parabola949

Untitled

Oct 31st, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private ["_bloodAmount","_humanityBool","_infectionChance","_humanityNegBool","_humanityNegAmount","_humanityAmount","_infectedLifeLost","_infectedLifeBool","_lastBloodbag","_bloodbagLastUsedTime","_bloodbagTime","_bloodbagUseTime","_bloodbagUsageTime","_incombat","_timeout"];
  2.  
  3.  
  4.  
  5. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  6. // Config Start-----------------------------------------------------------------------------------------------------------------------//
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  8.  
  9. _bloodAmount = 4000; // Amount of blood to give to player
  10. _bloodbagUseTime = 30; // Amount of time it takes in second for the player to use the self bloodbag
  11. _bloodbagLastUsedTime = 60; // Amount of time in seconds before player can use self bloodbag again after a succesful use
  12.  
  13. _infectionChance = 10; // Percent chance of player infection on self bloodbag (10 = 10% | 2 = 50% | 1 = 100%)
  14. _infectedLifeBool = true; // Whether the player can loose life if infected (True = On | False = off)
  15. _infectedLifeLost = 1000; // Amount of life to loose in becomes infected
  16.  
  17. _humanityBool = false; // Whether the player can get humanity from giving self a bloodbag (True = On | False = off)
  18. _humanityAmount = 50; // Amount of humanity to give player if _humanityBool is true (250 is default for normal bloodbags)
  19.  
  20. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  21. // Config End-------------------------------------------------------------------------------------------------------------------------//
  22. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  23.  
  24.  
  25.  
  26.  
  27.  
  28. ///////////////////////////////////////////////////////////////////////////////
  29. // Everything below need not be modified unless you know what you are doing! //
  30. ///////////////////////////////////////////////////////////////////////////////
  31.  
  32. _bloodbagTime = time - lastBloodbag; // Variable used for easy reference in determining the self bloodbag cooldown
  33. _bloodbagUsageTime = time;
  34. _timeout = player getVariable["combattimeout", 0];
  35. _inCombat = if (_timeout >= diag_tickTime) then { true } else { false };
  36.  
  37. if(_bloodbagTime < _bloodbagLastUsedTime) exitWith { // If cooldown is not done then exit script
  38.     cutText [format["You may not use Self Bloodbag this soon please wait %1!",(_bloodbagTime - _bloodbagLastUsedTime)], "PLAIN DOWN"]; //display text at bottom center of screen when players cooldown is not done
  39. };
  40.  
  41. if (_inCombat) then { // Check if in combat
  42.     cutText [format["You are in Combat and cannot give yourself a Bloodbag"], "PLAIN DOWN"]; //display text at bottom center of screen when in combat
  43. } else {
  44.  
  45.     player removeAction s_player_selfBloodbag; //remove the action from users scroll menu
  46.    
  47.     player playActionNow "Medic"; //play bloodbag animation
  48.    
  49.     ////////////////////////////////////////////////
  50.     // Fancy cancel if interrupted addition start //
  51.     ////////////////////////////////////////////////
  52.     r_interrupt = false; // public interuppt variable
  53.     _animState = animationState player; // get the animation state of the player
  54.     r_doLoop = true; // while true sets whether to continue self bloodbagging
  55.     _started = false; // this starts as false as a check
  56.     _finished = false; // this starts as false and when true later sets players blood
  57.     while {r_doLoop} do {
  58.         _animState = animationState player; // keep checking to make sure player is in correct animation
  59.         _isMedic = ["medic",_animState] call fnc_inString; // checking to make sure the animstate is the medic animation still
  60.         if (_isMedic) then {
  61.             _started = true; // this is a check to make sure everything is still ok
  62.         };
  63.         if(!_isMedic && !r_interrupt && (time - _bloodbagUsageTime) < _bloodbagUseTime) then {
  64.             player playActionNow "Medic"; //play bloodbag animation
  65.             _isMedic = true;
  66.         };
  67.         if (_started && !_isMedic && (time - _bloodbagUsageTime) > _bloodbagUseTime) then {
  68.             r_doLoop = false; // turns off the loop
  69.             _finished = true; // set finished to true to finish the self bloodbag and give player health/humanity
  70.             lastBloodbag = time; // the last self bloodbag time
  71.         };
  72.         if (r_interrupt) then {
  73.             r_doLoop = false; // if interuppted turns loop off early so _finished is never true
  74.         };
  75.         sleep 0.1;
  76.     };
  77.     r_doLoop = false; // make sure loop is off on successful self bloodbag
  78.     ///////////////////////////////////////////////
  79.     // Fancy cancel if interrupted addition end //
  80.     //////////////////////////////////////////////
  81.  
  82.     if (_finished) then {
  83.         player removeMagazine "ItemBloodbag"; //remove the used bloodbag from inventory
  84.  
  85.         r_player_blood = r_player_blood + _bloodAmount; //set players LOCAL blood to a certain ammount
  86.        
  87.         if(r_player_blood > 12000) then {
  88.             r_player_blood = 12000; // If players blood is greater then max amount allowed set it to max allowed (this check keeps an error at bay)
  89.         };
  90.        
  91.         // check if infected
  92.         if (random(_infectionChance) < 1) then {
  93.             r_player_infected = true; //set players client to show infection
  94.             player setVariable["USEC_infected",true,true]; //tell the server the player is infected
  95.             cutText [format["You have used a bloodbag on yourself but the bloodbag was infected!"], "PLAIN DOWN"]; //display text at bottom center of screen if infected
  96.            
  97.             // check for if loosing life on infection is turned on
  98.             if(_infectedLifeBool) then {
  99.                 r_player_blood = r_player_blood - _infectedLifeLost; //set players LOCAL blood to a certain ammount
  100.                 player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
  101.             } else { // if loosing life is turned off
  102.                 r_player_lowblood = false; //set lowblood setting to false
  103.                 10 fadeSound 1; //slowly fade their volume back to maximum
  104.                 "dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; //disable post processing blur effect
  105.                 "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1],  [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5; //give them their colour back
  106.                 r_player_lowblood = false; //just double checking their blood isnt low
  107.                 player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
  108.             };
  109.         } else { // if not infected
  110.             r_player_lowblood = false; //set lowblood setting to false
  111.             10 fadeSound 1; //slowly fade their volume back to maximum
  112.             "dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; //disable post processing blur effect
  113.             "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1],  [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5; //give them their colour back
  114.             r_player_lowblood = false; //just double checking their blood isnt low
  115.             player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
  116.      
  117.             cutText [format["You have used a bloodbag on yourself!"], "PLAIN DOWN"]; //display text at bottom center of screen on succesful self bloodbag
  118.         };
  119.        
  120.         // check if giving player humanity is on
  121.         if(_humanityBool) then {
  122.             [player,_humanityAmount] call player_humanityChange; // Set players humanity based on amount listed in config area
  123.         };
  124.     } else {
  125.         // this is for handling if interrupted
  126.         r_interrupt = false;
  127.         player switchMove "";
  128.         player playActionNow "stop";
  129.         cutText [format["You have interrupted giving yourself a bloodbag!"], "PLAIN DOWN"]; //display text at bottom center of screen on interrupt
  130.     };
  131. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement