Advertisement
Guest User

player_selfbloodbag.sqf

a guest
Jan 13th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.23 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////////////////////
  2. // Script writen by Krixes //
  3. // Infection chance and some comments added by Player2 //
  4. // Combat check added by istealth //
  5. // //
  6. // Version 1.4 //
  7. // //
  8. // Change Log: //
  9. // 1: Added bloodbag use timer //
  10. // 2: Added a timer for the amount of time before player can use self bloodbag again //
  11. //////////////////////////////////////////////////////////////////////////////////////////////
  12.  
  13. private ["_bloodAmount","_humanityBool","_infectionChance","_humanityNegBool","_humanityNegAmount","_humanityAmount","_infectedLifeLost","_infectedLifeBool","_lastBloodbag","_bloodbagLastUsedTime","_bloodbagTime","_bloodbagUseTime","_bloodbagUsageTime","_incombat","_timeout"];
  14. bloodbag_answer=nil;
  15. sbloodbag =
  16. [
  17. ["",true],
  18. ["Self Bloodbag Confirmation", [-1], "", -5, [["expression", ""]], "1", "0"],
  19. ["", [-1], "", -5, [["expression", ""]], "1", "0"],
  20. ["No", [2], "", -5, [["expression", "bloodbag_answer=false;"]], "1", "1"],
  21. ["Yes", [3], "", -5, [["expression", "bloodbag_answer=true;"]], "1", "1"],
  22. ["", [-1], "", -5, [["expression", ""]], "1", "0"],
  23. ["Exit", [-1], "", -3, [["expression", "bloodbag_answer=false;"]], "1", "1"]
  24. ];
  25. showCommandingMenu "#USER:sbloodbag";
  26. waitUntil {((!isNil 'bloodbag_answer')||(commandingMenu == ""))};
  27. if (isNil 'bloodbag_answer') then {bloodbag_answer=false;};
  28. if (bloodbag_answer) then
  29. {
  30. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. // Config Start-----------------------------------------------------------------------------------------------------------------------//
  32. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  33.  
  34. _bloodAmount = 8000; // Amount of blood to give to player
  35. _bloodbagUseTime = 10; // Amount of time it takes in second for the player to use the self bloodbag
  36. _bloodbagLastUsedTime = 60; // Amount of time in seconds before player can use self bloodbag again after a succesful use
  37.  
  38. _infectionChance = 10; // Percent chance of player infection on self bloodbag (10 = 10% | 2 = 50% | 1 = 100%)
  39. _infectedLifeBool = true; // Whether the player can loose life if infected (True = On | False = off)
  40. _infectedLifeLost = 1000; // Amount of life to loose in becomes infected
  41.  
  42. _humanityBool = false; // Whether the player can get humanity from giving self a bloodbag (True = On | False = off)
  43. _humanityAmount = 50; // Amount of humanity to give player if _humanityBool is true (250 is default for normal bloodbags)
  44.  
  45. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  46. // Config End-------------------------------------------------------------------------------------------------------------------------//
  47. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  48.  
  49.  
  50.  
  51.  
  52.  
  53. ///////////////////////////////////////////////////////////////////////////////
  54. // Everything below need not be modified unless you know what you are doing! //
  55. ///////////////////////////////////////////////////////////////////////////////
  56.  
  57. _bloodbagTime = time - lastBloodbag; // Variable used for easy reference in determining the self bloodbag cooldown
  58. _bloodbagUsageTime = time;
  59. _timeout = player getVariable["combattimeout", 0];
  60. _inCombat = if (_timeout >= diag_tickTime) then { true } else { false };
  61.  
  62. if(_bloodbagTime < _bloodbagLastUsedTime) exitWith { // If cooldown is not done then exit script
  63. 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
  64. };
  65.  
  66. if (_inCombat) then { // Check if in combat
  67. cutText [format["You are in Combat and cannot give yourself a Bloodbag"], "PLAIN DOWN"]; //display text at bottom center of screen when in combat
  68. } else {
  69.  
  70. player removeAction s_player_selfBloodbag; //remove the action from users scroll menu
  71.  
  72. player playActionNow "Medic"; //play bloodbag animation
  73.  
  74. ////////////////////////////////////////////////
  75. // Fancy cancel if interrupted addition start //
  76. ////////////////////////////////////////////////
  77. r_interrupt = false; // public interuppt variable
  78. _animState = animationState player; // get the animation state of the player
  79. r_doLoop = true; // while true sets whether to continue self bloodbagging
  80. _started = false; // this starts as false as a check
  81. _finished = false; // this starts as false and when true later sets players blood
  82. while {r_doLoop} do {
  83. _animState = animationState player; // keep checking to make sure player is in correct animation
  84. _isMedic = ["medic",_animState] call fnc_inString; // checking to make sure the animstate is the medic animation still
  85. if (_isMedic) then {
  86. _started = true; // this is a check to make sure everything is still ok
  87. };
  88. if(!_isMedic && !r_interrupt && (time - _bloodbagUsageTime) < _bloodbagUseTime) then {
  89. player playActionNow "Medic"; //play bloodbag animation
  90. _isMedic = true;
  91. };
  92. if (_started && !_isMedic && (time - _bloodbagUsageTime) > _bloodbagUseTime) then {
  93. r_doLoop = false; // turns off the loop
  94. _finished = true; // set finished to true to finish the self bloodbag and give player health/humanity
  95. lastBloodbag = time; // the last self bloodbag time
  96. };
  97. if (r_interrupt) then {
  98. r_doLoop = false; // if interuppted turns loop off early so _finished is never true
  99. };
  100. sleep 0.1;
  101. };
  102. r_doLoop = false; // make sure loop is off on successful self bloodbag
  103. ///////////////////////////////////////////////
  104. // Fancy cancel if interrupted addition end //
  105. //////////////////////////////////////////////
  106.  
  107. if (_finished) then {
  108. _mags = magazines player;
  109. if ("ItemBloodbag" in _mags) then {
  110. player removeMagazine "ItemBloodbag"; //remove the used bloodbag from inventory
  111. } else {
  112. if ("bloodBagOPOS" in _mags) then {
  113. player removeMagazine "bloodBagOPOS"; //remove the used bloodbag from inventory
  114. } else {
  115. if ("bloodBagONEG" in _mags) then {
  116. player removeMagazine "bloodBagONEG"; //remove the used bloodbag from inventory
  117. } else {
  118. if ("bloodBagABPOS" in _mags) then {
  119. player removeMagazine "bloodBagABPOS"; //remove the used bloodbag from inventory
  120. } else {
  121. if ("bloodBagABNEG" in _mags) then {
  122. player removeMagazine "bloodBagABNEG"; //remove the used bloodbag from inventory
  123. } else {
  124. if ("bloodBagBPOS" in _mags) then {
  125. player removeMagazine "bloodBagBPOS"; //remove the used bloodbag from inventory
  126. } else {
  127. if ("bloodBagAPOS" in _mags) then{
  128. player removeMagazine "bloodBagAPOS"; //remove the used bloodbag from inventory
  129. } else {
  130. if ("bloodBagANEG" in _mags) then {
  131. player removeMagazine "bloodBagANEG"; //remove the used bloodbag from inventory
  132. } else {
  133. if ("WholebloodBagOPOS" in _mags) then {
  134. player removeMagazine "WholebloodBagOPOS"; //remove the used bloodbag from inventory
  135. } else {
  136. if ("WholebloodBagONEG" in _mags) then {
  137. player removeMagazine "WholebloodBagONEG"; //remove the used bloodbag from inventory
  138. } else {
  139. if ("WholebloodBagABPOS" in _mags) then {
  140. player removeMagazine "WholebloodBagABPOS"; //remove the used bloodbag from inventory
  141. } else {
  142. if ("WholebloodBagABNEG" in _mags) then {
  143. player removeMagazine "WholebloodBagABNEG"; //remove the used bloodbag from inventory
  144. } else {
  145. if ("WholebloodBagBPOS" in _mags) then {
  146. player removeMagazine "WholebloodBagBPOS"; //remove the used bloodbag from inventory
  147. } else {
  148. if ("WholebloodBagAPOS" in _mags) then{
  149. player removeMagazine "WholebloodBagAPOS"; //remove the used bloodbag from inventory
  150. } else {
  151. if ("WholebloodBagANEG" in _mags) then {
  152. player removeMagazine "WholebloodBagANEG"; //remove the used bloodbag from inventory
  153. };};};};};};};};};};};};};};};
  154. r_player_blood = r_player_blood + _bloodAmount; //set players LOCAL blood to a certain ammount
  155.  
  156. if(r_player_blood > 12000) then {
  157. 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)
  158. };
  159.  
  160. // check if infected
  161. if (random(_infectionChance) < 0) then {
  162. r_player_infected = true; //set players client to show infection
  163. player setVariable["USEC_infected",true,true]; //tell the server the player is infected
  164. 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
  165.  
  166. // check for if loosing life on infection is turned on
  167. if(_infectedLifeBool) then {
  168. r_player_blood = r_player_blood - _infectedLifeLost; //set players LOCAL blood to a certain ammount
  169. player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
  170. } else { // if loosing life is turned off
  171. r_player_lowblood = false; //set lowblood setting to false
  172. 10 fadeSound 1; //slowly fade their volume back to maximum
  173. "dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; //disable post processing blur effect
  174. "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
  175. r_player_lowblood = false; //just double checking their blood isnt low
  176. player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
  177. };
  178. } else { // if not infected
  179. r_player_lowblood = false; //set lowblood setting to false
  180. 10 fadeSound 1; //slowly fade their volume back to maximum
  181. "dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; //disable post processing blur effect
  182. "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
  183. r_player_lowblood = false; //just double checking their blood isnt low
  184. player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
  185.  
  186. cutText [format["You have used a bloodbag on yourself!"], "PLAIN DOWN"]; //display text at bottom center of screen on succesful self bloodbag
  187. };
  188.  
  189. // check if giving player humanity is on
  190. if(_humanityBool) then {
  191. [player,_humanityAmount] call player_humanityChange; // Set players humanity based on amount listed in config area
  192. };
  193. } else {
  194. // this is for handling if interrupted
  195. r_interrupt = false;
  196. player switchMove "";
  197. player playActionNow "stop";
  198. cutText [format["You have interrupted giving yourself a bloodbag!"], "PLAIN DOWN"]; //display text at bottom center of screen on interrupt
  199. };
  200. };
  201. } else {
  202. systemChat ("Self Bloodbag Canceled.");
  203. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement