ZoriaRPG

ZScript Remote Door Handling Pre-Alpha

Nov 15th, 2016
115
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Better Method:
  2.  
  3. // When we enter a screen for which we haven't saved the doors, since the last load, we will read
  4. //Screen->Doors, and place invisible combos with no solidity, on layer 1, or 2, at a position by each door, to indicate its type.
  5. //Thereafter, every frame, until Link changes screens, we will check if the types that we place match Screen->Doors,
  6. //and if not, we update them to the correct types.
  7. //We flag Screen->D that we stored them, and we save them to the primary doors array.
  8. //We will backup from this array, and restore to it, as an entry point/reference.
  9. //We store the last screen that Link visited, and the dmap, in Link->Misc.
  10. //If this changes, we know that the screen changed.
  11. //When the screen changes, we remove the flag that we set on the last screen.
  12.  
  13. const int LINK_LAST_SCREEN = 10; //Index of Link->Misc[] to use to store screen and DMap.
  14.  
  15. void StoreDMapScreen(){
  16.     int a[2];
  17.     a[0] = Game->GetCurScreen() / 10000;
  18.     a[1] = Game->GetCurDMap();
  19.     Link->Misc[LINK_LAST_SCREEN] = a[0] + a[1];
  20. }
  21.  
  22. int GetLastScreen(){
  23.     return ( Link->Misc[LINK_LAST_SCREEN] - ( Link->Misc[LINK_LAST_SCREEN] << 0 )) *10000;
  24. }
  25.  
  26. int GetLastDMap() { return Link->Misc[LINK_LAST_SCREEN] << 0; }
  27.  
  28. bool ScreenChanged() { return ( Game->GetCurScreen() != GetLastScreen() ); }
  29. bool DMapChanged() { return ( Game->GetCurDMap() != GetLastDMap() ); }
  30.  
  31. //Just a silly reminder to do this at the start of every game.
  32. void SetInitialScreenDMap() { StoreDMapScreen(); }
  33.  
  34. //Update if the screen changes. We will want to do some other things at this time, so we might want to package them all together.
  35. void UpdateScreenDMap() { if ( ScreenChanged() || DMapChanged() ) StoreDMapScreen(); }
  36.  
  37.  
  38. //-----------------
  39.  
  40.  
  41. //Door types. Use with Screen->Door[]
  42. const int D_WALL                = 0;
  43. const int D_OPEN                = 1;
  44. const int D_LOCKED              = 2;
  45. const int D_UNLOCKED            = 3; // A locked door that has been opened
  46. const int D_SHUTTER             = 4; // Defeat enemies to unlock this door
  47. const int D_BOMB                = 6; // A door that changes when bombed
  48. const int D_BOMBED              = 7; // A door that has been bombed
  49. const int D_WALKTHRU            = 8; // Push against the wall to pass through
  50. const int D_BOSSLOCKED          = 10;
  51. const int D_BOSSUNLOCKED        = 11; // A boss door that has been opened
  52. const int D_OPENSHUTTER         = 12; // A shutter that has been opened
  53. const int D_1WAYSHUTTER         = 14; // A shutter that locks behind you and never opens
  54.  
  55. //Backup Doors
  56.  
  57. int StoredDoors[];
  58. //We should do two combos per door. DO we want to use comboD or COmboFI?
  59.  
  60. const int CMB_D_WALL
  61.  
  62. //Unique combos for doors and walls? This would be better with flags, so let's do it that way.
  63. const int CMB_D_WALL                = 0;
  64. const int CMB_D_OPEN                = 1;
  65. const int CMB_D_LOCKED              = 2;
  66. const int CMB_D_UNLOCKED            = 3; // A locked door that has been opened
  67. const int CMB_D_SHUTTER             = 4; // Defeat enemies to unlock this door
  68. const int CMB_D_BOMB                = 6; // A door that changes when bombed
  69. const int CMB_D_BOMBED              = 7; // A door that has been bombed
  70. const int CMB_D_WALKTHRU            = 8; // Push against the wall to pass through
  71. const int CMB_D_BOSSLOCKED          = 10;
  72. const int CMB_D_BOSSUNLOCKED        = 11; // A boss door that has been opened
  73. const int CMB_D_OPENSHUTTER         = 12; // A shutter that has been opened
  74. const int CMB_D_1WAYSHUTTER         = 14; // A shutter that locks behind you and never opens
  75.  
  76.  
  77. //We need a combo type for 'normal' states, and a flag for opened states.
  78. const int CT_D_WALL                = CT_SRCIPT1;
  79. const int CF_WALL_WALKTHROUGH = CF_SCRIPT2; //This fla if we can walk through it.
  80. //ActuallyI'm not sure if we need that, as that's just a wall that ZC does funny things with.
  81. //We could just ignore storeing walkthrough walls.
  82. const int CT_D_DOOR = CT_SCRIPT2; //Open, or locked door.
  83.    
  84. const int CT_DOOR                = CF_SCRIPT1; //Combo CT_D_WALL + FLAG
  85. const int CF_LOCKDOOR                = CF_SCRIPT1; //If it's a locked door combo, it'll be CT_DOOR ad CF_LOCKDDOOR
  86. //const int FLAG_D_UNLOCKED            = 3; A locked door becomes door combo, but without the locked fla
  87. //CF_SCRIPT1 is an open state
  88.  
  89. //DOn't locked doors have their own combo type?
  90.  
  91. const int FLAG_D_LOCKED              = 2;
  92.  
  93. const int CT_SHUTTER = CT_SCRIPT2; //ANy shutter
  94. const int CF_SHUTTER_OPEN = CF_SCRIPT1
  95. const int CF_SHUTTER_CLOSED = CF_SCRIPT2
  96. const int CF_SHUTTER_1WAY = CF_SCRIPT3
  97.  
  98. const int CT_BOMBWALL = ? //Bomb walls should be a bomb flag, bomb next?
  99. const int CF_BOMBED = CF_SCRIPT1; //it's unlocked, so flag it.
  100.  
  101. const int CT_BOSSDOOR = CT_SCRIPT5; //Likewise, boss doors are their own combo type, so we should need to do this.
  102. const int CF_BOSSOPEN = CF_SCRIPT1; //it is open, so flag it.
  103.  
  104.  
  105.  // A locked door that has been opened
  106. const int FLAG_D_SHUTTER             = 4; // Defeat enemies to unlock this door
  107. const int FLAG_D_BOMB                = 6; // A door that changes when bombed
  108. const int FLAG_D_BOMBED              = 7; // A door that has been bombed
  109. //const int FLAG_D_WALKTHRU            = 8; // Push against the wall to pass through
  110. const int FLAG_D_BOSSLOCKED          = 10;
  111. const int FLAG_D_BOSSUNLOCKED        = 11; // A boss door that has been opened
  112. //const int FLAG_D_OPENSHUTTER         = 12; // A shutter that has been opened
  113. //const int FLAG_D_1WAYSHUTTER         = 14; // A shutter that locks behind you and never opens
  114.  
  115. Wall Sets
  116. wall
  117. open
  118. locked  unlocked
  119. shutter-closed  shutter_open    1-way
  120. bomb    bombed
  121. walkthrouh
  122. bosslock    bosslock_opem
  123.  
  124. void CheckDoors(){ } //Check doors by combo locations, and combo types/flags, then store them for this screen int he array if they differ from what's stored.
  125. //We do this only when we enter a screen. I'm not sure if 1-way shutters could break. Who wantsx to waer that they will?
  126.  
  127. void RestoreDoors() { } //if the Screen->Doors array differs from what is on the screen, update it.
  128.  
  129. //If we are using classic, and only one set of door combos for all dungeons, we can do it by ComboD
  130.  
  131. void StoreDoors[] {} //Use ComboD from the screens, but wait, we need to copy those combos to layer 1!
  132.     //it may be easier to use combos and flags on layer 1 for this, period.
  133.     //When Link enters a screen, we read Screen->Doors, and place invisible combos on layer 1. These will persist as long as the game is not quit.
  134.     //WIll that suffice?We need to know what to do if we quit the game.
  135.     //At  least this will give us a way to READ the doors on any screen.
  136.     //In this case, we can ignore flags, and just use pure comboD, as we can define some invisible combos for this.
  137.    
  138.    
  139. void SetRoomDoors(){
  140.         //Read the invisible combos on the screen, and set Screen->Doors based on them, before Waitdraw, when we enter any screen.
  141.    
  142.    
  143. }
  144. void CheckClassicDoors() {
  145.     int doors[8];
  146.     //We only check if the screen changes, if a temp flag is not set.
  147.     //We the screen changes, and we check, we set a temp flag. We'll remove that somehow when we leave the screen.
  148.     //Link->Misc seems a good place to store it.
  149.    
  150.     //We'll compare the present state of doors[] when doing this, and only store if the doors[4] differs from our combos.
  151.     //! Actually, it would be safer to check if the doors[4] differ every frame, so that any changes are saved.
  152.     //Do we also need a flag in Link->Misc tht we've restored?
  153. }
  154.    
  155. void RestoreClassicDoors() {
  156.    
  157. }
  158.    
  159. const int DOORS_ARE_ALL_NES_STYLE = 0; //Set to 1, to use ChassicDoors instead of ordinary  doors when choosing which functions to call.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×