Advertisement
ywkls

Ring System

Jun 10th, 2021
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int GameVars[65536];
  2.  
  3. const int RING_COUNT = 53;//How many rings you have
  4. const int RING_SET = 54;//What ring is equipped
  5. const int RING_TILE = 1000;//First index to store ring tiles
  6. const int RING_CSET = 1010;//First index to store ring Csets
  7. const int RING_OBTAINED = 1020;//Frist index to store ring ids
  8.  
  9. const int NUM_RINGS = 9;//Max number of rings you can get.
  10. //Due to how things work in arrays, this is one less than actual max
  11. const int RING_MESSAGE = 507;//First of ten messages describing rings
  12.  
  13. void RingSystem(){
  14. int ring_set = GameVars[RING_SET];//Save what ring is equipped
  15. int old_ring= GameVars[RING_OBTAINED+ring_set];//Save item id of ring
  16. int ring= old_ring;//Store separately for later comparison
  17. int RingMessage[]= "Press left or right to change equipped ring";//It's a string!
  18. //You have a ring
  19. if(GameVars[RING_COUNT]){
  20. int Message[256];//Buffer for loading messages
  21. int string;//Message to load
  22. //You press right
  23. if(Link->PressRight){
  24. //Damp inputs
  25. Link->PressRight= false;
  26. Link->InputRight= false;
  27. //Cycle through all indices
  28. do{
  29. ring_set++;
  30. if(ring_set==NUM_RINGS+1)//You've reached the end of the available indices
  31. ring_set=0;//Set back to start
  32. }
  33. while(!GameVars[RING_OBTAINED+ring_set])
  34. //Reset ring id to new value
  35. ring= GameVars[RING_OBTAINED+ring_set];
  36. Game->PlaySound(SFX_MENU_SELECT);
  37. }
  38. //You press left
  39. else if(Link->PressLeft){
  40. Link->PressLeft= false;
  41. Link->InputLeft= false;
  42. do{
  43. ring_set--;
  44. if(ring_set==-1)//If you go below zero
  45. ring_set=NUM_RINGS;//Set to max ring
  46. }
  47. while(!GameVars[RING_OBTAINED+ring_set])
  48. ring= GameVars[RING_OBTAINED+ring_set];
  49. Game->PlaySound(SFX_MENU_SELECT);
  50. }
  51. //The ring id has changed
  52. if(ring!=old_ring){
  53. //Take away old ring
  54. Link->Item[old_ring]= false;
  55. //Give new ring
  56. Link->Item[ring]= true;
  57. }
  58. //Determine what index to point to
  59. GameVars[RING_SET]= ring_set;
  60. //Determine what message to point to
  61. string= RING_MESSAGE+ring_set;
  62. //Load message into buffer
  63. GetMessage(string, Message);
  64. //You have assigned a ring
  65. if(GameVars[RING_SET]!=-1){
  66. //Draw decscription of ring
  67. Screen->DrawString(1,24,4,FONT_GBLA,0x08,0x69,TF_NORMAL,Message,128);
  68. //Draw tile of ring
  69. Screen->FastTile(1,28,19,GameVars[RING_TILE+ring_set],
  70. GameVars[RING_CSET+ring_set],OP_OPAQUE);
  71. }
  72. //You have more than one ring
  73. if(GameVars[RING_COUNT]>=2)
  74. //Display a string
  75. Screen->DrawString(1,8,136,FONT_GBLA,0x08,0x69,TF_NORMAL,RingMessage,128);
  76. }
  77. }
  78.  
  79. //D0- Message to show
  80. //D1- Index of array to store data
  81. // 0-Number of Rings
  82. //D2- Tile of ring
  83. //D3- CSet of ring
  84. //D4- Item id of ring
  85.  
  86. item script Ring_Item{
  87. void run(int message, int ring, int tile, int cset,int ring_id){
  88. GameVars[RING_OBTAINED+ring]= ring_id;
  89. GameVars[RING_TILE+ring]= tile;
  90. GameVars[RING_CSET+ring]= cset;
  91. GameVars[RING_COUNT]++;
  92. GameVars[RING_SET]= ring;
  93. Screen->Message(message);
  94. }
  95. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement