Guest User

Untitled

a guest
Sep 29th, 2011
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. #include <a_samp>
  2. #include <foreach>
  3.  
  4. #define RELEASED(%0) \
  5. (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  6.  
  7. forward OnPlayerShot(playerid);
  8.  
  9. new PlayerTimer[MAX_PLAYERS];
  10. new Float:BotHealth[MAX_PLAYERS];
  11. new BotDead[MAX_PLAYERS];
  12.  
  13. new const Float: WeaponDamages[43] =
  14. {
  15. 0.0, //ID 1
  16. 0.0, //ID 2
  17. 0.0, //ID 3
  18. 0.0, //ID 4
  19. 0.0, //ID 5
  20. 0.0, //ID 6
  21. 0.0, //ID 7
  22. 0.0, //ID 8
  23. 0.0, //ID 9
  24. 0.0, //ID 10
  25. 0.0, //ID 11
  26. 0.0, //ID 12
  27. 0.0, //ID 13
  28. 0.0, //ID 14
  29. 0.0, //ID 15
  30. 0.0, //ID 16
  31. 0.0, //ID 17
  32. 0.0, //ID 18
  33. 0.0, //ID 19
  34. 0.0, //ID 20
  35. 0.0, //ID 21
  36. 5.5, //ID 23
  37. 5.5, //ID 24
  38. 6.5, //ID 25
  39. 0.0, //ID 26
  40. 0.0, //ID 27
  41. 3.5, //ID 28
  42. 0.0, //ID 29
  43. 6.5, //ID 30
  44. 2.5, //ID 31
  45. 0.0, //ID 32
  46. 4.5, //ID 33
  47. 0.0, //ID 34
  48. 0.0, //ID 35
  49. 0.0, //ID 36
  50. 0.0, //ID 37
  51. 0.0, //ID 38
  52. 0.0, //ID 39
  53. 0.0, //ID 40
  54. 0.0, //ID 41
  55. 0.0, //ID 42
  56. 0.0, //ID 43
  57.  
  58. };
  59.  
  60. // Stocks
  61. stock IsPlayerFacingPlayer(playerid, playerid2, Float:dOffset) // a_angles.inc -ből, by Tanz0rz
  62. {
  63.  
  64. new
  65. Float:X,
  66. Float:Y,
  67. Float:Z,
  68. Float:pX,
  69. Float:pY,
  70. Float:pZ,
  71. Float:pA,
  72. Float:ang;
  73.  
  74. if(!IsPlayerConnected(playerid)) return 0;
  75.  
  76. GetPlayerPos(playerid2, pX, pY, pZ);
  77. GetPlayerPos(playerid, X, Y, Z);
  78. GetPlayerFacingAngle(playerid, pA);
  79.  
  80. if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  81. else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
  82. else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  83.  
  84. if(AngleInRangeOfAngle(-ang, pA, dOffset)) return true;
  85.  
  86. return false;
  87. }
  88.  
  89. stock AngleInRangeOfAngle(Float:a1, Float:a2, Float:range)
  90. {
  91.  
  92. a1 -= a2;
  93. if((a1 < range) && (a1 > -range)) return true;
  94.  
  95. return false;
  96.  
  97. }
  98. //
  99.  
  100. public OnFilterScriptInit()
  101. {
  102. return 1;
  103. }
  104.  
  105. public OnFilterScriptExit()
  106. {
  107. return 1;
  108. }
  109.  
  110. public OnPlayerConnect(playerid)
  111. {
  112. if(!IsPlayerNPC(playerid)){PlayerTimer[playerid] = SetTimerEx("OnPlayerShot", 150, true, "i", playerid);}
  113. return 1;
  114. }
  115.  
  116. public OnPlayerDisconnect(playerid)
  117. {
  118. if(!IsPlayerNPC(playerid)){KillTimer(PlayerTimer[playerid]);}
  119. return 1;
  120. }
  121.  
  122. public OnPlayerSpawn(playerid)
  123. {
  124. if(IsPlayerNPC(playerid)){
  125. BotHealth[playerid] = 100.0;
  126. BotDead[playerid] = 0;
  127. }
  128. return 1;
  129. }
  130.  
  131. public OnPlayerShot(playerid)
  132. {
  133. if(!IsPlayerNPC(playerid))
  134. {
  135. new o_keys, up_dw, lt_rt;
  136. GetPlayerKeys(playerid, o_keys, up_dw, lt_rt);
  137. foreach(Bot, botid)
  138. {
  139. if(o_keys == KEY_FIRE || o_keys == (KEY_FIRE+128))
  140. {
  141. if(IsPlayerFacingPlayer(playerid, botid, 5.0) && !IsPlayerInAnyVehicle(botid))
  142. {
  143. if(BotHealth[botid] > 0.5)
  144. {
  145. BotHealth[botid] -= WeaponDamages[GetPlayerWeapon(playerid) -1];
  146. }
  147. else if(BotHealth[botid] < 0.5)
  148. {
  149. BotDead[botid] ++;
  150. ApplyAnimation(botid, "Wuzi","CS_Dead_Guy", 1,0,1,0,0,0);
  151. if(BotDead[botid] > 10)
  152. {
  153. SpawnPlayer(botid);
  154. BotDead[botid] = 0;
  155. }
  156. }
  157. }
  158. }
  159. if(o_keys != KEY_FIRE || o_keys != (KEY_FIRE+128))
  160. {
  161. if(BotHealth[botid] < 0.5)
  162. {
  163. BotDead[botid] ++;
  164. ApplyAnimation(botid, "Wuzi","CS_Dead_Guy", 1,0,1,0,0,0);
  165. if(BotDead[botid] > 10)
  166. {
  167. SpawnPlayer(botid);
  168. BotDead[botid] = 0;
  169. }
  170. }
  171. }
  172. }
  173. }
  174. }
  175.  
Advertisement
Add Comment
Please, Sign In to add comment