prontera,142,175,6 script Battleground Deathmatch 733,{ end; OnInit: .minplayer2start = 5; // number of players to start this event automatically .winningscore = 3; // how many rounds to win .eventlasting = 20*60; // event last 20 minutes or the system abort itself .registerlasting = 5*60; // 5 minutes to join setarray .rewardwin, 29329,3; // reward to winning team setarray .rewardlose, 29329,1; // reward to losing team .rewardwinsize = getarraysize( .rewardwin ); .rewardlosesize = getarraysize( .rewardlose ); .teamname$[1] = "Red"; .teamname$[2] = "Blue"; bindatcmd "bgpvp", strnpcinfo(0)+"::OnCommand", 99, 100; getmapxy .map$, .x, .y, 1; end; OnCommand: if ( compare( .@atcmd_parameters$, "on" ) ) { if ( .start ) dispbottom "Battle Ground DeathMatch System already started."; else goto L_Start; } else if ( compare( .@atcmd_parameters$, "off" ) ) { if ( !.start ) dispbottom "Battle Ground DeathMatch System not yet start."; else { .gmname$ = strcharinfo(0); .start = 0; .skip = 1; awake strnpcinfo(0); end; } } else if ( !.start ) dispbottom "Battle Ground DeathMatch System is currently not running."; dispbottom "Use "+ .@atcmd_command$ +" on to start the event."; dispbottom "Use "+ .@atcmd_command$ +" off to abort this event"; end; OnStart: if ( getwaitingroomstate(0) < .minplayer2start ) announce "[ Battle Ground DeathMatch System ] : ["+ getwaitingroomstate(0) + "/" + .minplayer2start +"] players.", bc_all, 0x00CED1; else awake strnpcinfo(0); end; OnClock0000: OnClock0200: OnClock0400: OnClock0600: OnClock0800: OnClock1000: OnClock1200: OnClock1400: OnClock1600: OnClock1800: OnClock2000: OnClock2200: L_Start: if ( .start ) end; announce "[ Battle Ground DeathMatch System ] Event is now Open ! Come to prontera to join !", bc_all, 0x00CED1; waitingroom "[Battle Ground DeathMatch]", .minplayer2start +1, strnpcinfo(0)+"::OnStart", 1; .start = 1; sleep .registerlasting * 1000; if ( !.start ) { delwaitingroom strnpcinfo(0); announce "[ Battle Ground DeathMatch System ] "+ .gmname$ +" has aborted this Event !", bc_all, 0x00CED1; .skip = 0; end; } .start = 2; announce "[ Battle Ground DeathMatch System ] Battleground has started", bc_all, 0x00CED1; .@tmp = waitingroom2bg( .map$, .x, .y, "", "" ); bg_destroy .@tmp; .teamid[1] = .red = createbgid( "bat_b01", 61,150, strnpcinfo(0)+"::OnRedQuit", strnpcinfo(0)+"::OnRedDead" ); .teamid[2] = .blue = createbgid( "bat_b01", 327,150, strnpcinfo(0)+"::OnBlueQuit", strnpcinfo(0)+"::OnBlueDead" ); callfunc "rand__", .minplayer2start, $@rand; for ( .@i = 0; .@i < $@arenamembersnum; .@i++ ) setbgid ( .@i % 2 )? .red : .blue, $@arenamembers[ $@rand[.@i] ]; delwaitingroom strnpcinfo(0); callsub L_setwall; bg_updatescore "bat_b01", 0, 0; bg_warp .red, "bat_b01", 61,150; bg_warp .blue, "bat_b01", 327,150; sleep 4000 * !.skip; mapannounce "bat_b01", "Kill all opponent team to gain 1 point, score "+ .winningscore +" points to win !", bc_map; sleep 2000 * !.skip; while (1) { for ( .@i = 5; .@i > 0; .@i-- ) { mapannounce "bat_b01", "["+ .@i +"]", bc_map; sleep 1000 * !.skip; } if ( .score[1] == .winningscore -1 && .score[2] == .winningscore -1 ) mapannounce "bat_b01", "Final Round start!", bc_map; else mapannounce "bat_b01", "Round "+ .round++ +" start!", bc_map; callsub L_delwall; .life[1] = bg_get_data( .teamid[1], 0 ); .life[2] = bg_get_data( .teamid[2], 0 ); callsub L_make_player_move; sleep .eventlasting * 1000 * !.skip; bg_updatescore "bat_b01", .score[1], .score[2]; if ( .score[1] == .winningscore || .score[2] == .winningscore || !.winside ) break; .winside = 0; sleep 5000 * !.skip; callsub L_make_player_move; bg_warp .red, "bat_b01", 61,150; bg_warp .blue, "bat_b01", 327,150; callsub L_setwall; sleep 1000 * !.skip; } if ( .winside ) { mapannounce "bat_b01", " "+ .teamname$[ .winside ] +" side wins !", bc_map; callsub L_reward, ( .winside == 1 )? .red : .blue, .rewardwin, .rewardwinsize; callsub L_reward, ( .winside == 1 )? .blue : .red, .rewardlose, .rewardlosesize; } else if ( .start ) mapannounce "bat_b01", "[ Battle Ground DeathMatch System ] Time Out. Aborting the match.", bc_map; else mapannounce "bat_b01", "[ Battle Ground DeathMatch System ] "+ .gmname$ +" has aborted this Event !", bc_map, 0x00CED1; sleep 5000; callsub L_make_player_move; mapwarp "bat_b01", .map$, .x, .y; bg_destroy .red; bg_destroy .blue; callsub L_delwall; .round = .winside = .skip = .score[1] = .score[2] = .life[1] = .life[2] = .teamid[1] = .teamid[2] = .start = 0; end; L_reward: getbgusers getarg(0); for ( .@i = 0; .@i < $@arenamembersnum; .@i++ ) for ( .@j = 0; .@j < getarg(2); .@j += 2 ) getitem getelementofarray( getarg(1), .@j ), getelementofarray( getarg(1), .@j +1 ), $@arenamembers[.@i]; return; L_setwall: setwall "bat_b01", 58,153, 6, 6, 0, "bg_pvp_round_red_1"; setwall "bat_b01", 64,153, 6, 4, 0, "bg_pvp_round_red_2"; setwall "bat_b01", 64,147, 6, 2, 0, "bg_pvp_round_red_3"; setwall "bat_b01", 58,147, 6, 0, 0, "bg_pvp_round_red_4"; setwall "bat_b01", 324,153, 6, 6, 0, "bg_pvp_round_blue_1"; setwall "bat_b01", 330,153, 6, 4, 0, "bg_pvp_round_blue_2"; setwall "bat_b01", 330,147, 6, 2, 0, "bg_pvp_round_blue_3"; setwall "bat_b01", 324,147, 6, 0, 0, "bg_pvp_round_blue_4"; return; L_delwall: delwall "bg_pvp_round_red_1"; delwall "bg_pvp_round_red_2"; delwall "bg_pvp_round_red_3"; delwall "bg_pvp_round_red_4"; delwall "bg_pvp_round_blue_1"; delwall "bg_pvp_round_blue_2"; delwall "bg_pvp_round_blue_3"; delwall "bg_pvp_round_blue_4"; return; L_make_player_move: getbgusers .red; for ( .@i = 0; .@i < $@arenamembersnum; .@i++ ) { attachrid $@arenamembers[.@i]; setoption Option_Xmas | Option_Invisible, 0; pcblockmove getcharid(3), 0; } getbgusers .blue; for ( .@i = 0; .@i < $@arenamembersnum; .@i++ ) { attachrid $@arenamembers[.@i]; setoption Option_Xmas | Option_Invisible, 0; pcblockmove getcharid(3), 0; } return; OnRedQuit: callsub L_quit, 1, 2; OnBlueQuit: callsub L_quit, 2, 1; L_quit: percentheal 100, 100; setoption Option_Xmas | Option_Invisible, 0; pcblockmove getcharid(3), 0; .life[ getarg(0) ]--; if ( !bg_get_data( .teamid[ getarg(0) ], 0 ) ) { mapannounce "bat_b01", "All "+ .teamname$[ getarg(0) ] +" team members has Quit !", bc_map, 0xff3333; // purposely use different color .score[ getarg(1) ] = .winningscore; .winside = getarg(1); .skip = 1; awake strnpcinfo(0); } else if ( !.life[ getarg(0) ] ) { .winside = getarg(1); mapannounce "bat_b01", " "+ .teamname$[ getarg(1) ] +" team has defeated the opponent team, "+ .teamname$[ getarg(1) ] +" team score a point !", bc_map; .score[ getarg(1) ]++; awake strnpcinfo(0); } end; OnRedDead: callsub L_dead, 1, 2; OnBlueDead: callsub L_dead, 2, 1; L_dead: .life[ getarg(0) ]--; if ( !.life[ getarg(0) ] ) { .winside = getarg(1); mapannounce "bat_b01", " "+ .teamname$[ getarg(1) ] +" team has defeated the opponent team, "+ .teamname$[ getarg(1) ] +" team score a point !", bc_all; .score[ getarg(1) ]++; awake strnpcinfo(0); } sleep2 1250; percentheal 100,100; if ( getcharid(4) ) { setoption Option_Xmas | Option_Invisible, 1; pcblockmove getcharid(3), 1; } end; } bat_b01 mapflag battleground 2 bat_b01 mapflag nosave SavePoint bat_b01 mapflag nowarp bat_b01 mapflag nowarpto bat_b01 mapflag noteleport bat_b01 mapflag nomemo bat_b01 mapflag nopenalty bat_b01 mapflag nobranch bat_b01 mapflag noicewall