viewing paste Unknown #53499 | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
function    script  F_ShuffleNumbers    {
    deletearray getarg(2);
    .@static = getarg(0);
    .@range = getarg(1) +1 - .@static;
    .@count = getarg(3, .@range);
    if (.@range <= 0 || .@count <= 0)
        return 0;
    if (.@count > .@range)
        .@count = .@range;
    for (.@i = 0; .@i < .@range; ++.@i)
        .@temparray[.@i] = .@i;
    for (.@i = 0; .@i < .@count; ++.@i) {
        .@rand = rand(.@range);
        set getelementofarray( getarg(2), .@i ), .@temparray[.@rand] + .@static;
        .@range--;
        .@temparray[.@rand] = .@temparray[.@range];
    }
    return .@count;
}
 
-       script  GM Command      -1,{
OnInit:
        bindatcmd "kvm", strnpcinfo(0)+"::OnCommand",40,40;
OnCommand:
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;
        }       
          
prontera,157,179,5  script  DeathMatch  1_M_BARD,{
    mes "[DeathMatch]";
    mes "Warping to Registration Room";
    close2;
    warp "bat_room",85,93;
    close;
    }
                        
bat_room,82,97,5    script  BG DeathMatch   1_F_MARIA,{
 
    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;
L_reward:
    bg_get_data getarg(0), 1;
    for ( .@i = 0; .@i < $@arenamemberscount; .@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_c03", 54,122, 6, DIR_NORTHEAST, false, "bg_pvp_round_red";
    setwall "bat_c03", 140,56, 6, DIR_NORTHEAST, false, "bg_pvp_round_blue";
    return;
L_delwall:
    delwall "bg_pvp_round_red";
    delwall "bg_pvp_round_blue";
    return;
L_make_player_move:
    setarray .@team, .red, .blue;
    for ( .@j = 0; .@j < 2; .@j++ ) {
        bg_get_data .@team[.@j], 1;
        for ( .@i = 0; .@i < $@arenamemberscount; .@i++ ) {
            attachrid $@arenamembers[.@i];
            setoption Option_Xmas | Option_Invisible, false;
            pcblockmove getcharid(3), false;
            pcblockskill getcharid(3), false;
        }
    }
    return;
OnRedQuit: callsub L_quit, .red, .blue, "Red", "Blue";
OnBlueQuit: callsub L_quit, .blue, .red, "Blue", "Red";
L_quit:
    if ( checkoption( Option_Xmas | Option_Invisible ) == false )
        .life[ getarg(0) ]--;
    percentheal 100, 100;
    setoption Option_Xmas | Option_Invisible, false;
    pcblockmove getcharid(3), false;
    pcblockskill getcharid(3), false;
    if ( !bg_get_data( getarg(0), 0 ) ) {
        mapannounce "bat_c03", "All "+ getarg(2) +" team members has Quit !", bc_all, 0xff3333; // purposely use different color
        .score[ getarg(1) ] = .winningscore;
        .winside = getarg(1);
        .skip = true;
        awake strnpcinfo(0);
    }
    else if ( !.life[ getarg(0) ] ) {
        .winside = getarg(1);
        mapannounce "bat_c03", " "+ getarg(3) +" team has defeated the opponent team, "+ getarg(3) +" team score a point !", bc_all;
        .score[ getarg(1) ]++;
        awake strnpcinfo(0);
    }
    else
        bg_updatescore "bat_c03", .life[.red], .life[.blue];
    end;
OnRedDead: callsub L_dead, .red, .blue, "Red", "Blue";
OnBlueDead: callsub L_dead, .blue, .red, "Blue", "Red";
L_dead:
    .life[ getarg(0) ]--;
    if ( !.life[ getarg(0) ] ) {
        .winside = getarg(1);
        mapannounce "bat_c03", " "+ getarg(3) +" team has defeated the opponent team, "+ getarg(3) +" team score a point !", bc_all;
        .score[ getarg(1) ]++;
        awake strnpcinfo(0);
    }
    else
        bg_updatescore "bat_c03", .life[.red], .life[.blue];
    sleep2 1250;
    percentheal 100,100;
    if ( getcharid(4) ) {
        setoption Option_Xmas | Option_Invisible, true;
        pcblockmove getcharid(3), true;
        pcblockskill getcharid(3), true;
    }
    end;
}
 
bat_c03,149,59,4    script  Berry Ticket NPC    112,{
    mes "[Berry Ticket NPC]";
    mes "What would you like to do?";
    switch(select("Ygg Berry to Berry Ticket","Berry Ticket to Ygg Berry","Information")) {
    
case 1:
    if (countitem(607) < 50) goto L_NE;
    delitem 607,50;
    getitem 30000,1;
    close;
L_NE:
    mes "I'm Sorry but you don't have enough Ygg Berry.";
    close;
 
case 2:
    if (checkweight(607,50) == 0 ) goto L_OW;
    if (countitem(30000) < 1) goto L_NEEDITEM;
    delitem 30000,1;
    getitem 607,50;
    close;
case 3:
    next;
    mes "[Berry Ticket NPC]";
    mes "I can convert your 'Berry Ticket' into 50pcs Ygg Berry and vice versa.";
    close;
L_NEEDITEM:
    mes "[Berry Ticket NPC]";
    mes "Sorry you don't have Berry Ticket";
    close;
L_OW:
    mes "[Berry Ticket NPC]";
    mes "Sorry your overweight";
    close;
 
    }
 
}
                
bat_c03,50,125,6    duplicate(Berry Ticket NPC) Berry Ticket NPC#1  112
prontera,151,177,3  duplicate(BG DeathMatch)    GameMaster#1    89
 
bat_c03 mapflag battleground    2
bat_c03 mapflag nosave  SavePoint
bat_c03 mapflag nowarp
bat_c03 mapflag nowarpto
bat_c03 mapflag noteleport
bat_c03 mapflag nomemo
bat_c03 mapflag nopenalty
bat_c03 mapflag nobranch
bat_c03 mapflag noicewall
 
 
-   script  BG_Check_IP -1,{
OnInit:
   setmapflag "bat_room", mf_loadevent;
   end;
 
OnPCLoadMapEvent:
 
   if (strcharinfo(3) != "bat_room") end;
   set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+getcharip()+"'",.@aid);
 
   if (.@size < 2) end;
   set .@self, getcharid(3);
   for(set .@i,0; .@i<.@size; set .@i,.@i+1) {
       if (.@aid[.@i] == .@self)
           continue;
       if (attachrid(.@aid[.@i])) {
           if (compare(strcharinfo(3),"bat_")) {
               set .@name$, strcharinfo(0);
               attachrid(.@self);
               message strcharinfo(0),"Character "+.@name$+" is already logged into Battlegrounds with your IP.";
               warp "SavePoint",0,0;
               end;
           }
       }
   }
 
   end;
}
Viewed 5207 times, submitted by Guest.