Advertisement
ZoriaRPG

ZScript SavePoints for JudasRising v2

Dec 26th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 36.93 KB | None | 0 0
  1. //Save Points for JudasRising by ZoriaRPG
  2. //25th December, 2016
  3.  
  4. ///////////
  5. /// FFC ///
  6. ///////////
  7.  
  8.  
  9. //! The physical save station.
  10. //! D0 : Each station needs a unique ID, ranging from 1 to 20.
  11. //! D1 : The reill type to allow at this save point, where 0 == none, 1 == health only,
  12. //!         2 == ,agic only, and 3 == both health and magic.
  13. //! D2 : Set to '1' to allow warping from this station to another. Otherwise, set to 0.
  14. //! The script is set up to allow up to a total of twenty save stations using the menus.
  15. ffc script MetroidSaveStation{
  16.     void run(int station_number, int refill, int allow_warp){
  17.         bool pressed;
  18.         int choice;
  19.        
  20.        
  21.         while ( true ) {
  22.             //If this station is active...
  23.                 //Draw station ID.
  24.                 if ( WarpPointActive(station_number) && station_number ) {
  25.                     //Draw the station ID, firstthe background
  26.                     Screen->DrawInteger(    MET_SAVE_STATION_DRAW_ID_FONT_LAYER,
  27.                                 this->X + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_X_OFFSET,
  28.                                 this->Y + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_Y_OFFSET,
  29.                                 MET_SAVE_STATION_DRAW_ID_FONT,
  30.                                 MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_COLOUR, 0,
  31.                                 MET_SAVE_STATION_DRAW_ID_FONT_WIDTH,
  32.                                 MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT,
  33.                                 station_number, 0, OP_OPAQUE);
  34.                     //Then, the foreground...
  35.                     Screen->DrawInteger(    MET_SAVE_STATION_DRAW_ID_FONT_LAYER,
  36.                                 this->X + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_X_OFFSET,
  37.                                 this->Y + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_OFFSET,
  38.                                 MET_SAVE_STATION_DRAW_ID_FONT,
  39.                                 MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_COLOUR, 0,
  40.                                 MET_SAVE_STATION_DRAW_ID_FONT_WIDTH,
  41.                                 MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT,
  42.                                 station_number, 0, OP_OPAQUE);
  43.                 }
  44.                    
  45.                
  46.  
  47.                    
  48.                 //|| ( !Tango_MenuIsActive() && SamusCanTeleport() )
  49.             while ( ( !pressed && !Tango_MenuIsActive() ) ) {
  50.                 if ( DistX(this, SAVEPOINTS_DIST_X) && DistY(this, SAVEPOINTS_DIST_Y) && LinkFacing(this) ) {
  51.                     if  ( MET_SAVE_USE_BUTTON_R && Link->PressR ) { pressed = true; Link->PressR = false; Link->InputR = false; }
  52.                     if  ( MET_SAVE_USE_BUTTON_L && Link->PressL ) { pressed = true; Link->PressL = false; Link->InputL = false; }
  53.                     if  ( MET_SAVE_USE_BUTTON_A && Link->PressA ) { pressed = true; Link->PressA = false; Link->InputA = false; }
  54.                     if  ( MET_SAVE_USE_BUTTON_B && Link->PressB ) { pressed = true; Link->PressB = false; Link->InputB = false; }
  55.                     if  ( MET_SAVE_USE_BUTTON_EX1 && Link->PressEx1 ) { pressed = true; Link->PressEx1 = false; Link->InputEx1 = false; }
  56.                     if  ( MET_SAVE_USE_BUTTON_EX2 && Link->PressEx2 ) { pressed = true; Link->PressEx2 = false; Link->InputEx2 = false; }
  57.                     if  ( MET_SAVE_USE_BUTTON_EX3 && Link->PressEx3 ) { pressed = true; Link->PressEx3 = false; Link->InputEx3 = false; }
  58.                     if  ( MET_SAVE_USE_BUTTON_EX4 && Link->PressEx4 ) { pressed = true; Link->PressEx4 = false; Link->InputEx4 = false; }
  59.                     if  ( MET_SAVE_USE_BUTTON_START && Link->PressStart ) { pressed = true; Link->PressStart = false; Link->InputStart = false; }
  60.                     if  ( MET_SAVE_USE_BUTTON_MAP && Link->PressMap ) { pressed = true; Link->PressMap = false; Link->InputMap = false; }
  61.                
  62.                 }
  63.                 //If this station is active...
  64.                 //Draw station ID.
  65.                 if ( WarpPointActive(station_number) && station_number  ) {
  66.                     //Draw the station ID, firstthe background
  67.                     Screen->DrawInteger(    MET_SAVE_STATION_DRAW_ID_FONT_LAYER,
  68.                                 this->X + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_X_OFFSET,
  69.                                 this->Y + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_Y_OFFSET,
  70.                                 MET_SAVE_STATION_DRAW_ID_FONT,
  71.                                 MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_COLOUR, 0,
  72.                                 MET_SAVE_STATION_DRAW_ID_FONT_WIDTH,
  73.                                 MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT,
  74.                                 station_number, 0, OP_OPAQUE);
  75.                     //Then, the foreground...
  76.                     Screen->DrawInteger(    MET_SAVE_STATION_DRAW_ID_FONT_LAYER,
  77.                                 this->X + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_X_OFFSET,
  78.                                 this->Y + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_OFFSET,
  79.                                 MET_SAVE_STATION_DRAW_ID_FONT,
  80.                                 MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_COLOUR, 0,
  81.                                 MET_SAVE_STATION_DRAW_ID_FONT_WIDTH,
  82.                                 MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT,
  83.                                 station_number, 0, OP_OPAQUE);
  84.                 }
  85.                
  86.                 Waitframe();
  87.             }
  88.                
  89.             if ( pressed ) {
  90.                 pressed = false;
  91.                 //Set coordinates for this station:
  92.                
  93.                 if ( station_number ) SetWarpPoint(station_number,this);
  94.                
  95.                 //Activate this station if it is inactive
  96.                 if ( !WarpPointActive(station_number) && station_number )  WarpPointActive(station_number,true);
  97.                    
  98.                 //MetroidSaveStationMenu(int station_number);
  99.                
  100.                 //Do menu
  101.                 if ( !station_number && !refill ) choice = MetroidSaveStationMenu(station_number,3,allow_warp);
  102.                 else choice = MetroidSaveStationMenu(station_number,refill,allow_warp);
  103.  
  104.                 if ( choice < 0 && choice > -9999) {
  105.                    
  106.                     if ( DEBUG_WARPS ) {
  107.                         int debug1[]="The warp menu returned: ";
  108.                         TraceS(debug1); Trace(choice);
  109.                         int d2[]="Warping Samus...";
  110.                         TraceS(d2);
  111.                         int d3[]="Using Station ID: ";
  112.                         TraceS(d3); int c = choice*-1; Trace(c);
  113.                     }
  114.                    
  115.                     WarpSamus( (choice * -1), MET_WARP_EFFECT_DURATION );
  116.                 }
  117.                 //Do save, activate, or warp when menu returns
  118.                     //!No, handled by the manu.
  119.                
  120.             }
  121.             Waitframe(); //Main while loop.
  122.         }
  123.     }
  124. }
  125.  
  126.  
  127. //Array
  128. int SavePoints[214747];
  129.  
  130. //!Indices 0-5 are not used to store coordinates
  131.  
  132. const int MET_SAVE_LAST_SAVESTATION = 0; //ID of last    save station used. arr[0]
  133. const int ISWARPING = 1; //arr[1] :     Used by accessors
  134. const int FLASHINGGREEN = 2; //arr[2] : ...
  135. const int TELEPORTING = 3; //arr[3] :   ...
  136. const int ARRIVING = 4; //arr[4] :  ...
  137.  
  138. //Because we number stations starting at '1', array indices arr[5] through arr[10] are unused.
  139.  
  140. const int MET_SAVE_BASE = 5; // First index of save point values.
  141.                 //!     In reality, it is this, plus six, because we start Warp Station IDs at '1'.
  142. const int MET_SAVE_INDICES = 6; //Math. Indices used per set o hold warp station datum.
  143.  
  144. const int MET_SAVE_ID = 0; //Holds the ID of the point in game.
  145. const int MET_SAVE_DMAP = 1; //The DMAP for a given warp.
  146. const int MET_SAVE_SCREEN = 2; //The screen of a given warp.
  147. const int MET_SAVE_X = 3; //The X position to warp to.
  148. const int MET_SAVE_Y = 4; //The Y position to warp to.
  149. const int MET_SAVE_STATION_ACTIVE = 5; //The Y position to warp to.
  150.  
  151.  
  152. ////////////////
  153. /// Settings ///
  154. ////////////////
  155.  
  156. //Enable some save point menu settings globally.
  157. //Enable these to override all save point settings.
  158.  
  159. const int DEBUG_WARPS = 1;
  160.  
  161. const int SAVEPOINTS_ALLOW_WARPING = 0;
  162. const int SAVEPOINTS_ALLOW_REFILL = 0;
  163. const int SAVEPOINTS_REFILL_MAGIC = 0;
  164. const int SAVEPOINTS_REFILL_HP = 0;
  165.  
  166. const int SAVEPOINTS_DIST_X = 20;
  167. const int SAVEPOINTS_DIST_Y = 20;
  168.  
  169. const int HP_REFILL_RATE = 30;
  170. const int SFX_ETANK_REFILL = 60;
  171.  
  172. const int INITIAL_SCREEN = 58;
  173. const int INITIAL_DMAP = 06;
  174. const int INITIAL_X = 120;
  175. const int INITIAL_Y = 112;
  176.  
  177.  
  178. const int DEBUG_MENUS = 1; //Set to 1 to enable debugging. 0 to disable.
  179.  
  180. const int SFX_ERROR = 0; //Set to generic error sound.
  181.  
  182. const int MET_SAVE_NUMBER_OF_SAVEPOINTS = 20; //Set to the number of save points in the entire quest.
  183.  
  184. //Activation Buttons
  185. const int MET_SAVE_USE_BUTTON_A = 0; //Set any of these to '1' to allow trigering the save point with that button.
  186. const int MET_SAVE_USE_BUTTON_B = 0;
  187. const int MET_SAVE_USE_BUTTON_L = 0;
  188. const int MET_SAVE_USE_BUTTON_R = 0;
  189. const int MET_SAVE_USE_BUTTON_EX1 = 0;
  190. const int MET_SAVE_USE_BUTTON_EX2 = 1;
  191. const int MET_SAVE_USE_BUTTON_EX3 = 0;
  192. const int MET_SAVE_USE_BUTTON_EX4 = 1;
  193. const int MET_SAVE_USE_BUTTON_START = 1;
  194. const int MET_SAVE_USE_BUTTON_MAP = 0;
  195.  
  196. //Settings
  197. const int MET_WARP_EFFECT_DURATION = 60;  //Duration of warp special visuals.
  198.  
  199. const int MET_SAVE_STATION_REG = 9; //Screen->D[reg]
  200. const int MET_SAVE_STATION_DRAW_ID_FONT = 0;
  201. const int MET_SAVE_STATION_DRAW_ID_FONT_LAYER = 2;
  202. const int MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_COLOUR = 0x0F; //Black
  203. const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_COLOUR = 0x01; //White
  204. const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_SCALE = -1;  //DrawString(0 scale factor
  205. const int MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_X_OFFSET = 8;  //Offset from f->X
  206. const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_X_OFFSET = 9;  //Offset from f->X
  207. const int MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_Y_OFFSET = 8;  //Offset from f->Y
  208. const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_OFFSET = 9;  //Offset from f->Y
  209. const int MET_SAVE_STATION_ = 0; //Default constant template for this beast.
  210. const int MET_SAVE_STATION_DRAW_ID_FONT_WIDTH = 16;
  211. const int MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT = 16;
  212.  
  213. const int SFX_SAVE_ERROR = 80; //
  214. const int SFX_SAVE_SUCCESS = 7; //
  215. const int SFX_TELEPORT_TRANSITION = 37; //Sound effect of teleportation EFFECT.
  216. //const int SFX_WARP_ERROR = 80;
  217. const int SFX_TELEPORT = 67; //Sound effect for teleportation matrix item.
  218.  
  219. //const int WARP_WAVE = 30;
  220.  
  221. const int TELEPORT_CIRCLE_COLOUR = 181; //Colour for teleport circle.
  222. const int TELEPORT_WAVE = 60; //Duration of Teleport Wave Effect
  223.  
  224. //! We'll remove this in a future edit.
  225. const int SFX_SET_TELEPORT = 21; //Menu Sound for Setting Teleport Destination
  226.  
  227.  
  228. //const int FLASH_LAYER = 6;
  229. //const int TELEPORT_OVERLAY = 5;
  230. //const int TELEPORT_SAFETY = 10;
  231.  
  232. //const int WARP_DURATION = 80;
  233.  
  234. //Drawing Colours - ! Set to colours in your palette, or adjust as you see fit.
  235. const int WARP_GREEN = 45;
  236. const int WARP_BLUE = 11;
  237. const int WARP_YELLOW = 126;
  238. const int WARP_TEAL = 88;
  239. const int WARP_LTBLUE = 93; //or 88
  240. const int WARP_LTGREEN = 44;
  241. const int WARP_BRIGHTGREEN = 47;
  242. const int WARP_PERIDOT = 97;
  243. const int WARP_SMOKE = 73;
  244.  
  245.  
  246. //if you lack an init script, use this one.
  247. //Otherwise, if your init scrit doesn't call anying from this, add these function calls to it, then remove
  248. //this one.
  249.  
  250. //global script Init{
  251. //  void run(){
  252. //      //IsDead(false);
  253. //      SetDefaultWarpPoint();
  254. //      //Initialize counters.
  255. //      SetCommonStyleData(WINDOW_STYLE_1);
  256. //      SetCommonStyleData(WINDOW_STYLE_2);
  257. //      SetCommonStyleData(WINDOW_STYLE_3);
  258. //  }
  259. //}
  260.  
  261.  
  262.  
  263.  
  264. void SetDefaultWarpPoint(){
  265.     SavePoints[MET_SAVE_BASE + MET_SAVE_ID + ( 128 * MET_SAVE_INDICES ) ] = 128;
  266.     SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( 128 * MET_SAVE_INDICES ) ] = INITIAL_DMAP;
  267.     SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( 128 * MET_SAVE_INDICES ) ] = INITIAL_SCREEN;
  268.     SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( 128 * MET_SAVE_INDICES ) ] = INITIAL_X;
  269.     SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( 128 * MET_SAVE_INDICES ) ] = INITIAL_Y;
  270.     if ( DEBUG_WARPS ) {
  271.         int s0[]="Runnin SetDefaultWarpPoint:";
  272.         TraceS(s0);
  273.         int s[]="Default Warp DMap: ";
  274.         int s1[]="Default Warp Screen: ";
  275.         TraceNL(); TraceS(s); Trace(SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( 128 * MET_SAVE_INDICES ) ]);
  276.         TraceNL(); TraceS(s1); Trace(SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( 128 * MET_SAVE_INDICES ) ]);
  277.     }
  278.     SetGameRestoreStation(128);
  279. }
  280.  
  281. //Accessors
  282. bool SamusIsWarping(){ return (SavePoints[ISWARPING] != 0); }
  283. bool FlashingGreen(){ return (SavePoints[FLASHINGGREEN] != 0); }
  284. bool SamusTeleporting(){ return (SavePoints[TELEPORTING] != 0); }
  285. bool SamusArriving(){ return (SavePoints[ARRIVING] != 0); }
  286.  
  287. void SamusWarping(bool state){ if ( state ) SavePoints[ISWARPING] = 1; else SavePoints[ISWARPING] = 0;}
  288. void FlashingGreen(bool state){ if ( state ) SavePoints[FLASHINGGREEN] = 1; else SavePoints[FLASHINGGREEN] = 0;}
  289. void SamusTeleporting(bool state){ if ( state ) SavePoints[TELEPORTING] = 1; else SavePoints[TELEPORTING] = 0;}
  290. void SamusArriving(bool state){ if ( state ) SavePoints[ARRIVING] = 1; else SavePoints[ARRIVING] = 0;}
  291.  
  292. //Returns if samus can teleport, or activate a save point station.
  293. bool SamusCanTeleport(){
  294.     return true; //If you want conditions, they go in this function.
  295. }
  296.  
  297.  
  298.  
  299. //We do this when we activate the station.
  300. void SetWarpPoint(int warp_id, ffc f){
  301.     SavePoints[MET_SAVE_BASE + MET_SAVE_ID + ( warp_id * MET_SAVE_INDICES ) ] = warp_id;
  302.     SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES ) ] = Game->GetCurDMap();
  303.     SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES ) ] = Game->GetCurScreen();
  304.     SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( warp_id * MET_SAVE_INDICES ) ] = f->X;
  305.     SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( warp_id * MET_SAVE_INDICES ) ] = f->Y;
  306.     if ( DEBUG_WARPS ) {
  307.         int s0[]="Setting Warp Point via SetWarpPoint(int warp_id, ffc f) for station ID: ";
  308.         int s[]="Warp DMap: ";
  309.         int s1[]="Warp Screen: ";
  310.         TraceNL(); TraceS(s0); Trace(warp_id);
  311.         TraceNL(); TraceS(s); Trace(SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES ) ]);
  312.         TraceNL(); TraceS(s1); Trace(SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES ) ]);
  313.     }
  314. }
  315.  
  316. //A way to set the point based on Samus coordinates, instead of ffc coordinates, if needed.
  317. void SetWarpPoint(int warp_id){
  318.     SavePoints[MET_SAVE_BASE + MET_SAVE_ID + ( warp_id * MET_SAVE_INDICES ) ] = warp_id;
  319.     SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES ) ] = Game->GetCurDMap();
  320.     SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES ) ] = Game->GetCurScreen();
  321.     SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( warp_id * MET_SAVE_INDICES ) ] = Link->X;
  322.     SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( warp_id * MET_SAVE_INDICES ) ] = Link->Y;
  323.     if ( DEBUG_WARPS ) {
  324.         int s0[]="Setting Warp Point via SetWarpPoint(int warp_id) for station ID: ";
  325.         int s[]="Warp DMap: ";
  326.         int s1[]="Warp Screen: ";
  327.         TraceNL(); TraceS(s0); Trace(warp_id);
  328.         TraceNL(); TraceS(s); Trace(SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES ) ]);
  329.         TraceNL(); TraceS(s1); Trace(SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES ) ]);
  330.     }
  331. }
  332.  
  333. //Checks if a given station is active.
  334. int WarpPointActive(int station_id) {
  335.     return SavePoints[MET_SAVE_BASE + MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_INDICES )];
  336.     if ( DEBUG_WARPS ) {
  337.         int s0[]="Running WarpPointActive(int station_id) and checking if the following staion is active: ";
  338.         int s[]="Status: ";
  339.         TraceNL(); TraceS(s0); Trace(station_id);
  340.         TraceNL(); TraceS(s); Trace(SavePoints[MET_SAVE_BASE + MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_INDICES )]);
  341.     }
  342. }
  343.  
  344. //Sets a given warp point active/inactive.
  345. void WarpPointActive(int station_id, bool setting) {
  346.     if ( setting ) SavePoints[MET_SAVE_BASE + MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_INDICES )] = 1;
  347.     else SavePoints[MET_SAVE_BASE + MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_INDICES )] = 0;
  348.     if ( DEBUG_WARPS ) {
  349.         int s0[]="Setting Warp Point status with WarpPointActive(int id, bool set) for station ID: ";
  350.         int s[]="To status: ";
  351.         int s1[]="After attempt, status returned: ";
  352.         TraceNL(); TraceS(s0); Trace(station_id);
  353.         TraceNL(); TraceS(s); TraceB(setting);
  354.         TraceNL(); TraceS(s1); Trace(SavePoints[MET_SAVE_BASE + MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_INDICES )]);
  355.     }
  356. }
  357. }  
  358.  
  359. //Saving the game automation.
  360. void SaveGame(int station_id){
  361.     SetGameRestoreStation(station_id);
  362.     ///
  363.     Game->Save();
  364. }
  365.  
  366. //Save and quit automation.
  367. void SaveGameAndQuit(int station_id){
  368.     SetGameRestoreStation(station_id);
  369.     Game->Save();
  370.     Game->End();
  371. }
  372.  
  373. //Sets the station that we'll load when the player reloads the game.
  374. void SetGameRestoreStation(int station_id){
  375.     SavePoints[MET_SAVE_LAST_SAVESTATION] = station_id;
  376.     if ( DEBUG_WARPS ) {
  377.         int s0[]="Running SetGameRestoreStation(int id): ";
  378.         int s[]="Restore point is: ";
  379.         TraceNL(); TraceS(s0);
  380.         TraceNL(); TraceS(s); Trace(SavePoints[MET_SAVE_LAST_SAVESTATION]);
  381.     }
  382. }
  383.  
  384. //Gets the station to use as a restore point, on player death, or onContinue.
  385. int GetGameRestoreStation(){
  386.     if ( DEBUG_WARPS ) {
  387.         int s0[]="Running GetGameRestoreStation(): ";
  388.         int s[]="Restore point is: ";
  389.         TraceNL(); TraceS(s0);
  390.         TraceNL(); TraceS(s); Trace(SavePoints[MET_SAVE_LAST_SAVESTATION]);
  391.     }
  392.     return SavePoints[MET_SAVE_LAST_SAVESTATION];
  393. }
  394.  
  395. //Call during onContinue script, or on death.
  396. void RestoreGame(){
  397.     if ( DEBUG_WARPS ) {
  398.         int s0[]="Running RestoreGame(): ";
  399.         TraceNL(); TraceS(s0);
  400.     }
  401.         //if the game has been saved, then we have a restore station set
  402.     if ( GetGameRestoreStation() ) {
  403.         if ( DEBUG_WARPS ) {
  404.             int s0[]="Found a return point: ";
  405.             int s[]="Doing WarpSamus(int id, int dur): ";
  406.             TraceNL(); TraceS(s0);
  407.             TraceNL(); TraceS(s); Trace(GetGameRestoreStation()); Trace(dur);
  408.         }
  409.         WarpSamus( GetGameRestoreStation(), MET_WARP_EFFECT_DURATION );
  410.     }
  411.     else {
  412.         if ( DEBUG_WARPS ) {
  413.             int s0[]="ERROR: Could not find return point! ";
  414.             TraceNL(); TraceS(s0);
  415.         }
  416.     }
  417. }
  418.  
  419. // Tango Functions
  420.  
  421.  
  422. // There are certainly other ways to handle these...
  423. // Vars used by the Tango menu.
  424. //int menuCommand;
  425. //int menuArg;
  426.  
  427. //Tango Menu Init
  428. //void SetUpWindow(int slot, int style, int x, int y, int size)
  429. //{
  430. //    SetStyleSize(style, size);
  431. //    Tango_ClearSlot(slot);
  432. //    Tango_SetSlotStyle(slot, style);
  433. //    Tango_SetSlotPosition(slot, x, y);
  434. //}
  435.  
  436. //Quick way to drop a string into a Tango dialogue box.
  437. //void ShowString(int string, int slot, int style, int x, int y)
  438. //{
  439. //    SetUpWindow(slot, style, x, y, SIZE_LARGE);
  440. //    Tango_LoadString(slot, string);
  441. //    Tango_ActivateSlot(slot);
  442. //    while(Tango_SlotIsActive(slot))  
  443. //        Waitframe();
  444. //}
  445.  
  446.  
  447.    
  448. void DebugMetroidSaveStationMenu(int val) {
  449.     int t[]="MetroidSaveStationMenu() returned: ";
  450.     TraceNL(); TraceS(t); Trace(val); TraceNL();
  451. }
  452.  
  453. void DebugRefill(int val){
  454.     int t[]="Refill is set to: ";
  455.     TraceNL(); TraceS(t); Trace(val); TraceNL();
  456. }
  457.  
  458. void DebuggingMetroidSaveStation(){
  459.     int t[]="Debugging int MetroidSaveStationMenu(int station_id, int refill)";
  460.     TraceNL(); TraceS(t); TraceNL();
  461. }
  462.  
  463.  
  464. //refill == 0 for none, 1 for hp, 2 for mp, 3 for both
  465. //Menu called by the save station ffc.
  466. int MetroidSaveStationMenu(int station_id, int refill, int warp) {
  467.     if ( DEBUG_MENUS ) {
  468.         DebuggingMetroidSaveStation();
  469.         DebugRefill(refill);
  470.     }
  471.     int lineBreak[]="@26";
  472.     int line1[]="@choice(1)Save@26";
  473.     int line3[]="@choice(2)Warp@26";
  474.     int line2[]="@choice(5)Refill@26";
  475.     int line4[]="@choice(3)Save and Quit@26";
  476.     int line5[]="@choice(4)Cancel";
  477.     int initmenu[]="@domenu(1)@suspend()";
  478.    
  479.    
  480.     if ( DEBUG_WARPS ) {
  481.         int debug1[]="Running MetroidSaveStationMenu()";
  482.         TraceS(debug1);
  483.     }
  484.    
  485.     if ( station_id ) {
  486.        
  487.         if ( DEBUG_WARPS ) {
  488.             int debug[]="Found station ID: ";
  489.             TraceS(debug); Trace(station_id);
  490.         }
  491.         SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_1, 32, 32, SIZE_LARGE);
  492.         Tango_LoadString(WINDOW_SLOT_1, line1);
  493.         if ( refill || SAVEPOINTS_ALLOW_REFILL ) Tango_AppendString(WINDOW_SLOT_1, line2);
  494.         if ( DEBUG_WARPS ) {
  495.             int debug[]="Refill is: ";
  496.             TraceS(debug); Trace(refill);
  497.         }
  498.         if ( warp || SAVEPOINTS_ALLOW_WARPING ) Tango_AppendString(WINDOW_SLOT_1, line3);
  499.         if ( DEBUG_WARPS ) {
  500.             int debug[]="Warp is: ";
  501.             TraceS(debug); Trace(warp);
  502.         }
  503.         Tango_AppendString(WINDOW_SLOT_1, line4);
  504.         Tango_AppendString(WINDOW_SLOT_1, line5);
  505.         Tango_AppendString(WINDOW_SLOT_1, initmenu);
  506.         Tango_ActivateSlot(WINDOW_SLOT_1);
  507.     }
  508.    
  509.     else {  //Refill station, only. Arg d1 will default to 3 in this case, if it is un-set.
  510.         SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_1, 32, 32, SIZE_LARGE);
  511.         Tango_LoadString(WINDOW_SLOT_1, line2);
  512.         Tango_AppendString(WINDOW_SLOT_1, line5);
  513.         Tango_AppendString(WINDOW_SLOT_1, initmenu);
  514.         Tango_ActivateSlot(WINDOW_SLOT_1);
  515.     }
  516.  
  517.    
  518.     while(!Tango_MenuIsActive()){
  519.        
  520.         Waitframe();
  521.     }
  522.    
  523.     // Save the state again...
  524.     int slotState[278];
  525.     int menuState[960];
  526.     int cursorPos;
  527.     Tango_SaveSlotState(WINDOW_SLOT_1, slotState);
  528.     Tango_SaveMenuState(menuState);
  529.    
  530.     int done = 0;
  531.     int choice;
  532.     while(true){
  533.    
  534.         while( Tango_MenuIsActive() ) {
  535.             cursorPos=Tango_GetMenuCursorPosition();
  536.             Waitframe();
  537.         }
  538.        
  539.         choice = Tango_GetLastMenuChoice();
  540.         if ( choice == 1 ) { // Save the game
  541.             SaveGame(station_id);
  542.             Game->PlaySound(SFX_SAVE_SUCCESS);
  543.             int text[]="Game Saved";
  544.             Tango_ClearSlot(2);
  545.             ShowString(text, WINDOW_SLOT_2, WINDOW_STYLE_2, 48, 48);
  546.             done = -9999;
  547.         }
  548.         else if ( choice == 2 ) { //Warp
  549.             //! Run the warp menu.
  550.             done = WarpMenu();
  551.             // done = choice;
  552.             //menuArg = choice;
  553.         }
  554.        
  555.         else if ( choice == 3 ) { //Save and quit
  556.             Game->PlaySound(SFX_SAVE_SUCCESS);
  557.             SaveGameAndQuit(station_id);
  558.             done = choice;
  559.         }
  560.        
  561.         else if ( choice == 4 ) {//cancel
  562.             done = -9999;
  563.         }
  564.        
  565.         else if ( choice == 5 ) { //refill
  566.             RefillMenu(refill);
  567.             done = -9999;
  568.         }
  569.        
  570.         if ( done ) {
  571.             break;
  572.         //  return choice;
  573.         }
  574.         else {
  575.             Tango_RestoreSlotState(WINDOW_SLOT_1, slotState);
  576.             Tango_RestoreMenuState(menuState);
  577.             Tango_SetMenuCursorPosition(cursorPos);
  578.         }
  579.     }
  580.    
  581.     Tango_ClearSlot(WINDOW_SLOT_1);
  582.     if ( DEBUG_MENUS ) DebugMetroidSaveStationMenu(done);
  583.     if ( DEBUG_WARPS ) {
  584.                 int debug[]="Choice is: ";
  585.                 TraceS(debug); Trace(choice);
  586.                 int debug[]="Done is: ";
  587.                 TraceS(debug); Trace(done);
  588.             }
  589.     return done;
  590. }
  591.  
  592. //Populte these functions with instructions to refill stocks.  
  593.  
  594. void RefillMissiles() {}
  595.  
  596.    
  597. void DebuggingRefillMenu(){
  598.     int t[]="Debugging Refillmeny(int type)";
  599.     TraceNL(); TraceS(t); TraceNL();
  600. }
  601.    
  602.    
  603. //refill == 0 for none, 1 for hp, 2 for mp, 3 for both
  604. int RefillMenu(int type){
  605.     if ( DEBUG_MENUS ) {
  606.         DebuggingRefillMenu();
  607.         DebugRefill(type);
  608.     }
  609.     int lineBreak[]="@26";
  610.    
  611.     //Three springs per destination pair. We'll check if they are active, and only display those that are actie.
  612.        
  613.     int missiles[]="@choice(1)Refill Magic@26";
  614.     int health[]="@choice(2)Refill Energy@26";
  615.         int both[]="@choice(3)Refill Both@26";
  616.  
  617.    
  618.     int initmenu[]="@domenu(1)@suspend()";
  619.    
  620.    
  621.     //int restoredmissiles[]="Magic replenished.";
  622.     //int restoredhealth[]="Health replenished.";
  623.     //int restoredboth[]="Energy and missile supplies replenished.";
  624.    
  625.     //We can change '10' to cancel if needed.
  626.    
  627.     SetUpWindow(WINDOW_SLOT_3, WINDOW_STYLE_1, 32, 32, SIZE_LARGE);
  628.    
  629.     //Magic Only
  630.    
  631.     //ShowString(restoredmissiles, WINDOW_SLOT_4, WINDOW_STYLE_1, 48, 48);
  632.    
  633.    
  634.     if ( type == 2 )  {
  635.         Tango_LoadString(WINDOW_SLOT_3, missiles);
  636.         Tango_AppendString(WINDOW_SLOT_3, initmenu);
  637.         Tango_ActivateSlot(WINDOW_SLOT_3);
  638.     }
  639.    
  640.     //Health only
  641.    
  642.     if ( type == 1 )  {
  643.         Tango_LoadString(WINDOW_SLOT_3, health);
  644.         Tango_AppendString(WINDOW_SLOT_3, initmenu);
  645.         Tango_ActivateSlot(WINDOW_SLOT_3);
  646.     }
  647.    
  648.     //Both
  649.    
  650.     if ( type == 3 )  {
  651.         Tango_LoadString(WINDOW_SLOT_3, missiles);
  652.         Tango_LoadString(WINDOW_SLOT_3, health);
  653.         Tango_LoadString(WINDOW_SLOT_3, both);
  654.         Tango_AppendString(WINDOW_SLOT_3, initmenu);
  655.         Tango_ActivateSlot(WINDOW_SLOT_3);
  656.     }
  657.    
  658.        
  659.  
  660.  
  661.    
  662.     while(!Tango_MenuIsActive()){
  663.        
  664.         Waitframe();
  665.     }
  666.    
  667.     // Save the state again...
  668.     int slotState[278];
  669.     int menuState[960];
  670.     int cursorPos;
  671.     Tango_SaveSlotState(WINDOW_SLOT_3, slotState);
  672.     Tango_SaveMenuState(menuState);
  673.    
  674.     int done = 0;
  675.     int choice;
  676.     while(true){
  677.    
  678.         while( Tango_MenuIsActive() ) {
  679.             cursorPos=Tango_GetMenuCursorPosition();
  680.             Waitframe();
  681.         }
  682.        
  683.        
  684.        
  685.         choice = Tango_GetLastMenuChoice();
  686.        
  687.         if ( choice == 1 ) { //Refill magic
  688.             Game->DCounter[CR_MAGIC] = Link->MaxMP;
  689.             Tango_ClearSlot(WINDOW_SLOT_2);
  690.             done = -99999;
  691.         }
  692.        
  693.        
  694.         if ( choice == 2 ) { //Refill missiles
  695.             Game->DCounter[CR_LIFE] = Link->MaxHP;
  696.             Tango_ClearSlot(WINDOW_SLOT_2);
  697.             done = -99999;
  698.         }
  699.        
  700.         if ( choice == 3 ) { //Refill both
  701.             Game->DCounter[CR_MAGIC] = Link->MaxMP;
  702.             Game->DCounter[CR_LIFE] = Link->MaxHP;
  703.             Tango_ClearSlot(WINDOW_SLOT_2);
  704.             done = -99999;
  705.         }
  706.        
  707.         if ( done ) {
  708.             break;
  709.         //  return choice;
  710.         }
  711.         else {
  712.             Tango_RestoreSlotState(WINDOW_SLOT_3, slotState);
  713.             Tango_RestoreMenuState(menuState);
  714.             Tango_SetMenuCursorPosition(cursorPos);
  715.         }
  716.     }
  717.    
  718.     Tango_ClearSlot(WINDOW_SLOT_3);
  719.     return done;
  720. }
  721.  
  722. //Warp menu, called by MetroidSaveStationMenu(), or by other functions/scripts.
  723. int WarpMenu(){
  724.  
  725.     int lineBreak[]="@26";
  726.    
  727.     //Three springs per destination pair. We'll check if they are active, and only display those that are actie.
  728.         int line1_both[]="@choice(1)Go 1@tab(56)@choice(2)Go 2@26";
  729.     int line1_first[]="@choice(1)Go 1@26";
  730.         int line1_second[]="   @tab(56)@choice(2)Go 2@26";
  731.    
  732.     int line2_both[]="@choice(3)Go 3@tab(56)@choice(4)Go 4@26";
  733.     int line2_first[]="@choice(3)Go 3@26";
  734.         int line2_second[]="   @tab(56)@choice(4)Go 4@26";
  735.    
  736.     int line3_both[]="@choice(5)Go 5@tab(56)@choice(6)Go 6@26";
  737.     int line3_first[]="@choice(5)Go 5@26";
  738.         int line3_second[]="   @tab(56)@choice(6)Go 6@26";
  739.    
  740.     int line4_both[]="@choice(7)Go 7@tab(56)@choice(8)Go 8@26";
  741.     int line4_first[]="@choice(7)Go 7@26";
  742.         int line4_second[]="   @tab(56)@choice(8)Go 8@26";
  743.    
  744.     int line5_both[]="@choice(9)Go 9@tab(56)@choice(10)Go 10@26";
  745.     int line5_first[]="@choice(9)Go 9@26";
  746.         int line5_second[]="   @tab(56)@choice(10)Go 10@26";
  747.    
  748.     int line6_both[]="@choice(11)Go 11@tab(56)@choice(12)Go 12@26";
  749.     int line6_first[]="@choice(11)Go 11@26";
  750.         int line6_second[]="   @tab(56)@choice(12)Go 12@26";
  751.    
  752.     int line7_both[]="@choice(13)Go 13@tab(56)@choice(14)Go 14@26";
  753.     int line7_first[]="@choice(13)Go 13@26";
  754.         int line7_second[]="   @tab(56)@choice(14)Go 14@26";
  755.    
  756.     int line8_both[]="@choice(15)Go 15@tab(56)@choice(16)Go 16@26";
  757.     int line8_first[]="@choice(15)Go 15@26";
  758.         int line8_second[]="   @tab(56)@choice(16)Go 16@26";
  759.    
  760.     int line9_both[]="@choice(17)Go 17@tab(56)@choice(18)Go 18@26";
  761.     int line9_first[]="@choice(17)Go 17@26";
  762.         int line9_second[]="   @tab(56)@choice(18)Go 18@26";
  763.    
  764.     int line10_both[]="@choice(19)Go 19@tab(56)@choice(20)Go 20@26";
  765.     int line10_first[]="@choice(19)Go 19@26";
  766.         int line10_second[]="   @tab(56)@choice(20)Go 20@26";
  767.    
  768.     int initmenu[]="@domenu(1)@suspend()";
  769.    
  770.    
  771.     if ( DEBUG_WARPS ) {
  772.         int debug1[]="Running WarpMenu()";
  773.         TraceS(debug1);
  774.     }
  775.    
  776.     //We can change '10' to cancel if needed.
  777.    
  778.     SetUpWindow(WINDOW_SLOT_2, WINDOW_STYLE_3, 32, 32, SIZE_LARGE);
  779.    
  780.     if ( WarpPointActive(1) && WarpPointActive(2) ) Tango_LoadString(WINDOW_SLOT_2, line1_both);
  781.     if ( WarpPointActive(1) && !WarpPointActive(2) ) Tango_LoadString(WINDOW_SLOT_2, line1_first);
  782.     if ( !WarpPointActive(1) && WarpPointActive(2) ) Tango_LoadString(WINDOW_SLOT_2, line1_second);
  783.    
  784.     if ( WarpPointActive(3) && WarpPointActive(4) ) Tango_AppendString(WINDOW_SLOT_2, line2_both);
  785.     if ( WarpPointActive(3) && !WarpPointActive(4) ) Tango_AppendString(WINDOW_SLOT_2, line2_first);
  786.     if ( WarpPointActive(3) && WarpPointActive(4) ) Tango_AppendString(WINDOW_SLOT_2, line2_second);
  787.    
  788.     if ( WarpPointActive(5) && WarpPointActive(6) ) Tango_AppendString(WINDOW_SLOT_2, line3_both);
  789.     if ( WarpPointActive(5) && !WarpPointActive(6) ) Tango_AppendString(WINDOW_SLOT_2, line3_first);
  790.     if ( WarpPointActive(5) && WarpPointActive(6) ) Tango_AppendString(WINDOW_SLOT_2, line3_second);
  791.    
  792.     if ( WarpPointActive(7) && WarpPointActive(8) ) Tango_AppendString(WINDOW_SLOT_2, line4_both);
  793.     if ( WarpPointActive(7) && !WarpPointActive(8) ) Tango_AppendString(WINDOW_SLOT_2, line4_first);
  794.     if ( WarpPointActive(7) && WarpPointActive(8) ) Tango_AppendString(WINDOW_SLOT_2, line4_second);
  795.    
  796.     if ( WarpPointActive(9) && WarpPointActive(10) ) Tango_AppendString(WINDOW_SLOT_2, line5_both);
  797.     if ( WarpPointActive(9) && !WarpPointActive(10) ) Tango_AppendString(WINDOW_SLOT_2, line5_first);
  798.     if ( WarpPointActive(9) && WarpPointActive(10) ) Tango_AppendString(WINDOW_SLOT_2, line5_second);
  799.    
  800.     if ( WarpPointActive(11) && WarpPointActive(12) ) Tango_AppendString(WINDOW_SLOT_2, line6_both);
  801.     if ( WarpPointActive(11) && !WarpPointActive(12) ) Tango_AppendString(WINDOW_SLOT_2, line6_first);
  802.     if ( WarpPointActive(11) && WarpPointActive(12) ) Tango_AppendString(WINDOW_SLOT_2, line6_second);
  803.    
  804.     if ( WarpPointActive(13) && WarpPointActive(14) ) Tango_AppendString(WINDOW_SLOT_2, line7_both);
  805.     if ( WarpPointActive(13) && !WarpPointActive(14) ) Tango_AppendString(WINDOW_SLOT_2, line7_first);
  806.     if ( WarpPointActive(13) && WarpPointActive(14) ) Tango_AppendString(WINDOW_SLOT_2, line7_second);
  807.    
  808.     if ( WarpPointActive(15) && WarpPointActive(16) ) Tango_AppendString(WINDOW_SLOT_2, line8_both);
  809.     if ( WarpPointActive(15) && !WarpPointActive(16) ) Tango_AppendString(WINDOW_SLOT_2, line8_first);
  810.     if ( WarpPointActive(15) && WarpPointActive(16) ) Tango_AppendString(WINDOW_SLOT_2, line8_second);
  811.    
  812.     if ( WarpPointActive(17) && WarpPointActive(18) ) Tango_AppendString(WINDOW_SLOT_2, line9_both);
  813.     if ( WarpPointActive(17) && !WarpPointActive(18) ) Tango_AppendString(WINDOW_SLOT_2, line9_first);
  814.     if ( WarpPointActive(17) && WarpPointActive(18) ) Tango_AppendString(WINDOW_SLOT_2, line9_second);
  815.    
  816.     if ( WarpPointActive(19) && WarpPointActive(20) ) Tango_AppendString(WINDOW_SLOT_2, line10_both);
  817.     if ( WarpPointActive(19) && !WarpPointActive(20) ) Tango_AppendString(WINDOW_SLOT_2, line10_first);
  818.     if ( WarpPointActive(19) && WarpPointActive(20) ) Tango_AppendString(WINDOW_SLOT_2, line10_second);
  819.    
  820.     Tango_AppendString(WINDOW_SLOT_2, initmenu);
  821.    
  822.         Tango_ActivateSlot(WINDOW_SLOT_2);
  823.  
  824.  
  825.    
  826.     while(!Tango_MenuIsActive()){
  827.        
  828.         Waitframe();
  829.     }
  830.    
  831.     // Save the state again...
  832.     int slotState[278];
  833.     int menuState[960];
  834.     int cursorPos;
  835.     Tango_SaveSlotState(WINDOW_SLOT_2, slotState);
  836.     Tango_SaveMenuState(menuState);
  837.    
  838.     int done = 0;
  839.     int choice;
  840.     while(true){
  841.    
  842.         while( Tango_MenuIsActive() ) {
  843.             cursorPos=Tango_GetMenuCursorPosition();
  844.             Waitframe();
  845.         }
  846.        
  847.        
  848.        
  849.         choice = Tango_GetLastMenuChoice();
  850.        
  851.         if ( choice ) {
  852.             Tango_ClearSlot(WINDOW_SLOT_2);
  853.             done = choice * -1;
  854.         }
  855.        
  856.         if ( done ) {
  857.             break;
  858.         //  return choice;
  859.         }
  860.         else {
  861.             Tango_RestoreSlotState(WINDOW_SLOT_2, slotState);
  862.             Tango_RestoreMenuState(menuState);
  863.             Tango_SetMenuCursorPosition(cursorPos);
  864.         }
  865.     }
  866.    
  867.     Tango_ClearSlot(WINDOW_SLOT_2);
  868.     if ( DEBUG_MENUS ) DebugWarpChoice(done);
  869.    
  870.     if ( DEBUG_WARPS ) {
  871.         int debug[]="Selected return point ID is: ";
  872.         TraceS(debug); Trace(choice);
  873.         int d2[]="Converted value is: ";
  874.         TraeceS(d2); Trace(done);
  875.     }
  876.     return done;
  877. }
  878.    
  879. void DebugWarpChoice(int val){
  880.     int t[]="WarpMenu() returned: ";
  881.     TraceNL(); TraceS(t); Trace(val); TraceNL();
  882. }
  883.  
  884. //Does the warp animation, and the phsyical warp.
  885. void WarpSamus(int warp_id, int warpDuration) {
  886.     int startHP = Link->HP;
  887.     int goDMAP = SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES )];
  888.     int goSCREEN = SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES )];
  889.     int goX = SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( warp_id * MET_SAVE_INDICES )];
  890.     int goY = SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( warp_id * MET_SAVE_INDICES )];
  891.     if ( DEBUG_WARPS ) {
  892.         int s0[]="Running WarpSamus(int id, int dur)";
  893.         TraceS(s0);
  894.         int s[]="Warping to DMap: ";
  895.         int s1[]="Warping to Screen: ";
  896.         TraceNL(); TraceS(s); Trace(goDMAP);
  897.         TraceNL(); TraceS(s1); Trace(goSCREEN);
  898.     }
  899.    
  900.     if ( SamusCanTeleport() ) {
  901.         Game->PlaySound(SFX_TELEPORT_TRANSITION);
  902.         //freezeAction();
  903.         SamusTeleporting(true);
  904.         SamusArriving(true);
  905.         for(int i = warpDuration; i > 0; i--){ //Duration of song/effect.
  906.             NoAction(); //Freeze Link
  907.             //Game->PlaySound(SFX_TELEPORT_TRANSITION);
  908.             //Create animation.
  909.             Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 );
  910.            
  911.             FlashingGreen(false);
  912.  
  913.            
  914.             do {
  915.                 for ( int j = 1; j > 0; j--){
  916.                     ScreenToLayer(goDMAP, goSCREEN, 4, 75);
  917.                     Screen->Rectangle(5, 0, 0, 256, 172, WARP_GREEN, 1, 0, 0, 0, true, 25);
  918.                     Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, 1, 1, 0, 0, 0, false, 100 );
  919.                     FlashingGreen(true);
  920.                     Waitframe();
  921.                 }
  922.             } while(SamusTeleporting() && !FlashingGreen());
  923.                
  924.             do {   
  925.                 for ( int j = 1; j > 0; j--){
  926.                 ScreenToLayer(goDMAP, goSCREEN, 4, 80);
  927.                 Screen->Rectangle(5, 0, 0, 256, 172, WARP_LTGREEN, 1, 0, 0, 0, true, 10);
  928.                 Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 );
  929.                 FlashingGreen(false);
  930.                
  931.                 Waitframe();
  932.                 }
  933.                
  934.             } while(SamusTeleporting() && FlashingGreen());
  935.  
  936.             if ( Link->HP < startHP ) {
  937.                 return; //If Link is hurt, quit
  938.             }
  939.             Waitframe();
  940.         }
  941.            
  942.         Screen->Wavy =60;
  943.         if ( DEBUG_WARPS ) {
  944.             int s[]="Performing warp action to screen, dmap): ";
  945.             TraceS(s); Trace(goDMAP), Trace(goSCREEN);
  946.         }
  947.         Link->PitWarp( goDMAP, goSCREEN );
  948.         Link->X = goX;
  949.         Link->Y = goY;
  950.  
  951.         SamusTeleporting(false);
  952.         //unfreezeAction();
  953.         Waitframe();
  954.         SamusTeleporting(false);
  955.         FlashingGreen(false);
  956.  
  957.     }
  958.            
  959.         else {
  960.             Game->PlaySound(SFX_WARP_ERROR);
  961.             SamusWarping(false);
  962.         //NotEnoughMP();
  963.             //return;
  964.         }
  965.    
  966. }
  967.  
  968. //Does the warp animation, and the phsyical warp.
  969. void WarpSamusForced(int warp_id, int warpDuration) {
  970.     int startHP = Link->HP;
  971.     int goDMAP = SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES )];
  972.     int goSCREEN = SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES )];
  973.     int goX = SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( warp_id * MET_SAVE_INDICES )];
  974.     int goY = SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( warp_id * MET_SAVE_INDICES )]; 
  975.     if ( DEBUG_WARPS ) {
  976.         int s0[]="Running WarpSamusForced(int id, int dur)";
  977.         int s[]="Warping to DMap: ";
  978.         int s1[]="Warping to Screen: ";
  979.         TraceNL(); TraceS(s); Trace(goDMAP);
  980.         TraceNL(); TraceS(s1); Trace(goSCREEN);
  981.     }
  982.  
  983.         Game->PlaySound(SFX_TELEPORT_TRANSITION);
  984.         //freezeAction();
  985.         SamusTeleporting(true);
  986.         SamusArriving(true);
  987.         for(int i = warpDuration; i > 0; i--){ //Duration of song/effect.
  988.             NoAction(); //Freeze Link
  989.             //Game->PlaySound(SFX_TELEPORT_TRANSITION);
  990.             //Create animation.
  991.             Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 );
  992.            
  993.             FlashingGreen(false);
  994.  
  995.            
  996.             do {
  997.                 for ( int j = 1; j > 0; j--){
  998.                     ScreenToLayer(goDMAP, goSCREEN, 4, 75);
  999.                     Screen->Rectangle(5, 0, 0, 256, 172, WARP_GREEN, 1, 0, 0, 0, true, 25);
  1000.                     Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, 1, 1, 0, 0, 0, false, 100 );
  1001.                     FlashingGreen(true);
  1002.                     Waitframe();
  1003.                 }
  1004.             } while(SamusTeleporting() && !FlashingGreen());
  1005.                
  1006.             do {   
  1007.                 for ( int j = 1; j > 0; j--){
  1008.                 ScreenToLayer(goDMAP, goSCREEN, 4, 80);
  1009.                 Screen->Rectangle(5, 0, 0, 256, 172, WARP_LTGREEN, 1, 0, 0, 0, true, 10);
  1010.                 Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 );
  1011.                 FlashingGreen(false);
  1012.                
  1013.                 Waitframe();
  1014.                 }
  1015.                
  1016.             } while(SamusTeleporting() && FlashingGreen());
  1017.  
  1018.             if ( Link->HP < startHP ) {
  1019.                 return; //If Link is hurt, quit
  1020.             }
  1021.             Waitframe();
  1022.         }
  1023.            
  1024.         Screen->Wavy =60;
  1025.         if ( DEBUG_WARPS ) {
  1026.             int s[]="Performing warp action to screen, dmap): ";
  1027.             TraceS(s); Trace(goDMAP), Trace(goSCREEN);
  1028.         }
  1029.         Link->PitWarp( goDMAP, goSCREEN );
  1030.         Link->X = goX;
  1031.         Link->Y = goY;
  1032.  
  1033.         SamusTeleporting(false);
  1034.         //unfreezeAction();
  1035.         Waitframe();
  1036.         SamusTeleporting(false);
  1037.         FlashingGreen(false);
  1038.    
  1039. }
  1040.  
  1041.  
  1042. //Used if teleporting requires magic. Modify and use if desired.
  1043. bool NotEnoughMP(){
  1044.  
  1045.     int lineBreak[]="@26";
  1046.     int menuEnd[]="@domenu(1)@suspend()";
  1047.  
  1048.    
  1049.     int line2[]="You do not have enough MP to do that.@26";
  1050.     int line1[]="@choice(1)Done@26@26";
  1051.  
  1052.  
  1053.    
  1054.     SetUpWindow(WINDOW_SLOT_2, WINDOW_STYLE_2, 32, 32, SIZE_LARGE);
  1055.         Tango_LoadString(WINDOW_SLOT_2, line1);
  1056.         Tango_AppendString(WINDOW_SLOT_2, line2);
  1057.         Tango_AppendString(WINDOW_SLOT_2, menuEnd);
  1058.         Tango_ActivateSlot(WINDOW_SLOT_2);
  1059.    
  1060.    
  1061.     while(!Tango_MenuIsActive()){
  1062.        
  1063.         Waitframe();
  1064.     }
  1065.    
  1066.     // Save the state again...
  1067.     int slotState[274];
  1068.     int menuState[60];
  1069.     int cursorPos;
  1070.     Tango_SaveSlotState(WINDOW_SLOT_2, slotState);
  1071.     Tango_SaveMenuState(menuState);
  1072.    
  1073.     int done=0;
  1074.     int choice;
  1075.     while(true)
  1076.     {
  1077.    
  1078.         while(Tango_MenuIsActive())
  1079.         {
  1080.            
  1081.             cursorPos=Tango_GetMenuCursorPosition();
  1082.          
  1083.             Waitframe();
  1084.         }
  1085.        
  1086.         choice=Tango_GetLastMenuChoice();
  1087.         if(choice==0) // Canceled
  1088.             done=2;
  1089.            
  1090.         else if(choice == 1)
  1091.         {
  1092.             done=2;
  1093.         }
  1094.          
  1095.         else if (Link->PressEx1){
  1096.                 done = 2;
  1097.         }
  1098.         else
  1099.             done=2;
  1100.  
  1101.        
  1102.  
  1103.        
  1104.         if(done>0){
  1105.            
  1106.             break;
  1107.         }
  1108.         else
  1109.         {
  1110.             Tango_RestoreSlotState(WINDOW_SLOT_2, slotState);
  1111.             Tango_RestoreMenuState(menuState);
  1112.             Tango_SetMenuCursorPosition(cursorPos);
  1113.         }
  1114.     }
  1115.    
  1116.     Tango_ClearSlot(WINDOW_SLOT_2);
  1117.    
  1118.     if(done==1)
  1119.         return true; // Tell parent menu to close
  1120.     else
  1121.         return false; // Tell parent not to close
  1122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement