Advertisement
Guest User

Boss

a guest
Jan 24th, 2020
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.20 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #undef MAX_PLAYERS
  4. #define MAX_PLAYERS 50
  5.  
  6. #include <foreach>
  7. #include <fcnpc>
  8. #include <YSI\y_timers>
  9. #include <streamer>
  10. #include <zcmd>
  11.  
  12. new Text3D:boss_label = Text3D:0;
  13. new boss_area = 0;
  14. new boss_icon = 0;
  15. new boss = 65535;
  16. new bool:in_boss[MAX_PLAYERS char] = {false,...};
  17. new Text:boss_hp = Text:65535;
  18. new boss_timer = 0;
  19. new var_boss_wep_delay = 0;
  20.  
  21. #define BOSS_NAME "BOSS_NPC" //npc name
  22. #define BOSS_END_TIME 300000 //battle time
  23. #define BOSS_ICON 23 //icon type
  24. #define BOSS_DIALOG 1265 //boss dialog id
  25. #define BOSS_WORLD 5 //boss virtual world
  26. #define BOSS_SKIN 269 //boss skin
  27. #define PLAYER_WEAPON 31 //player weapon
  28. #define BOSS_WEAPON 31 //boss weapon
  29. #define BOSS_HEALTH 2500.0 //boss health
  30. #define BOSS_ACCURACY 0.8 //boss accuracy
  31. #define BOSS_CASH 80000 //victory cash
  32. #define BOSS_SCORE 25 //victory score
  33. #define BOSS_INTERIOR 0 //interior
  34. #define BOSS_X 3491.1252 //NPC_X_COORD
  35. #define BOSS_Y 1778.9089 //NPC_Y_COORD
  36. #define BOSS_Z 278.7320 //NPC_Z_COORD
  37. #define BOSS_ANGLE 188.0179 //NPC_ANGLE COORD
  38. #define PLAYER_X 3499.8665 //PLAYER_X_COORD
  39. #define PLAYER_Y 1701.0521 //PLAYER_Y_COORD
  40. #define PLAYER_Z 279.1448 //PLAYER_Z_COORD
  41. #define PLAYER_ANGLE 4.5954 //PLAYER_ANGLE_COORD
  42. #define BOSS_WEP_DELAY 20 //WEAPON CHANGE DELAY
  43.  
  44. Float:Pracent(Float:x, Float:y)
  45. {
  46. return ((x/y)*100);
  47. }
  48.  
  49. public OnFilterScriptInit()
  50. {
  51. boss_hp = TextDrawCreate(275.0, 420.0, "~w~%~r~~h~100");
  52. FCNPC_SetWeaponShootTime(boss, BOSS_WEAPON, 200);
  53. boss_label = CreateDynamic3DTextLabel("Boss Battle", 0xFB0000FF, 1088.3391, 1075.5221, 11.5582, 100.0);
  54. CreateObject(13657, 3451.7075,1721.0681,280.9664, 0.0000000,0.0000000,0.0000000, 1000);
  55. TextDrawFont(boss_hp, 3);
  56. TextDrawLetterSize(boss_hp, 1.0, 1.2);
  57. TextDrawSetOutline(boss_hp, 1);
  58. boss_area = CreateDynamicSphere(1088.3391, 1075.5221, 10.8382, 2.5, 0);
  59. boss_icon = CreateDynamicMapIcon(1088.3391, 1075.5221, 10.8382, BOSS_ICON, 0, 0);
  60. boss = FCNPC_Create(BOSS_NAME);
  61. FCNPC_SetVirtualWorld(boss, BOSS_WORLD);
  62. FCNPC_Spawn(boss, BOSS_SKIN, 1088.3391, 1075.5221, 10.8382);
  63. FCNPC_SetWeapon(boss, BOSS_WEAPON);
  64. FCNPC_SetHealth(boss, BOSS_HEALTH);
  65. return 1;
  66. }
  67.  
  68. public OnPlayerDeath(playerid, killerid, reason)
  69. {
  70. new name[47];
  71. if(in_boss{playerid})
  72. {
  73. var_boss_wep_delay = 0;
  74. SetPlayerInterior(playerid, 0);
  75. GetPlayerName(playerid, name, 24);
  76. strcat(name, " has lost the boss battle!");
  77. SendClientMessageToAll(0xFFFF00FF, name);
  78. SetPlayerVirtualWorld(playerid, 0);
  79. KillTimer(boss_timer);
  80. boss_timer = 0;
  81. FCNPC_Respawn(boss);
  82. TextDrawHideForPlayer(playerid, boss_hp);
  83. SetPlayerVirtualWorld(playerid, 0);
  84. in_boss{playerid} = false;
  85. SendClientMessage(playerid, 0xFFFF00FF, "You lost the battle!");
  86. }
  87. return 1;
  88. }
  89.  
  90. public OnPlayerDisconnect(playerid, reason)
  91. {
  92. if(in_boss{playerid})
  93. {
  94. var_boss_wep_delay = 0;
  95. in_boss{playerid} = false;
  96. KillTimer(boss_timer);
  97. boss_timer = 0;
  98. TextDrawHideForPlayer(playerid, boss_hp);
  99. FCNPC_Respawn(boss);
  100. SendClientMessageToAll(0xFFFF00FF, "The boss battle is open now");
  101. }
  102. return 1;
  103. }
  104.  
  105. public OnPlayerCommandReceived(playerid, cmdtext[])
  106. {
  107. if(in_boss{playerid})
  108. {
  109. if(strcmp("/leavebossmg", cmdtext) != 0)
  110. {
  111. SendClientMessage(playerid, 0xFF0000FF, "You cant use command during boss fight /leavebossmg");
  112. return 0;
  113. }
  114. }
  115. return 1;
  116. }
  117.  
  118. CMD:leavebossmg(playerid, params[])
  119. {
  120. new name[47];
  121. if(!in_boss{playerid}) return SendClientMessage(playerid, 0xFF0000FF, "You are not in boss battle");
  122. var_boss_wep_delay = 0;
  123. GetPlayerName(playerid, name, 24);
  124. strcat(name, " has left the boss battle!");
  125. KillTimer(boss_timer);
  126. boss_timer = 0;
  127. SetPlayerVirtualWorld(playerid, 0);
  128. SpawnPlayer(playerid);
  129. in_boss{playerid} = false;
  130. TextDrawHideForPlayer(playerid, boss_hp);
  131. FCNPC_Respawn(boss);
  132. SetPlayerInterior(playerid, 0);
  133. SendClientMessage(playerid, 0xFFFF00FF, "You quit the boss battle");
  134. SendClientMessageToAll(0xFFFF00FF, name);
  135. return 1;
  136. }
  137.  
  138. public FCNPC_OnTakeDamage(npcid, issuerid, Float:amount, weaponid, bodypart)
  139. {
  140. new string[18], Float:hp;
  141. hp = FCNPC_GetHealth(boss)-amount;
  142. format(string, 18, "~w~%%~r~~h~%d", floatround(Pracent(hp, BOSS_HEALTH), floatround_round));
  143. TextDrawSetString(boss_hp, string);
  144. return 1;
  145. }
  146.  
  147. public OnFilterScriptExit()
  148. {
  149. TextDrawDestroy(boss_hp);
  150. DestroyDynamic3DTextLabel(boss_label);
  151. FCNPC_Destroy(boss);
  152. DestroyDynamicMapIcon(boss_icon);
  153. if(boss_timer != 0)
  154. {
  155. KillTimer(boss_timer);
  156. boss_timer = 0;
  157. foreach(new i : Player)
  158. {
  159. if(!in_boss{i}) continue;
  160. SetPlayerInterior(i, 0);
  161. SetPlayerVirtualWorld(i, 0);
  162. SetPlayerHealth(i, 100.0);
  163. break;
  164. }
  165. }
  166. return 1;
  167. }
  168.  
  169. public OnPlayerEnterDynamicArea(playerid, areaid)
  170. {
  171. new Float:HP;
  172. if(areaid == boss_area)
  173. {
  174. SendClientMessage(playerid, 0xFFFF00FF, "Check if the boss battle is open from anywhere /boss");
  175. if(boss_timer != 0)
  176. {
  177. SendClientMessage(playerid, 0xFF0000FF, "Someone is in this challange please wait");
  178. return 1;
  179. }
  180. GetPlayerHealth(playerid, HP);
  181. if(HP <= 100.0)
  182. {
  183. ShowPlayerDialog(playerid, BOSS_DIALOG, 0, "{FF0000}Boss Battle", "{FF0000}Are you ready to fight the boss?", "{00FF00}Ready", "{FF0000}Im Out");
  184. }
  185. }
  186. return 1;
  187. }
  188.  
  189. forward BOSS_END();
  190.  
  191. public BOSS_END()
  192. {
  193. foreach(new i : Player)
  194. {
  195. if(!in_boss{i}) continue;
  196. SetPlayerInterior(i, 0);
  197. var_boss_wep_delay = 0;
  198. SetPlayerVirtualWorld(i, 0);
  199. SpawnPlayer(i);
  200. PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
  201. SendClientMessage(i, 0xFFFF00FF, "Boss Battle out of time!");
  202. in_boss{i} = false;
  203. TextDrawHideForPlayer(i, boss_hp);
  204. }
  205. FCNPC_Respawn(boss);
  206. boss_timer = 0;
  207. return 1;
  208. }
  209.  
  210. public FCNPC_OnDeath(npcid, killerid, reason)
  211. {
  212. new name[24], string[74];
  213. if(npcid == boss)
  214. {
  215. if(boss_timer == 0) return 1;
  216. SetPlayerInterior(killerid, 0);
  217. GetPlayerName(killerid, name, 24);
  218. KillTimer(boss_timer);
  219. boss_timer = 0;
  220. var_boss_wep_delay = 0;
  221. SetPlayerVirtualWorld(killerid, 0);
  222. SpawnPlayer(killerid);
  223. in_boss{killerid} = false;
  224. FCNPC_Respawn(boss);
  225. TextDrawHideForPlayer(killerid, boss_hp);
  226. PlayerPlaySound(killerid, 1057, 0.0, 0.0, 0.0);
  227. GivePlayerMoney(killerid, BOSS_CASH);
  228. SetPlayerScore(killerid, GetPlayerScore(killerid)+BOSS_SCORE);
  229. SendClientMessage(killerid, 0x00FF00FF, "You won the boss battle!");
  230. format(string, 74, "%s won the boss battle and got +$%d and %d scores", name, BOSS_CASH, BOSS_SCORE);
  231. SendClientMessageToAll(0x00FF00FF, string);
  232. }
  233. return 1;
  234. }
  235.  
  236. task BOSS_FOLLOW[1000]()
  237. {
  238. new rand;
  239. if(boss_timer != 0)
  240. {
  241. foreach(new i : Player)
  242. {
  243. if(!in_boss{i}) continue;
  244. FCNPC_GoToPlayer(boss, i);
  245. break;
  246. }
  247. if(var_boss_wep_delay < BOSS_WEP_DELAY)
  248. {
  249. var_boss_wep_delay ++;
  250. return 1;
  251. }
  252. rand = random(5);
  253. switch(rand)
  254. {
  255. case 0: FCNPC_SetWeapon(boss, 31);
  256. case 1: FCNPC_SetWeapon(boss, 24);
  257. case 2: FCNPC_SetWeapon(boss, 28);
  258. case 3: FCNPC_SetWeapon(boss, 27);
  259. case 4: FCNPC_SetWeapon(boss, 35);
  260. case 5: FCNPC_SetWeapon(boss, 16);
  261. }
  262. var_boss_wep_delay = 0;
  263. }
  264. return 1;
  265. }
  266.  
  267. CMD:boss(playerid, params[])
  268. {
  269. if(boss_timer != 0) return SendClientMessage(playerid, 0xFF0000FF, "Boss battle is closed currently");
  270. SendClientMessage(playerid, 0x00FF00FF, "Boss battle is open");
  271. return 1;
  272. }
  273.  
  274. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  275. {
  276. switch(dialogid)
  277. {
  278. case BOSS_DIALOG:
  279. {
  280. if(response)
  281. {
  282. //Save Weapons Here
  283. if(boss_timer != 0) return SendClientMessage(playerid, 0xFF0000FF, "Someone allready started this challange you gotta click faster on the buttons!");
  284. ResetPlayerWeapons(playerid);
  285. var_boss_wep_delay = 0;
  286. SetPlayerInterior(playerid, BOSS_INTERIOR);
  287. SendClientMessage(playerid, 0xFFFF00FF, "To leave boss battle /leavebossmg");
  288. boss_timer = SetTimer("BOSS_END", BOSS_END_TIME, false);
  289. GivePlayerWeapon(playerid, PLAYER_WEAPON, 9999999);
  290. TextDrawShowForPlayer(playerid, boss_hp);
  291. GivePlayerWeapon(playerid, 16, 20);
  292. SetPlayerPos(playerid, PLAYER_X, PLAYER_Y, PLAYER_Z);
  293. SetPlayerFacingAngle(playerid, PLAYER_ANGLE);
  294. SetCameraBehindPlayer(playerid);
  295. in_boss{playerid} = true;
  296. FCNPC_Respawn(boss);
  297. FCNPC_SetPosition(boss, BOSS_X, BOSS_Y, BOSS_Z);
  298. FCNPC_SetAngle(boss, BOSS_ANGLE);
  299. FCNPC_SetHealth(boss, BOSS_HEALTH);
  300. FCNPC_SetWeaponAccuracy(boss, BOSS_WEAPON, BOSS_ACCURACY);
  301. FCNPC_SetWeapon(boss, BOSS_WEAPON);
  302. TextDrawSetString(boss_hp, "~w~%~r~~h~100");
  303. FCNPC_UseInfiniteAmmo(boss, true);
  304. FCNPC_AimAtPlayer(boss, playerid, true);
  305. SetPlayerVirtualWorld(playerid, BOSS_WORLD);
  306. return 1;
  307. }
  308. SendClientMessage(playerid, 0xFF0000FF, "Haha chicken!");
  309. }
  310. }
  311. return 0;
  312. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement