Advertisement
lokpurple

Untitled

Sep 19th, 2014
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.93 KB | None | 0 0
  1. //===== eAthena Script ============================================
  2. //= Scuffle Event
  3. //===== By: =======================================================
  4. //= AnnieRuru
  5. //===== Current Version: ==========================================
  6. //= 2.1
  7. //===== Compatible With: ==========================================
  8. //= hercules 2014-09-04
  9. //===== Description: ==============================================
  10. //= randomly pick 2 active players and put them to fight .. for reward
  11. //===== Topic =====================================================
  12. //= http://hercules.ws/board/topic/4746-
  13. //===== Additional Comments: ======================================
  14. //= first, randomly pick players and register via '@scuffle'.
  15. //= those players quick enough to register will get in the ring.
  16. //= then, its Last Man Standing. Winner get prize.
  17. //=================================================================
  18.  
  19. // callfunc "shuffle", <start index>, <last index>, <output array>{, <count> };
  20. function script shuffle__ {
  21. .@static = getarg(0);
  22. .@range = getarg(1) +1 - .@static;
  23. .@count = getarg(3, 0);
  24. if ( .@range <= 0 )
  25. return 0;
  26. if ( !.@count || .@count > .@range )
  27. .@count = .@range;
  28. while ( .@i < .@count ) {
  29. .@r = .@save = rand( .@i, .@range -1 ) ;
  30. if ( !.@tmp1[.@i] ) {
  31. .@r = .@tmp1[.@r] ? .@tmp2[.@r] : .@r;
  32. .@tmp2[.@i] = .@r;
  33. .@tmp2[.@save] = .@i;
  34. .@tmp1[.@save] = 1;
  35. set getelementofarray( getarg(2), .@i ), .@r + .@static;
  36. if ( .@save < .@count )
  37. set getelementofarray( getarg(2), .@save ), .@i + .@static;
  38. }
  39. .@i++;
  40. }
  41. return .@count;
  42. }
  43.  
  44. - script scuffle -1,{
  45. OnInit:
  46. .minpick = 4; // how many players are picked for the registration for this scuffle
  47. .picktime = 60; // how long does the registration time needed for the players to type @scuffle to get into the ring. 60 = 60 seconds
  48.  
  49. .players = 2; // how many players are quick enough to get in the ring for this scuffle
  50. .lasting = 10*60; // how long will the duel last ... in seconds ... 10*60 = 10 minutes
  51.  
  52. .idle = 60; // only pick those who were active in last 60 seconds for this scuffle
  53. .level = 55; // only pick those who are higher than this level for this scuffle
  54. .map$ = "guild_vs2"; // use an empty map and small enough for this scuffle
  55. setarray .reward, 502,3, 501,1; // reward to the winner
  56. bindatcmd "scuffle", strnpcinfo(0)+"::OnJoin", 0,100;
  57.  
  58. setarray .@mapflag,
  59. mf_pvp,
  60. mf_pvp_noparty,
  61. mf_pvp_noguild,
  62. mf_nowarp,
  63. mf_nowarpto,
  64. mf_nomemo,
  65. mf_nosave,
  66. mf_noreturn,
  67. mf_noteleport,
  68. mf_noicewall,
  69. mf_nopenalty;
  70. .@mf_size = getarraysize( .@mapflag );
  71. for ( .@i = 0; .@i < .@mf_size; .@i++ )
  72. setmapflag .map$, .@mapflag[.@i];
  73. mapwarp .map$, "prontera", 150,150;
  74. .rewardsize = getarraysize(.reward);
  75. end;
  76. OnClock0000: // Configure time here ...
  77. OnClock0600:
  78. OnClock1200:
  79. OnClock1800:
  80. .start = 1;
  81. mapwarp .map$, "prontera", 150,150;
  82. announce "[Scuffle] Event has started ! Now randomly picking players to join.", bc_all;
  83. getmemberaid ALL_CLIENT;
  84. callfunc "shuffle__", 0, $@onlinecount -1, .@r;
  85. freeloop 1;
  86. .@i = 0;
  87. while ( .@i < $@onlinecount ) {
  88. attachrid $@onlineaid[ .@r[.@i] ];
  89. 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
  90. // if (1) { // for debug
  91. .pickcid[.picknum] = getcharid(0);
  92. .pickaid[.picknum] = getcharid(3);
  93. .@pickip$ = .@pickip$ +"#"+ getcharip() +"#";
  94. .picknum++;
  95. if ( .picknum == .minpick )
  96. break;
  97. }
  98. .@i++;
  99. }
  100. .@pickip$ = "";
  101. freeloop 0;
  102. if ( .picknum == .minpick ) {
  103. for ( .@i = 0; .@i < .picknum; .@i++ ) {
  104. attachrid .pickaid[.@i];
  105. dispbottom "[Scuffle] You have been picked for the scuffle. Type '@scuffle' to get into the ring !";
  106. }
  107. }
  108. else {
  109. announce "[Scuffle] Event can't find enough players to fill in.", bc_all;
  110. deletearray .pickcid;
  111. deletearray .pickaid;
  112. .picknum = .start = 0;
  113. end;
  114. }
  115. sleep .picktime * 1000;
  116. if ( .duelnum < .players ) {
  117. announce "[Scuffle] Event can't start because these selected players are not registering.", bc_all;
  118. deletearray .pickcid;
  119. deletearray .pickaid;
  120. deletearray .duelcid;
  121. deletearray .duelaid;
  122. deletearray .duelname$;
  123. .picknum = .start = .duelnum = 0;
  124. end;
  125. }
  126. deletearray .pickcid;
  127. deletearray .pickaid;
  128. .picknum = 0;
  129. .start = 2;
  130. announce "[Scuffle] has started between ["+ implode( .duelname$, "] and [" )+"] !", bc_all;
  131. for ( .@i = 0; .@i < .players; .@i++ ) {
  132. getmapxy .@map$, .@x, .@y, 0, .duelname$[.@i];
  133. .duelmap$[.@i] = .@map$;
  134. .duelx[.@i] = .@x;
  135. .duely[.@i] = .@y;
  136. warpchar .map$, 0,0, .duelcid[.@i];
  137. }
  138. sleep .lasting * 1000;
  139. if ( .duelnum > 1 ) {
  140. announce "[Scuffle] has drag on for too long, nobody wins ...", bc_all;
  141. for ( .@i = 0; .@i < .duelnum; .@i++ )
  142. warpchar .duelmap$[.@i], .duelx[.@i], .duely[.@i], .duelcid[.@i];
  143. }
  144. else {
  145. announce "[Scuffle] has a winner ! "+ .duelname$ +" won !", bc_all;
  146. for ( .@i = 0; .@i < .rewardsize; .@i += 2 )
  147. getitem .reward[.@i], .reward[.@i +1], .duelaid;
  148. warpchar .duelmap$, .duelx, .duely, .duelcid;
  149. }
  150. deletearray .duelaid;
  151. deletearray .duelcid;
  152. deletearray .duelname$;
  153. deletearray .duelmap$;
  154. deletearray .duelx;
  155. deletearray .duely;
  156. .duelnum = .start = 0;
  157. end;
  158. OnJoin:
  159. if ( !.start ) {
  160. dispbottom "[Scuffle] Event has ended.";
  161. end;
  162. }
  163. if ( .start == 2 ) {
  164. dispbottom "[Scuffle] Event has started.";
  165. end;
  166. }
  167. for ( .@i = 0; .@i < .picknum; .@i++ )
  168. if ( getcharid(0) == .pickcid[.@i] )
  169. break;
  170. if ( .@i == .picknum ) {
  171. dispbottom "[Scuffle] You are not picked for this event.";
  172. end;
  173. }
  174. dispbottom "[Scuffle] You are now registered for this event.";
  175. .duelcid[.duelnum] = getcharid(0);
  176. .duelaid[.duelnum] = getcharid(3);
  177. .duelname$[.duelnum] = strcharinfo(0);
  178. .duelnum++;
  179. detachrid;
  180. for ( .@i = 0; .@i < .duelnum; .@i++ ) {
  181. if ( isloggedin( .duelaid[.@i], .duelcid[.@i] ) ) {
  182. attachrid .duelaid[.@i];
  183. if ( getmapflag( strcharinfo(3), mf_nowarp ) || getmapflag( strcharinfo(3), mf_nowarpto ) ) {
  184. dispbottom "[Scuffle] You are disqualified for this event because you went into another map.";
  185. deletearray .duelcid[.@i], 1;
  186. deletearray .duelaid[.@i], 1;
  187. deletearray .duelname$[.@i], 1;
  188. .duelnum--;
  189. .@i--;
  190. }
  191. else if ( checkvending() ) {
  192. dispbottom "[Scuffle] You are disqualified for this event because you open a shop.";
  193. deletearray .duelcid[.@i], 1;
  194. deletearray .duelaid[.@i], 1;
  195. deletearray .duelname$[.@i], 1;
  196. .duelnum--;
  197. .@i--;
  198. }
  199. else if ( checkchatting() ) {
  200. dispbottom "[Scuffle] You are disqualified for this event because you open a pub.";
  201. deletearray .duelcid[.@i], 1;
  202. deletearray .duelaid[.@i], 1;
  203. deletearray .duelname$[.@i], 1;
  204. .duelnum--;
  205. .@i--;
  206. }
  207. }
  208. else {
  209. deletearray .duelcid[.@i], 1;
  210. deletearray .duelaid[.@i], 1;
  211. deletearray .duelname$[.@i], 1;
  212. .duelnum--;
  213. .@i--;
  214. }
  215. }
  216. if ( .duelnum < .players ) {
  217. announce "[Scuffle] event now having "+ .duelnum +" participant.", bc_all;
  218. // announce "[Scuffle] event now having "+ .duelnum +" participant and they are "+ implode( .duelname$, "," ), bc_all;
  219. end;
  220. }
  221. awake strnpcinfo(0);
  222. end;
  223. OnPCLogoutEvent:
  224. OnPCDieEvent:
  225. if ( strcharinfo(3) != .map$ ) end;
  226. while ( getcharid(3) != .duelaid[.@i] && .@i < .duelnum ) .@i++;
  227. if ( .@i == .duelnum ) end;
  228. mapannounce .map$, "[Scuffle] "+ strcharinfo(0) +" has knock out from the ring !", bc_map;
  229. warpchar .duelmap$[.@i], .duelx[.@i], .duely[.@i], .duelcid[.@i];
  230. deletearray .duelaid[.@i], 1;
  231. deletearray .duelcid[.@i], 1;
  232. deletearray .duelname$[.@i], 1;
  233. deletearray .duelmap$[.@i], 1;
  234. deletearray .duelx[.@i], 1;
  235. deletearray .duely[.@i], 1;
  236. .duelnum--;
  237. if ( .duelnum == 1 )
  238. awake strnpcinfo(0);
  239. end;
  240. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement