viewing paste topic/15913-a instanced_bg_emp_r | 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
// http://herc.ws/board/topic/15913-annieruru-emp-bg/
 
/* db\re\instance_db.txt
34,BG_EMP,86400,86400,bat_a02,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_emp  1_F_MARIA,{
    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 ) {
        announce .size +" players join", bc_npc | bc_area;
        end;
    }
    if ( instance_create( "BG_EMP", IM_NONE ) < 0 ) {
        announce "Fail to create instanced battleground.", bc_all;
        end;
    }
    deletearray .aid;
    .size = 0;
    end;
OnInit:
    .minplayer2start = 1;      // minimum players to start (ex. if 3vs3, set to 3)
    .eventlasting    = 20*60;  // event duration before auto-reset (20 minutes * seconds)
    setarray .rewarditem[0],   // rewards for the winning team: <item>,<amount>,...
        501, 10;
    end;
}
bat_a02,0,0,0   script  bg_emp#ins  -1,{
OnInstanceInit:
    'main$ = "bg_emp";
    'map$ = strnpcinfo(4);
    'red = bg_create( 'map$, 157,347, instance_npcname( strnpcinfo(0) )+"::OnRedQuit", instance_npcname( strnpcinfo(0) )+"::OnRedDead" );
    'blue = bg_create( 'map$, 142,51, instance_npcname( strnpcinfo(0) )+"::OnBlueQuit", instance_npcname( strnpcinfo(0) )+"::OnBlueDead" );
    callfunc "F_ShuffleNumbers", 0, getvariableofnpc( .minplayer2start, 'main$ ) *2 -1, .@r;
    for ( .@i = 0; .@i < getvariableofnpc( .size, 'main$ ); ++.@i ) {
        attachrid getvariableofnpc( getd( ".aid["+ .@r[.@i] +"]" ), 'main$ );
        bg_join ( .@i % 2 )? 'red : 'blue;
    }
    detachrid;
    bg_warp 'red, 'map$, 171,346;
    bg_warp 'blue, 'map$, 162,50;
    setwall 'map$, 164,347, 6, 4, 0, "bg_emp_red"+ 'red;
    setwall 'map$, 154,51, 6, 4, 0, "bg_emp_blue"+ 'blue;
    sleep 6000;
    instance_announce 0, "The rules are simple. The first team to break the opponent's Emperium wins!", bc_map;
    sleep 3000;
    for ( .@i = 5; .@i > 0; --.@i ) {
        instance_announce 0, "["+ .@i +"]", bc_map;
        sleep 1000;
    }
    instance_announce 0, "Start!", bc_map;
    bg_monster 'red, 'map$, 171,346, "--ja--",1915, instance_npcname( strnpcinfo(0) )+"::OnRedDown";
    bg_monster 'blue, 'map$, 162,50, "--ja--",1914, instance_npcname( strnpcinfo(0) )+"::OnBlueDown";
    delwall "bg_emp_red"+ 'red;
    delwall "bg_emp_blue"+ 'blue;
    sleep getvariableofnpc( .eventlasting, 'main$ ) * 1000;
    killmonster 'map$, instance_npcname( strnpcinfo(0) )+"::OnRedDown";
    killmonster 'map$, instance_npcname( strnpcinfo(0) )+"::OnBlueDown";
    if ( 'winside ) {
        instance_announce 0, "- "+( ('winside == 'red)? "Red" : "Blue" )+" Team is victorious! -", bc_map;
        bg_get_data 'winside, 1;
        for ( .@i = 0; .@i < $@arenamemberscount; ++.@i )
            getitem getvariableofnpc( .rewarditem[0], 'main$ ), getvariableofnpc( .rewarditem[1], 'main$ ), $@arenamembers[.@i];
    } else
        instance_announce 0, "- The match has ended in a draw! -", bc_map;
    sleep 5000;
    bg_warp 'red, "prontera", 155,182;
    bg_warp 'blue, "prontera", 158,182;
    bg_destroy 'red;
    bg_destroy 'blue;
    instance_destroy;
    end;
OnRedDown:  callsub L_EmpDown, "Red", 'blue;
OnBlueDown: callsub L_EmpDown, "Blue", 'red;
L_EmpDown:
    instance_announce 0, strcharinfo(0) +" has destroyed "+ getarg(0) +" Team's Emperium.", bc_map;
    'winside = getarg(1);
    awake instance_npcname( strnpcinfo(0) );
    end;
OnRedDead:
OnBlueDead:
    sleep2 1250;
    percentheal 100,100;
    end;
OnRedQuit:  callsub L_Quit, 'red, "Red", 'blue;
OnBlueQuit: callsub L_Quit, 'blue, "Blue", 'red;
L_Quit:
    bg_leave;
    percentheal 100, 100;
    if ( !bg_get_data( getarg(0), 0 ) ) {
        instance_announce 0, "All "+ getarg(1) +" team members have quit!", bc_map, 0xff3333;
        'winside = getarg(2);
        awake instance_npcname( strnpcinfo(0) );
    }
    end;
}
bat_a02 mapflag battleground
bat_a02 mapflag nosave  SavePoint
bat_a02 mapflag nowarp
bat_a02 mapflag nowarpto
bat_a02 mapflag noteleport
bat_a02 mapflag nomemo
bat_a02 mapflag nopenalty
bat_a02 mapflag nobranch
bat_a02 mapflag noicewall
Viewed 1120 times, submitted by AnnieRuru.