ywkls

Ring System with Multiple Slots

Jun 11th, 2021
21
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int NUM_RINGS = 9;
  2. const int RING_MESSAGE = 507;
  3.  
  4. void RingSystem(){
  5. int ring_slot= GameVars[RING_SLOT];
  6. int ring_set = GameVars[RING_SET];
  7. int ring_set2= GameVars[RING_SET+1];
  8. int ring_set3= GameVars[RING_SET+2];
  9. int old_ring= GameVars[RING_SET];
  10. int ring= old_ring;
  11. int old_ring2= GameVars[RING_OBTAINED+1];
  12. int ring2= old_ring2;
  13. int old_ring3= GameVars[RING_OBTAINED+2];
  14. int ring3= old_ring3;
  15. int BoxDn[]= "Press A to increase slot";
  16. int BoxUp[]= "Press B to decrease slot";
  17. int RingMessage[]= "Press left or right to change equipped ring";
  18. int ring_id;
  19. if(GameVars[RING_COUNT]){
  20. int Message[256];
  21. int string;
  22. int Message2[256];
  23. int string2;
  24. int Message3[256];
  25. int string3;
  26. if(Link->PressRight){
  27. Link->PressRight= false;
  28. Link->InputRight= false;
  29. do{
  30. if(!ring_slot){
  31. ring_set++;
  32. if(ring_set>=NUM_RINGS+1)
  33. ring_set=0;
  34. if(GameVars[RING_SET+1]!=-1){
  35. if(ring_set==ring_set2){
  36. ring_set++;
  37. if(ring_set>=NUM_RINGS+1)
  38. ring_set=0;
  39. }
  40. if(GameVars[RING_SET+2]!=-1){
  41. if(ring_set==ring_set3){
  42. ring_set++;
  43. if(ring_set>=NUM_RINGS+1)
  44. ring_set=0;
  45. }
  46. }
  47. }
  48. ring_id= ring_set;
  49.  
  50. }
  51. else if(ring_slot==1){
  52. ring_set2++;
  53. if(ring_set==ring_set2){
  54. ring_set2++;
  55. if(ring_set2>=NUM_RINGS+1)
  56. ring_set2=0;
  57. if(GameVars[RING_SET+2]!=-1){
  58. if(ring_set2==ring_set3){
  59. ring_set2++;
  60. if(ring_set2>=NUM_RINGS+1)
  61. ring_set2=0;
  62. }
  63. }
  64. ring_id= ring_set2;
  65. }
  66. else if(ring_slot==2){
  67. ring_set3++;
  68. if(ring_set==ring_set3){
  69. ring_set3++;
  70. if(ring_set2==ring_set3){
  71. ring_set3++;
  72. if(ring_set3>=NUM_RINGS+1)
  73. ring_set3=0;
  74. ring_id= ring_set3
  75. }
  76. }
  77. while(!GameVars[RING_OBTAINED+ring_id])
  78. ring= GameVars[RING_OBTAINED+ring_set];
  79. ring2= GameVars[RING_OBTAINED+ring_set2];
  80. ring3= GameVars[RING_OBTAINED+ring_set3];
  81. Game->PlaySound(SFX_MENU_SELECT);
  82. }
  83. else if(Link->PressLeft){
  84. Link->PressLeft= false;
  85. Link->InputLeft= false;
  86. do{
  87. if(!ring_slot){
  88. ring_set--;
  89. if(ring_set<=-1)
  90. ring_set=NUM_RINGS;
  91. if(GameVars[RING_SET+1]!=-1){
  92. if(ring_set==ring_set2){
  93. ring_set--;
  94. if(ring_set<=-1)
  95. ring_set=NUM_RINGS;
  96. }
  97. if(GameVars[RING_SET+2]!=-1){
  98. if(ring_set==ring_set3){
  99. ring_set--;
  100. if(ring_set<=-1)
  101. ring_set=NUM_RINGS;
  102. }
  103. }
  104. }
  105. ring_id= ring_set;
  106.  
  107. }
  108. else if(ring_slot==1){
  109. ring_set2--;
  110. if(ring_set==ring_set2){
  111. ring_set2--;
  112. if(ring_set2<=-1)
  113. ring_set2=NUM_RINGS;
  114. if(GameVars[RING_SET+2]!=-1){
  115. if(ring_set2==ring_set3){
  116. ring_set2--;
  117. if(ring_set2<=-1)
  118. ring_set2=NUM_RINGS;
  119. }
  120. }
  121. ring_id= ring_set2;
  122. }
  123. else if(ring_slot==2){
  124. ring_set3--;
  125. if(ring_set==ring_set3){
  126. ring_set3--;
  127. if(ring_set2==ring_set3){
  128. ring_set3--;
  129. if(ring_set3<=-1)
  130. ring_set3=NUM_RINGS;
  131. ring_id= ring_set3
  132. }
  133. }
  134. while(!GameVars[RING_OBTAINED+ring_id])
  135. ring= GameVars[RING_OBTAINED+ring_set];
  136. ring2= GameVars[RING_OBTAINED+ring_set2];
  137. ring3= GameVars[RING_OBTAINED+ring_set3];
  138. Game->PlaySound(SFX_MENU_SELECT);
  139. }
  140. if(Link->PressA){
  141. Link->PressA= false;
  142. Link->InputA= false;
  143. if(GameVars[RING_COUNT]>=2){
  144. if(GameVars[RING_COUNT]==2){
  145. ring_slot++;
  146. if(ring_slot>=2)
  147. ring_slot=0;
  148. GameVars[RING_SLOT]= ring_slot;
  149. }
  150. else if(GameVars[RING_COUNT]>=3){
  151. ring_slot++;
  152. if(ring_slot>=3)
  153. ring_slot=0;
  154. GameVars[RING_SLOT]= ring_slot;
  155. }
  156. Game->PlaySound(SFX_PLACE);
  157. }
  158. }
  159. if(Link->PressB){
  160. Link->PressB= false;
  161. Link->InputB= false;
  162. if(GameVars[RING_COUNT]>=2){
  163. if(GameVars[RING_COUNT]==2){
  164. ring_slot--;
  165. if(ring_slot<=-1)
  166. ring_slot=2;
  167. GameVars[RING_SLOT]= ring_slot;
  168. }
  169. else if(GameVars[RING_COUNT]>=3){
  170. ring_slot--;
  171. if(ring_slot<=-1)
  172. ring_slot=3;
  173. GameVars[RING_SLOT]= ring_slot;
  174. }
  175. Game->PlaySound(SFX_PLACE);
  176. }
  177. }
  178. if(ring!=old_ring){
  179. Link->Item[old_ring]= false;
  180. Link->Item[ring]= true;
  181. }
  182. if(ring2!=old_ring2){
  183. Link->Item[old_ring2]= false;
  184. Link->Item[ring2]= true;
  185. }
  186. if(ring3!=old_ring3){
  187. Link->Item[old_ring3]= false;
  188. Link->Item[ring3]= true;
  189. }
  190. GameVars[RING_SET]= ring_set;
  191. GameVars[RING_SET+1]= ring_set2;
  192. GameVars[RING_SET+2]= ring_set3;
  193. string= RING_MESSAGE+ring_set;
  194. GetMessage(string, Message);
  195. string2= RING_MESSAGE+ring_set2;
  196. GetMessage(string2, Message2);
  197. string3= RING_MESSAGE+ring_set3;
  198. GetMessage(string3, Message3);
  199. if(GameVars[RING_SET]!=-1){
  200. Screen->DrawString(1,24,4,FONT_GBLA,0x08,0x69,TF_NORMAL,Message,128);
  201. Screen->FastTile(1,28,19,GameVars[RING_TILE+ring_set],
  202. GameVars[RING_CSET+ring_set],OP_OPAQUE);
  203. }
  204. if(GameVars[RING_SET+1]!=-1){
  205. Screen->DrawString(1,24,32,FONT_GBLA,0x08,0x69,TF_NORMAL,Message2,128);
  206. Screen->FastTile(1,28,47,GameVars[RING_TILE+ring_set2],
  207. GameVars[RING_CSET+ring_set2],OP_OPAQUE);
  208. }
  209. if(GameVars[RING_SET+2]!=-1){
  210. Screen->DrawString(1,24,60,FONT_GBLA,0x08,0x69,TF_NORMAL,Message3,128);
  211. Screen->FastTile(1,28,75,GameVars[RING_TILE+ring_set3],
  212. GameVars[RING_CSET+ring_set3],OP_OPAQUE);
  213. }
  214. if(GameVars[RING_COUNT]>=2){
  215. Screen->DrawString(1,8,136,FONT_GBLA,0x08,0x69,TF_NORMAL,RingMessage,128);
  216. Screen->DrawString(1,8,120,FONT_GBLA,0x08,0x69,TF_NORMAL,BoxDn,128);
  217. Screen->DrawString(1,8,128,FONT_GBLA,0x08,0x69,TF_NORMAL,BoxUp,128);
  218. if(GameVars[RING_SLOT]==0)
  219. Screen->FastTile(1,0,19,POINTER_TILE,
  220. POINTER_CSET,OP_OPAQUE);
  221. else if(GameVars[RING_SLOT]==1)
  222. Screen->FastTile(1,0,47,POINTER_TILE,
  223. POINTER_CSET,OP_OPAQUE);
  224. else if(GameVars[RING_SLOT]==2)
  225. Screen->FastTile(1,0,75,POINTER_TILE,
  226. POINTER_CSET,OP_OPAQUE);
  227. }
  228. }
  229. }
  230.  
  231. const int POINTER_CSET= 0;
  232. const int POINTER_TILE= 0;
RAW Paste Data Copied