ZoriaRPG

Mirror for 2.55 (WIP)

Mar 26th, 2019
319
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ffc script sparkle
  2. {
  3.     enum { x, y, lwdmap, lwmap, screen, dwdmap, valid, LAST };
  4.     int loc[LAST];
  5.     const int FFID = 30; //ffc index
  6.     const int CMB = 2000; //sparkle combo
  7.     void set(int lwdmap, int lwmap, int scr, int dworld)
  8.     {
  9.         loc[x] = Hero->X;
  10.         loc[y] = Hero->Y;
  11.         loc[lwdmap] = Game->GetCurDMap();
  12.         loc[lwmap] = Game->GetCurMap();
  13.         loc[screen] = Game->GetCurScreen();
  14.         loc[dwdmap] = dworld;
  15.     }
  16.     void clear()
  17.     {
  18.         mapdata m = Game->LoadMapData(loc[map], loc[screen]);
  19.         m->FFCData[FFID] = 0;
  20.         m->FFCScript[FFID] = 0;
  21.     }
  22.     void setvalid(){loc[valid] = 1;}
  23.     bool isvalid() { return (loc[valid]); }
  24.     void create() //Need to call in Link.init if there is a valid mirror sparkle.
  25.     {
  26.         if ( !isvalid() ) return; //because the init script sets it, it needs to be valid.
  27.         mapdata m = Game->LoadMapData(loc[map], loc[screen]);
  28.         m->FFCData[FFID] = CMB;
  29.         m->FFCX[FFID] = loc[x];
  30.         m->FFCY[FFID] = loc[y];
  31.         m->FFCScript[FFIC] = id;
  32.     }
  33.     void draw() //
  34.     {
  35.         if ( Game->GetCurDMap() == loc[dmap] )
  36.         {
  37.             if ( Game->GetCurScreen() == loc[screen] )
  38.             {
  39.                 ffc f = Screen->LoadFFC(FFID);
  40.                 f->Data = CMB;
  41.                 f->X = loc[x];
  42.                 f->Y = loc[y];
  43.             }
  44.         }
  45.     }
  46.     int id() { return ( Game->GetFFCScript("sparkle");
  47.     void run()
  48.     {
  49.         while(1)
  50.         {
  51.             if ( Link->Misc[mirror.LM_WARPTIMER] )
  52.             {
  53.                 --Link->Misc[mirror.LM_WARPTIMER];
  54.                 Waitframe();
  55.                 continue;
  56.             }
  57.             if ( Collision(this) )
  58.             {
  59.                 //warp back
  60.                 Link->WarpEx(loc[dmap], Game->GetCurScreen(), loc[x], loc[y], mirror.WARPSFX, mirror.WARPVISUAL, ... ); //IDR the args order right now.
  61.             }
  62.             Waitframe();
  63.         }
  64.        
  65.        
  66.     }
  67. }
  68.  
  69. item script mirror
  70. {
  71.     enum { LIGHT1, DARK1, MAX_PAIR }
  72.     const int ERRSOUND = 64;
  73.     const int NOWARP_TIME = 150;
  74.     const int LM_WARPTIMER = 30; ///Link->Misc index to store the timer to prevent warping Link
  75.     const int WARPSFX = 65;
  76.    
  77.     const int WARPVISUAL = 2;
  78.     int maps[MAX_PAIR] =
  79.     {
  80.         1, 2 //light, then dark, in pairs
  81.     };
  82.     int lightdmap()
  83.     {
  84.         for ( int q = 0; q < MAX_PAIR; ++q )
  85.         {
  86.             if ( maps[q] == Game->GetCurDMap() ) return maps[q-1];
  87.         }
  88.         return -1;
  89.     }
  90.    
  91.     int dungeons[]= { 3 }; /List of dungeons.
  92.     void run()
  93.     {
  94.         int destdmap = lightdmap();
  95.         if ( destmap == -1 ) //error, can;t warp out
  96.         {
  97.             Audio->PlaySound(ERRSOUND);
  98.             Quit();
  99.         }
  100.         mapdata destmap = Game->LoadMapData(DMapMap[destdmap], Game->GetCurScreen());
  101.         if ( destmap->isSolid(Link->X, Link->Y) )
  102.         {
  103.             Audio->PlaySound(ERRSOUND);
  104.             //show visual effect, drawing screen to layer
  105.             Quit()
  106.         }
  107.         sparkle.clear();
  108.         sparkle.set(destdmap, DMapMap[destdmap], Game->GetCurScreen(), Game->GetCurDMap());
  109.         sparkle.setvalid();
  110.         sparkle.create();
  111.         Link->Misc[LM_WARPTIMER] = NOWARP_TIME;
  112.         Link->WarpEx(destdmap, Game->GetCurScreen(), Link->X, Link->Y, ... ); //IDR the args order right now.
  113.        
  114.     }
  115. }
  116.        
  117.        
  118.        
  119.                
  120.             }
RAW Paste Data