Advertisement
ZoriaRPG

ZScript: Z3 Style Magic Mirror (v0.3.0, Tested, Working)

Nov 22nd, 2016
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.34 KB | None | 0 0
  1. ///////////////////////
  2. /// Z3 Magic Mirror ///
  3. /// v0.3.0          ///
  4. /// 22-Nov-2016     ///
  5. /// By: ZoriaRPG    ///
  6. ///////////////////////////////////////
  7. /// Partial Rewrite of my Original  ///
  8. /// WarpFunctions.zh b1.1 from 2014 ///
  9. /// originally made by request for  ///
  10. /// Obderhode and used in the quest ///
  11. /// 'The Three Whistles'            ///
  12. ///////////////////////////////////////
  13.  
  14. //! To-Do
  15. //! Add in freeze flags and ghost suspension
  16.  
  17.  //! BUG    If Link is warped onto an entrance/exit (cave walk down/u) warp tile, that tile will activate and he will
  18.  //!        seem to walk in and out of a place then error out and return.
  19.  
  20. /// Global Array
  21. int Mirror[214747];
  22.  
  23. const int TEST_MIRROR_SPARKLE = 0;
  24. const int MIRROR_SPARKLE_BEFORE_WAITDRAW = 0;
  25.  
  26. //Moon Pearl Goodies
  27. const int I_MIRROR = 160;
  28. const int I_MOONPEARL = 200;
  29. const int I_BUNNYRING = 201; //A wisp ring twith a LTM for Bunny Sprites
  30.  
  31. //Options
  32. const int WARP_RETURNS_ON_INJURY        = 1;
  33. const int REQUIRE_MOON_PEARL            = 1;
  34. const int MIRROR_RETURNS_TO_DUNGEON_ENTRANCE    = 1; //This requires placing a warp return square on dungeon entrance screens.
  35.  
  36. const int MIRROR_POST_WARP_TIMER_NUM_FRAMES = 75; // Number of frames afer warping, before Link may use a warp return sparkle.
  37.  
  38. const int POST_WARP_LINK_IS_INVINCIBLE      = 0;     //If se tto '1', Link->CollDetection will be disabled for a number of
  39.                         //frames equal to:
  40.  
  41. const int WARP_INVULNERABILITY_FRAMES       = 90; //Number of frames that Link is invulnerable after warping.
  42.  
  43. //!! Caution: This may conflict with other items that grant invulnerability!
  44.  
  45.  
  46. ///Constants for Array Indices of Mirror[]
  47.  
  48. const int IS_WARPING        = 0;
  49. const int AFTER_WARP        = 1;
  50. const int RETURN_WARP       = 2;
  51. const int AFTER_RETURN_WARP     = 3;
  52.  
  53. const int WARP_SPARKLE          = 10;
  54. const int WARP_SPARKLE_DMAP         = 11;
  55. const int WARP_SPARKLE_SCREEN       = 12;
  56. const int WARP_SPARKLE_X        = 13;
  57. const int WARP_SPARKLE_Y        = 14;
  58. const int WARP_SPARKLE_RETURN_DMAP  = 15;
  59.  
  60. const int WARP_LINK_X           = 20;
  61. const int WARP_LINK_Y           = 21;
  62. const int WARP_LINK_Z           = 22;
  63. const int WARP_LINK_HP          = 23;
  64. const int WARP_LINK_TEMP_INVULNERABILITY = 24;
  65.  
  66. const int MIRROR_SPARKLE_COMBO_FRAME = 30; //Mirror array index
  67. const int MIRROR_POST_WARP_TIMER = 40;
  68.  
  69.  
  70.  
  71. //Settings
  72.  
  73. //Sounds
  74. const int SFX_WARP_ERROR    = 67;
  75. const int SFX_WARP      = 73;
  76. const int SFX_WARP_DUNGEON  = 16;
  77.  
  78. const int WARP_WAVE_DUR     = 100; //Duration of warp wavy animation (overworld)
  79. const int WARP_WAVE_DUR_DUNGEON = 100; //Duration of warp wavy animation (inside dungeons)
  80.  
  81. const int WARP_DUR      = 60;
  82. const int POST_WARP_DELAY   = 15;
  83.  
  84.  
  85.  
  86. //Mirror Sparkle Settings
  87. const int MIRROR_SPARKLE_COMBO      = 32596; // COmbo of sparkle or other warp return effect.
  88. const int MIRROR_SPARKLE_COMBO_LAYER    = 2;
  89. const int MIRROR_SPARKLE_COMBO_W    = 1;
  90. const int MIRROR_SPARKLE_COMBO_H    = 1;
  91. const int MIRROR_SPARKLE_COMBO_CSET     = 0;
  92. const int MIRROR_SPARKLE_COMBO_XSCALE   = -1;
  93. const int MIRROR_SPARKLE_COMBO_YSCALE   = -1;
  94. const int MIRROR_SPARKLE_COMBO_RX   = 0;
  95. const int MIRROR_SPARKLE_COMBO_RY   = 0;
  96. const int MIRROR_SPARKLE_COMBO_RANGLE   = 0;
  97.  
  98. const int MIRROR_SPARKLE_COMBO_FLIP     = 0;
  99. const int MIRROR_SPARKLE_COMBO_OPACITY  = 64;
  100.  
  101. const int MIRROR_SPARKLE_COMBO_NUM_FRAMES = 4;
  102. const int MIRROR_SPARKLE_COMBO_INIT_FRAME = 1;
  103.  
  104.  
  105.  
  106.  
  107. //Accessors
  108. int IsWarping(){ return Mirror[IS_WARPING]; }
  109. void IsWarping(bool state){ if ( state ) Mirror[IS_WARPING] = 1; else Mirror[IS_WARPING] = 0; }
  110.  
  111. int AfterWarp(){ return Mirror[AFTER_WARP]; }
  112. void AfterWarp(bool state){ if ( state ) Mirror[AFTER_WARP] = 1; else Mirror[AFTER_WARP] = 0; }
  113.  
  114. int IsReturnWarping(){ return Mirror[RETURN_WARP]; }
  115. void IsReturnWarping(bool state){ if ( state ) Mirror[RETURN_WARP] = 1; else Mirror[RETURN_WARP] = 0; }
  116.  
  117. int AfterReturnWarp(){ return Mirror[AFTER_RETURN_WARP]; }
  118. void AfterReturnWarp(bool state){ if ( state ) Mirror[AFTER_RETURN_WARP] = 1; else Mirror[AFTER_RETURN_WARP] = 0; }
  119.  
  120. int WarpSparkle(){ return Mirror[WARP_SPARKLE]; }
  121. void WarpSparkle(bool state){ if ( state ) Mirror[WARP_SPARKLE] = 1; else Mirror[WARP_SPARKLE] = 0; }
  122.  
  123. int WarpSparkleReturn(){ return Mirror[WARP_SPARKLE_RETURN_DMAP]; }
  124. void WarpSparkleReturn(int dmap){ Mirror[WARP_SPARKLE_RETURN_DMAP] = dmap; }
  125.  
  126. int WarpSparkleDMap(){ return Mirror[WARP_SPARKLE_DMAP]; }
  127. void WarpSparkleDMap(int dmap){ Mirror[WARP_SPARKLE_DMAP] = dmap; }
  128.  
  129. int WarpSparkleX(){ return Mirror[WARP_SPARKLE_X]; }
  130. void WarpSparkleX(int x){ Mirror[WARP_SPARKLE_X] = x; }
  131.  
  132. int WarpSparkleY(){ return Mirror[WARP_SPARKLE_Y]; }
  133. void WarpSparkleY(int y){ Mirror[WARP_SPARKLE_Y] = y; }
  134.  
  135. int WarpSparkleScreen(){ return Mirror[WARP_SPARKLE_SCREEN]; }
  136. void WarpSparkleScreen(int screen){ Mirror[WARP_SPARKLE_SCREEN] = screen; }
  137.  
  138. //The following four functions are used to manipulate,a nd check the post-warp timer,
  139. //that prevents Link from being sent back by a sparkle as soon as he finishes warping.
  140.  
  141. int WarpReturnWait(){ return Mirror[MIRROR_POST_WARP_TIMER]; }
  142. void ReducePostWarpTimer(){ if ( Mirror[MIRROR_POST_WARP_TIMER] > 0 ) Mirror[MIRROR_POST_WARP_TIMER]--; }
  143. void SetPostWarpTimer(){ Mirror[MIRROR_POST_WARP_TIMER] = MIRROR_POST_WARP_TIMER_NUM_FRAMES; }
  144. void ClearPostWarpTimer(){ Mirror[MIRROR_POST_WARP_TIMER] = 0; }
  145.  
  146.  
  147. //Functions
  148.  
  149. //Checks the present DMap and returns irts counterpart.
  150. //!! You must set up the arrays inside this function, for it to work.
  151. int GetOtherworldlyDMap(int dmap){
  152.     int q[4];
  153.     int LightWorldDMaps[]={3,-1,-1,-1,-1}; //Populate these two arrays with the IDs of your light and dark world dmaps
  154.     int DarkWorldDMaps[]={8,-1,-1,-1,-1}; //in matched pairs.
  155.     for ( q[0] = 0; q[0] < SizeOfArray(LightWorldDMaps); q[0]++ ) {
  156.         q[1] = LightWorldDMaps[ q[0] ];
  157.         q[2] = DarkWorldDMaps[ q[0] ];
  158.         if ( dmap == q[1] ) return DarkWorldDMaps[ q[0] ];
  159.         if ( dmap == q[2] ) return LightWorldDMaps[ q[0] ];
  160.     }
  161.     return -1;
  162. }
  163.  
  164. //Returns if the present dmap is a dark world dmap
  165. //!! You must set up the arrays inside this function, for it to work.
  166. bool IsDarkWorld(){
  167.     int DarkWorldDMaps[]={8,-1,-1,-1,-1};
  168.     for ( int q = 0; q < SizeOfArray(DarkWorldDMaps); q++ ) {
  169.         if ( Game->GetCurDMap() == DarkWorldDMaps[q] ) return true;
  170.     }
  171.     return false;
  172. }
  173.  
  174. //Generates coordinates for the warp return sparkle.
  175. //this is set when we use the mirror.
  176. void SetWarpReturn(){
  177.     WarpSparkle(true);
  178.     WarpSparkleX(Link->X);
  179.     WarpSparkleY(Link->Y);
  180.     WarpSparkleDMap( GetOtherworldlyDMap( Game->GetCurDMap() ) );
  181.     WarpSparkleScreen(Game->GetCurScreen());
  182.     WarpSparkleReturn(Game->GetCurDMap());
  183. }
  184.  
  185. //Removes the warp sparkle, after using it.
  186. void ClearWarpSparkle(){
  187.     WarpSparkle(false);
  188.     WarpSparkleX(-100);
  189.     WarpSparkleY(-100);
  190.     WarpSparkleDMap(-1);
  191.     WarpSparkleScreen(-1);
  192.     WarpSparkleReturn(-1);
  193. }
  194.  
  195. //Returns if Link is in a dungeon based on the array dungeonDMaps[]
  196. //!! You must set up the array inside this function, for it to work.
  197. bool IsDungeonDMap(){
  198.     int dungeonDMaps[]={20,21,22};//List all dungeon DMaps here
  199.     for ( int q = 0; q < SizeOfArray(dungeonDMaps); q++ ) {
  200.         if ( Game->GetCurDMap() == dungeonDMaps[q] ) return true;
  201.         return false;
  202.     }
  203. }
  204.  
  205. //Returns if the warp destination is solid, prior to warping.
  206. bool WarpDestSolid(int x, int y, int screen, int map){
  207.     return ( Game->GetComboSolid(map, screen, ComboAt(x,y)) );
  208. }
  209.    
  210. //! Main Functions to Call before Waitdraw()
  211.  
  212. //Handles the initial warp routines.
  213. void MirrorWarpLink() {
  214.     if ( IsWarping() ){
  215.         Link->X = Mirror[WARP_LINK_X];
  216.         Link->Y = Mirror[WARP_LINK_Y];
  217.         SetPostWarpTimer();
  218.         NoAction();
  219.         Game->PlaySound(SFX_WARP);
  220.         Screen->Wavy = WARP_WAVE_DUR;
  221.         //Freeze all enemies and ghost scripts
  222.         for(int q = (WARP_WAVE_DUR + POST_WARP_DELAY) / 2; q > 0; q--){
  223.             NoAction();
  224.             Waitframe();
  225.         }
  226.         //resume npcs and ghost scripts
  227.         Link->PitWarp(GetOtherworldlyDMap(Game->GetCurDMap()), Game->GetCurScreen());
  228.         IsWarping(false);
  229.         for(int q = (WARP_WAVE_DUR + POST_WARP_DELAY) / 2; q > 0; q--){
  230.             NoAction();
  231.             Waitframe();
  232.         }
  233.         AfterWarp(true);
  234.     }
  235.    
  236.     if (IsReturnWarping() ){
  237.         Mirror[WARP_LINK_HP] = Link->HP;
  238.  
  239.         Link->X = WarpSparkleX();
  240.         Link->Y = WarpSparkleY();
  241.         NoAction();
  242.         Game->PlaySound(SFX_WARP);
  243.         Screen->Wavy = WARP_WAVE_DUR;
  244.         //Freeze all enemies and ghost scripts
  245.         for(int q = (WARP_WAVE_DUR + POST_WARP_DELAY) / 2; q > 0; q--){
  246.             NoAction();
  247.             Waitframe();
  248.         }
  249.         //resume npcs and ghost scripts
  250.         Link->PitWarp(WarpSparkleReturn(), WarpSparkleScreen());
  251.        
  252.         IsReturnWarping(false);
  253.         for(int q = (WARP_WAVE_DUR + POST_WARP_DELAY) / 2; q > 0; q--){
  254.             NoAction();
  255.             Waitframe();
  256.         }
  257.         AfterReturnWarp(true);
  258.     }
  259. }
  260.  
  261. //Post-warp cleanup, and bounce.
  262. void WarpFinish() {
  263.     if (AfterWarp()){
  264.         if ( Link->Action == LA_GOTHURTLAND || Link->Action == LA_GOTHURTWATER ) Link->HitDir = -1;
  265.         //SetWarpReturn();
  266.         //If the destination is solid, send Link back.
  267.         if ( WarpDestSolid(CenterLinkX(), CenterLinkY(), Game->GetCurScreen(), Game->GetCurMap() ) ) {
  268.             ClearWarpSparkle();
  269.             Game->PlaySound(SFX_WARP_ERROR);
  270.             WaitNoAction();
  271.             Screen->Wavy = WARP_WAVE_DUR;
  272.             //freeze all enemies and ghost scripts.
  273.             for(int q = (WARP_WAVE_DUR + POST_WARP_DELAY); q > 0; q--){
  274.                 NoAction();
  275.                 Waitframe();
  276.             }
  277.             //resume npcs and ghost scripts
  278.             Link->X = Mirror[WARP_LINK_X];
  279.             Link->Y = Mirror[WARP_LINK_Y];
  280.             Link->PitWarp(GetOtherworldlyDMap(Game->GetCurDMap()), Game->GetCurScreen());
  281.             Screen->Wavy = WARP_WAVE_DUR;
  282.            
  283.             AfterWarp(false);
  284.             for(int q = (WARP_WAVE_DUR + POST_WARP_DELAY); q > 0; q--){
  285.                 NoAction();
  286.                 Waitframe();
  287.             }
  288.         }
  289.         if ( Link->HP < Mirror[WARP_LINK_HP] && WARP_RETURNS_ON_INJURY) { //If Link is injured, send him back.
  290.             Link->HP = Mirror[WARP_LINK_HP];
  291.             Game->PlaySound(SFX_WARP);
  292.             Screen->Wavy = WARP_WAVE_DUR;
  293.             //freeze all enemies and ghost scripts.
  294.             for(int q = (WARP_WAVE_DUR + POST_WARP_DELAY) / 2; q > 0; q--){
  295.                 NoAction();
  296.                 Waitframe();
  297.             }
  298.             //resume npcs and ghost scripts
  299.             Link->X = Mirror[WARP_LINK_X];
  300.             Link->Y = Mirror[WARP_LINK_Y];
  301.             Link->PitWarp(WarpSparkleReturn(), Game->GetCurScreen());
  302.  
  303.             Link->X = Mirror[WARP_LINK_X];
  304.             Link->Y = Mirror[WARP_LINK_Y];
  305.             Link->HP = Mirror[WARP_LINK_HP];
  306.            
  307.             AfterWarp(false);
  308.             for(int q = (WARP_WAVE_DUR + POST_WARP_DELAY) / 2; q > 0; q--){
  309.                 NoAction();
  310.                 Waitframe();
  311.             }
  312.         }
  313.         else {
  314.             Link->X = Mirror[WARP_LINK_X];
  315.             Link->Y = Mirror[WARP_LINK_Y];
  316.             //SetPostWarpTimer();
  317.             //Mirror[WARP_LINK_TEMP_INVULNERABILITY] = WARP_INVULNERABILITY_FRAMES;
  318.             AfterWarp(false);
  319.         }
  320.     }
  321.    
  322.     if (AfterReturnWarp()){
  323.         if ( Link->Action == LA_GOTHURTLAND || Link->Action == LA_GOTHURTWATER ) Link->HitDir = -1;
  324.         ClearWarpSparkle();
  325.         Mirror[WARP_LINK_TEMP_INVULNERABILITY] = WARP_INVULNERABILITY_FRAMES;
  326.         AfterReturnWarp(false);
  327.         ClearPostWarpTimer();
  328.            
  329.     }
  330.    
  331.     if ( POST_WARP_LINK_IS_INVINCIBLE ) {
  332.         if ( Mirror[WARP_LINK_TEMP_INVULNERABILITY] ) {
  333.             //If we find a way to Flicker Link, it goes here.
  334.             Link->CollDetection = false;
  335.             Mirror[WARP_LINK_TEMP_INVULNERABILITY]--;
  336.         }
  337.         if ( !Mirror[WARP_LINK_TEMP_INVULNERABILITY] ) Link->CollDetection = true;
  338.     }
  339.    
  340.     //if ( Mirror[MIRROR_POST_WARP_TIMER] > 0 ) Mirror[MIRROR_POST_WARP_TIMER]--;
  341. }
  342.  
  343.  
  344. //Creates the mirror return sparkle.
  345. void MirrorSparkle(){
  346.     if ( Game->GetCurDMap() == WarpSparkleDMap() && Game->GetCurScreen() == WarpSparkleScreen() ) {
  347.         Screen->DrawCombo(  MIRROR_SPARKLE_COMBO_LAYER, WarpSparkleX(), WarpSparkleY(),
  348.             MIRROR_SPARKLE_COMBO, MIRROR_SPARKLE_COMBO_H, MIRROR_SPARKLE_COMBO_W, MIRROR_SPARKLE_COMBO_CSET,
  349.             MIRROR_SPARKLE_COMBO_XSCALE, MIRROR_SPARKLE_COMBO_YSCALE, MIRROR_SPARKLE_COMBO_RX,
  350.             MIRROR_SPARKLE_COMBO_RY, MIRROR_SPARKLE_COMBO_RANGLE, Mirror[MIRROR_SPARKLE_COMBO_FRAME],
  351.             MIRROR_SPARKLE_COMBO_FLIP, true, MIRROR_SPARKLE_COMBO_OPACITY) ; //Mirror sparkle
  352.        
  353.         //Reduce the frames
  354.         if ( Mirror[MIRROR_SPARKLE_COMBO_FRAME] >= MIRROR_SPARKLE_COMBO_NUM_FRAMES ) Mirror[MIRROR_SPARKLE_COMBO_FRAME] = MIRROR_SPARKLE_COMBO_INIT_FRAME;
  355.         else Mirror[MIRROR_SPARKLE_COMBO_FRAME]++;
  356.            
  357.         if ( !WarpReturnWait() && !IsTempInvincible() ){
  358.            
  359.             if ( Abs( Link->X - WarpSparkleX()) < 8 && Abs(Link->Y - WarpSparkleY()) < 8 )
  360.             {
  361.                 //Reurn Link via the portal
  362.                 IsReturnWarping(true);
  363.             }
  364.         }
  365.     }
  366. }
  367.  
  368. bool IsTempInvincible(){
  369.     if ( Mirror[WARP_LINK_TEMP_INVULNERABILITY] && POST_WARP_LINK_IS_INVINCIBLE ) return true;
  370.     if ( !Mirror[WARP_LINK_TEMP_INVULNERABILITY] || !POST_WARP_LINK_IS_INVINCIBLE ) return false;
  371. }
  372.  
  373. void TestSparkle(){
  374.     int x = WarpSparkleX();
  375.     int y = WarpSparkleY();
  376.     if ( x < 0 ) x = 0;
  377.     if ( y < 0 ) y = 0;
  378.     Screen->DrawCombo(  MIRROR_SPARKLE_COMBO_LAYER, x, y,
  379.             MIRROR_SPARKLE_COMBO, MIRROR_SPARKLE_COMBO_H, MIRROR_SPARKLE_COMBO_W, MIRROR_SPARKLE_COMBO_CSET,
  380.             MIRROR_SPARKLE_COMBO_XSCALE, MIRROR_SPARKLE_COMBO_YSCALE, MIRROR_SPARKLE_COMBO_RX,
  381.             MIRROR_SPARKLE_COMBO_RY, MIRROR_SPARKLE_COMBO_RANGLE, Mirror[MIRROR_SPARKLE_COMBO_FRAME],
  382.             MIRROR_SPARKLE_COMBO_FLIP, true, MIRROR_SPARKLE_COMBO_OPACITY) ; //Mirror sparkle
  383.        
  384.         //Reduce the frames
  385.         if ( Mirror[MIRROR_SPARKLE_COMBO_FRAME] >= MIRROR_SPARKLE_COMBO_NUM_FRAMES ) Mirror[MIRROR_SPARKLE_COMBO_FRAME] = MIRROR_SPARKLE_COMBO_INIT_FRAME;
  386.         else Mirror[MIRROR_SPARKLE_COMBO_FRAME]++;
  387. }
  388.  
  389.  
  390. //Runs the moon pearl bunny sprite change, and halts using any item other than the mirror.
  391. void MoonPearl(){
  392.     if ( IsDarkWorld() && !Link->Item[I_MOONPEARL] && !Link->Item[I_BUNNYRING] ) Link->Item[I_BUNNYRING] = true;
  393.     if ( !IsDarkWorld() && Link->Item[I_BUNNYRING] ) Link->Item[I_BUNNYRING] = false;
  394.     if ( IsDarkWorld() && Link->Item[I_MOONPEARL] && Link->Item[I_BUNNYRING] ) Link->Item[I_BUNNYRING] = false;
  395.     if ( Link->Item[I_BUNNYRING] ) {
  396.         if ( Link->PressA && GetEquipmentA() != I_MIRROR ) Link->PressA = false;
  397.         if ( Link->PressB && GetEquipmentB() != I_MIRROR ) Link->PressB = false;
  398.     }
  399. }
  400.  
  401. /// Items
  402.  
  403. item script Mirror{
  404.     void run(){
  405.         if ( IsDungeonDMap() && MIRROR_RETURNS_TO_DUNGEON_ENTRANCE ) {
  406.             //Warp to dungeon entrance.
  407.             Game->PlaySound(SFX_WARP_DUNGEON);
  408.             Screen->Wavy = WARP_WAVE_DUR_DUNGEON;
  409.             Link->Warp(Game->GetCurDMap(), Game->DMapContinue[Game->GetCurDMap()]);
  410.         }
  411.         else {
  412.             if ( IsDarkWorld() ) {
  413.                 SetPostWarpTimer();
  414.                 //Mirror[MIRROR_POST_WARP_TIMER] = MIRROR_POST_WARP_TIMER_NUM_FRAMES;
  415.                 Mirror[WARP_LINK_X] = Link->X;
  416.                 Mirror[WARP_LINK_Y] = Link->Y;
  417.                 Mirror[WARP_LINK_HP] = Link->HP;
  418.                 SetWarpReturn();
  419.                 IsWarping(true);
  420.             }
  421.             //Warp to other world
  422.             if ( !IsDarkWorld() && SFX_WARP_ERROR ) Game->PlaySound(SFX_WARP_ERROR);
  423.         }
  424.     }
  425. }
  426.  
  427. //Global Script Example
  428.  
  429. global script Z3_Mirror{
  430.     void run(){
  431.         while(true){
  432.             if ( REQUIRE_MOON_PEARL ) MoonPearl();
  433.             ReducePostWarpTimer();
  434.             MirrorWarpLink();
  435.            
  436.             //if ( TEST_MIRROR_SPARKLE ) TestSparkle();
  437.             //if ( MIRROR_SPARKLE_BEFORE_WAITDRAW ) MirrorSparkle();
  438.             WarpFinish();
  439.             Waitdraw();
  440.            
  441.             //if ( !MIRROR_SPARKLE_BEFORE_WAITDRAW ) MirrorSparkle();
  442.             if ( WarpSparkle() ) MirrorSparkle(); //Call only if it exists.
  443.             Waitframe();
  444.         }
  445.     }
  446. }
  447.  
  448. //Deprecated
  449.  
  450. const int SOLIDITY_CHECK_DISTANCE = 8;
  451.  
  452. bool TouchingSolid(int x, int y) {
  453.     if ( Screen->isSolid(x,y) ||
  454.         Screen->isSolid(x + SOLIDITY_CHECK_DISTANCE, y) ||
  455.         Screen->isSolid(x + SOLIDITY_CHECK_DISTANCE, y+SOLIDITY_CHECK_DISTANCE) ||
  456.         Screen->isSolid(x + SOLIDITY_CHECK_DISTANCE, y-SOLIDITY_CHECK_DISTANCE) ||
  457.         Screen->isSolid(x - SOLIDITY_CHECK_DISTANCE, y) ||
  458.         Screen->isSolid(x - SOLIDITY_CHECK_DISTANCE, y+SOLIDITY_CHECK_DISTANCE) ||
  459.         Screen->isSolid(x - SOLIDITY_CHECK_DISTANCE, y-SOLIDITY_CHECK_DISTANCE) ) {
  460.         return true;
  461.     }
  462.     return false;
  463. }
  464.  
  465. //Cape
  466.  
  467. //Cane of Byrna
  468.  
  469. //! I need to include these, along with IsInvisible() and IsInvincible() to ensure that there ar eno comflicts between this and other cape/cane scripts.
  470.  
  471. const int CAPE_ON = 50;
  472. const int BYRNA_ON = 51;
  473.  
  474. item script CapeOfInvisibility{
  475.     void run(){
  476.         if ( Mirror[CAPE_ON] ) { Mirror[CAPE_ON] = 0; }
  477.         else Mirror[CAPE_ON] = 1;
  478.     }
  479. }
  480.  
  481. item script CaneOfByrna{
  482.     void run(){
  483.         if ( Mirror[BYRNA_ON] ) { Mirror[BYRNA_ON] = 0; }
  484.         else Mirror[BYRNA_ON] = 1;
  485.     }
  486. }
  487.  
  488. void CaneOfByrna(){}
  489. void CapeOfInvisibility(){}
  490.  
  491. bool IsInvisible(){
  492.     if ( Mirror[CAPE_ON] ) return true;
  493.     return false;
  494. }
  495.  
  496. bool IsInvincible(){
  497.     if ( Mirror[BYRNA_ON] || Mirror[WARP_LINK_TEMP_INVULNERABILITY] ) return true;
  498.     return false;
  499. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement