viewing paste topic/6990- bg_pvp_sign_map_0.1 | 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
-       script  sdkfksdfjsdfgdf -1,{
OnInit:
        .eventlasting = 30 * 60; // how long would the event last or it auto-reset. 30 *60 = 30 mins
        .min2start = 2; // minimum player to start
        .startingscore = 50; // score at start
        setarray .rewardwin, 501,10, 502,5, 503,3; // reward to winning team
        setarray .rewardlose, 501,5, 502,3, 503,1; // reward to losing team
 
        .rewardwinsize = getarraysize( .rewardwin );
        .rewardlosesize = getarraysize( .rewardlose );
        bindatcmd "joinbg", strnpcinfo(0)+"::OnJoin";
        bindatcmd "leavebg", strnpcinfo(0)+"::OnLeave";
        end;
OnLeave:
        while ( .signup_aid[.@i] != getcharid(3) && .@i < .signup_count )
                .@i++;
        if ( .@i == .signup_count ) {
                dispbottom "you not yet sign up in this event";
                end;
        }
        deletearray .signup_aid[.@i], 1;
        .signup_count--;
        dispbottom "You have leave the registration of this event";
        end;
OnJoin:
        if ( getmapflag( strcharinfo(3), mf_nowarp ) || getmapflag( strcharinfo(3), mf_nowarpto ) ) {
                dispbottom "you can't sign up for this event from the map you are in";
                end;
        }
        while ( .signup_aid[.@i] != getcharid(3) && .@i < .signup_count )
                .@i++;
        if ( .@i < .signup_count ) {
                dispbottom "you have already sign up in this event";
                end;
        }
        .signup_aid[ .signup_count ] = getcharid(3);
        .signup_count++;
        dispbottom "You are now signed to the BG event";
//      .@i = 1; // DEBUG
//      .@signup_name$ = rid2name( .signup_aid[0] );
//      while ( .signup_aid[.@i] ) {
//              .@signup_name$ = .@signup_name$ +","+ rid2name( .signup_aid[.@i] );
//              .@i++;
//      }
//      dispbottom "[Debug] Currently have "+ .signup_count +" sign-in and they are "+ .@signup_name$;
L_start:
        for ( .@i = 0; .@i < .signup_count; .@i++ ) {
                if ( attachrid( .signup_aid[.@i] ) ) {
                        if ( getmapflag( strcharinfo(3), mf_nowarp ) ) { // player has went into another event
                                deletearray .signup_aid[.@i], 1;
                        }
                }
                else {
                        deletearray .signup_aid[.@i], 1;
                        .signup_count--;
                        .@i--;
                }      
        }
        if ( .start || .signup_count < .min2start ) {
                announce "Currently there are "+ .signup_count +" players registered", bc_all;
                end;
        }
        announce "event started", bc_all;
        .start = 1;
        .map = rand(1,3);
        .red = createbgid( "guild_vs"+ .map, 20,50, strnpcinfo(0)+"::OnRedQuit", strnpcinfo(0)+"::OnRedDead" );
        .blue = createbgid( "guild_vs"+ .map, 80,50, strnpcinfo(0)+"::OnBlueQuit", strnpcinfo(0)+"::OnBlueDead" );
        callfunc "shuffle__", 0, .min2start -1, .@r;
        .@modulus = rand(2);
        for ( .@i = 0; .@i < .signup_count; .@i++ )
                setbgid ( .@i %2 == .@modulus )? .red : .blue, .signup_aid[ .@r[.@i] ];
        deletearray .signup_aid, .min2start;
        .signup_count -= .min2start;
        bg_warp .red, "guild_vs"+ .map, 20,50;
        bg_warp .blue, "guild_vs"+ .map, 80,50;
        .score[1] = .score[2] = .startingscore;
        bg_updatescore "guild_vs"+ .map, .score[1], .score[2];
        sleep .eventlasting * 1000;
        if ( .start == 1 ) {
                if ( .score[1] > .score[2] ) {
                        mapannounce "guild_vs"+ .map, " Red side wins !", bc_all;
                        callsub L_reward, .red, .rewardwin, .rewardwinsize;
                        callsub L_reward, .blue, .rewardlose, .rewardlosesize;
                }
                else if ( .score[1] < .score[2] ) {
                        mapannounce "guild_vs"+ .map, " Blue side wins !", bc_all;
                        callsub L_reward, .blue, .rewardwin, .rewardwinsize;
                        callsub L_reward, .red, .rewardlose, .rewardlosesize;
                }
                else {
                        mapannounce "guild_vs"+ .map, "Draw !", bc_all;
                        callsub L_reward, .red, .rewardlose, .rewardlosesize;
                        callsub L_reward, .blue, .rewardlose, .rewardlosesize;
                }
        }
        bg_warp .red, "prontera", 155,182;
        bg_warp .blue, "prontera", 158,182;
        bg_destroy .red;
        bg_destroy .blue;
        .start = .map = 0;
        deletearray .score;
        goto L_start;
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;
OnRedDead: callsub L_dead, 1;
OnBlueDead: callsub L_dead, 2;
L_dead:
        .score[ getarg(0) ]--;
        bg_updatescore "guild_vs"+ .map, .score[1], .score[2];
        if ( !.score[ getarg(0) ] )
                awake strnpcinfo(0);
        while ( checkcell( strcharinfo(3), .@x = rand(200), .@y = rand(200), cell_chknopass ) );
        bg_team_setxy getcharid(4), .@x, .@y;
        sleep2 1250;
        percentheal 100,100;
        if ( getmapflag( strcharinfo(3), mf_battleground ) )
                warp strcharinfo(3), 0,0;
        end;
OnRedQuit: callsub L_quit, 1, .red;
OnBlueQuit: callsub L_quit, 2, .blue;
L_quit:
        percentheal 100, 100;
        if ( bg_get_data( getarg(1), 0 ) ) end;
        mapannounce "guild_vs"+ .map, "All "+ .teamname$[ getarg(0) ] +" team members has Quit !", bc_all, 0xFF3333;
        .score[ getarg(0) ] = 0;
        awake strnpcinfo(0);
        end;
}
guild_vs1       mapflag battleground    2
guild_vs1       mapflag nosave  SavePoint
guild_vs1       mapflag nowarp
guild_vs1       mapflag nowarpto
guild_vs1       mapflag noreturn
guild_vs1       mapflag noteleport
guild_vs1       mapflag nomemo
guild_vs1       mapflag nopenalty
guild_vs1       mapflag nobranch
guild_vs1       mapflag noicewall
 
guild_vs2       mapflag battleground    2
guild_vs2       mapflag nosave  SavePoint
guild_vs2       mapflag nowarp
guild_vs2       mapflag nowarpto
guild_vs2       mapflag noreturn
guild_vs2       mapflag noteleport
guild_vs2       mapflag nomemo
guild_vs2       mapflag nopenalty
guild_vs2       mapflag nobranch
guild_vs2       mapflag noicewall
 
guild_vs3       mapflag battleground    2
guild_vs3       mapflag nosave  SavePoint
guild_vs3       mapflag nowarp
guild_vs3       mapflag nowarpto
guild_vs3       mapflag noreturn
guild_vs3       mapflag noteleport
guild_vs3       mapflag nomemo
guild_vs3       mapflag nopenalty
guild_vs3       mapflag nobranch
guild_vs3       mapflag noicewall
Viewed 1096 times, submitted by AnnieRuru.