Advertisement
Guest User

Untitled

a guest
Nov 17th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.44 KB | None | 0 0
  1. // GPC Online Library
  2. // bejeweled_2_endless_mode_auto-play.gpc
  3.  
  4. /* =====================================================================
  5. * BEJEWELED 2 ENDLESS MODE AUTO-PLAY
  6. *
  7. * Authors: BuckSatan
  8. *
  9. * Version: 1.0
  10. *
  11. * Overview:
  12. * Automates gameplay so that you can complete Endless Mode with the
  13. * click of a single button. Probably not fast or smart enough for
  14. * other modes.
  15. *
  16. * Details:
  17. * Clicking Right-Stick will toggle auto-play mode on/off. Auto-play
  18. * begins by moving the game cursor to a bottom corner position. It
  19. * will then try swapping the current jewel with both the adjacent
  20. * jewel and the one above before moving to the adjacent position.
  21. * When the end of the row is reached, auto-play attempts to swap
  22. * only with the jewel above, then moves up and reverses direction.
  23. * When all moves have been exhausted, auto-play returns to a bottom-
  24. * corner position and the whole process repeats. This pattern
  25. * ensures the whole board will be thoroughly checked for moves and
  26. * tends to find moves closer to the bottom first for the possiblity
  27. * of better cascades.
  28. *
  29. * Please note--clicking Right-Stick to disable Auto-Play will only
  30. * take effect once the current row is completely processed.
  31. * ===================================================================== */
  32.  
  33.  
  34. //
  35. // DEFINES
  36. // --------------------------------------------------------------------
  37.  
  38. // Bejeweled Board Dimensions
  39. define NUM_ROWS = 8; // Rows on Bejeweled Board
  40. define LAST_ROW = 7; // Last Row Number
  41. define NUM_COLS = 8; // Columns on Bejeweled Board
  42. define LAST_COL = 7; // Last Column Number
  43.  
  44. // Movement Control
  45. define LEFT_TO_RIGHT = 0; // Traverse Row Left->Right
  46. define RIGHT_TO_LEFT = 1; // Traverse Row Right->Left
  47.  
  48. // Timings
  49. define THOLD_MOVE = 40; // Time to hold move active
  50. define TWAIT_MOVE = 40; // Time to wait between moves
  51. define THOLD_SWAP = 40; // Time to hold swap active
  52. define TWAIT_SWAP = 800; // Time to wait between swaps
  53.  
  54.  
  55. //
  56. // DATA SEGMENT
  57. // --------------------------------------------------------------------
  58. // (none required)
  59.  
  60.  
  61. //
  62. // REMAPPINGS
  63. // --------------------------------------------------------------------
  64. // (none required)
  65.  
  66.  
  67. //
  68. // VARIABLES
  69. // --------------------------------------------------------------------
  70. int auto_play = 0; // Toggle Auto-Play
  71. int curr_row = NUM_ROWS; // Current Row Position
  72. int curr_col = NUM_COLS; // Current Column Position
  73. int direction = LEFT_TO_RIGHT; // Direction to move/match
  74. int h_button = XB360_LEFT; // Button to use for horizonal
  75. int v_button = XB360_DOWN; // Button to use for vertical
  76.  
  77.  
  78. //
  79. // INITIALIZATION
  80. // --------------------------------------------------------------------
  81. // (none required)
  82.  
  83.  
  84. //
  85. // MAIN
  86. // --------------------------------------------------------------------
  87. main {
  88.  
  89. // Toggle Activate Auto-Play
  90. if (event_press(XB360_RS)) {
  91. auto_play = !auto_play;
  92.  
  93.  
  94. // De-Activate AutoPlay if already running
  95. if (combo_running(AutoPlay)) {
  96. combo_stop(AutoPlay)
  97. }
  98. }
  99.  
  100. // Activate when toggle set
  101. if (auto_play) {
  102. combo_run(AutoPlay)
  103. }
  104. }
  105.  
  106.  
  107. //
  108. // COMBOS
  109. // --------------------------------------------------------------------
  110.  
  111. // Move One Position to the Left or Right
  112. combo MoveHorizontal {
  113. set_val(h_button, 100);
  114. wait(THOLD_MOVE);
  115. set_val(h_button, 0);
  116. wait(TWAIT_MOVE);
  117. }
  118.  
  119.  
  120. // Move One Position Up or Down
  121. combo MoveVertical {
  122. set_val(v_button, 100);
  123. wait(THOLD_MOVE);
  124. set_val(v_button, 0);
  125. wait(TWAIT_MOVE);
  126. }
  127.  
  128.  
  129. // Swap Current Jewel to the Left or Right
  130. combo SwapHorizontal {
  131. set_val(XB360_A, 100);
  132. wait(THOLD_SWAP);
  133. set_val(h_button, 100);
  134. wait(THOLD_SWAP);
  135. set_val(XB360_A, 0);
  136. set_val(h_button, 0);
  137. wait(TWAIT_SWAP);
  138. }
  139.  
  140.  
  141. // Swap Current Jewel with Above
  142. combo SwapUp {
  143. set_val(XB360_A, 100);
  144. wait(THOLD_SWAP);
  145. set_val(XB360_UP, 100);
  146. wait(THOLD_SWAP);
  147. set_val(XB360_A, 0);
  148. set_val(XB360_UP, 0);
  149. wait(TWAIT_SWAP);
  150. }
  151.  
  152.  
  153. // Traverse Middle or Bottom Row
  154. combo TraverseRow {
  155.  
  156. // Reset Horizontal Direction
  157. if (direction == LEFT_TO_RIGHT) {
  158. h_button = XB360_RIGHT;
  159. } else {
  160. h_button = XB360_LEFT;
  161. }
  162.  
  163. // Column 1
  164. call (SwapHorizontal);
  165. call (SwapUp);
  166. call (MoveHorizontal);
  167.  
  168. // Column 2
  169. call (SwapHorizontal);
  170. call (SwapUp);
  171. call (MoveHorizontal);
  172.  
  173. // Column 3
  174. call (SwapHorizontal);
  175. call (SwapUp);
  176. call (MoveHorizontal);
  177.  
  178. // Column 4
  179. call (SwapHorizontal);
  180. call (SwapUp);
  181. call (MoveHorizontal);
  182.  
  183. // Column 5
  184. call (SwapHorizontal);
  185. call (SwapUp);
  186. call (MoveHorizontal);
  187.  
  188. // Column 6
  189. call (SwapHorizontal);
  190. call (SwapUp);
  191. call (MoveHorizontal);
  192.  
  193. // Column 7
  194. call (SwapHorizontal);
  195. call (SwapUp);
  196. call (MoveHorizontal);
  197.  
  198. // Column 8
  199. call (SwapUp);
  200. call (MoveVertical);
  201.  
  202. // Reverse Direction
  203. if (direction == LEFT_TO_RIGHT) {
  204. direction = RIGHT_TO_LEFT;
  205. } else {
  206. direction = LEFT_TO_RIGHT;
  207. }
  208. }
  209.  
  210.  
  211. // Traverse Top Row
  212. combo TraverseTopRow {
  213.  
  214. // Reset Horizontal Direction
  215. if (direction == LEFT_TO_RIGHT) {
  216. h_button = XB360_RIGHT;
  217. } else {
  218. h_button = XB360_LEFT;
  219. }
  220.  
  221. // Column 1
  222. call (SwapHorizontal);
  223. call (MoveHorizontal);
  224.  
  225. // Column 2
  226. call (SwapHorizontal);
  227. call (MoveHorizontal);
  228.  
  229. // Column 3
  230. call (SwapHorizontal);
  231. call (MoveHorizontal);
  232.  
  233. // Column 4
  234. call (SwapHorizontal);
  235. call (MoveHorizontal);
  236.  
  237. // Column 5
  238. call (SwapHorizontal);
  239. call (MoveHorizontal);
  240.  
  241. // Column 6
  242. call (SwapHorizontal);
  243. call (MoveHorizontal);
  244.  
  245. // Column 7
  246. call (SwapHorizontal);
  247. call (MoveHorizontal);
  248.  
  249. // Column 8
  250. // (nothing left to do)
  251. }
  252.  
  253.  
  254. // Main Auto-Play Sequence
  255. combo AutoPlay {
  256.  
  257. // ------------------------------
  258. // Return Home
  259. // ------------------------------
  260.  
  261. // Set Horizontal Direction
  262. if (direction == LEFT_TO_RIGHT) {
  263. h_button = XB360_LEFT;
  264. } else {
  265. h_button = XB360_RIGHT;
  266. }
  267.  
  268. // Set Vertical Direction
  269. v_button = XB360_DOWN;
  270.  
  271. // Return Horizontal
  272. call (MoveHorizontal); // 1
  273. call (MoveHorizontal); // 2
  274. call (MoveHorizontal); // 3
  275. call (MoveHorizontal); // 4
  276. call (MoveHorizontal); // 5
  277. call (MoveHorizontal); // 6
  278. call (MoveHorizontal); // 7
  279.  
  280. // Return Vertical
  281. call (MoveVertical); // 1
  282. call (MoveVertical); // 2
  283. call (MoveVertical); // 3
  284. call (MoveVertical); // 4
  285. call (MoveVertical); // 5
  286. call (MoveVertical); // 6
  287. call (MoveVertical); // 7
  288.  
  289. // Reset Vertical Direction
  290. v_button = XB360_UP;
  291.  
  292.  
  293. // ------------------------------
  294. // Traverse Rows
  295. // ------------------------------
  296. call (TraverseRow); // Row 1
  297. call (TraverseRow); // Row 2
  298. call (TraverseRow); // Row 3
  299. call (TraverseRow); // Row 4
  300. call (TraverseRow); // Row 5
  301. call (TraverseRow); // Row 6
  302. call (TraverseRow); // Row 7
  303. call (TraverseTopRow); // Row 8
  304. }
  305.  
  306.  
  307. //
  308. // FUNCTIONS
  309. // --------------------------------------------------------------------
  310. // (none required)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement