Advertisement
Guest User

Boss

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