Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== eAthena Script ============================================
- //= Scuffle Event
- //===== By: =======================================================
- //= AnnieRuru
- //===== Current Version: ==========================================
- //= 2.1
- //===== Compatible With: ==========================================
- //= hercules 2014-09-04
- //===== Description: ==============================================
- //= randomly pick 2 active players and put them to fight .. for reward
- //===== Topic =====================================================
- //= http://hercules.ws/board/topic/4746-
- //===== Additional Comments: ======================================
- //= first, randomly pick players and register via '@scuffle'.
- //= those players quick enough to register will get in the ring.
- //= then, its Last Man Standing. Winner get prize.
- //=================================================================
- // callfunc "shuffle", <start index>, <last index>, <output array>{, <count> };
- function script shuffle__ {
- .@static = getarg(0);
- .@range = getarg(1) +1 - .@static;
- .@count = getarg(3, 0);
- if ( .@range <= 0 )
- return 0;
- if ( !.@count || .@count > .@range )
- .@count = .@range;
- while ( .@i < .@count ) {
- .@r = .@save = rand( .@i, .@range -1 ) ;
- if ( !.@tmp1[.@i] ) {
- .@r = .@tmp1[.@r] ? .@tmp2[.@r] : .@r;
- .@tmp2[.@i] = .@r;
- .@tmp2[.@save] = .@i;
- .@tmp1[.@save] = 1;
- set getelementofarray( getarg(2), .@i ), .@r + .@static;
- if ( .@save < .@count )
- set getelementofarray( getarg(2), .@save ), .@i + .@static;
- }
- .@i++;
- }
- return .@count;
- }
- - script scuffle -1,{
- OnInit:
- .minpick = 4; // how many players are picked for the registration for this scuffle
- .picktime = 60; // how long does the registration time needed for the players to type @scuffle to get into the ring. 60 = 60 seconds
- .players = 2; // how many players are quick enough to get in the ring for this scuffle
- .lasting = 10*60; // how long will the duel last ... in seconds ... 10*60 = 10 minutes
- .idle = 60; // only pick those who were active in last 60 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
- setarray .reward, 502,3, 501,1; // reward to the winner
- bindatcmd "scuffle", strnpcinfo(0)+"::OnJoin", 0,100;
- 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: // Configure time here ...
- OnClock0600:
- OnClock1200:
- OnClock1800:
- .start = 1;
- mapwarp .map$, "prontera", 150,150;
- announce "[Scuffle] Event has started ! Now randomly picking players to join.", bc_all;
- getmemberaid ALL_CLIENT;
- callfunc "shuffle__", 0, $@onlinecount -1, .@r;
- freeloop 1;
- .@i = 0;
- while ( .@i < $@onlinecount ) {
- attachrid $@onlineaid[ .@r[.@i] ];
- if ( !checkvending() && !checkchatting() && !getmapflag( strcharinfo(3), mf_nowarp ) && !getmapflag( strcharinfo(3), mf_nowarpto ) && !getgmlevel() && checkidle() < .idle && BaseLevel >= .level && !compare( .@pickip$, "#"+ getcharip() +"#" ) ) { // not vendor, not inside an event map and excluding GMs
- // if (1) { // for debug
- .pickcid[.picknum] = getcharid(0);
- .pickaid[.picknum] = getcharid(3);
- .@pickip$ = .@pickip$ +"#"+ getcharip() +"#";
- .picknum++;
- if ( .picknum == .minpick )
- break;
- }
- .@i++;
- }
- .@pickip$ = "";
- freeloop 0;
- if ( .picknum == .minpick ) {
- for ( .@i = 0; .@i < .picknum; .@i++ ) {
- attachrid .pickaid[.@i];
- dispbottom "[Scuffle] You have been picked for the scuffle. Type '@scuffle' to get into the ring !";
- }
- }
- else {
- announce "[Scuffle] Event can't find enough players to fill in.", bc_all;
- deletearray .pickcid;
- deletearray .pickaid;
- .picknum = .start = 0;
- end;
- }
- sleep .picktime * 1000;
- if ( .duelnum < .players ) {
- announce "[Scuffle] Event can't start because these selected players are not registering.", bc_all;
- deletearray .pickcid;
- deletearray .pickaid;
- deletearray .duelcid;
- deletearray .duelaid;
- deletearray .duelname$;
- .picknum = .start = .duelnum = 0;
- end;
- }
- deletearray .pickcid;
- deletearray .pickaid;
- .picknum = 0;
- .start = 2;
- announce "[Scuffle] has started between ["+ implode( .duelname$, "] and [" )+"] !", bc_all;
- for ( .@i = 0; .@i < .players; .@i++ ) {
- getmapxy .@map$, .@x, .@y, 0, .duelname$[.@i];
- .duelmap$[.@i] = .@map$;
- .duelx[.@i] = .@x;
- .duely[.@i] = .@y;
- warpchar .map$, 0,0, .duelcid[.@i];
- }
- sleep .lasting * 1000;
- if ( .duelnum > 1 ) {
- announce "[Scuffle] has drag on for too long, nobody wins ...", bc_all;
- for ( .@i = 0; .@i < .duelnum; .@i++ )
- warpchar .duelmap$[.@i], .duelx[.@i], .duely[.@i], .duelcid[.@i];
- }
- else {
- announce "[Scuffle] has a winner ! "+ .duelname$ +" won !", bc_all;
- for ( .@i = 0; .@i < .rewardsize; .@i += 2 )
- getitem .reward[.@i], .reward[.@i +1], .duelaid;
- warpchar .duelmap$, .duelx, .duely, .duelcid;
- }
- deletearray .duelaid;
- deletearray .duelcid;
- deletearray .duelname$;
- deletearray .duelmap$;
- deletearray .duelx;
- deletearray .duely;
- .duelnum = .start = 0;
- end;
- OnJoin:
- if ( !.start ) {
- dispbottom "[Scuffle] Event has ended.";
- end;
- }
- if ( .start == 2 ) {
- dispbottom "[Scuffle] Event has started.";
- end;
- }
- for ( .@i = 0; .@i < .picknum; .@i++ )
- if ( getcharid(0) == .pickcid[.@i] )
- break;
- if ( .@i == .picknum ) {
- dispbottom "[Scuffle] You are not picked for this event.";
- end;
- }
- dispbottom "[Scuffle] You are now registered for this event.";
- .duelcid[.duelnum] = getcharid(0);
- .duelaid[.duelnum] = getcharid(3);
- .duelname$[.duelnum] = strcharinfo(0);
- .duelnum++;
- detachrid;
- for ( .@i = 0; .@i < .duelnum; .@i++ ) {
- if ( isloggedin( .duelaid[.@i], .duelcid[.@i] ) ) {
- attachrid .duelaid[.@i];
- if ( getmapflag( strcharinfo(3), mf_nowarp ) || getmapflag( strcharinfo(3), mf_nowarpto ) ) {
- dispbottom "[Scuffle] You are disqualified for this event because you went into another map.";
- deletearray .duelcid[.@i], 1;
- deletearray .duelaid[.@i], 1;
- deletearray .duelname$[.@i], 1;
- .duelnum--;
- .@i--;
- }
- else if ( checkvending() ) {
- dispbottom "[Scuffle] You are disqualified for this event because you open a shop.";
- deletearray .duelcid[.@i], 1;
- deletearray .duelaid[.@i], 1;
- deletearray .duelname$[.@i], 1;
- .duelnum--;
- .@i--;
- }
- else if ( checkchatting() ) {
- dispbottom "[Scuffle] You are disqualified for this event because you open a pub.";
- deletearray .duelcid[.@i], 1;
- deletearray .duelaid[.@i], 1;
- deletearray .duelname$[.@i], 1;
- .duelnum--;
- .@i--;
- }
- }
- else {
- deletearray .duelcid[.@i], 1;
- deletearray .duelaid[.@i], 1;
- deletearray .duelname$[.@i], 1;
- .duelnum--;
- .@i--;
- }
- }
- if ( .duelnum < .players ) {
- announce "[Scuffle] event now having "+ .duelnum +" participant.", bc_all;
- // announce "[Scuffle] event now having "+ .duelnum +" participant and they are "+ implode( .duelname$, "," ), bc_all;
- end;
- }
- awake strnpcinfo(0);
- end;
- OnPCLogoutEvent:
- OnPCDieEvent:
- if ( strcharinfo(3) != .map$ ) end;
- while ( getcharid(3) != .duelaid[.@i] && .@i < .duelnum ) .@i++;
- if ( .@i == .duelnum ) end;
- mapannounce .map$, "[Scuffle] "+ strcharinfo(0) +" has knock out from the ring !", bc_map;
- warpchar .duelmap$[.@i], .duelx[.@i], .duely[.@i], .duelcid[.@i];
- deletearray .duelaid[.@i], 1;
- deletearray .duelcid[.@i], 1;
- deletearray .duelname$[.@i], 1;
- deletearray .duelmap$[.@i], 1;
- deletearray .duelx[.@i], 1;
- deletearray .duely[.@i], 1;
- .duelnum--;
- if ( .duelnum == 1 )
- awake strnpcinfo(0);
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement