Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 50
- #include <foreach>
- #include <fcnpc>
- #include <YSI\y_timers>
- #include <streamer>
- #include <zcmd>
- new Text3D:boss_label = Text3D:0;
- new boss_area = 0;
- new boss_icon = 0;
- new boss = 65535;
- new bool:in_boss[MAX_PLAYERS char] = {false,...};
- new Text:boss_hp = Text:65535;
- new boss_timer = 0;
- new var_boss_wep_delay = 0;
- #define BOSS_NAME "BOSS_NPC" //npc name
- #define BOSS_END_TIME 300000 //battle time
- #define BOSS_ICON 23 //icon type
- #define BOSS_DIALOG 1265 //boss dialog id
- #define BOSS_WORLD 5 //boss virtual world
- #define BOSS_SKIN 269 //boss skin
- #define PLAYER_WEAPON 31 //player weapon
- #define BOSS_WEAPON 31 //boss weapon
- #define BOSS_HEALTH 2500.0 //boss health
- #define BOSS_ACCURACY 0.8 //boss accuracy
- #define BOSS_CASH 80000 //victory cash
- #define BOSS_SCORE 25 //victory score
- #define BOSS_INTERIOR 0 //interior
- #define BOSS_X 3491.1252 //NPC_X_COORD
- #define BOSS_Y 1778.9089 //NPC_Y_COORD
- #define BOSS_Z 278.7320 //NPC_Z_COORD
- #define BOSS_ANGLE 188.0179 //NPC_ANGLE COORD
- #define PLAYER_X 3499.8665 //PLAYER_X_COORD
- #define PLAYER_Y 1701.0521 //PLAYER_Y_COORD
- #define PLAYER_Z 279.1448 //PLAYER_Z_COORD
- #define PLAYER_ANGLE 4.5954 //PLAYER_ANGLE_COORD
- #define BOSS_WEP_DELAY 20 //WEAPON CHANGE DELAY
- Float:Pracent(Float:x, Float:y)
- {
- return ((x/y)*100);
- }
- public OnFilterScriptInit()
- {
- boss_hp = TextDrawCreate(275.0, 420.0, "~w~%~r~~h~100");
- FCNPC_SetWeaponShootTime(boss, BOSS_WEAPON, 200);
- boss_label = CreateDynamic3DTextLabel("Boss Battle", 0xFB0000FF, 1088.3391, 1075.5221, 11.5582, 100.0);
- CreateObject(13657, 3451.7075,1721.0681,280.9664, 0.0000000,0.0000000,0.0000000, 1000);
- TextDrawFont(boss_hp, 3);
- TextDrawLetterSize(boss_hp, 1.0, 1.2);
- TextDrawSetOutline(boss_hp, 1);
- boss_area = CreateDynamicSphere(1088.3391, 1075.5221, 10.8382, 2.5, 0);
- boss_icon = CreateDynamicMapIcon(1088.3391, 1075.5221, 10.8382, BOSS_ICON, 0, 0);
- boss = FCNPC_Create(BOSS_NAME);
- FCNPC_SetVirtualWorld(boss, BOSS_WORLD);
- FCNPC_Spawn(boss, BOSS_SKIN, 1088.3391, 1075.5221, 10.8382);
- FCNPC_SetWeapon(boss, BOSS_WEAPON);
- FCNPC_SetHealth(boss, BOSS_HEALTH);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- new name[47];
- if(in_boss{playerid})
- {
- var_boss_wep_delay = 0;
- SetPlayerInterior(playerid, 0);
- GetPlayerName(playerid, name, 24);
- strcat(name, " has lost the boss battle!");
- SendClientMessageToAll(0xFFFF00FF, name);
- SetPlayerVirtualWorld(playerid, 0);
- KillTimer(boss_timer);
- boss_timer = 0;
- FCNPC_Respawn(boss);
- TextDrawHideForPlayer(playerid, boss_hp);
- SetPlayerVirtualWorld(playerid, 0);
- in_boss{playerid} = false;
- SendClientMessage(playerid, 0xFFFF00FF, "You lost the battle!");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(in_boss{playerid})
- {
- var_boss_wep_delay = 0;
- in_boss{playerid} = false;
- KillTimer(boss_timer);
- boss_timer = 0;
- TextDrawHideForPlayer(playerid, boss_hp);
- FCNPC_Respawn(boss);
- SendClientMessageToAll(0xFFFF00FF, "The boss battle is open now");
- }
- return 1;
- }
- public OnPlayerCommandReceived(playerid, cmdtext[])
- {
- if(in_boss{playerid})
- {
- if(strcmp("/leavebossmg", cmdtext) != 0)
- {
- SendClientMessage(playerid, 0xFF0000FF, "You cant use command during boss fight /leavebossmg");
- return 0;
- }
- }
- return 1;
- }
- CMD:leavebossmg(playerid, params[])
- {
- new name[47];
- if(!in_boss{playerid}) return SendClientMessage(playerid, 0xFF0000FF, "You are not in boss battle");
- var_boss_wep_delay = 0;
- GetPlayerName(playerid, name, 24);
- strcat(name, " has left the boss battle!");
- KillTimer(boss_timer);
- boss_timer = 0;
- SetPlayerVirtualWorld(playerid, 0);
- SpawnPlayer(playerid);
- in_boss{playerid} = false;
- TextDrawHideForPlayer(playerid, boss_hp);
- FCNPC_Respawn(boss);
- SetPlayerInterior(playerid, 0);
- SendClientMessage(playerid, 0xFFFF00FF, "You quit the boss battle");
- SendClientMessageToAll(0xFFFF00FF, name);
- return 1;
- }
- public FCNPC_OnTakeDamage(npcid, issuerid, Float:amount, weaponid, bodypart)
- {
- new string[18], Float:hp;
- hp = FCNPC_GetHealth(boss)-amount;
- format(string, 18, "~w~%%~r~~h~%d", floatround(Pracent(hp, BOSS_HEALTH), floatround_round));
- TextDrawSetString(boss_hp, string);
- return 1;
- }
- public OnFilterScriptExit()
- {
- TextDrawDestroy(boss_hp);
- DestroyDynamic3DTextLabel(boss_label);
- FCNPC_Destroy(boss);
- DestroyDynamicMapIcon(boss_icon);
- if(boss_timer != 0)
- {
- KillTimer(boss_timer);
- boss_timer = 0;
- foreach(new i : Player)
- {
- if(!in_boss{i}) continue;
- SetPlayerInterior(i, 0);
- SetPlayerVirtualWorld(i, 0);
- SetPlayerHealth(i, 100.0);
- break;
- }
- }
- return 1;
- }
- public OnPlayerEnterDynamicArea(playerid, areaid)
- {
- new Float:HP;
- if(areaid == boss_area)
- {
- SendClientMessage(playerid, 0xFFFF00FF, "Check if the boss battle is open from anywhere /boss");
- if(boss_timer != 0)
- {
- SendClientMessage(playerid, 0xFF0000FF, "Someone is in this challange please wait");
- return 1;
- }
- GetPlayerHealth(playerid, HP);
- if(HP <= 100.0)
- {
- ShowPlayerDialog(playerid, BOSS_DIALOG, 0, "{FF0000}Boss Battle", "{FF0000}Are you ready to fight the boss?", "{00FF00}Ready", "{FF0000}Im Out");
- }
- }
- return 1;
- }
- forward BOSS_END();
- public BOSS_END()
- {
- foreach(new i : Player)
- {
- if(!in_boss{i}) continue;
- SetPlayerInterior(i, 0);
- var_boss_wep_delay = 0;
- SetPlayerVirtualWorld(i, 0);
- SpawnPlayer(i);
- PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
- SendClientMessage(i, 0xFFFF00FF, "Boss Battle out of time!");
- in_boss{i} = false;
- TextDrawHideForPlayer(i, boss_hp);
- }
- FCNPC_Respawn(boss);
- boss_timer = 0;
- return 1;
- }
- public FCNPC_OnDeath(npcid, killerid, reason)
- {
- new name[24], string[74];
- if(npcid == boss)
- {
- if(boss_timer == 0) return 1;
- SetPlayerInterior(killerid, 0);
- GetPlayerName(killerid, name, 24);
- KillTimer(boss_timer);
- boss_timer = 0;
- var_boss_wep_delay = 0;
- SetPlayerVirtualWorld(killerid, 0);
- SpawnPlayer(killerid);
- in_boss{killerid} = false;
- FCNPC_Respawn(boss);
- TextDrawHideForPlayer(killerid, boss_hp);
- PlayerPlaySound(killerid, 1057, 0.0, 0.0, 0.0);
- GivePlayerMoney(killerid, BOSS_CASH);
- SetPlayerScore(killerid, GetPlayerScore(killerid)+BOSS_SCORE);
- SendClientMessage(killerid, 0x00FF00FF, "You won the boss battle!");
- format(string, 74, "%s won the boss battle and got +$%d and %d scores", name, BOSS_CASH, BOSS_SCORE);
- SendClientMessageToAll(0x00FF00FF, string);
- }
- return 1;
- }
- task BOSS_FOLLOW[1000]()
- {
- new rand;
- if(boss_timer != 0)
- {
- foreach(new i : Player)
- {
- if(!in_boss{i}) continue;
- FCNPC_GoToPlayer(boss, i);
- break;
- }
- if(var_boss_wep_delay < BOSS_WEP_DELAY)
- {
- var_boss_wep_delay ++;
- return 1;
- }
- rand = random(5);
- switch(rand)
- {
- case 0: FCNPC_SetWeapon(boss, 31);
- case 1: FCNPC_SetWeapon(boss, 24);
- case 2: FCNPC_SetWeapon(boss, 28);
- case 3: FCNPC_SetWeapon(boss, 27);
- case 4: FCNPC_SetWeapon(boss, 35);
- case 5: FCNPC_SetWeapon(boss, 16);
- }
- var_boss_wep_delay = 0;
- }
- return 1;
- }
- CMD:boss(playerid, params[])
- {
- if(boss_timer != 0) return SendClientMessage(playerid, 0xFF0000FF, "Boss battle is closed currently");
- SendClientMessage(playerid, 0x00FF00FF, "Boss battle is open");
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case BOSS_DIALOG:
- {
- if(response)
- {
- //Save Weapons Here
- if(boss_timer != 0) return SendClientMessage(playerid, 0xFF0000FF, "Someone allready started this challange you gotta click faster on the buttons!");
- ResetPlayerWeapons(playerid);
- var_boss_wep_delay = 0;
- SetPlayerInterior(playerid, BOSS_INTERIOR);
- SendClientMessage(playerid, 0xFFFF00FF, "To leave boss battle /leavebossmg");
- boss_timer = SetTimer("BOSS_END", BOSS_END_TIME, false);
- GivePlayerWeapon(playerid, PLAYER_WEAPON, 9999999);
- TextDrawShowForPlayer(playerid, boss_hp);
- GivePlayerWeapon(playerid, 16, 20);
- SetPlayerPos(playerid, PLAYER_X, PLAYER_Y, PLAYER_Z);
- SetPlayerFacingAngle(playerid, PLAYER_ANGLE);
- SetCameraBehindPlayer(playerid);
- in_boss{playerid} = true;
- FCNPC_Respawn(boss);
- FCNPC_SetPosition(boss, BOSS_X, BOSS_Y, BOSS_Z);
- FCNPC_SetAngle(boss, BOSS_ANGLE);
- FCNPC_SetHealth(boss, BOSS_HEALTH);
- FCNPC_SetWeaponAccuracy(boss, BOSS_WEAPON, BOSS_ACCURACY);
- FCNPC_SetWeapon(boss, BOSS_WEAPON);
- TextDrawSetString(boss_hp, "~w~%~r~~h~100");
- FCNPC_UseInfiniteAmmo(boss, true);
- FCNPC_AimAtPlayer(boss, playerid, true);
- SetPlayerVirtualWorld(playerid, BOSS_WORLD);
- return 1;
- }
- SendClientMessage(playerid, 0xFF0000FF, "Haha chicken!");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement