viewing paste give 1 zeny for every bg players | Athena

Posted on the | Last edited on
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
// https://rathena.org/board/topic/115504-bg_warp-and-instance_enter-are-equals/
 
/* db\re\instance_db.txt
34,BG_PVP,86400,86400,bat_c01,100,95
*/
 
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;
        .@temparray[.@rand] = .@temparray[--.@range];
    }
    return .@count;
}
 
prontera,150,185,5  script  BG_SIGNUP   1_F_MARIA,{
    .minplayer2start = 1; // 1vs1
    mes "Test ... BG_PVP + BG_EMP combine";
    mes "kill all opponent team to win";
    mes "or kill the shining plant to win";
    next;
    while ( .aid[.@i] != getcharid(3) && .@i < .size ) ++.@i;
    if ( .@i < .size ) {
        mes "You already join the queue.";
        close;
    }
    select "join";
    mes "you have to stick to this map";
    close2;
    .aid[ .size++ ] = getcharid(3);
    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) ) {
                deletearray .aid[.@i], 1;
                --.@i;
                --.size;
            }
        }
    }
    detachrid;
    if ( .size == .minplayer2start *2 ) {
        instance_create( "BG_PVP", IM_NONE );
        deletearray .aid;
        .size = 0;
    }
    else
        announce .size +" players join", bc_npc | bc_area;
    end;
}
bat_c01,0,0,0   script  BG_PVP_EMP  -1,{
OnInstanceInit:
    announce instance_id() +" ID start", bc_all;
    monster strnpcinfo(4), 100,95, "--ja--", 1083,1, instance_npcname( strnpcinfo(0) )+"::OnPlantDown";
    'red = bg_create( strnpcinfo(4), 90,95, instance_npcname( strnpcinfo(0) )+"::OnRedQuit", instance_npcname( strnpcinfo(0) )+"::OnRedDead" );
    'blue = bg_create( strnpcinfo(4), 90,95, instance_npcname( strnpcinfo(0) )+"::OnBlueQuit", instance_npcname( strnpcinfo(0) )+"::OnBlueDead" );
    callfunc "F_ShuffleNumbers", 0, getvariableofnpc( .size, "BG_SIGNUP" ) -1, .@r;
    for ( .@i = 0; .@i < getvariableofnpc( .size, "BG_SIGNUP" ); ++.@i ) {
        attachrid getvariableofnpc( getd( ".aid["+ .@r[.@i] +"]" ), "BG_SIGNUP" );
        bg_join ( .@i % 2 )? 'red : 'blue;
    }
    detachrid;
    bg_warp 'red, strnpcinfo(4), 90,95;
    bg_warp 'blue, strnpcinfo(4), 110,95;
    initnpctimer;
    sleep 30000; // time out
    if ( !'winside )
        announce "Battle end as time out", bc_npc | bc_map | bc_blue;
    else if ( 'winside == 'red ) {
        announce "- Red side Won the match !", bc_npc | bc_map | bc_blue;
        callsub L_reward, 'red;
    }
    else if ( 'winside == 'blue ) {
        announce "- Blue side Won the match !", bc_npc | bc_map | bc_blue;
        callsub L_reward, 'blue;
    }
    bg_destroy 'red;
    bg_destroy 'blue;
    mapwarp strnpcinfo(4), "prontera",150,185;
    sleep 1; // prevent aFree error
    instance_destroy;
    end;
OnTimer1000:
    bg_get_data 'red, 1;
    for ( .@i = 0; .@i < $@arenamemberscount; ++.@i ) {
        attachrid $@arenamembers[.@i];
        ++Zeny;
    }
    bg_get_data 'blue, 1;
    for ( .@i = 0; .@i < $@arenamemberscount; ++.@i ) {
        attachrid $@arenamembers[.@i];
        ++Zeny;
    }
    initnpctimer;
    end;
L_reward:
    bg_get_data getarg(0), 1;
    for ( .@i = 0; .@i < $@arenamemberscount; ++.@i )
        getitem 501,1, $@arenamembers[.@i];
    return;
OnPlantDown:
    announce strcharinfo(0) +" from "+( ( getcharid(4) == 'red )? "Red" : "Blue" )+" team has killed the shining plant !", bc_npc | bc_map | bc_blue;
    'winside = getcharid(4);
    awake instance_npcname( strnpcinfo(0) );
    end;
OnRedQuit: callsub L_Quit, 'red, 'blue, "Red";
OnBlueQuit: callsub L_Quit, 'blue, 'red, "Blue";
L_Quit:
    if ( bg_get_data( getarg(0), 0 ) ) end;
    announce "All "+ getarg(2) +" team members has Quit!", bc_npc | bc_map | bc_blue;
    'winside = getarg(1);
    awake instance_npcname( strnpcinfo(0) );
    end;
OnRedDead: callsub L_Dead, 'red, 'blue, "Red";
OnBlueDead: callsub L_Dead, 'blue, 'red, "Blue";
L_Dead:
    bg_leave;
    if ( bg_get_data( getarg(0), 0 ) ) end;
    announce "All "+ getarg(2) +" team members has killed!", bc_npc | bc_map | bc_blue;
    'winside = getarg(1);
    awake instance_npcname( strnpcinfo(0) );
    sleep2 1250;
    percentheal 100,100;
    end;
}
bat_c01 mapflag battleground
bat_c01 mapflag nosave  SavePoint
bat_c01 mapflag nowarp
bat_c01 mapflag nowarpto
bat_c01 mapflag noteleport
bat_c01 mapflag nomemo
bat_c01 mapflag nopenalty
bat_c01 mapflag nobranch
bat_c01 mapflag noicewall
Viewed 951 times, submitted by AnnieRuru.