bat_room,82,97,5 script BG DeathMatch 1_F_MARIA,{
if(getgmlevel() >= 40) {
mes "Hello GM!";
switch(select("Turn ON/OFF Event:Set Players & Rounds")) {
case 1:
if (.play) {
mes " The Event is currently ON ";
} else {
mes " The Event is currently OFF ";
mes "Would you like to ON? ";
}
if(select("Yes:No")==2) close;
close2;
if (.play) {
set .play,0;
disablenpc "DeathMatch";
disablenpc "BG DeathMatch";
announce " A GM has turn the Event OFF", 0;
end;
}
set .play,1;
announce " The Event will start in a few moments", 0;
goto OnStart;
end;
}
mes "You can set the number of players and rounds in Deathmatch";
next;
mes "Input Players per Team";
mes "ex: 2 = 2v2";
mes "Min. 2 [ per Team ] Max. 20";
while(.@players < 2 || .@players > 20) {
input .@players;
if(!.@players)
end;
}
next;
mes "Input Event Round/s";
mes "Min. 1 [ per Round ] Max. 5";
while(.@rounds < 1 || .@rounds > 5) {
input .@rounds;
if(!.@rounds)
end;
}
.partysize = .@players;
.winningscore = .@rounds;
.active = true;
end;
}
if(!.active) {
message strcharinfo(PC_NAME),"The BG is not active.";
end;
}
goto L_dialog;
OnInit:
RegisterSchedule("*",13,04,"Death Match");
disablenpc "BG DeathMatch";
disablenpc "DeathMatch";
disablenpc "Berry Ticket NPC";
disablenpc "Gamemaster";
.partysize = 1; // minimum number of players on each side needed to start this event. eg: 2vs2 = 2
.winningscore = 2; // how many rounds to win
.eventlasting = 5*60; // each round last 5 minutes or the system abort itself
setarray .rewardwin, 12103,1, 30000,5; // reward to winning team
setarray .rewardlose, 675,1; // reward to losing team
.rewardwinsize = getarraysize( .rewardwin );
.rewardlosesize = getarraysize( .rewardlose );
setwall "bat_c03", 50,130, 2, DIR_NORTHEAST, false, "bg_pvp_round_red_respawn";
setwall "bat_c03", 148,52, 2, DIR_NORTHEAST, false, "bg_pvp_round_blue_respawn";
end;
OnStart:
set .play,1;
enablenpc "Gamemaster";
announce "BG Deathmatch: Registration will open in 3 Minutes!!", 0;
sleep 1000;
announce "BG Deathmatch: Registration will open in 2 Minutes!!", 0;
sleep 1000;
announce "BG Deathmatch: Registration will open in 1 Minute!!", 0;
sleep 1000;
announce "BG Deathmatch: Only the first "+ .partysize *2 +" players to register will be able to join", 0;
sleep 1000;
announce "BG Deathmatch: First team to get "+ .winningscore +" point/s will win the event", 0;
sleep 1000;
announce "BG Deathmatch: Registration will open in 30 seconds!!",0;
sleep 1000;
announce "BG Deathmatch: Warper is Located at Prontera 156,132",0;
sleep 1000;
announce "BG Deathmatch: Registration is now open", 0;
enablenpc "DeathMatch";
sleep 1000;
enablenpc "BG DeathMatch";
end;
L_dialog:
mes "[Battle Ground DeathMatch]";
if ( .start == true ) {
mes "Battleground is on-going";
close;
}
while ( .aid[.@i] != getcharid(3) && .@i < .size ) { .@i++; }
if ( .@i < .size ) {
mes "You already join the event.";
close;
}
select "join";
mes "Make sure to stay in the registration map";
close2;
.aid[ .size ] = getcharid(3);
.size++;
for ( .@i = 0; .@i < .size; .@i++ ) {
if ( !isloggedin( .aid[.@i] ) ) {
deletearray .aid[.@i], 1;
.@i--;
.size--;
}
else {
attachrid .aid[.@i];
if ( strcharinfo(3) != strnpcinfo(4) ) {
dispbottom "[Battle Ground DeathMatch] You have forfeit the registration.";
deletearray .aid[.@i], 1;
.@i--;
.size--;
}
}
}
detachrid;
if ( .size < .partysize *2 ) {
announce "[Battle Ground DeathMatch] "+ .size +" players has join.", bc_woe|bc_all;
end;
}
announce "BG Deathmatch has Started", 0;
disablenpc "DeathMatch";
enablenpc "Berry Ticket NPC";
sleep 1000;
.red = bg_create( "bat_c03",50,131, strnpcinfo(0)+"::OnRedQuit", strnpcinfo(0)+"::OnRedDead" );
.blue = bg_create( "bat_c03",149,52, strnpcinfo(0)+"::OnBlueQuit", strnpcinfo(0)+"::OnBlueDead" );
callfunc "F_ShuffleNumbers", 0, .size -1, .@r;
for ( .@i = 0; .@i < .size; .@i++ ) {
attachrid .aid[ .@r[.@i] ];
bg_join ( .@i % 2 )? .red : .blue;
}
detachrid;
deletearray .aid;
.size = 0;
.start = true;
callsub L_setwall;
bg_warp .red, "bat_c03", 53,128;
bg_warp .blue, "bat_c03", 146,56;
.life[.red] = bg_get_data( .red, 0 );
.life[.blue] = bg_get_data( .blue, 0 );
while (true) {
for ( .@i = 5; .@i > 0; .@i-- ) {
mapannounce "bat_c03", "["+ .@i +"]", bc_map;
if ( !.skip ) sleep 1000;
}
if ( .score[.red] == .winningscore -1 && .score[.blue] == .winningscore -1 )
mapannounce "bat_c03", "Final Round start!", bc_map;
else {
.round++;
mapannounce "bat_c03", "Round "+ .round +" start!", bc_map;
}
callsub L_make_player_move; // I dunno why sometimes players still stuck when having teamates logout, but when I put this here it never happens again :O
callsub L_delwall;
disablenpc "Berry Ticket NPC";
disablenpc "Berry Ticket NPC#1";
bg_updatescore "bat_c03", .life[.red], .life[.blue];
if ( !.skip ) sleep .eventlasting * 1000;
bg_updatescore "bat_c03", .score[.red], .score[.blue];
if ( .score[.red] == .winningscore || .score[.blue] == .winningscore || !.winside ) break;
.winside = 0;
.life[.red] = bg_get_data( .red, 0 );
.life[.blue] = bg_get_data( .blue, 0 );
if ( !.skip ) sleep 5000;
callsub L_make_player_move;
bg_warp .red, "bat_c03", 53,128;
bg_warp .blue, "bat_c03", 146,56;
enablenpc "Berry Ticket NPC";
enablenpc "Berry Ticket NPC#1";
callsub L_setwall;
if ( !.skip ) sleep 1000;
}
disablenpc "BG DeathMatch";
if ( .winside == .red ) {
mapannounce "bat_c03", "- Red side Won the match !", bc_map;
callsub L_reward, .red, .rewardwin, .rewardwinsize;
callsub L_reward, .blue, .rewardlose, .rewardlosesize;
}
else if ( .winside == .blue ) {
mapannounce "bat_c03", "- Blue side Won the match !", bc_map;
callsub L_reward, .blue, .rewardwin, .rewardwinsize;
callsub L_reward, .red, .rewardlose, .rewardlosesize;
}
else {
mapannounce "bat_c03", "- Time Out ! End as a Draw due to purposely drag out the match.", bc_map;
callsub L_reward, .blue, .rewardlose, .rewardlosesize;
callsub L_reward, .red, .rewardlose, .rewardlosesize;
}
sleep 5000;
callsub L_make_player_move;
bg_warp .red, "prontera", 156,177;
bg_warp .blue, "prontera", 154,177;
bg_destroy .red;
bg_destroy .blue;
.round = .winside = .score[.red] = .score[.blue] = .life[.red] = .life[.blue] = .start = .skip = false;
end;