Advertisement
ywkls

Save Point

Aug 31st, 2020
37
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int START_SAVE_POINT = 1;
  2.  
  3. //! The physical save station.
  4. //! D0 : Each station needs a unique ID, ranging from 1 to 10.
  5. //! The script is set up to allow up to a total of ten save stations using the menus.
  6.  
  7. ffc script Save_Point{
  8. void run(int station_number){
  9. bool pressed;
  10. int choice;
  11. if(station_number==START_SAVE_POINT){
  12. if(Screen->D[station_number]==0){
  13. SaveGame(station_number);
  14. SaveDMap();
  15. Screen->D[station_number]=1;
  16. }
  17. }
  18. while ( true ) {
  19. while ( !pressed && !Tango_MenuIsActive() ) {
  20. if (LinkCollision(this)){
  21. if ( PressExamine() ) {
  22. pressed = true;
  23. DampButton(BUTTON_EX1);
  24. }
  25. DampButton(BUTTON_EX3);
  26. DampButton(BUTTON_EX4);
  27. }
  28. Waitframe();
  29. }
  30.  
  31. if ( pressed ) {
  32. pressed = false;
  33. //Set coordinates for this station:
  34. choice = SavePointMenu(station_number);
  35. }
  36. Waitframe(); //Main while loop.
  37. }
  38. }
  39. }
  40.  
  41. //Menu called by the save station ffc.
  42. int SavePointMenu(int station_id) {
  43. int lineBreak[]="@26";
  44. int line1[]="@choice(1)Save@26";
  45. int line2[]="@choice(2)Save and Quit@26";
  46. int line3[]="@choice(3)Cancel";
  47. int initmenu[]="@domenu(1)@suspend()";
  48.  
  49. if ( station_id ) {
  50. SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_1, 32, 16, SIZE_SMALL);
  51. Tango_LoadString(WINDOW_SLOT_1, line1);
  52. Tango_AppendString(WINDOW_SLOT_1, line2);
  53. Tango_AppendString(WINDOW_SLOT_1, line3);
  54. Tango_AppendString(WINDOW_SLOT_1, initmenu);
  55. Tango_ActivateSlot(WINDOW_SLOT_1);
  56. }
  57.  
  58. while(!Tango_MenuIsActive())
  59. Waitframe();
  60.  
  61. // Save the state again...
  62. int slotState[278];
  63. int menuState[960];
  64. int cursorPos;
  65. Tango_SaveSlotState(WINDOW_SLOT_1, slotState);
  66. Tango_SaveMenuState(menuState);
  67.  
  68. int done = 0;
  69. int choice;
  70. while(true){
  71.  
  72. while( Tango_MenuIsActive() ) {
  73. cursorPos=Tango_GetMenuCursorPosition();
  74. Link->Jump=0;
  75. Waitframe();
  76. }
  77.  
  78. choice = Tango_GetLastMenuChoice();
  79. if ( choice == 1) { // Save the game
  80. SaveGame(station_id);
  81. SaveDMap();
  82. Game->PlaySound(SFX_SAVE_SUCCESS);
  83. int text[]="Game Saved";
  84. Tango_ClearSlot(2);
  85. ShowString(text, WINDOW_SLOT_2, WINDOW_STYLE_2, 48, 32);
  86. done = -9999;
  87. }
  88. else if ( choice == 2 ) { //Save and quit
  89. Game->PlaySound(SFX_SAVE_SUCCESS);
  90. SaveDMap();
  91. SaveGameAndQuit(station_id);
  92. done = choice;
  93. }
  94. else if ( choice == 3)//Cancel
  95. done = -9999;
  96.  
  97. if ( done )
  98. break;
  99. // return choice;
  100. else {
  101. Tango_RestoreSlotState(WINDOW_SLOT_1, slotState);
  102. Tango_RestoreMenuState(menuState);
  103. Tango_SetMenuCursorPosition(cursorPos);
  104. }
  105. }
  106.  
  107. Tango_ClearSlot(WINDOW_SLOT_1);
  108. return done;
  109. }
  110.  
  111. //Saves DMap and Screen Data to array.
  112. void SaveDMap(){
  113. if(DestinyVars[CURRENT_OVERWORLD]==LABRYNNA_OVERWORLD){
  114. DestinyVars[SAVE_X_LABRYNNA]= Link->X;
  115. DestinyVars[SAVE_Y_LABRYNNA]= Link->Y;
  116. DestinyVars[SAVE_DMAP_LABRYNNA] = Game->GetCurDMap();
  117. DestinyVars[SAVE_SCREEN_LABRYNNA] = Game->GetCurDMapScreen();
  118. }
  119. else if(DestinyVars[CURRENT_OVERWORLD]==MIRROR_OVERWORLD){
  120. DestinyVars[SAVE_X_MIRROR] = Link->X;
  121. DestinyVars[SAVE_Y_MIRROR] = Link->Y;
  122. DestinyVars[SAVE_DMAP_MIRROR] = Game->GetCurDMap();
  123. DestinyVars[SAVE_SCREEN_MIRROR] = Game->GetCurDMapScreen();
  124. }
  125. }
  126.  
  127. //Saving the game automation.
  128. void SaveGame(int station_id){
  129. SetGameSavePoint(station_id);
  130. Game->Save();
  131. }
  132.  
  133. //Save and quit automation.
  134. void SaveGameAndQuit(int station_id){
  135. SetGameSavePoint(station_id);
  136. Game->Save();
  137. Game->End();
  138. }
  139.  
  140. void SetStyleSize(int style, int size)
  141. {
  142. if(size==SIZE_SMALL)
  143. {
  144. Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
  145. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 59380);
  146. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 10);
  147. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 3);
  148.  
  149. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 160);
  150. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 48);
  151. //Tango_SetStyleAttribute(style, TANGO_STYLE_FLAGS, TANGO_FLAG_FREEZE_SCREEN);
  152.  
  153. }
  154. else if (size==SIZE_MEDIUM)
  155. {
  156. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 59280);
  157. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 10);
  158. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 5);
  159.  
  160. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 160);
  161. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 80);
  162. //Tango_SetStyleAttribute(style, TANGO_STYLE_FLAGS, TANGO_FLAG_FREEZE_SCREEN);
  163. }
  164. else if(size == SIZE_LARGE)
  165. {
  166. Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
  167. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 59280);
  168. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 8);
  169. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 6);
  170.  
  171. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 112);
  172. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 96);
  173.  
  174. //Tango_SetStyleAttribute(style, TANGO_STYLE_FLAGS, TANGO_FLAG_FREEZE_SCREEN);
  175. }
  176. else if(size == SIZE_WIDE){
  177. Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
  178. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 52260);
  179. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 11);
  180. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 3);
  181.  
  182. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 176);
  183. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 48);
  184. }
  185. else if(size == SIZE_TALL){
  186. Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
  187. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 52260);
  188. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 11);
  189. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 6);
  190.  
  191. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 176);
  192. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 80);
  193. }
  194. else{
  195. Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
  196. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 52360);
  197. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 10);
  198. Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 3);
  199.  
  200. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 160);
  201. Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 80);
  202. }
  203. }
  204.  
  205. //Tango Menu Init
  206. void SetUpWindow(int slot, int style, int x, int y, int size)
  207. {
  208. SetStyleSize(style, size);
  209. Tango_ClearSlot(slot);
  210. Tango_SetSlotStyle(slot, style);
  211. Tango_SetSlotPosition(slot, x, y);
  212. }
  213.  
  214. //Quick way to drop a string into a Tango dialogue box.
  215. void ShowString(int string, int slot, int style, int x, int y)
  216. {
  217. SetUpWindow(slot, style, x, y, SIZE_SMALL);
  218. Tango_LoadString(slot, string);
  219. Tango_ActivateSlot(slot);
  220. while(Tango_SlotIsActive(slot))
  221. Waitframe();
  222. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement