ZoriaRPG

ZScript: Flying Fortress Alpha 0.4

May 20th, 2017
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //! We need a GetScreenDown and GetScreenUp function pair to go with the virtual maps.
  2.             }
  3.  
  4. int _____GRAM[1024];
  5. const int LOOPS_Q = 1023;
  6.  
  7.  
  8. int Fortresses[27]; //tmer, dir, speed, x, y, dmap, screen
  9.  
  10. const int FORTRESS_TIMER = 0;
  11. const int FORTRESS_DIR = 1;
  12. const int FORTRESS_SPEED = 2;
  13. const int FORTRESS_X = 3;
  14. const int FORTRESS_Y = 4;
  15. const int FORTRESS_DMAP_ID = 5;
  16. const int FORTRESS_SCREEN_ID = 6;
  17. const int FORTRESS_TILE = 7;
  18. const int FORTRESS_CSET = 8;
  19. const int FORTRES_SCALE = 9; //Scale it, blast you!
  20. const int FORTRESS_SHADOW_TILE = 10;
  21. const int FORTRESS_SHADOW_ = 11; //More scaling effects, for perspective.
  22.  
  23. const int FORTRESS_DMAP_OFFSET = 12;  // Multiply this * Fortress ID, then add element.
  24.  
  25. const int NUM_FORTRESSES = 9;
  26.  
  27. const int FORTRESS_MOVE_TMER_MIN = 120;
  28. const int FORTRESS_MOVE_TMER_MAX = 400;
  29.  
  30. const int FORTRESS_MOVE_DIST_MIN = 6;
  31. const int FORTRESS_MOVE_DIST_MAX = 14;
  32.  
  33. //! Let's hardcode some DMAPS! Z
  34.  
  35. const int FF_DMAP_SCREEN_VALID = 0;
  36. const int FF_DMAP_SCREEN_INVALID = -1;
  37. const int FF_DMAP_SCREEN_BOUNDARY = 1; //1 or higher is a screen boundary.
  38.  
  39. //A virtual DMap. 0s are empty space, 1s are screens, 2s are boundaries.
  40. //Should each edge and corner be a unique value
  41.  
  42. /*
  43. -1 empty space
  44. 0 has sceens on each side
  45.  
  46. 1 cannot turn up
  47. 2 cannot turn down
  48. 4 cannot turn right
  49. 8 cannot turn up
  50.  
  51.  
  52. */
  53. const int NOT_VALID_SCREEN = -1;
  54. const int CANNOT_TURN_UP = 1;
  55. const int CANNOT_TURN_DOWN = 2;
  56. const int CANNOT_TURN_RIGHT = 4;
  57. const int CANNOT_TURN_LEFT = 8;
  58.  
  59. //A virtual map with the edges marked.
  60. int virtual_map_1[]={
  61.     9,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
  62.     8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
  63.     8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
  64.     8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
  65.     8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
  66.     8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
  67.     8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
  68.     10,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6 }
  69.    
  70. //Determines a random, legal directions, based on values on a vritual map.
  71. int FindLegalTurn(int virtual_map, int screen){
  72.     if ( virtual_map[screen] == 1 ) {  //cannot turn up
  73.         return ( Choose(DIR_RIGHT, DIR_LEFT, DIR_DOWN) );
  74.     }
  75.     if ( virtual_map[screen] == 2 ) { //cannot tuen down
  76.         return ( Choose(DIR_RIGHT, DIR_LEFT, DIR_UP) );
  77.     }
  78.     if ( virtual_map[screen] == 4 ) { //cannot turn right
  79.         return ( Choose(DIR_LEFT, DIR_DOWN, DIR_UP) );
  80.     }
  81.     if ( virtual_map[screen] == 5 ) { //cannot turn up or right
  82.         return ( Choose(DIR_DOWN, DIR_LEFT) );
  83.     }
  84.     if ( virtual_map[screen] == 6 ) { //cannot turn down or right
  85.         return ( Choose(DIR_UP, DIR_LEFT) );
  86.     }
  87.     if ( virtual_map[screen] == 8 ) { //cannot turn left
  88.         return ( Choose(DIR_RIGHT, DIR_DOWN, DIR_UP) );
  89.     }
  90.     if ( virtual_map[screen] == 9 ) { //cannot turn left or up
  91.         return ( Choose(DIR_RIGHT, DIR_DOWN) );
  92.     }
  93.     if ( virtual_map[screen] == 10 ) { //cannot turn left or down
  94.         return ( Choose(DIR_RIGHT, DIR_UP) );
  95.     }
  96.     return Rand(0,3); //Otherwise, return a random direction.
  97. }
  98.  
  99.  
  100. const int FORTRESS_1_TILE = 100;
  101. const int FORTRESS_SHADOW_TILE = 101;
  102. const int FORTRESS_SHADOW_Y_OFFSET = 70;
  103. const int FORTRESS_DRAW_LAYER = 6;
  104. const int FORTRESS_SHADOW_DRAW_LAYER = 6;
  105. const int FORTRESS_TILEWIDTH = 1;
  106. const int FORTRESS_TILEHEIGHT = 1;
  107.  
  108. const int FORTRESS_SHADOW_CSET = 0;
  109.  
  110. void DrawFortress(int fortress_id, int tile){
  111.     //if it is on this dmap
  112.     if ( FortressDMap(fortress_id) == Game->GetCurDMap() ) {
  113.         //...and this screen
  114.         if ( FortressScreen(fortress_id) == Game->GetCurScreen() ) {
  115.             //Draw it
  116.             Screen->DrawTile(FORTRESS_DRAW_LAYER,FortressTile(fortress_id), FortressX(fortress_id), FortressY(fortress_id),
  117.             FORTRESS_TILEWIDTH, FORTRESS_TILEHEIGHT, FortressCSet(fortress_id), FortressScale(fortress_id), FortressScale(fortress_id),
  118.             0, 0, 0, 0, true, OP_OPAQUE);
  119.             //Draw its shadow.
  120.            
  121.             Screen->DrawTile(FORTRESS_DRAW_LAYER,FortressShadowTile(fortress_id), FortressX(fortress_id), FortressY(fortress_id)+FORTRESS_SHADOW_Y_OFFSET,
  122.             FORTRESS_TILEWIDTH, FORTRESS_TILEHEIGHT, FORTRESS_SHADOW_CSET, FortresShadowScale(fortress_id), FortresShadowScale(fortress_id),
  123.             0, 0, 0, 0, true, OP_OPAQUE);
  124.         }
  125.     }
  126. }
  127.  
  128. bool FortressCanMove(int fortress_id, int virtual_map, int screen){
  129.     int dir = FortressDir(fortress_id);
  130.     int scr = FortressScreen(fortress_id);
  131.     //If the fortress is on a screen edge, check if that is a dmap edge, too.
  132.     if ( FortressAtScreenEdge(fortress_id, FortressDir(fortress_id) ){
  133.         if ( dir == DIR_LEFT ) {
  134.             if ( virtual_map[scr] >= 8 ) return false;
  135.             return true;
  136.         }
  137.         if ( dir == DIR_RIGHT ){
  138.             if ( virtual_map[scr] >= 4 &&  virtual_map[scr] <= 6 ) return false;
  139.             return true;
  140.         }
  141.         if ( dir == DIR_DOWN ) {
  142.             if ( virtual_map[scr] == 10 || virtual_map[scr] == 2 || virtual_map[scr] == 6 ) return false;
  143.             return true;
  144.         }
  145.         if ( dir == DIR_UP ) {
  146.             if ( virtual_map[scr] == 9 || virtual_map[scr] == 1 || virtual_map[scr] == 5 ) return false;
  147.             return true;
  148.         }
  149.     }
  150.     return true; //The fortress is not on a screen edge, so it can move freely.
  151. }
  152.  
  153. //Moves the fortress based on its speed, and changes its direction if it cannot move.
  154. void MoveFortress(int fortress_id, int virtual_map){
  155.     if ( FortressCanMove(fortress_id) ) {
  156.         if ( FortressDir(fortress_id) == DIR_LEFT ) {
  157.             //If it is on the edge of a screen
  158.             if ( FortressAtScreenEdge(fortress_id, FortressDir(fortress_id)) {
  159.                 //Move it one screen to the left and reset its X
  160.                 FortressScreen(fortress_id, FortressScreen(fortress_id)-1);
  161.                 FortressX(fortress_id,255);
  162.             }
  163.             //Move left
  164.             else FortressX(fortress_id, FortressX(fortress_id)-FortressSpeed(fortress_id));
  165.         }
  166.         if ( FortressDir(fortress_id) == DIR_RIGHT ) {
  167.             if ( FortressAtScreenEdge(fortress_id, FortressDir(fortress_id)) {
  168.                 //Move it one screen to the right and reset its X
  169.                 FortressScreen(fortress_id, FortressScreen(fortress_id)+1);
  170.                 FortressX(fortress_id,0);
  171.             }
  172.             //Move right
  173.             else FortressX(fortress_id, FortressX(fortress_id)+FortressSpeed(fortress_id));
  174.         }
  175.         if ( FortressDir(fortress_id) == DIR_UP ) {
  176.             if ( FortressAtScreenEdge(fortress_id, FortressDir(fortress_id)) {
  177.                 //Move it one screen up and reset its Y
  178.                 FortressScreen(fortress_id, FortressScreen(fortress_id)-=16); //THese values depend on an overworld DMap type
  179.                 FortressY(fortress_id,175); //! We need a GetScreenDown and GetScreenUp function pair to go with the virtual maps.
  180.             }
  181.             //Move up
  182.             FortressY(fortress_id, FortressY(fortress_id)-FortressSpeed(fortress_id));
  183.         }
  184.         if ( FortressDir(fortress_id) == DIR_DOWN ) {
  185.             if ( FortressAtScreenEdge(fortress_id, FortressDir(fortress_id)) {
  186.                 //Move it one screen down and reset its Y
  187.                 FortressScreen(fortress_id, FortressScreen(fortress_id)+16);
  188.                 FortressY(fortress_id,0);
  189.             }
  190.             //Move down
  191.             FortressY(fortress_id, FortressY(fortress_id)+FortressSpeed(fortress_id));
  192.         }
  193.     }
  194.     else {
  195.         //Change the direction.
  196.         FortressDir( fortress_id, FindLegalTurn(fortress_id, virtual_map) );
  197.     }
  198. }
  199.  
  200. int virtual_map_0[]={
  201.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  202.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  203.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  204.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  205.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  206.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  207.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  208.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
  209.    
  210.  
  211.  
  212. //Main fortress function. Call once per fortress, pointing to its id and the virtual map that it uses.
  213. void DoFortress(int fortress_id, int virtual_map){
  214.     DoFortressTmers(fortress_id);
  215.     MoveFortress(fortress_id, virtual_map); //Moves the fortress every frame, and chanhges its direction fi it cannot move.
  216.     //UpdateFortressScreen(fortress_id); //If the fortress moves off-screen, wrap it to the next one.
  217.     DrawFortress(fortress_id);
  218. }
  219.  
  220.  
  221. global script test_fortress{
  222.     void run(){
  223.         while(true){
  224.             for ( _____GRAM[LOOPS_Q] = 0; _____GRAM[LOOPS_Q]  < 9; _____GRAM[LOOPS_Q]++ ) {
  225.                 DoFortress(q);
  226.             }
  227.             Waitdraw();
  228.             Waitframe();
  229.         }
  230.     }
  231. }
  232.  
  233. void DoFortressTmers(int fortress_id){
  234.     if FortressTimer(fortress_id) <= 0 ) {
  235.         TurnFortress(fortress_id);
  236.     }
  237.     else {
  238.         FortressTime(fortress_id, FortressTIme(fortress_id)-1); //Reduce the timer.
  239.     }
  240. }
  241.  
  242.  
  243. const int FORTRESS_WIDTH = 8;  //Sprite dimensions.
  244. const int FORTRESS_HEIGHT = 8;
  245. const int FORTRESS_Z_LOCATION = 100; //must match this Z to enter.
  246.  
  247. bool FortressAtScreenEdge(int fortress_id, int dir){
  248.     if ( dir == DIR_LEFT && FottressX(fortress_id) <= 0+FORTRESS_WIDTH ) return true;
  249.     if ( dir == DIR_RIGHT && FortressX(fortress_id) >= 256 ) return true;
  250.     if ( dir == DIR_UP && FortressY(fortress_id)+FORTRESS_HEIGHT < 0 ) return true;
  251.     if ( dir == DIR_DOWN && FortrwessY(fortress_id) >= 176 ) return true;
  252.     return false;
  253. }
  254. //Turns the fortress if its timer expires.
  255. bool TurnFortress(int fortress_id) { {
  256.     //Choose a direction other than the present diretion.
  257.     int dir;
  258.     do { //Pick a random direction that differs from this direction.
  259.         dir = Rand(0,7);
  260.     } while ( dir != FortressDir(fortress_id);
  261.     FortressDir(fortress_id, dir); //Change the direction.
  262.     //Reset the turn timer to a randomised value. .
  263.     FortressTimer(fortress_id, FortressTime(FORTRESS_TIME_MIN, FORTRESS_TIME_MAX, FORTRESS_TIME_FRACTIONAL_MIN, FORTRESS_TIME_FRACTIONAL_MAX) );
  264. }
  265.    
  266. const int FORTRESS_TIME_MIN = 0; //minutes
  267. const int FORTRESS_TIME_MAX = 3; //minutes
  268. const int FORTRESS_TIME_FRACTIONAL_MIN = 10; //seconds
  269. const int FORTRESS_TIME_FRACTIONAL_MAX = 59; //seconds
  270.    
  271. //Accessors for Fortresses[]
  272. int FortressX(int fort_id){ return (Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_X]<<0); } //Truncated
  273. int FortressY(int fort_id){ return (Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_Y]<<0); } //Truncated
  274. int FortressDir(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_DIR]; }
  275. int FortressSpeed(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SPEED]; }
  276. int FortressDMap(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_DMAP_ID]; }
  277. int FortressScreen(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SCREEN_ID]; }
  278. int FortressTimer(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_TIMER]; }
  279. void FortressX(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_X] = VBound(v,0,255); }
  280. void FortressY(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_Y] = VBound(v,0,175); }
  281. void FortressDir(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_DIR] = VBound(v,0,7); }
  282. void FortressSpeed(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SPEED] = Abs(v); }
  283. void FortressDMap(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_DMAP_ID] = v; }
  284. void FortressScreen(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SCREEN_ID] = VBound(v,0,255); }
  285. void FortressTimer(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_TIMER] = Abs(v); }
  286. void FortressY(int fort_id, int v){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_Y] = VBound(v,0,175); }
  287. int FortressY(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_Y]; }
  288. int FortressTile(int fortress_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_TILE]; }
  289. void FortressTile(int fortress_id, int tile(){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_TILE] = tile; }
  290. int FortressCSet(int fortress_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_CSET]; }
  291. void FortressCSet(int fortress_id, int v){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_CSET] = v; }
  292. int FortresScale(int fortress_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SCALE]; }
  293. void FortressScale(int fortress_id, int scale) { Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SCALE] = scale; }
  294. int FortressShadowTile(int fortress_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SHADOW_TILE]; }
  295. void FortressShadowTile(int fortress_id, int tile) { Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SHADOW_TILE] = tile; }
  296. int FortresShadowScale(int fortress_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SHADOW_SCALE]; }
  297. void FortressShadowScale(int fortress_id, int scale) { Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SHADOW_SCALE] = scale; }
  298.  
  299. //Set the turn timer.
  300. int FortressTime(int time_min, time_max, int frac_time, int frac_max){
  301.     int t = Rand(time_min,time_max); int tt = (Rand(frac_time, frac_max) / 60);
  302.     Return (t+tt)*60;
  303. }
  304.  
  305. //! For world-wrapping, in a future version
  306.  
  307. int virtual_map[114]; //nine dmaps screen, x, y, left_bound, rightbound, topbound, bottombound* dmaps];
  308. const int DMAP1 = 0;
  309. const int DMAP_COLS = 12;
  310. //start ( dmap, start screen, screen_left, screen_right, screen_up, screen_down, dma_left, dmap_right, dmap_down, dmap_up, x, y ) * dmap count
  311. int virtualmap_dmap-connections[numdmaps];
  312.  
  313. //Call in init script to set up all the boundaries, dest screens, and so forth.
  314. void SetMapBound(int ptr, int type, int screen, bool wrapdmap, int wrapto){
  315.     //Set the screen that is the left most, and the screen on the right of the dmap to wrap into.
  316.     //If we are wrapping to another dmap, we need to know it.
  317.     if ( type == BOUND_LEFT ) {
  318.        
  319.         //We need to automatically set up wraps to dmaps using GetWrapDMap()
  320.        
  321.         ptr[FLF_MAP_BOUND_LEFT = screen; //the screen at which we start the wrap
  322.         ptr[FLF_MAP_BOUND_LEFT_WRAPTO_SCREEN] = wrapto; //the screen at which we end the map
  323.         if ( wrapdmap ) ptr[FLF_MAP_BOUND_LEFT_WRAPTO_DMAP] = GetWrapDMap(Game->GetCurDMap(DIR_LEFT); //the dmap on which we end the wrap.
  324.         ptr[FLF_X] = 255; //We wrapped left from x=0, so we wrap to x = 255.
  325.     }
  326.     if ( type == BOUND_RIGHT ) {
  327.         ptr[FLF_MAP_BOUND_RIGHT = screen; //the screen at which we start the wrap
  328.         ptr[FLF_MAP_BOUND_RIGHT_WRAPTO_SCREEN] = wrapto; //the screen at which we end the map
  329.         if ( wrapdmap ) ptr[FLF_MAP_BOUND_RIGHT_WRAPTO_DMAP] = GetWrapDMap(Game->GetCurDMap(DIR_RIGHT);  //the dmap on which we end the wrap.
  330.         ptr[FLF_X] = 0; //We wrapped left from x=255, so we wrap to x = 0.
  331.     }
  332.     if ( type == BOUND_UP ) {
  333.         ptr[FLF_MAP_BOUND_UP = screen; //the screen at which we start the wrap
  334.         ptr[FLF_MAP_BOUND_UP_WRAPTO_SCREEN] = wrapto; //the screen at which we end the map
  335.         if ( wrapdmap != -1 ) ptr[FLF_MAP_BOUND_UP_WRAPTO_DMAP] = GetWrapDMap(Game->GetCurDMap(DIR_UP); //the dmap on which we end the wrap.
  336.         ptr[FLF_Y] = 175; //We wrapped left from y=0, so we wrap to Y = 175.
  337.     }
  338.     if ( type == BOUND_DOWN ) {
  339.         ptr[FLF_MAP_BOUND_DOWN = screen; //the screen at which we start the wrap
  340.         ptr[FLF_MAP_BOUND_DOWN_WRAPTO_SCREEN] = wrapto; //the screen at which we end the map
  341.         if ( wrapdmap != -1 ) ptr[FLF_MAP_BOUND_DOWN_WRAPTO_DMAP] = GetWrapDMap(Game->GetCurDMap(DIR_DOWN);  //the dmap on which we end the wrap.
  342.         ptr[FLF_Y] = 0; //We wrapped left from y=175, so we wrap to Y = 0.
  343.     }
  344. }
  345.  
  346. /*
  347. int WrapDMap(int dmap){
  348.     int dmap = Game->GetCurDMap();
  349.    
  350.     //checck ths table to see if we are on the edge of a dmap and wrappinf to another one,
  351.     //if so, return its value
  352.     //otherwise, return the current dmap.
  353.    
  354.     int dmap1[128]={
  355.         0,0,0,0,0,0
  356. }
  357. */
  358. const int DMAP_COLS = 4; //Actual columns
  359. const int DMAP_ROWS = 4; //Actual rows
  360. int GetWrapDMap(int source, int dir){
  361.     int virtual_dmaps[ (4_dirs +1 )* NumDMaps] {
  362.        
  363.        
  364.         //Layout of the world by DMap IDs.
  365.        
  366.         0000
  367.         0000
  368.         0000
  369.         0000,
  370.        
  371.         //Left position from each
  372.        
  373.         3012
  374.         7456
  375.         11, 8910,
  376.         15, 12, 13, 14,
  377.        
  378.         //Right position from each
  379.        
  380.         1230
  381.         5674
  382.         910, 11, 8
  383.         13, 14, 15, 12,
  384.        
  385.         //Down position from each
  386.        
  387.         4567
  388.         8910, 11,
  389.         12, 13, 14, 15,
  390.         0123,
  391.        
  392.         //Up position from each
  393.        
  394.         12, 13, 14, 15,
  395.         0123
  396.         8910, 11,
  397.         78910,
  398.     }
  399.    
  400.     if ( dir == DIR_LEFT ) return [virtual_dmaps[pos+((DMAP_COLS*DMAP_ROWS)*1)];
  401.     if ( dir == DIR_RIGHT ) return [virtual_dmaps[pos+((DMAP_COLS*DMAP_ROWS)*2)];
  402.     if ( dir == DIR_DOWN ) return [virtual_dmaps[pos+((DMAP_COLS*DMAP_ROWS)*3)];
  403.     if ( dir == DIR_UP ) return [virtual_dmaps[pos+((DMAP_COLS*DMAP_ROWS)*4)];
  404.     return -1;//Error
  405. }
  406.  
  407.  
  408.  
  409.  
  410. //If our DMap is square, this part is easier.
  411. int virtual_maps[]={    0,  0x1F,    0,     0x1F,
  412.             0,  0x1F,    0,     0x1F,
  413.             0,  0x1F,    0,     0x1F,
  414.             0,  0x1F,    0,     0x1F,
  415.             0,  0x1F,    0,     0x1F,
  416.             0,  0x1F,    0,     0x1F,
  417.             0,  0x1F,    0,     0x1F,
  418.             0,  0x1F,    0,     0x1F,
  419.             0,  0x1F,    0,     0x1F,
  420.  
  421. }; //Topleft, Topright, BottomLeft, BottomRight Screen IDs
  422.  
  423.  
  424.  
  425.  
  426. //! Deprecated --------------------------------------------------------------------------------------------------------
  427.  
  428. bool TurnFortress(int fortress_id) {
  429.     if ( ( FortressAtScreenEdge(fortres_id), FortressDir(fortress_id) ) || FortressTimer(fortress_id) <= 0 ) {
  430.         //Choose a direction other than the present diretion.
  431.         int dir;
  432.         do { //Pick a random direction that differs from this direction.
  433.             dir = Rand(0,7);
  434.         } while ( dir != FortressDir(fortress_id);
  435.         FortressDir(fortress_id, dir); //Change the direction.
  436.     }
  437. }
  438.  
  439. int MoveForetressSpeed()
  440.  
  441.  
  442. //Edge of Boundary Screen
  443. bool FortressAtDMapEdge(int virtual_map){
  444.    
  445.    
  446.    
  447. }
  448.  
  449. void SetFortressTimers(int ptr){
  450.     nt sz = SzeOfArray(ptr);
  451.     for ( int q = 0; q < sz; q += NUM_FORTRESSES )  ptr[q] = Rand(FORTRESS_MOVE_TMER_MIN,FORTRESS_MOVE_TMER_MAX);
  452. }
  453. void DoFortressTmers(int ptr){
  454.     int sz = SizeOfArray(ptr);
  455.     for ( int q = 0; q < sz; q += NUM_FORTRESSES ) {
  456.         if ( ptr[q] <= 0 ) { MoveFortress(q); ptr[q] = Rand(FORTRESS_MOVE_TMER_MIN,FORTRESS_MOVE_TMER_MAX); }
  457.         else ptr[q]--;
  458.     }
  459. }
  460.  
  461. int MoveFortressDir(int ptr) {
  462.     int dirs[4] = {UP, DOWN, LEFT, RIGHT};
  463.     int dir = dirs[Rand(0,4)]; //What about angles?
  464.     //
  465. }
  466.  
  467.  
  468. //I forgot what this was supposed to do, ans I may as well start fresh after I resolve DMap boundaries.
  469. void MoveFortress(int ptr){
  470.     int distx = Rand(FORTRESS_MOVE_DIST_MIN, FORTRESS_MOVE_DIST_MAX);
  471.     int disty = Rand(FORTRESS_MOVE_DIST_MIN, FORTRESS_MOVE_DIST_MAX);
  472.     bool neg = RandB();
  473.     if ( neg )
  474.     //Avoid jiter somehow?
  475. }
  476.    
  477. void MoveFortress(int id)}
  478.  
  479. const int FLF_MAP_
  480.  
  481. //! THis function is Not finished
  482. //Boundary Screen?
  483. bool FortressAtDMapBoundary(int fortress_id, int virtual_map, int offset){
  484.    
  485.     //Map out the screens of this DMap.
  486.     int map[4];
  487.     for ( int q = 0; q < 3; q++ ) {
  488.         map[q] = virtual_map[(offset*4)+q];
  489.     }
  490.    
  491.     int edges[4];
  492.    
  493.     if ( FortressScreen(fortress_id) % map[0] == 0 ) edges[0] = 1; //on left side of dmap. //Will this work of the DMap has an offset???
  494.    
  495.     //Decide which screens are dmap boundaries.
  496.    
  497.     //If the fortress is on one of these screens, return true.
  498. }
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.

×