Advertisement
Capuche

Queue_bg_on_official

May 8th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.84 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Queue Battleground
  3. //===== By: ==================================================
  4. //= Capuche
  5. //===== Current Version: =====================================
  6. //= 1.0
  7. //===== Compatible With: =====================================
  8. //= rAthena SVN
  9. //===== Description: =========================================
  10. //= A sample queue system to register in official bg.
  11. //= Diff of official bg at the end of the script.
  12. //============================================================
  13.  
  14. bat_room,178,162,5 script Register BG 56,{
  15. function CheckPlayerBg; function RegisterBg;
  16.  
  17. if( @side_tmp ) {
  18. mes "You already are on the waiting line...";
  19. mes "You have ^FF0000"+ ( getd( ".signup_count_"+ .name_bg$[ @bg_type ] + @side_tmp ) -1 ) +"^000000 People(s) before you.";
  20. close;
  21. }
  22. mes "Would you like to compete ?";
  23. next;
  24. if( select( "Let's do it!", "no thanks" ) -1 ) close;
  25. if( .random_bg ) // Random BG ?
  26. .@s = .random_bg;
  27. else {
  28. mes "Select the bg.";
  29. .@s = select( .menu_bg$ ) -1;
  30. }
  31. if( getd( ".random_"+ .name_bg$[.@s] ) ) // random team ? Croix or Guillaume
  32. @side_tmp = .@side = ( getd( ".signup_count_"+ .name_bg$[.@s] +"1" ) == getd( ".min_size_"+ .name_bg$[.@s] ) ? 2 : ( getd( ".signup_count_"+ .name_bg$[.@s] +"2" ) == getd( ".min_size_"+ .name_bg$[.@s] ) ? 1 : rand( 1,2 ) ) );
  33. else
  34. @side_tmp = .@side = select( ( getd( ".signup_count_"+ .name_bg$[.@s] + "1" ) == getd( ".min_size_"+ .name_bg$[.@s] ) ? "" : "Croix side" ), ( getd( ".signup_count_"+ .name_bg$[.@s] + "2" ) == getd( ".min_size_"+ .name_bg$[.@s] ) ? "" : "Guillaume side" ) );
  35.  
  36. setd ".signup_aid_"+ .name_bg$[.@s] + .@side +"["+ getd( ".signup_count_"+ .name_bg$[.@s] + .@side ) +"]", getcharid(3);
  37. setd ".signup_count_"+ .name_bg$[.@s] + .@side, getd( ".signup_count_"+ .name_bg$[.@s] + .@side ) +1;
  38. CheckPlayerBg(); // Just clean the array queue
  39. @bg_type = .@s;
  40. switch( .@s ){
  41. case 0: donpcevent "start#bat_b01::OnReadyCheck"; break;
  42. case 1: donpcevent "start#bat_a01::OnReadyCheck"; break;
  43. case 2: donpcevent "KvM01_BG::OnReadyCheck";
  44. }
  45. close;
  46.  
  47.  
  48. // Functions Part
  49. // --------------
  50.  
  51. // Assign a BG ID to the player when the bg start
  52. // Delete aid and the count of players in the array queue
  53.  
  54. function RegisterBg {
  55. .@s = getarg(0);
  56. for( .@i = 0; .@i < getd( ".min_size_"+ .name_bg$[.@s] ); .@i++ ) {
  57. setbgid getarg(1), getd( ".signup_aid_"+ .name_bg$[.@s] +"1[" +.@i +"]" );
  58. setbgid getarg(2), getd( ".signup_aid_"+ .name_bg$[.@s] +"2[" +.@i +"]" );
  59. }
  60. deletearray getd( ".signup_aid_"+ .name_bg$[.@s] +"1" ), getd( ".min_size_"+ .name_bg$[.@s] );
  61. deletearray getd( ".signup_aid_"+ .name_bg$[.@s] +"2" ), getd( ".min_size_"+ .name_bg$[.@s] );
  62. setd ".signup_count_"+ .name_bg$[.@s] +"1", getd( ".signup_count_"+ .name_bg$[.@s] +"1" ) - getd( ".min_size_"+ .name_bg$[.@s] );
  63. setd ".signup_count_"+ .name_bg$[.@s] +"2", getd( ".signup_count_"+ .name_bg$[.@s] +"2" ) - getd( ".min_size_"+ .name_bg$[.@s] );
  64. if( .random_bg ) .random_bg = rand( 1,.size_bg );
  65. end;
  66. }
  67.  
  68. // clear the array
  69. // send the player's position to his character in the bg queue
  70.  
  71. function CheckPlayerBg {
  72. for( .@side = 1; .@side < 3; .@side++ ) {
  73. for( .@j = 0; .@j < .size_bg; .@j++ ) {
  74. for ( set .@i, 0; .@i < getd( ".signup_count_"+ .name_bg$[.@j] + .@side ); set .@i, .@i +1 ) {
  75. if ( getd( ".signup_aid_"+ .name_bg$[.@j] + .@side +"["+.@i+"]" ) != getarg( 0,1 ) && attachrid( getd( ".signup_aid_"+ .name_bg$[.@j] + .@side +"["+.@i+"]" ) ) ) {
  76. if ( getmapflag( strcharinfo(3), mf_battleground ) ) { // has join another bg, just in case
  77. deletearray getd( ".signup_aid_"+ .name_bg$[.@j] + .@side +"["+.@i+"]" ), 1;
  78. setd ".signup_count_"+ .name_bg$[.@j] + .@side, getd( ".signup_count_"+ .name_bg$[.@j] + .@side ) -1;
  79. @bg_type = @side_tmp = 0;
  80. .@i--;
  81. }
  82. else {
  83. dispbottom "You have ^FF0000"+ ( getd( ".signup_count_"+ .name_bg$[.@j] + .@side ) - .@i -1 ) +"^000000 Peoples before you.";
  84. @bg_type = .@j;
  85. @side_tmp = .@side;
  86. }
  87. }
  88. else {
  89. deletearray getd( ".signup_aid_"+ .name_bg$[.@j] + .@side +"["+.@i+"]" ), 1;
  90. setd ".signup_count_"+ .name_bg$[.@j] + .@side, getd( ".signup_count_"+ .name_bg$[.@j] + .@side ) -1;
  91. .@i--;
  92. }
  93. }
  94. }
  95. }
  96. return;
  97. }
  98.  
  99.  
  100.  
  101. // Event Part
  102. // ----------
  103.  
  104. OnFlaviusStart:
  105. $@FlaviusBG1_id2 = createbgid( "bat_b01",390,10,"start#bat_b01::OnCroixQuit","" );
  106. $@FlaviusBG1_id1 = createbgid( "bat_b01",10,290,"start#bat_b01::OnGuillaumeQuit","" );
  107. RegisterBg( 0, $@FlaviusBG1_id1, $@FlaviusBG1_id2 ); // ( bg index in .name_bg$ ) ( bg1 id ) ( bg2 id )
  108.  
  109. OnTierraStart:
  110. $@TierraBG1_id1 = createbgid( "bat_a01",50,374,"start#bat_a01::OnGuillaumeQuit","" );
  111. $@TierraBG1_id2 = createbgid( "bat_a01",42,16,"start#bat_a01::OnCroixQuit","" );
  112. RegisterBg( 1, $@TierraBG1_id1, $@TierraBG1_id2 );
  113.  
  114. OnKvMStart:
  115. $@KvM01BG_id1 = createbgid( "bat_c01",52,129,"KvM01_BG::OnGuillaumeQuit","KvM01_BG::OnGuillaumeDie" );
  116. $@KvM01BG_id2 = createbgid( "bat_c01",147,55,"KvM01_BG::OnCroixQuit","KvM01_BG::OnCroixDie" );
  117. RegisterBg( 2, $@KvM01BG_id1, $@KvM01BG_id2 );
  118.  
  119. OnPCLogoutEvent:
  120. CheckPlayerBg( getcharid(3) ); // Clear the array queue and delete the aid
  121. end;
  122.  
  123. OnPCLoadMapEvent:
  124. if( compare( strcharinfo(3), "bat_" ) || strcharinfo(3) == strnpcinfo(4) )
  125. @bg_type = @side_tmp = 0;
  126. end;
  127. OnInit:
  128. .random_bg = 0; // random bg ( 1 : random, 0 : choice bg )
  129.  
  130. .random_Flavius = 1; // Flavius random ? ( 1 : random, 0 : choice ) - if 1 the player has no choice he is sent in a random team
  131. .random_Tierra = 1; // Tierra random ?
  132. .random_KvM = 1; // KvM random ?
  133.  
  134. .min_size_Flavius = 1; // number min of players to start Flavius - must be the SAME in the flavius setting in the svn
  135. .min_size_KvM = 1; // Tierra
  136. .min_size_Tierra = 1; // KvM
  137.  
  138. setarray .name_bg$, "Flavius", "Tierra", "KvM"; // Menu + is used to set the variables. Don't touch if you don't know what you do.
  139.  
  140. // Others - no need to touch
  141. setmapflag "bat_a01",mf_loadevent; // mapflag to clear the @ bg variables
  142. setmapflag "bat_b01",mf_loadevent;
  143. setmapflag "bat_c01",mf_loadevent;
  144. setmapflag strnpcinfo(4),mf_loadevent;
  145.  
  146. mapannounce strnpcinfo(4), "An admin had reload please re-enregister.",0;
  147. mapwarp strnpcinfo(4),"prontera",150,150,0; // to clear the @ bg variables when @reload
  148.  
  149. .size_bg = getarraysize( .name_bg$ );
  150. .menu_bg$ = implode( .name_bg$, ":" );
  151. if( .random_bg ) .random_bg = rand( 1,.size_bg );
  152. end;
  153. }
  154.  
  155. /*
  156.  
  157. Index: npc/battleground/flavius/flavius01.txt
  158. ===================================================================
  159. --- npc/battleground/flavius/flavius01.txt (révision 17251)
  160. +++ npc/battleground/flavius/flavius01.txt (copie de travail)
  161. @@ -22,21 +22,22 @@
  162. //============================================================
  163. bat_room,86,227,4 script Lieutenant Ator 418,{
  164. end;
  165. -OnInit:
  166. - waitingroom "Battle Station",11,"start#bat_b01::OnReadyCheck",1,0,80;
  167. - end;
  168. +// OnInit:
  169. + // waitingroom "Battle Station",2,"start#bat_b01::OnReadyCheck",1,0,80;
  170. + // end;
  171. OnEnterBG:
  172. - set $@FlaviusBG1_id1, waitingroom2bg("bat_b01",10,290,"start#bat_b01::OnGuillaumeQuit","");
  173. + // set $@FlaviusBG1_id1, waitingroom2bg("bat_b01",10,290,"start#bat_b01::OnGuillaumeQuit","");
  174. end;
  175. }
  176.  
  177. bat_room,85,204,0 script Lieutenant Thelokus 414,{
  178. end;
  179. -OnInit:
  180. - waitingroom "Battle Station",11,"start#bat_b01::OnReadyCheck",1,0,80;
  181. - end;
  182. +// OnInit:
  183. + // waitingroom "Battle Station",11,"start#bat_b01::OnReadyCheck",1,0,80;
  184. + // end;
  185. OnEnterBG:
  186. - set $@FlaviusBG1_id2, waitingroom2bg("bat_b01",390,10,"start#bat_b01::OnCroixQuit","");
  187. + // set $@FlaviusBG1_id2, waitingroom2bg("bat_b01",390,10,"start#bat_b01::OnCroixQuit","");
  188. + donpcevent "Register BG::OnFlaviusStart";
  189. end;
  190. }
  191.  
  192. @@ -79,13 +80,15 @@
  193. OnReadyCheck:
  194. if( $@FlaviusBG1 )
  195. end;
  196. - set .@Guillaume, getwaitingroomstate(0,"Lieutenant Ator");
  197. - set .@Croix, getwaitingroomstate(0,"Lieutenant Thelokus");
  198. +// set .@Guillaume, getwaitingroomstate(0,"Lieutenant Ator");
  199. +// set .@Croix, getwaitingroomstate(0,"Lieutenant Thelokus");
  200. + set .@Croix, getvariableofnpc( .signup_count_Flavius1, "Register BG" );
  201. + set .@Guillaume, getvariableofnpc( .signup_count_Flavius2, "Register BG" );
  202. if( !.@Guillaume && !.@Croix ) {
  203. donpcevent "#bat_b01_timer::OnStop";
  204. end;
  205. }
  206.  
  207. Index: npc/battleground/kvm/kvm01.txt
  208. ===================================================================
  209. --- npc/battleground/kvm/kvm01.txt (révision 17251)
  210. +++ npc/battleground/kvm/kvm01.txt (copie de travail)
  211. @@ -24,12 +24,12 @@
  212. bat_room,169,226,5 script KVM Waiting Room#a::KvM01R_Guillaume 418,{
  213. end;
  214.  
  215. -OnInit:
  216. - waitingroom "Battle Station 5 Players",6,"KvM01_BG::OnGuillaumeJoin",1;
  217. - end;
  218. +// OnInit:
  219. + // waitingroom "Battle Station 5 Players",6,"KvM01_BG::OnGuillaumeJoin",1;
  220. + // end;
  221.  
  222. OnEnterBG:
  223. - set $@KvM01BG_id1, waitingroom2bg("bat_c01",52,129,"KvM01_BG::OnGuillaumeQuit","KvM01_BG::OnGuillaumeDie");
  224. + // set $@KvM01BG_id1, waitingroom2bg("bat_c01",52,129,"KvM01_BG::OnGuillaumeQuit","KvM01_BG::OnGuillaumeDie");
  225. end;
  226. }
  227.  
  228. @@ -38,12 +38,13 @@
  229. bat_room,169,205,3 script KVM Waiting Room#b::KvM01R_Croix 414,{
  230. end;
  231.  
  232. -OnInit:
  233. - waitingroom "Battle Station 5 Players",6,"KvM01_BG::OnCroixJoin",1;
  234. - end;
  235. +// OnInit:
  236. + // waitingroom "Battle Station 5 Players",6,"KvM01_BG::OnCroixJoin",1;
  237. + // end;
  238.  
  239. OnEnterBG:
  240. - set $@KvM01BG_id2, waitingroom2bg("bat_c01",147,55,"KvM01_BG::OnCroixQuit","KvM01_BG::OnCroixDie");
  241. + // set $@KvM01BG_id2, waitingroom2bg("bat_c01",147,55,"KvM01_BG::OnCroixQuit","KvM01_BG::OnCroixDie");
  242. + donpcevent "Register BG::OnKvMStart";
  243. end;
  244. }
  245.  
  246. @@ -173,10 +174,12 @@
  247. OnReadyCheck:
  248. if( $@KvM01BG )
  249. end;
  250. - set .@Guillaume, getwaitingroomstate(0,"KvM01R_Guillaume");
  251. - set .@Croix, getwaitingroomstate(0,"KvM01R_Croix");
  252. + // set .@Guillaume, getwaitingroomstate(0,"KvM01R_Guillaume");
  253. + // set .@Croix, getwaitingroomstate(0,"KvM01R_Croix");
  254. + set .@Croix, getvariableofnpc( .signup_count_KvM1, "Register BG" );
  255. + set .@Guillaume, getvariableofnpc( .signup_count_KvM2, "Register BG" );
  256.  
  257. Index: npc/battleground/tierra/tierra01.txt
  258. ===================================================================
  259. --- npc/battleground/tierra/tierra01.txt (révision 17251)
  260. +++ npc/battleground/tierra/tierra01.txt (copie de travail)
  261. @@ -23,24 +23,25 @@
  262. bat_room,57,227,5 script Lieutenant Kalos 418,{
  263. end;
  264.  
  265. -OnInit:
  266. - waitingroom "Battle Station",11,"start#bat_a01::OnReadyCheck",1,0,80;
  267. - end;
  268. +// OnInit:
  269. + // waitingroom "Battle Station",11,"start#bat_a01::OnReadyCheck",1,0,80;
  270. + // end;
  271.  
  272. OnEnterBG:
  273. - set $@TierraBG1_id1, waitingroom2bg("bat_a01",50,374,"start#bat_a01::OnGuillaumeQuit","");
  274. + // set $@TierraBG1_id1, waitingroom2bg("bat_a01",50,374,"start#bat_a01::OnGuillaumeQuit","");
  275. end;
  276. }
  277.  
  278. bat_room,58,204,1 script Lieutenant Eyor 414,{
  279. end;
  280.  
  281. -OnInit:
  282. - waitingroom "Battle Station",11,"start#bat_a01::OnReadyCheck",1,0,80;
  283. - end;
  284. +// OnInit:
  285. + // waitingroom "Battle Station",11,"start#bat_a01::OnReadyCheck",1,0,80;
  286. + // end;
  287.  
  288. OnEnterBG:
  289. - set $@TierraBG1_id2, waitingroom2bg("bat_a01",42,16,"start#bat_a01::OnCroixQuit","");
  290. + // set $@TierraBG1_id2, waitingroom2bg("bat_a01",42,16,"start#bat_a01::OnCroixQuit","");
  291. + donpcevent "Register BG::OnTierraStart";
  292. end;
  293. }
  294.  
  295. @@ -127,13 +128,15 @@
  296. OnReadyCheck:
  297. if( $@TierraBG1 )
  298. end;
  299. - set .@Guillaume, getwaitingroomstate(0,"Lieutenant Kalos");
  300. - set .@Croix, getwaitingroomstate(0,"Lieutenant Eyor");
  301. + // set .@Guillaume, getwaitingroomstate(0,"Lieutenant Kalos");
  302. + // set .@Croix, getwaitingroomstate(0,"Lieutenant Eyor");
  303. + set .@Croix, getvariableofnpc( .signup_count_Tierra1, "Register BG" );
  304. + set .@Guillaume, getvariableofnpc( .signup_count_Tierra2, "Register BG" );
  305. if( !.@Guillaume && !.@Croix ) {
  306. donpcevent "#bat_a01_timer::OnStop";
  307. end;
  308. }
  309.  
  310. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement