viewing paste topic/4746- scuffle-event | 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
-   script  scuffle -1,{
OnInit:
    .players = 2; // how many players are select for the scuffle
    .idle = 30; // only pick those who were active in last 30 seconds for this scuffle
    .level = 55; // only pick those who are higher than this level for this scuffle
    .map$ = "guild_vs2"; // use an empty map and small enough for this scuffle
    .lasting = 10 *60; // how long will the duel last ... in seconds ...
    setarray .reward, 502,3, 501,1; // reward to the winner
 
    setarray .@mapflag,
        mf_pvp,
        mf_pvp_noparty,
        mf_pvp_noguild,
        mf_nowarp,
        mf_nowarpto,
        mf_nomemo,
        mf_nosave,
        mf_noreturn,
        mf_noteleport,
        mf_noicewall,
        mf_nopenalty;
    .@mf_size = getarraysize( .@mapflag );
    for ( .@i = 0; .@i < .@mf_size; .@i++ )
        setmapflag .map$, .@mapflag[.@i];
    mapwarp .map$, "prontera", 150,150;
    .rewardsize = getarraysize(.reward);
    end;
OnClock0000: // time to start ...
OnClock0315:
OnClock0600:
OnClock0900:
    .@nb = query_sql( "select account_id, name from `char` where online = 1 order by rand() limit 100", .@aid, .@name$ );
    for ( .@i = 0; .@i < .@nb; .@i++ ) {
        attachrid .@aid[.@i];
        if ( !checkvending() && !checkchatting() && !getmapflag( strcharinfo(3), mf_nowarp ) && !getmapflag( strcharinfo(3), mf_nowarpto ) && !getgmlevel() && checkidle() < .idle && BaseLevel >= .level ) { // not vendor, not inside an event map and excluding GMs
            .@duelid[.@c] = .@aid[.@i];
            .@duelname$[.@c] = .@name$[.@i];
            .@c++;
            if ( .@c == .players ) {
                break;
            }
        }
    }
    if ( .@c < .players ) end; // can't even find enough players
    announce "["+ implode( .@duelname$, "] and [" )+"] has started a scuffle", bc_all;
    for ( .@i = 0; .@i < .players; .@i++ ) {
        .duel[.@i] = .@duelid[.@i];
        getmapxy .@map$, .@x, .@y, 0, .@duelname$[.@i];
        .duelmap$[.@i] = .@map$;
        .duelx[.@i] = .@x;
        .duely[.@i] = .@y;
        attachrid .@duelid[.@i];
        warp .map$, 0,0;
    }
    sleep .lasting * 1000;
    .@size = getarraysize( .duel );
    if ( .@size > 1 ) {
        announce "The scuffle drag on for too long, nobody wins", bc_all;
        for ( .@i = 0; .@i < .@size; .@i++ ) {
            attachrid .duel[.@i];
            warp .duelmap$[.@i], .duelx[.@i], .duely[.@i];
        }
    }
    else {
        attachrid .duel;
        announce strcharinfo(0) +" won the scuffle !", bc_all;
        for ( .@i = 0; .@i < .rewardsize; .@i += 2 )
            getitem .reward[.@i], .reward[.@i +1];
        warp .duelmap$, .duelx, .duely;
    }
    deletearray .duel;
    deletearray .duelmap$;
    deletearray .duelx;
    deletearray .duely;
    end;
OnPCLogoutEvent:
OnPCDieEvent:
    if ( strcharinfo(3) != .map$ ) end;
    while ( getcharid(3) != .duel[.@i] && .@i < .players ) .@i++;
    if ( .@i == .players ) end;
    attachrid .duel[.@i];
    warp .duelmap$[.@i], .duelx[.@i], .duely[.@i];
    deletearray .duel[.@i], 1;
    deletearray .duelmap$[.@i], 1;
    deletearray .duelx[.@i], 1;
    deletearray .duely[.@i], 1;
    if ( getarraysize( .duel ) > 1 ) end;
    awake strnpcinfo(0);
    end;
}
Viewed 1229 times, submitted by AnnieRuru.