Advertisement
ZoriaRPG

ZScript: Flying Fortress Alpha 0.3

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