Advertisement
ZoriaRPG

Arkanoid.zs (Alpha 0.26)

Aug 26th, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 78.41 KB | None | 0 0
  1. import "std.zh"
  2.  
  3. //TODO:
  4. // Add corner check for WALLS for various angles.
  5. // Implement new angles after collision with walls and bricks.
  6. // Implement enemies.
  7.  
  8. /* Wall drop issue might be because the dir is being set
  9. when the ball is past the wall, then the ball is being
  10. moved BACK tot he wall, and the dir is being checked again.
  11.  
  12. Might be fixed by either storing the previous ball dir on a change, and
  13. if it goes out of bounds, force that dir again after moving it back into bounds;
  14. or by only checking for equality on the walls.
  15. */
  16.  
  17. //Arkanoid script
  18. //v0.26
  19. //26th August, 2018
  20.  
  21. //////////////////////
  22. /// Script issues: ///
  23. //////////////////////
  24.  
  25. // We need to either re-arrange the living/dead/death logic, or add another animation phase.
  26. // May as well set up the Vaus explosion and add it with a SPARKLE LWeapon.
  27.  
  28.  
  29. /* ZC issues:
  30.     Continue script does not run when Init script runs. It NEEDS to do that! Otherwise, settings that affect things such as Link's tile
  31.     don't happen before the opening wipe.
  32.    
  33. */
  34.  
  35. ffc script version_alpha_0_25
  36. {
  37.     void run(){}
  38. }
  39.  
  40. /// Changes, Revision History
  41. ///
  42. ///
  43. /// Alpha 0.16: Reverted Alpha 0.15 changes back to before adding any angular physics.
  44. ///     Then, re-implemented ONLY the Vaus midpoint physics.
  45. ///     Fixed the hack for UID in brick.take_hit(). This means that ZC 2.54 Alpha **32** is now the minimum ZC version.
  46.  
  47. ///Alpha 0.18: Added 'fast mouse' mode, enabled using V to increase the fast mouse speed, and C tpo decrease it.
  48. ///     The mouse mode must be enabled for this to function!
  49. /// Fast Mouse moves the Vaus N pixels per frame, based on the distance that the mouse travels * fast_mouse.
  50.  
  51. ///Alpha 0.19: Added a frame check to keyboard keys V and B.
  52.  
  53. ///Alpha 0.20: Added an ffc script that reports the version when assigning slots after compiling.
  54.  
  55. ///Alpha 0.21: Added code for advancing to the next stage.
  56.  
  57. ///Alpha 0.22: Fixed code for level advancement. Added second stage.
  58. ///Alpha 0.23: Fixed brick.all_gone() counting gold bricks.
  59. ///Alpha 0.24: Fixed a bug in ball.check_rightwall() where a right-up moving ball was set to a right-ward angle/dir on contact.
  60. ///      : This was the cause of the ball falling like a stone.
  61. ///      : Fixed a bug where angles that we were comparing against in ball.check_hitvaus() had the wrong equality constants,
  62. ///      : and thus, were returning false.  
  63. ///      : Added hold_Link_y() to the additional while loops so that the player can't escape that screen by holding directions
  64. ///      : on the single frame where that loop runs.
  65. ///Alpha 0.25: Added capsule class, and set up base functions, to generate capsules and make them fall.
  66. ///      : Capsules now appear int he game, but as of this time, they do not activate any power-ups.
  67. ///
  68. /// NOTE:  VAUS BREAK could use 'moving link' to the next screen to scroll it as an effect.
  69.  
  70. //! Bug: Right side of vaus angle zones are reversed. RUU is to the right of RU. RRU seems not to exist.
  71. //! I should be drawing red v-lines over the points where the ball zones are on the paddle.
  72.  
  73. typedef const int config;
  74.  
  75.  
  76. config BRICK_CHANCE_CAPSULE     = 50;
  77. config FAST_MOUSE_MAX       = 6;
  78. config MAX_STAGES       = 2; //Number of stages/levels in the game.
  79. config MAX_BALL_SPEED       = 300;
  80. config MIN_ZC_ALPHA_BUILD   = 35; //Alphas are negatives, so we neex to check maximum, not minimum.
  81. config STARTING_LIVES       = 5;
  82. config CAPSULE_FALL_SPEED   = 1;
  83.  
  84. const float ARKANOID_VERSION = 0.25;
  85.  
  86. //Radians for special directions.
  87. const float DIR_UUL = 4.3197;
  88. const float DIR_LUU = 4.3197;
  89. const float DIR_LLU = 3.5343;
  90. const float DIR_ULL = 3.5343;
  91. const float DIR_LLD = 2.7489;
  92. const float DIR_DLL = 2.7489;
  93. const float DIR_DDL = 1.9635;
  94. const float DIR_LDD = 1.9635;
  95. const float DIR_DDR = 1.1781;
  96. const float DIR_RDD = 1.1781;
  97. const float DIR_RRD = 0.3927;
  98. const float DIR_DRR = 0.3927;
  99. const float DIR_RRU = 5.1051;
  100. const float DIR_URR = 5.1051;
  101. const float DIR_RUU = 5.1141;
  102. const float DIR_UUR = 5.1141;
  103.  
  104. int last_mouse_x;
  105. int fast_mouse;
  106.  
  107.  
  108.  
  109.  
  110.  
  111. int GAME[256];
  112. const int GAME_MISC_FLAGS = 0;
  113. const int GMFS_PLAYED_GAME_OVER_MUSIC = 0x01;
  114.  
  115. const int FFC_VAUS = 1;
  116. const int CMB_VAUS_EXTENDED = 1528;
  117. const int CMB_VAUS = 1524;
  118. const int CMB_VAUS_DEAD = 1520;
  119.  
  120. const int MID_STAGE_START = 4;
  121. const int NPCM_AWARDED_POINTS = 3; //brick->Misc[], flag to mark if points were awarded to the player.
  122. const int NPC_ATTRIB_POINTS = 0; //brick->Attributes[], value for score.
  123.  
  124. //Counters
  125. const int CR_SCORE = 7; //script 1
  126. const int CR_LIVES = 8;
  127.  
  128. int quit;
  129.  
  130. const int QUIT_TITLE = -1;
  131. const int QUIT_GAME_RUNNING = 0; //i.e., !quit
  132. const int QUIT_GAMEOVER = 1;
  133.  
  134.  
  135.  
  136. int caught;
  137. int frame;
  138. bool newstage = true;
  139. bool revive_vaus = false;
  140.  
  141.  
  142. int ball_x;
  143. int ball_y;
  144. int ball_dir;
  145. int ball_angle;
  146. int ball_speed;
  147. int ball_vx;
  148. int ball_vy;
  149. int paddle_x;
  150. int paddle_y;
  151. int paddle_width = 16;
  152. int paddle_speed = 2;
  153. int extended;
  154.  
  155. int ball_uid;
  156.  
  157. bool leveldone = false;
  158. int cur_stage;
  159.  
  160. //animation
  161. int death_frame;
  162.  
  163. const int DEATH_ANIM_MAX = 8;
  164.  
  165. int death_anim[DEATH_ANIM_MAX];
  166. const int DEATH_ANIM_TIMER = 0;
  167. const int DEATH_ANIM_1 = 1; //1-7 Unused
  168. const int DEATH_ANIM_2 = 2;
  169. const int DEATH_ANIM_3 = 3;
  170. const int DEATH_ANIM_4 = 4;
  171. const int DEATH_ANIM_5 = 5;
  172. const int DEATH_ANIM_6 = 6;
  173. const int DEATH_ANIM_COUNTDOWN_TO_QUIT = 7;
  174.  
  175.  
  176.  
  177. const int COUNTDOWN_TO_QUIT_FRAMES = 289; //36*8+1;
  178.  
  179. int templayer[4];
  180.  
  181. int input_accel; //pressing left and right for multiple frames increases this
  182. int frames_pressed[18];
  183.  
  184. //ffc paddle;
  185.  
  186. int hit_zones[5]; //angle offsets for where the ball strikes the paddle
  187.  
  188. const int WALL_LEFT = 24;
  189. const int WALL_TOP = 8; //Mix Ball Y
  190. const int WALL_RIGHT = 232;
  191.  
  192. const int BALL_MIN_Y = 9; //ceiling +1
  193. const int BALL_MAX_Y = 145; //one pixel under paddle top
  194. const int BALL_MIN_X = 25; //left wall +1
  195. const int BALL_MAX_X = 229; //right wall -1
  196.  
  197.  
  198.  
  199. const int START_PADDLE_X = 62;
  200. const int START_PADDLE_Y = 160;
  201. const int START_PADDLE_WIDTH = 32;
  202. const int START_PADDLE_HEIGHT = 8;
  203. const int BALL_WIDTH = 4;
  204. const int BALL_HEIGHT = 4;
  205. const int START_BALL_X = 98; //(START_PADDLE_X + 36);
  206. const int START_BALL_Y = 156; //START_PADDLE_Y - 4;
  207. const int START_BALL_DIR = 5; //DIR_UPRIGHT;
  208. const int START_BALL_RADS = 220; //angle in radians
  209. const int START_BALL_SPEED = 45;
  210. const int START_BALL_VX = 0;
  211. const int START_BALL_VY = 0;
  212.  
  213. const int PADDLE_MIN_X = 25;
  214. const int PADDLE_MAX_X = 200; //WALL_RIGHT -32; //This one varies as the paddle width may change.
  215. const int PADDLE_MAX_X_EXTENDED = 184; //WALL_RIGHT - 48; //This one varies as the paddle width may change.
  216. const int PADDLE_MIN_X_EXTENDED = 25;
  217.  
  218. const int _MOUSE_X = 0;
  219. const int _MOUSE_Y = 1;
  220. const int _MOUSE_LCLICK = 2;
  221.  
  222. //const float ACCEL_FACTOR = 0.25;
  223.  
  224. const int FRAMES_PER_MOVEMENT = 10;
  225. int USE_ACCEL = 0; //Do we accelerate KB/JP input?
  226. int USE_MOUSE = 0; //Are we using the mouse?
  227.  
  228.  
  229. /*
  230. const int CB_UP     = 0;
  231. const int CB_DOWN   = 1;
  232. const int CB_LEFT   = 2;
  233. const int CB_RIGHT  = 3;
  234. const int CB_A      = 4;
  235. const int CB_B      = 5;
  236. const int CB_L      = 7;
  237. const int CB_R      = 8;
  238. const int CB_START  = 6;
  239. const int CB_MAP    = 9;
  240. const int CB_EX1    = 10;
  241. const int CB_EX2    = 11;
  242. const int CB_EX3    = 12;
  243. const int CB_EX4    = 13;
  244. const int CB_AXIS_UP    = 14;
  245. const int CB_AXIS_DOWN  = 15;
  246. const int CB_AXIS_LEFT  = 16;
  247. const int CB_AXIS_RIGHT = 17;
  248.  
  249. */
  250.  
  251. ffc script paddle
  252. {
  253.     void run(){}
  254.    
  255.     bool move(bool mouse, bool accel, ffc p)
  256.     {
  257.         int dir; int dist;
  258.         if ( mouse )
  259.         {
  260.             Game->ClickToFreezeEnabled = false;
  261.             if ( fast_mouse )
  262.             {
  263.                 int distx = Input->Mouse[_MOUSE_X] - last_mouse_x;
  264.                 //Trace(distx);
  265.                 last_mouse_x = Input->Mouse[_MOUSE_X];
  266.                 if ( !extended )
  267.                 {
  268.                    
  269.                     if ( distx < 0 )
  270.                     {
  271.                         Trace(distx);
  272.                         for ( int q = Abs(distx) * fast_mouse; q > 0 ; --q )
  273.                         {
  274.                            
  275.                             if ( p->X > PADDLE_MIN_X )
  276.                             {
  277.                                 --p->X;
  278.                             }
  279.                            
  280.                         }
  281.                     }
  282.                     else if ( distx > 0 )
  283.                     {
  284.                         Trace(distx);
  285.                         for ( int q = Abs(distx) * fast_mouse; q > 0 ; --q )
  286.                         {
  287.                            
  288.                             if ( p->X < PADDLE_MAX_X )
  289.                             {
  290.                                 ++p->X;
  291.                             }
  292.                            
  293.                         }
  294.                     }
  295.                 }
  296.                 else //extended
  297.                 {
  298.                    
  299.                     if ( distx < 0 )
  300.                     {
  301.                         for ( int q = Abs(distx); q > 0 ; --q )
  302.                         {
  303.                             for ( int q = fast_mouse; q > 0; --q )
  304.                             {
  305.                                 if ( p->X > PADDLE_MIN_X_EXTENDED )
  306.                                 {
  307.                                     --p->X;
  308.                                 }
  309.                             }
  310.                         }
  311.                     }
  312.                     else
  313.                     {
  314.                         for ( int q = Abs(distx); q > 0 ; --q )
  315.                         {
  316.                             for ( int q = fast_mouse; q > 0; --q )
  317.                             {
  318.                                 if ( p->X > PADDLE_MAX_X_EXTENDED )
  319.                                 {
  320.                                     ++p->X;
  321.                                 }
  322.                             }
  323.                         }
  324.                     }
  325.                 }
  326.                
  327.             }
  328.             else
  329.             {
  330.                 //get the mouse movement this frame and apply a relative amount to the paddle
  331.                 //set the dir here
  332.                 //set the dist here
  333.                 //if moving left
  334.                 //if ( p->X > PADDLE_MIN_X )
  335.                 //{
  336.                 //  p->X = Input->Mouse[_MOUSE_X];
  337.                     //apply change -- ZC has no special mouse tracking.
  338.                 //}
  339.                 //if moving right
  340.                 if ( !extended )
  341.                 {
  342.                     if ( Input->Mouse[_MOUSE_X] <= PADDLE_MAX_X )
  343.                     {
  344.                         if ( Input->Mouse[_MOUSE_X] >= PADDLE_MIN_X )
  345.                         {
  346.                             //apply change
  347.                             p->X = Input->Mouse[_MOUSE_X];
  348.                         }
  349.                     }
  350.                 }
  351.                 else
  352.                 {
  353.                     if ( Input->Mouse[_MOUSE_X] <= PADDLE_MAX_X_EXTENDED )
  354.                     {
  355.                         if ( Input->Mouse[_MOUSE_X] >= PADDLE_MIN_X_EXTENDED )
  356.                         {
  357.                             //apply change
  358.                             p->X = Input->Mouse[_MOUSE_X];
  359.                         }
  360.                     }
  361.                 }
  362.             }
  363.         }
  364.         else //using a KB or joypad
  365.         {
  366.             Game->ClickToFreezeEnabled = true;
  367.             //check how long the dir button is held
  368.             if ( accel ) //if we allow acceleratiopn, move N pixeld * accel factor * frames held
  369.             {
  370.                
  371.                 if ( !extended )
  372.                 {
  373.                     if (  Input->Button[CB_LEFT] )
  374.                     {
  375.                         for ( int q = frames_pressed[CB_LEFT]; q > 0 ; --q )
  376.                         {
  377.                             if ( p->X > PADDLE_MIN_X )
  378.                             {
  379.                                 --p->X;
  380.                             }
  381.                         }
  382.                     }
  383.                     if (  Input->Button[CB_RIGHT] )
  384.                     {
  385.                         for ( int q = frames_pressed[CB_RIGHT]; q > 0; --q )
  386.                         {
  387.                             if ( p->X < PADDLE_MAX_X )
  388.                             {
  389.                                 ++p->X;
  390.                             }
  391.                         }
  392.                     }
  393.                 }
  394.                
  395.             }
  396.            
  397.             else //no accel offered, move a static number of pixels
  398.             {
  399.                
  400.                 if ( !extended )
  401.                 {
  402.                     if (  Input->Button[CB_LEFT] )
  403.                     {
  404.                         for ( int q = 0; q < paddle_speed; ++q )
  405.                         {
  406.                             if ( p->X > PADDLE_MIN_X )
  407.                             {
  408.                                 --p->X;
  409.                             }
  410.                         }
  411.                     }
  412.                     if (  Input->Button[CB_RIGHT] )
  413.                     {
  414.                         for ( int q = 0; q < paddle_speed; ++q )
  415.                         {
  416.                             if ( p->X < PADDLE_MAX_X )
  417.                             {
  418.                                 ++p->X;
  419.                             }
  420.                         }
  421.                     }
  422.                 }
  423.                 else
  424.                 {
  425.                     if (  Input->Button[CB_LEFT] )
  426.                     {
  427.                         if ( p->X > PADDLE_MIN_X_EXTENDED )
  428.                         {
  429.                             --p->X;
  430.                         }
  431.                     }
  432.                     if (  Input->Button[CB_RIGHT] ) {
  433.                         if ( p->X < PADDLE_MAX_X_EXTENDED )
  434.                         {
  435.                             ++p->X;
  436.                         }
  437.                     }
  438.                    
  439.                 }
  440.             }
  441.         }
  442.        
  443.     }
  444.  
  445.     void check_input()
  446.     {
  447.         if ( Input->Button[CB_LEFT] ) ++frames_pressed[CB_LEFT];
  448.         else frames_pressed[CB_LEFT] = 0;
  449.         if ( Input->Button[CB_RIGHT] ) ++frames_pressed[CB_RIGHT];
  450.         else frames_pressed[CB_RIGHT] = 0;
  451.        
  452.     }
  453.    
  454.     void extend(ffc p)
  455.     {
  456.         if ( extended )
  457.         {
  458.             if ( p->TileWidth < 3 )
  459.             {
  460.                 p->Data = CMB_VAUS_EXTENDED;
  461.                 p->TileWidth = 3;
  462.             }
  463.         }
  464.         else
  465.         {
  466.             if ( p->TileWidth > 2 )
  467.             {
  468.                 p->Data = CMB_VAUS;
  469.                 p->TileWidth = 2;
  470.             }
  471.         }
  472.     }
  473.     void setup(ffc p)
  474.     {
  475.         p->Y = START_PADDLE_Y;
  476.         p->X = START_PADDLE_X;
  477.         p->Data = CMB_VAUS;
  478.         p->TileWidth = 2;
  479.        
  480.     }
  481.     void dead(ffc p)
  482.     {
  483.         p->Data = CMB_VAUS_DEAD;
  484.         p->TileWidth = 2;
  485.         death_frame = frame;
  486.     }
  487.    
  488.  
  489. }
  490.  
  491. const int MISC_BALLID = 0; //Misc index of Vaud->Misc[]
  492. const int MISC_DEAD = 1; //Misc index of Vaud->Misc[]
  493. const int MISC_LAUNCHED = 0; //Misc index of ball->Misc[]
  494.  
  495. const int BALL_MINIMUM_Y = 24; //Invisible line at which point, ball is lost.
  496.  
  497. ffc script holdlink
  498. {
  499.     void run()
  500.     {
  501.         while(1)
  502.         {
  503.             Link->Y = START_PADDLE_Y - 4;
  504.             Waitframe();
  505.         }
  506.     }
  507. }
  508.        
  509. const int TEST_254_GETPIXEL = 1;
  510.  
  511. global script arkanoid
  512. {
  513.    
  514.     void run()
  515.     {
  516.         check_min_zc_build();
  517.        
  518.         TraceNL(); TraceS("Starting Arkanoid"); TraceNL(); TraceS("Game 'quit' state: "); Trace(quit);
  519.         TraceNL(); TraceS("Game version, Alpha "); Trace(ARKANOID_VERSION);
  520.        
  521.         //frame = -1;
  522.         ffc vaus = Screen->LoadFFC(FFC_VAUS);
  523.         lweapon movingball;
  524.         npc vaus_guard;
  525.         bool ext;
  526.         Link->CollDetection = false;
  527.         Link->DrawYOffset = -32768;
  528.        
  529.         if ( TEST_254_GETPIXEL )
  530.         {
  531.             bitmap bmp = Game->LoadBitmapID(RT_SCREEN);
  532.             int col[20];
  533.             for ( int q = 0; q < 20; ++ q )
  534.             {
  535.                 col[q] = bmp->GetPixel(10+q*8,10+q*8);
  536.             }
  537.             TraceNL();
  538.             for ( int q = 0; q < 20; ++q )
  539.             {
  540.                 TraceS("Bitmap col: "); Trace(col[q]);
  541.             }
  542.            
  543.             Screen->SetRenderTarget(2);
  544.             Screen->Rectangle(0, 0, 0, 256, 256, 0x55, 100, 0, 0, 0, true, 128);
  545.             Screen->SetRenderTarget(RT_SCREEN);
  546.             Waitframe();
  547.            
  548.             bitmap offscreen = Game->LoadBitmapID(2);
  549.             int col2[20];
  550.             for ( int q = 0; q < 20; ++ q )
  551.             {
  552.                 col2[q] = offscreen->GetPixel(10+q*8,10+q*8);
  553.             }
  554.             TraceNL();
  555.             for ( int q = 0; q < 20; ++q )
  556.             {
  557.                 TraceS("Offscreen Bitmap col: "); Trace(col2[q]);
  558.             }
  559.         }
  560.        
  561.         ball.setup_sprite(SPR_BALL);
  562.         while(true)
  563.         {
  564.             while(!quit)
  565.             {
  566.                 ++frame;
  567.                 if ( Input->Key[KEY_L] ) ++Game->Counter[CR_LIVES];
  568.                 hold_Link_y(); //Don't allow Link to leave the screen, bt
  569.                     //keep his X and Y matched to the Vaus!
  570.                 hold_Link_x(vaus); //Link is used to cause floating enemies to home in on the vaus.
  571.                 while ( newstage )
  572.                 {
  573.                     hold_Link_y();
  574.                     vaus = Screen->LoadFFC(FFC_VAUS);
  575.                     //vaus_guard = Screen->CreateNPC(NPC_VAUSGUARD);
  576.                     Game->PlayMIDI(MID_STAGE_START);
  577.                     brick.setup();
  578.                     Waitframes(6);
  579.                    
  580.                     brick.clear_combos();
  581.                    
  582.                     TraceS("Setting up Vaus on a new stage");
  583.                     paddle.setup(vaus);
  584.                     TraceS("Creating a ball on a new stage");
  585.                     ball.create(vaus);
  586.                     movingball = vaus->Misc[MISC_BALLID];
  587.                     vaus->Misc[MISC_DEAD] = 0;
  588.                     newstage = false; //on a new stage, these aren't working right yet.
  589.                    
  590.                    
  591.                 }
  592.                 while ( leveldone )
  593.                 {
  594.                     hold_Link_y();
  595.                     //play stage end music
  596.                     //Warp to new screen here.
  597.                     if ( cur_stage < MAX_STAGES )
  598.                     {
  599.                    
  600.                         Link->PitWarp(Game->GetCurDMap(), Game->GetCurScreen()+1);
  601.                         ++cur_stage;
  602.                         newstage = true;
  603.                         //continue;
  604.                     }
  605.                     else
  606.                     {
  607.                         Game->PlayMIDI(1);
  608.                         while(1)
  609.                         {
  610.                             Screen->DrawString(6, 96, 80, 1, 0x51, 0x00, 0, "DEMO OVER", 128);
  611.                             Waitdraw(); Waitframe();
  612.                         }
  613.                     }
  614.                     leveldone = false;
  615.                 }
  616.                 if ( revive_vaus ) //when this is called, the ball breaks through all bricks. Something isn't being set.
  617.                 {
  618.                     Game->PlayMIDI(MID_STAGE_START);
  619.                     vaus->Misc[MISC_DEAD] = 0;
  620.                     revive_vaus = false;
  621.                    
  622.                     paddle.setup(vaus);
  623.                     ball.create(vaus);
  624.                     movingball = vaus->Misc[MISC_BALLID];
  625.                 }
  626.                
  627.                 if ( !vaus->Misc[MISC_DEAD] )
  628.                 {
  629.                     if ( !newstage )
  630.                     {
  631.                         if ( !Screen->NumNPCs() )
  632.                         {
  633.                             leveldone = true;
  634.                             continue;
  635.                         }
  636.                            
  637.                         if ( brick.all_gone() )
  638.                         {
  639.                        
  640.                             leveldone = true;
  641.                             continue;
  642.                         }
  643.                        
  644.                        
  645.                     }
  646.                     if ( Input->Key[KEY_9] )
  647.                     {
  648.                         bitmap bmp = Game->LoadBitmapID(RT_SCREEN);
  649.                         int col[20];
  650.                         for ( int q = 0; q < 20; ++ q )
  651.                         {
  652.                             col[q] = bmp->GetPixel(10+q*8,10+q*8);
  653.                         }
  654.                         TraceNL();
  655.                         for ( int q = 0; q < 20; ++q )
  656.                         {
  657.                             TraceS("Bitmap col: "); Trace(col[q]);
  658.                         }
  659.                        
  660.                         Screen->SetRenderTarget(2);
  661.                         Screen->Rectangle(0, 0, 0, 256, 256, 0x55, 100, 0, 0, 0, true, 128);
  662.                         Screen->SetRenderTarget(RT_SCREEN);
  663.                         Waitframe();
  664.                        
  665.                         bitmap offscreen = Game->LoadBitmapID(2);
  666.                         int col2[20];
  667.                         for ( int q = 0; q < 20; ++ q )
  668.                         {
  669.                             col2[q] = offscreen->GetPixel(10+q*8,10+q*8);
  670.                         }
  671.                         TraceNL();
  672.                         for ( int q = 0; q < 20; ++q )
  673.                         {
  674.                             TraceS("Offscreen Bitmap col: "); Trace(col2[q]);
  675.                         }
  676.                     }  
  677.                     //if ( Input->Key[KEY_P] ) Trace(movingball->UID); //Frick, I'm an idiot. HIT_BY_LWEAPON is the SCREEN INDEX< not the UID!!
  678.                         //2.54 Absolutely needs HitBy_UID!
  679.                     if ( Input->Key[KEY_1] ) Trace(frame);
  680.                     //if ( frame%60 == 0 ) { Trace(movingball->Step); }
  681.                     //Trace(movingball->Step);
  682.                     change_setting(); //check for a setting change_setting
  683.                     paddle.extend(vaus);
  684.                     paddle.check_input();
  685.                     paddle.move(USE_MOUSE, USE_ACCEL, vaus);
  686.                    
  687.                     ball.launch(movingball);
  688.                     if ( !ball.launched(movingball) )
  689.                     {
  690.                         ball.move_with_vaus(movingball, vaus);
  691.                     }
  692.                    
  693.                    
  694.                     //clamp within bounds - MANDATORY because very fast Step speeds can cause the ball
  695.                     //to *phase* through pseudo-solid objects, such as walls and the Vaus.
  696.                     ball.clamp_rightwall(movingball);
  697.                     ball.clamp_ceiling(movingball);
  698.                     ball.clamp_leftwall(movingball);
  699.                     ball.clamp_bottom(movingball, vaus);
  700.                    
  701.                    
  702.                     //ball wall bounce checks
  703.                     ball.check_ceiling(movingball);
  704.                     ball.check_leftwall(movingball);
  705.                     ball.check_rightwall(movingball);
  706.                     ball.check_hitvaus(movingball, vaus);
  707.                     //ball.set_speed(movingball);
  708.                     /*
  709.                    
  710.                     I moved this to after Waitdraw, because I wanted the post-draw timing for ball bounce, and to ensure that
  711.                     the movingball lweapon stayed alive. -Z (Alpha 0.10)
  712.                     //Bounce ball on bricks.
  713.                     for ( int q = Screen->NumNPCs(); q > 0; --q )
  714.                     {
  715.                         npc b = Screen->LoadNPC(q);
  716.                         if ( b->Type != NPCT_OTHERFLOAT ) continue;
  717.                         TraceNL(); TraceS("movingball->X = "); Trace(movingball->X);
  718.                         TraceNL(); TraceS("movingball->Y = "); Trace(movingball->Y);
  719.                         brick.take_hit(b, movingball);
  720.                     }
  721.                     */
  722.                     movingball->DeadState = WDS_ALIVE; //Force it alive at all times if the vaus is alive.
  723.                         //We'll need another solition once we do the 3-way split ball. Bleah.
  724.                 }
  725.                
  726.                 //It's probably unwise to run this block twice! Where do I want it, before or after Waitdraw() ? -Z
  727.                 else
  728.                 {
  729.                     paddle.dead(vaus); //Set the death animation here.
  730.                    
  731.                     /*
  732.                     while ( (frame - 100) < death_frame )
  733.                     {
  734.                         //we should hide the vaus, and restart the stage here.
  735.                         ++frame;
  736.                         Waitdraw(); //Something is preventing the vaus from changing into the explosion style. S
  737.                         Waitframe();
  738.                     }
  739.                     lweapon deadball = movingball;
  740.                     deadball->DeadState = WDS_DEAD;
  741.                     movingball = vaus->Misc[10];
  742.                     if ( Game->Counter[CR_LIVES] )
  743.                     {
  744.                         --Game->Counter[CR_LIVES];
  745.                         revive_vaus = true;
  746.                     }
  747.                     */
  748.                    
  749.                 }
  750.                
  751.                 //Capsule mechanics
  752.                 capsule.all_fall();
  753.                
  754.                 Waitdraw();
  755.                
  756.                 if ( Input->Key[KEY_7] )
  757.                     {
  758.                         bitmap bmp = Game->LoadBitmapID(RT_SCREEN);
  759.                         int col[20];
  760.                         for ( int q = 0; q < 20; ++ q )
  761.                         {
  762.                             col[q] = bmp->GetPixel(10+q*8,10+q*8);
  763.                         }
  764.                         TraceNL();
  765.                         for ( int q = 0; q < 20; ++q )
  766.                         {
  767.                             TraceS("Bitmap col: "); Trace(col[q]);
  768.                         }
  769.                        
  770.                         Screen->SetRenderTarget(2);
  771.                         Screen->Rectangle(0, 0, 0, 256, 256, 0x55, 100, 0, 0, 0, true, 128);
  772.                         Screen->SetRenderTarget(RT_SCREEN);
  773.                         Waitframe();
  774.                        
  775.                         bitmap offscreen = Game->LoadBitmapID(2);
  776.                         int col2[20];
  777.                         for ( int q = 0; q < 20; ++ q )
  778.                         {
  779.                             col2[q] = offscreen->GetPixel(10+q*8,10+q*8);
  780.                         }
  781.                         TraceNL();
  782.                         for ( int q = 0; q < 20; ++q )
  783.                         {
  784.                             TraceS("Offscreen Bitmap col: "); Trace(col2[q]);
  785.                         }
  786.                     }
  787.                    
  788.                
  789.                 hold_Link_y();
  790.                
  791.                 if ( !vaus->Misc[MISC_DEAD] )
  792.                 {
  793.                     movingball->DeadState = WDS_ALIVE;
  794.                    
  795.                     //Bounce ball on bricks.
  796.                     for ( int q = Screen->NumNPCs(); q > 0; --q )
  797.                     {
  798.                         npc b = Screen->LoadNPC(q);
  799.                         if ( b->Type != NPCT_OTHERFLOAT ) continue;
  800.                         //TraceNL(); TraceS("movingball->X = "); Trace(movingball->X);
  801.                         //TraceNL(); TraceS("movingball->Y = "); Trace(movingball->Y);
  802.                         movingball->DeadState = WDS_ALIVE;
  803.                         //TraceNL(); TraceS("movingball ptr: "); Trace(movingball);
  804.                         brick.take_hit(b, movingball);
  805.                     }
  806.                    
  807.                 }
  808.                 else
  809.                 {
  810.                     paddle.dead(vaus);
  811.                     while ( (frame - 100) < death_frame )
  812.                     {
  813.                         //we should hide the vaus, and restart the stage here.
  814.                         ++frame;
  815.                         Waitdraw();
  816.                         Waitframe();
  817.                     }
  818.                     lweapon deadball = movingball;
  819.                     deadball->DeadState = WDS_DEAD;
  820.                     movingball = Debug->NULL(); //Because = NULL() requires alpha 32. :D
  821.                     if ( Game->Counter[CR_LIVES] )
  822.                     {
  823.                         --Game->Counter[CR_LIVES];
  824.                         revive_vaus = true;
  825.                     }
  826.                     else //Ugh, this is a mess. I might want to rewrite the gane over portion, as it feels as if it'll be a biugger kludge than just calling break.
  827.                     {
  828.                         if ( !death_anim[DEATH_ANIM_COUNTDOWN_TO_QUIT] )
  829.                         {
  830.                             death_anim[DEATH_ANIM_COUNTDOWN_TO_QUIT] = COUNTDOWN_TO_QUIT_FRAMES;
  831.                             continue;
  832.                         }
  833.                         else
  834.                         {
  835.                             --death_anim[DEATH_ANIM_COUNTDOWN_TO_QUIT];
  836.                             if ( death_anim[DEATH_ANIM_COUNTDOWN_TO_QUIT] == 1 )
  837.                             {
  838.                                 quit = QUIT_GAMEOVER; //Game over state.
  839.                                 TraceNL(); TraceS("Game 'quit' state is now: "); Trace(quit);
  840.                             }
  841.                         }
  842.                     }
  843.                        
  844.                 }
  845.                
  846.                 Waitframe();
  847.             }
  848.            
  849.             while (quit == QUIT_GAMEOVER) //Game Over
  850.             {
  851.                 if ( !(GAME[GAME_MISC_FLAGS]&GMFS_PLAYED_GAME_OVER_MUSIC) )
  852.                 {
  853.                     GAME[GAME_MISC_FLAGS]|=GMFS_PLAYED_GAME_OVER_MUSIC;
  854.                     //Play Game over MIDI
  855.                     Game->PlayMIDI(1);
  856.                 }
  857.                    
  858.                 Screen->DrawString(6, 96, 80, 1, 0x51, 0x00, 0, "GAME OVER", 128);
  859.                
  860.                 Waitdraw();
  861.                 Waitframe();
  862.             }
  863.             //We should never reach here.
  864.             Waitframe();
  865.         }
  866.     }
  867.     void change_setting()
  868.     {
  869.         if ( Input->Key[KEY_V] && (frame%10 == 0)) { if ( fast_mouse < FAST_MOUSE_MAX ) ++fast_mouse; TraceNL(); TraceS("fast_mouse is now: "); Trace(fast_mouse);  }
  870.         if ( Input->Key[KEY_C] && (frame%10 == 0) ) { if ( fast_mouse > 0 ) --fast_mouse; TraceNL(); TraceS("fast_mouse is now: "); Trace(fast_mouse);  }
  871.         if ( Input->Key[KEY_M] ) USE_MOUSE = 1;
  872.         if ( Input->Key[KEY_N] ) USE_MOUSE = 0;
  873.         if ( Input->Key[KEY_F] ) USE_ACCEL = 1;
  874.         if ( Input->Key[KEY_G] ) USE_ACCEL = 0;
  875.         if ( Input->Key[KEY_T] ) --paddle_speed; // paddle_speed = vbound(paddle_speed
  876.         if ( Input->Key[KEY_Y] ) ++paddle_speed; // paddle_speed = vbound(paddle_speed
  877.     }
  878.     void hold_Link_x(ffc v)
  879.     {
  880.         Link->X = v->X+(v->TileWidth*8);
  881.     }
  882.     void hold_Link_y()
  883.     {
  884.         Link->Y = START_PADDLE_Y - 4;
  885.     }
  886.     bool quit() { return ( quit ); }
  887.    
  888.     void check_min_zc_build()
  889.     {
  890.         if ( Game->Beta < MIN_ZC_ALPHA_BUILD )
  891.         {
  892.             Game->PlayMIDI(9);
  893.             int v_too_early = 600; int req_vers[3]; itoa(req_vers, MIN_ZC_ALPHA_BUILD);
  894.             TraceNL(); int vers[3]; itoa(vers,Game->Beta);
  895.             TraceS("This version of Arkanoid.qst requires Zelda Classic v2.54, Alpha (");
  896.             TraceS(req_vers);
  897.             TraceS("), or later.");
  898.             TraceNL();
  899.             TraceS("I'm detecting Zelda Classic v2.54, Alpha (");
  900.             TraceS(vers);
  901.             TraceS(") and therefore, I must refuse to run. :) ");
  902.             TraceNL();
  903.            
  904.             while(v_too_early--)
  905.             {
  906.                 //Screen->DrawString(7, 4, 40, 1, 0x04, 0x5F, 0,
  907.                 //"This version of Arkanoid.qst requires Zelda Classic 2.54, Alpha 32",
  908.                 //128);
  909.                 Screen->DrawString(7, 15, 40, 1, 0x04, 0x5F, 0,
  910.                 "You are not using a version of ZC adequate to run         ",
  911.                 128);
  912.                
  913.                 Screen->DrawString(7, 15, 55, 1, 0x04, 0x5F, 0,
  914.                 "this quest. Please see allegro.log for details.                   ",
  915.                 128);
  916.            
  917.                 Waitdraw();
  918.                 WaitNoAction();
  919.             }
  920.             Game->End();
  921.            
  922.         }
  923.     }
  924.    
  925. }
  926.  
  927. const int TILE_BALL = 50512;
  928. const int SPR_BALL = 100;
  929.  
  930.  
  931.  
  932. //preliminary ball
  933. ffc script ball
  934. {
  935.     void run(){}
  936.     void setup_sprite(int sprite_id)
  937.     {
  938.         spritedata sd = Game->LoadSpriteData(sprite_id);
  939.         sd->Tile = TILE_BALL;
  940.     }
  941.     void set_speed(lweapon b, int speed)
  942.     {
  943.         //Trace(bounces);
  944.         b->Step = speed; // bound(bounces,0,MAX_BOUNCES);
  945.         //Trace(b->Step);
  946.     }
  947.     void create(ffc vaus_id) //send the ball lweapon pointer back to the vaus
  948.     {
  949.         lweapon ball = Screen->CreateLWeapon(LW_SCRIPT1);
  950.         TraceNL(); TraceS("Creating ball with Script UID: "); Trace(ball->UID);
  951.         ball->HitWidth = 6; //Not 4, so that the ball bounces when its edges touch a brick.
  952.         ball->HitHeight = 6; //Not 4, so that the ball bounces when its edges touch a brick.
  953.         ball->UseSprite(SPR_BALL);
  954.         ball->X = vaus_id->X+18;
  955.         ball->Y = vaus_id->Y-2;
  956.         ball->Damage = 1;
  957.         ball_uid = ball->UID;
  958.         ball->HitXOffset = -1; //so that the ball bounces when its edges touch a brick.
  959.         ball->HitYOffset = -1; //so that the ball bounces when its edges touch a brick.
  960.         vaus_id->Misc[MISC_BALLID] = ball;
  961.     }
  962.     void launch(lweapon b)
  963.     {
  964.         if ( b->Misc[MISC_LAUNCHED] ) return;
  965.         bool launched;
  966.         for ( int q = CB_A; q < CB_R; ++q )
  967.         {
  968.             if ( Input->Press[q] ) { launched = true; break; }
  969.         }
  970.         if ( USE_MOUSE )
  971.         {
  972.             //if ( Input->Mouse[_MOUSE_LCLICK] )  //Not working?!
  973.             if ( Link->InputMouseB )
  974.                 launched = true;
  975.         }
  976.         if ( launched )
  977.         {
  978.             //b->Angular = true;
  979.             Game->PlaySound(6);
  980.             b->Dir = DIR_RIGHTUP;  
  981.             b->Step = 90;
  982.             b->Misc[MISC_LAUNCHED] = 1;
  983.         }
  984.     }
  985.     bool launched(lweapon b)
  986.     {
  987.         return (b->Misc[MISC_LAUNCHED]);
  988.     }
  989.     void launched(lweapon b, bool state)
  990.     {
  991.         b->Misc[MISC_LAUNCHED] = state;
  992.     }
  993.     void move(lweapon b)
  994.     {
  995.        
  996.     }
  997.     float bound(int val, int min, int max)
  998.     {
  999.         if ( val < min ) return min;
  1000.         if ( val > max ) return max;
  1001.         return val;
  1002.     }
  1003.     //Not launched yet.
  1004.     void move_with_vaus(lweapon b, ffc v)
  1005.     {
  1006.         b->X = v->X+18;
  1007.     }
  1008.     //ball.clamp*() are needed for when the step speed is so great that the ball skips past the equality checks.
  1009.     void clamp_ceiling(lweapon b)
  1010.     {
  1011.         if ( b->Y < BALL_MIN_Y )           
  1012.         {
  1013.             b->Y = BALL_MIN_Y;
  1014.         }
  1015.     }
  1016.     void clamp_leftwall(lweapon b)
  1017.     {
  1018.         if ( caught ) return; //don't do anything while the vaus is holding the ball
  1019.         if ( b->X < BALL_MIN_X ) b ->X = BALL_MIN_X;
  1020.     }
  1021.     void clamp_rightwall(lweapon b)
  1022.     {
  1023.         if ( caught ) return; //don't do anything while the vaus is holding the ball
  1024.         if ( b->X > BALL_MAX_X ) b->X = BALL_MAX_X;
  1025.     }
  1026.     /*
  1027.     void clamp_bottom(lweapon b, ffc v)
  1028.     {
  1029.         if ( caught ) return; //don't do anything while the vaus is holding the ball
  1030.         if ( b->Y+4 > v->Y+8 ) dead(b,v);
  1031.     }
  1032.     */
  1033.     //A function to check of the bounding will prevent the ball from falling out of field.
  1034.     void clamp_bottom(lweapon b, ffc v)
  1035.     {
  1036.         if ( caught ) return; //don't do anything while the vaus is holding the ball
  1037.         if ( b->Y+4 > v->Y ) b->Y = v->Y-4;
  1038.     }
  1039.     void check_ceiling(lweapon b)
  1040.     {
  1041.         if ( b->Y == BALL_MIN_Y )          
  1042.         {
  1043.             Game->PlaySound(7);
  1044.             if ( b->Angular )
  1045.             {
  1046.                 switch(b->Angle)
  1047.                 {
  1048.                     case DIR_LLU:
  1049.                     {
  1050.                         b->Angular = false;
  1051.                         b->Dir = DIR_LEFTDOWN;
  1052.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1053.                         break;
  1054.                     }
  1055.                     case DIR_LUU:
  1056.                     {
  1057.                         b->Angular = false;
  1058.                         b->Dir = DIR_LEFTDOWN;
  1059.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1060.                         break;
  1061.                     }
  1062.                     case DIR_RRU:
  1063.                     {
  1064.                         b->Angular = false;
  1065.                         b->Dir = DIR_RIGHTDOWN;
  1066.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1067.                         break;
  1068.                     }
  1069.                     case DIR_RUU:
  1070.                     {
  1071.                         b->Angular = false;
  1072.                         b->Dir = DIR_RIGHTDOWN;
  1073.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1074.                         break;
  1075.                     }
  1076.                    
  1077.                 }
  1078.             }
  1079.             else
  1080.             {
  1081.                 switch(b->Dir)
  1082.                 {
  1083.                     case DIR_RIGHTUP: { b->Dir = DIR_RIGHTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1084.                     case DIR_LEFTUP: { b->Dir = DIR_LEFTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1085.                     default: {
  1086.                         TraceNL(); TraceS("Ball direction invalid for ball.check_ceiling().");
  1087.                             TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  1088.                         b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1089.                 }
  1090.             }
  1091.         }
  1092.     }
  1093.     void check_leftwall(lweapon b)
  1094.     {
  1095.         if ( caught ) return; //don't do anything while the vaus is holding the ball
  1096.         if ( b->X == BALL_MIN_X )
  1097.         {
  1098.             Game->PlaySound(7);
  1099.             if ( b->Angular )
  1100.             {
  1101.                 switch(b->Angle)
  1102.                 {
  1103.                     case DIR_LLU:
  1104.                     {
  1105.                         b->Angular = false;
  1106.                         b->Dir = DIR_RIGHTUP;
  1107.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1108.                         break;
  1109.                     }
  1110.                     case DIR_LUU:
  1111.                     {
  1112.                         b->Angular = false;
  1113.                         b->Dir = DIR_RIGHTUP;
  1114.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1115.                         break;
  1116.                     }
  1117.                     case DIR_LLD:
  1118.                     {
  1119.                         b->Angular = false;
  1120.                         b->Dir = DIR_RIGHTDOWN;
  1121.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1122.                         break;
  1123.                     }
  1124.                     case DIR_LDD:
  1125.                     {
  1126.                         b->Angular = false;
  1127.                         b->Dir = DIR_RIGHTDOWN;
  1128.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1129.                         break;
  1130.                     }
  1131.                    
  1132.                 }
  1133.             }
  1134.             else
  1135.             {
  1136.                 switch(b->Dir)
  1137.                 {
  1138.                     case DIR_LEFTDOWN: { b->Dir = DIR_RIGHTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1139.                     case DIR_LEFTUP: { b->Dir = DIR_RIGHTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1140.                     default: {
  1141.                         TraceNL(); TraceS("Ball direction invalid for ball.check_leftwall().");
  1142.                             TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  1143.                         b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1144.                 }
  1145.             }
  1146.         }
  1147.     }
  1148.     void check_rightwall(lweapon b)
  1149.     {
  1150.         if ( caught ) return; //don't do anything while the vaus is holding the ball
  1151.         if ( b->X == BALL_MAX_X )
  1152.         {
  1153.             Game->PlaySound(7);
  1154.             if ( b->Angular )
  1155.             {
  1156.                 switch(b->Angle)
  1157.                 {
  1158.                     case DIR_RRD:
  1159.                     {
  1160.                         b->Angular = false;
  1161.                         b->Dir = DIR_LEFTDOWN;
  1162.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1163.                         break;
  1164.                     }
  1165.                     case DIR_RDD:
  1166.                     {
  1167.                         b->Angular = false;
  1168.                         b->Dir = DIR_LEFTDOWN;
  1169.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1170.                         break;
  1171.                     }
  1172.                     case DIR_RRU:
  1173.                     {
  1174.                         b->Angular = false;
  1175.                         b->Dir = DIR_LEFTUP;
  1176.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1177.                         break;
  1178.                     }
  1179.                     case DIR_RUU:
  1180.                     {
  1181.                         b->Angular = false;
  1182.                         b->Dir = DIR_LEFTUP;
  1183.                         b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1184.                         break;
  1185.                     }
  1186.                    
  1187.                 }
  1188.             }
  1189.             else
  1190.             {
  1191.                 switch(b->Dir)
  1192.                 {
  1193.                     case DIR_RIGHTDOWN: { b->Dir = DIR_LEFTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1194.                     case DIR_RIGHTUP: { b->Dir = DIR_LEFTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1195.                     default: {
  1196.                         TraceNL(); TraceS("Ball direction invalid for ball.check_rightwall().");
  1197.                             TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  1198.                         b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1199.                 }
  1200.             }
  1201.         }
  1202.     }
  1203.     void check_hitvaus(lweapon b, ffc v)
  1204.     {
  1205.         if ( launched(b) )
  1206.         {
  1207.            
  1208.             if ( b->Angular )
  1209.             {
  1210.                 if ( b->Angle == DIR_UUR ){ return; }
  1211.                 if ( b->Angle == DIR_UUL ) { return; }
  1212.                 if ( b->Angle == DIR_ULL ) { return; }
  1213.                 if ( b->Angle == DIR_URR ) { return; }
  1214.             }
  1215.             else
  1216.             {
  1217.                 if ( b->Dir == DIR_RIGHTUP ) { return; }
  1218.                 if ( b->Dir == DIR_LEFTUP ) { return; }
  1219.             }
  1220.             //if ( Collision(b,v) ) //We'll refine this, later.
  1221.            
  1222.             //else
  1223.             //{
  1224.                 int hit_position; int vaus_midpoint =  v->X+(((v->TileWidth*16)/2)-1);
  1225.                 int midpoint_segment = v->X+(((v->TileWidth*16)/6));
  1226.                 int ball_midpoint = b->X+3;
  1227.                
  1228.                 if ( b->Y+4 == v->Y )
  1229.                     //Now we need to check here, if the paddle is under the ball:
  1230.                 {
  1231.                     if ( b->X >= v->X-3 ) //-3, because the ball is 4px wide, so we cover the last pixel of the ball against the furst pixel of the Vaus
  1232.                     {
  1233.                         if ( b->X <= v->X+((v->TileWidth*16)+4) ) //no +3 here, because it's the actual X, so the first pixel of the ball is covered by the last pixel of the vaus.
  1234.                         {
  1235.                             Game->PlaySound(6);
  1236.                             //b->Y = v->Y-1;
  1237.                            
  1238.                             if ( ball_midpoint <= vaus_midpoint ) //hit left side of vaus
  1239.                             {
  1240.                                 //more left than up, hit end of Vaus
  1241.                                 if ( b->X <= (v->X-1) )
  1242.                                 //if ( Abs(ball_midpoint-vaus_midpoint) <= 2 )
  1243.                                 {
  1244.                                     //angular up
  1245.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR Left-left-Up");
  1246.                                    
  1247.                                     b->Angular = true;
  1248.                                     b->Angle = DIR_LLU;
  1249.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_LUU);
  1250.                                     return;
  1251.                                 }
  1252.                                
  1253.                                 //more up than left, hit close to centre
  1254.                                 //else if ( (Abs(b->X+2)-vaus_midpoint) <= 3 )
  1255.                                 //if ( Abs(ball_midpoint-vaus_midpoint) <= 2 )
  1256.                                 if ( (Abs(vaus_midpoint - b->X+2)) <= 3 )
  1257.                                 {
  1258.                                     //angular up
  1259.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR Left-Up-Up");
  1260.                                    
  1261.                                     b->Angular = true;
  1262.                                     b->Angle = DIR_LUU;
  1263.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1264.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_LUU);
  1265.                                     return;
  1266.                                 }
  1267.                                 //hit between the zones, normal left-up
  1268.                                 else
  1269.                                 {
  1270.                                
  1271.                                     //hit the centre midpoint
  1272.                                     //set angular = false
  1273.                                     //set DIR_UL
  1274.                                     TraceNL(); TraceS("Setting ball dir to DIGITAL Left-Up");
  1275.                                     //b->Y = v->Y-1;
  1276.                                     b->Angular = false;
  1277.                                     b->Dir = DIR_UPLEFT;
  1278.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1279.                                     return;
  1280.                                 }
  1281.                                
  1282.                             }
  1283.                             else if ( ball_midpoint > vaus_midpoint ) //hit right side of vaus
  1284.                             {
  1285.                                 /*
  1286.                                 if ( Abs(ball_midpoint-vaus_midpoint) <= 2 )
  1287.                                 {
  1288.                                     //angular up
  1289.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR RIGHT-Up-Up");
  1290.                                     --b->Y;
  1291.                                     b->Angular = true;
  1292.                                     b->Angle = DIR_RUU;
  1293.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_RUU);
  1294.                        
  1295.                                 }
  1296.                                 if ( b->X >= (v->X+(v->TileWidth*16)-2) )
  1297.                                 {
  1298.                                     //angular, sideways
  1299.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR right-right-Up");
  1300.                                     --b->Y;
  1301.                                     b->Angular = true;
  1302.                                     b->Angle = DIR_RRU;
  1303.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_RRU);
  1304.                        
  1305.                                 }
  1306.                                 */
  1307.                                 //more up then right, hit vaus close to centre
  1308.                                 if ( (Abs(vaus_midpoint - b->X)) <= 3 )
  1309.                                 {
  1310.                                     //angular up
  1311.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR RIGHT-Up-Up");
  1312.                                    
  1313.                                     b->Angular = true;
  1314.                                     b->Angle = DIR_RUU;
  1315.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1316.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_RUU);
  1317.                                     return;
  1318.                                 }
  1319.                                 //more right than up, hit end of vaus
  1320.                                 else if ( b->X > ( vaus_midpoint + ((v->TileWidth*16)/2)-4) )
  1321.                                 //else if ( (Abs(vaus_midpoint - b->X)) >= v->X+((v->TileWidth*16)/2)-1 )
  1322.                                 {
  1323.                                     //angular up
  1324.                                     TraceNL(); TraceS("Setting ball dir to ANGULAR RIGHT-right-Up");
  1325.                                    
  1326.                                     b->Angular = true;
  1327.                                     b->Angle = DIR_RRU;
  1328.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1329.                                     TraceNL(); TraceS("Checking if set angle evals true when compared against: "); TraceB(b->Angle == DIR_RUU);
  1330.                                     return;
  1331.                                 }
  1332.                                 else
  1333.                                 {
  1334.                                     //hit the centre midpoint
  1335.                                     //set angular = false
  1336.                                     //set DIR_UR
  1337.                                     TraceNL(); TraceS("Setting ball dir to DIGITAL Right-Up");
  1338.                                     //b->Y = v->Y-6;
  1339.                                     b->Angular = false;
  1340.                                     b->Dir = DIR_UPRIGHT;
  1341.                                     //b->Dir = DIR_UPRIGHT;
  1342.                                     b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1343.                                     return;
  1344.                                 }
  1345.                                
  1346.                             }
  1347.                                
  1348.                             else //catchall
  1349.                             {
  1350.                                 switch(b->Dir)
  1351.                                 {
  1352.                                     case DIR_LEFTDOWN: { b->Dir = DIR_LEFTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1353.                                     case DIR_RIGHTDOWN: { b->Dir = DIR_RIGHTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1354.                                     default: { b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  1355.                                 }
  1356.                             }
  1357.                         }
  1358.                         else
  1359.                         {
  1360.                             dead(b,v);
  1361.                         }
  1362.                     }
  1363.                     else
  1364.                     {
  1365.                         dead(b,v);
  1366.                     }
  1367.                 }
  1368.             //}
  1369.            
  1370.         }
  1371.     }
  1372.     void dead(lweapon b, ffc v)
  1373.     {
  1374.        
  1375.         Game->PlayMIDI(5);
  1376.         //remove the ball
  1377.         b->Y = -32768; b->Step = 0;
  1378.         v->Misc[MISC_DEAD] = 1;
  1379.         //if there are more balls in play, switch movingball to one of those
  1380.         //otherwise,
  1381.         //check next life
  1382.         //if more lives, reset playfield
  1383.         //otherwise game over
  1384.        
  1385.     }
  1386.    
  1387.    
  1388.    
  1389. }
  1390.  
  1391. ffc script ball_controller
  1392. {
  1393.     void run()
  1394.     {
  1395.         lweapon ball;
  1396.         lweapon active_ball; //will be used for when we have multiple balls.
  1397.         lweapon balls[3]; //for divide
  1398.         ball = Screen->CreateLWeapon(LW_SCRIPT1);
  1399.         ball->X = START_BALL_X;
  1400.         ball->Y = START_BALL_Y;
  1401.         this->Vx = START_BALL_VX;
  1402.         this->Vy = START_BALL_VY;
  1403.         bool alive = true;
  1404.         int num_balls = 1;
  1405.         while(alive)
  1406.         {
  1407.             if ( ball->Y <= BALL_MIN_Y )
  1408.             {
  1409.                 bounce();
  1410.             }
  1411.             if ( ball->X <= BALL_MIN_X )
  1412.             {
  1413.                 bounce();
  1414.             }
  1415.             if ( ball->X >= BALL_MAX_X )
  1416.             {
  1417.                 bounce();
  1418.             }
  1419.                
  1420.             if ( ball->Y >= BALL_MAX_Y )
  1421.             {
  1422.                 if ( num_balls < 2 )
  1423.                 {
  1424.                     alive = false;
  1425.                 }
  1426.                 else
  1427.                 {
  1428.                     kill_ball(ball); //removes this ball, and sets another ball to be the active one
  1429.                     --num_balls;
  1430.                 }
  1431.             }
  1432.             Waitframe();
  1433.         }
  1434.     }
  1435.     void bounce(){}
  1436.     void kill_ball(lweapon b){}
  1437.    
  1438. }
  1439.  
  1440. const int BRICK_MAX = 14;
  1441.  
  1442. //Layer 1
  1443. const int CMB_BRICK_RED     = 1488;
  1444. const int CMB_BRICK_WHITE   = 1490;
  1445. const int CMB_BRICK_BLUE    = 1492;
  1446. const int CMB_BRICK_ORANGE  = 1494;
  1447. const int CMB_BRICK_TEAL    = 1496;
  1448. const int CMB_BRICK_VIOLET  = 1498;
  1449. const int CMB_BRICK_GREEN   = 1500;
  1450. const int CMB_BRICK_YELLOW  = 1502;
  1451. const int CMB_BRICK_SILVER1 = 1504;
  1452. const int CMB_BRICK_SILVER2 = 1506;
  1453. const int CMB_BRICK_SILVER3 = 1508;
  1454. const int CMB_BRICK_SILVER4 = 1510;
  1455. const int CMB_BRICK_GOLD    = 1516;
  1456.  
  1457.  
  1458. //layer 2
  1459. const int CMB_BRICK_RED_LOW     = 1489;
  1460. const int CMB_BRICK_WHITE_LOW   = 1491;
  1461. const int CMB_BRICK_BLUE_LOW    = 1493;
  1462. const int CMB_BRICK_ORANGE_LOW  = 1495;
  1463. const int CMB_BRICK_TEAL_LOW    = 1497;
  1464. const int CMB_BRICK_VIOLET_LOW  = 1499;
  1465. const int CMB_BRICK_GREEN_LOW   = 1501;
  1466. const int CMB_BRICK_YELLOW_LOW  = 1503;
  1467. const int CMB_BRICK_SILVER1_LOW = 1505;
  1468. const int CMB_BRICK_SILVER2_LOW = 1507;
  1469. const int CMB_BRICK_SILVER3_LOW = 1509;
  1470. const int CMB_BRICK_SILVER4_LOW = 1511;
  1471. const int CMB_BRICK_GOLD_LOW    = 1517;
  1472.  
  1473. //enemies
  1474. const int NPC_BRICK_RED     = 181;
  1475. const int NPC_BRICK_WHITE   = 182;
  1476. const int NPC_BRICK_BLUE    = 183;
  1477. const int NPC_BRICK_ORANGE  = 184;
  1478. const int NPC_BRICK_TEAL    = 185;
  1479. const int NPC_BRICK_VIOLET  = 186;
  1480. const int NPC_BRICK_GREEN   = 187;
  1481. const int NPC_BRICK_YELLOW  = 188;
  1482. const int NPC_BRICK_SILVER1     = 189;
  1483. const int NPC_BRICK_SILVER2     = 190;
  1484. const int NPC_BRICK_SILVER3     = 255; //not set up yet;
  1485. const int NPC_BRICK_SILVER4     = 255; //not set up yet
  1486. const int NPC_BRICK_GOLD    = 191;
  1487.  
  1488.  
  1489. const int HIT_BY_LWEAPON = 2;
  1490. const int HIT_BY_LWEAPON_UID = 6;
  1491.  
  1492.  
  1493.  
  1494. const int CAPS_TYPE_EXTEND = 126;
  1495. const int CAPS_TYPE_BREAK = 129;
  1496. const int CAPS_TYPE_CATCH = 125;
  1497. const int CAPS_TYPE_DIVIDE = 128;
  1498. const int CAPS_TYPE_LASER = 127;
  1499. const int CAPS_TYPE_VAUS = 123;
  1500. const int CAPS_TYPE_SLOW = 124;
  1501.  
  1502. ffc script capsule
  1503. {
  1504.     void run(){}
  1505.     void create(int x, int y)
  1506.     {
  1507.         int type = choosetype();
  1508.         if ( type > 0 )
  1509.         {
  1510.             item capsule = Screen->CreateItem(type);
  1511.             capsule->X = x;
  1512.             capsule->Y = y;
  1513.         }
  1514.     }
  1515.     void drawover(item c)
  1516.     {
  1517.         //draw tile
  1518.     }
  1519.     bool check_hitvaus(item c, ffc v, lweapon b)
  1520.     {
  1521.        
  1522.         //if it hits, check the type
  1523.         int captype = c->ID;
  1524.         switch(captype)
  1525.         {
  1526.             case CAPS_TYPE_EXTEND: { extend(v); return true; }
  1527.             case CAPS_TYPE_BREAK: { escape(v); return true; }
  1528.             case CAPS_TYPE_CATCH: { catchball(v); return true; }
  1529.             case CAPS_TYPE_DIVIDE: { split(v); return true; }
  1530.             case CAPS_TYPE_LASER: { laser(v); return true; }
  1531.             case CAPS_TYPE_VAUS:{ extravaus(v); return true; }
  1532.             case CAPS_TYPE_SLOW:{ slow(v,b); return true; }
  1533.             default: break;
  1534.         }
  1535.                
  1536.         return false;      
  1537.            
  1538.            
  1539.     }
  1540.     void laser(ffc v)
  1541.     {
  1542.         //Game->PlaySound(capsule)
  1543.         //change the vaus data to the laser
  1544.         //laser = true;
  1545.         //entended = false;
  1546.         //catch = false;
  1547.     }
  1548.     void extend(ffc v)
  1549.     {
  1550.         //Game->PlaySound(capsule)
  1551.         //change the vaus data to the default
  1552.         //this is needed because collecting any powerup after
  1553.         //a laser capsule reverts fromt he laser status
  1554.         //laser = false;
  1555.         //extended = true;
  1556.         //catch = false;
  1557.     }
  1558.     void slow(ffc c, lweapon b)
  1559.     {
  1560.         //v->Data = default;
  1561.         //Game->PlaySound(capsule)
  1562.         //laser = false;
  1563.         //extended = false;
  1564.         //catch = false;
  1565.         //b->Step = default;
  1566.     }
  1567.     void escape(ffc v)
  1568.     {
  1569.         ////Game->PlaySound(capsule)
  1570.         //laser = false;
  1571.         //catch = false;
  1572.         //extended = false;
  1573.         //v->Data = default;
  1574.         //create exit
  1575.     }
  1576.     void extravaus(ffc v)
  1577.     {
  1578.         ////Game->PlaySound(capsule)
  1579.         //laser = false;
  1580.         //extended = false;
  1581.         //catch = false;
  1582.         //v->Data = default;
  1583.         //++Game->Counter[lives]
  1584.     }
  1585.     void split(ffc v, lweapon b)
  1586.     {
  1587.         ////Game->PlaySound(capsule)
  1588.         //laser = false;
  1589.         //extended = false;
  1590.         //catch = false;
  1591.         //v->Data = default;
  1592.         //fuck this is going to be hard to add
  1593.        
  1594.     }
  1595.     void catchball(ffc v)
  1596.     {
  1597.         ////Game->PlaySound(capsule)
  1598.         //laser = false;
  1599.         //extended = false;
  1600.         //v->Data = default;
  1601.         //catch = true;
  1602.        
  1603.     }
  1604.     int choosetype()
  1605.     {
  1606.         int typetable[] =
  1607.         {
  1608.             CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND, CAPS_TYPE_EXTEND,
  1609.             CAPS_TYPE_CATCH, CAPS_TYPE_CATCH, CAPS_TYPE_CATCH,
  1610.             CAPS_TYPE_DIVIDE, CAPS_TYPE_DIVIDE, CAPS_TYPE_DIVIDE,
  1611.             CAPS_TYPE_LASER, CAPS_TYPE_LASER, CAPS_TYPE_LASER,
  1612.             CAPS_TYPE_SLOW, CAPS_TYPE_SLOW, CAPS_TYPE_SLOW, CAPS_TYPE_SLOW, CAPS_TYPE_SLOW,
  1613.             CAPS_TYPE_VAUS, CAPS_TYPE_BREAK
  1614.            
  1615.            
  1616.         }; //each index is equal to a 1% chance
  1617.         //return ( typetable[Rand(0,99)] );
  1618.         //return CAPS_TYPE_EXTEND; //Testing this with one type, first.
  1619.         return ( typetable[Rand(0,SizeOfArray(typetable)-1)] );
  1620.     }
  1621.     void fall(item c)
  1622.     {
  1623.         for ( int q = 0; q < CAPSULE_FALL_SPEED; ++q )
  1624.         {
  1625.             ++c->Y;
  1626.         }
  1627.     }
  1628.     void all_fall()
  1629.     {
  1630.         for ( int q = Screen->NumItems(); q > 0; --q )
  1631.         {
  1632.             item c = Screen->LoadItem(q);
  1633.             fall(c);
  1634.             if ( c->Y > 256 ) Remove(c);
  1635.         }
  1636.     }
  1637. }
  1638.  
  1639.  
  1640.  
  1641. ffc script brick
  1642. {
  1643.     void run()
  1644.     {
  1645.     }
  1646.     bool drop_capsule(npc a)
  1647.     {
  1648.         if ( Rand(1,100) <= BRICK_CHANCE_CAPSULE )
  1649.         {
  1650.             capsule.create(a->X, a->Y);
  1651.         }
  1652.     }
  1653.     bool all_gone()
  1654.     {
  1655.         npc n; int count;
  1656.         for ( int q = Screen->NumNPCs(); q > 0; --q )
  1657.         {
  1658.             n = Screen->LoadNPC(q);
  1659.             if ( n->Type == NPCT_OTHERFLOAT )
  1660.             {
  1661.                 if ( n->HP < 1000 ) ++count;
  1662.             }
  1663.         }
  1664.         return ( count <= 0 );
  1665.     }
  1666.     float bound(int val, int min, int max)
  1667.     {
  1668.         if ( val < min ) return min;
  1669.         if ( val > max ) return max;
  1670.         return val;
  1671.     }
  1672.     bool hit(npc a, lweapon v)
  1673.     {
  1674.         /*
  1675.         if ( a->HitBy[HIT_BY_LWEAPON] < 1 ) return false;
  1676.         a->Misc[12] = Screen->LoadLWeapon(a->HitBy[HIT_BY_LWEAPON]);
  1677.         lweapon hitwpn = a->Misc[12];
  1678.         return ( hitwpn->UID == v->UID );
  1679.         */
  1680.         return ( a->HitBy[HIT_BY_LWEAPON_UID] == v->UID );
  1681.         //int indx; //Until we have UIDs working for HitBy[], we need to do it this way.
  1682.         //for ( int q = Screen->NumLWeapons(); q > 0; --q )
  1683.         //{
  1684.         //  lweapon temp = Screen->LoadLWeapon(q);
  1685.         //  if ( temp->UID == v->UID )
  1686.         //  {
  1687.         //      indx = q; break;
  1688.         //  }
  1689.         //}
  1690.         //Link->Misc[0] = v; //We'll use this as scratch untyped space for the moment. -Z
  1691.         //TraceS("brick.hit() Link->Misc[] is: "); Trace(Link->Misc[0]);
  1692.         //TraceS("brick.hit() v is: "); Trace(v);
  1693.         //int temp_UID = v->UID * 10000; //this is a bug in HITBY[]. The HitBy value being stored is being multiplied by 10000, and it should not be.
  1694.             //as UID is not, and NEVER should be!!!
  1695.         //TraceNL(); TraceS("v->UID is: "); Trace(v->UID);
  1696.         /*
  1697.         To determine where a brick was hit, we first scan each brick and look to see which was
  1698.         hit at all, by our lweapon.
  1699.        
  1700.         The, we check if that ball is belove, above, right of, or left of the brick,
  1701.         and we read its direction.
  1702.        
  1703.         Using a logic chain from this data, we determine the direction that the ball should next
  1704.         take, when it bounces.
  1705.        
  1706.         */
  1707.         //HitBy[]
  1708.        
  1709.         //if ( a->HitBy[HIT_BY_LWEAPON] )
  1710.         //{
  1711.         //  TraceNL(); TraceS("a->HitBy[HIT_BY_LWEAPON] id: "); Trace(a->HitBy[HIT_BY_LWEAPON]);
  1712.         //  TraceNL();
  1713.         //  TraceS("Our Link->Misc scratch value `is: "); Trace((Link->Misc[0]+1));
  1714.         //}
  1715.        
  1716.         //! We'll use this method again when we add UIDs to HitBy[] ! -Z
  1717.         //return ( a->HitBy[HIT_BY_LWEAPON] == temp_UID );
  1718.         //return ( a->HitBy[HIT_BY_LWEAPON] == indx ); //(Link->Misc[0]+1) );
  1719.        
  1720.     }
  1721.     bool hit_below(npc a, lweapon v)
  1722.     {
  1723.         if ( v->Y == (a->Y + 8) ) return true; //we could do bounce here.
  1724.     }
  1725.     bool hit_above(npc a, lweapon v)
  1726.     {
  1727.         if ( v->Y == (a->Y - 4) ) return true; //we could do bounce here.
  1728.     }
  1729.     bool hit_left(npc a, lweapon v)
  1730.     {
  1731.         if ( v->X == (a->X - 4) ) return true; //we could do bounce here.
  1732.     }
  1733.     bool hit_right(npc a, lweapon v)
  1734.     {
  1735.         if ( v->X == (a->X + 16 ) ) return true; //we could do bounce here.
  1736.     }
  1737.    
  1738.     void take_hit(npc a, lweapon b)
  1739.     {
  1740.         if ( hit(a,b) )
  1741.         {
  1742.             //TraceNL(); TraceS("Brick hit!");
  1743.             b->DeadState = WDS_ALIVE;
  1744.             //TraceNL(); TraceS("brick->X = "); Trace(a->X);
  1745.             //TraceNL(); TraceS("brick->Y = "); Trace(a->Y);
  1746.             //TraceNL(); TraceS("ball->X = "); Trace(v->X);
  1747.             //TraceNL(); TraceS("ball->Y = "); Trace(v->Y);
  1748.             if ( hit_below(a,b) )
  1749.             {
  1750.                 //check the corners:
  1751.                 //lower-left corner
  1752.                 if ( hit_left(a,b) )
  1753.                 {
  1754.                    
  1755.                     if ( b->Angular )
  1756.                     {
  1757.                         switch(b->Angle)
  1758.                         {
  1759.                             case DIR_RRU:
  1760.                             {
  1761.                                 b->Angular = false;
  1762.                                 b->Dir = DIR_RIGHTDOWN;
  1763.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1764.                                 break;
  1765.                             }
  1766.                             case DIR_RRD:
  1767.                             {
  1768.                                 b->Angular = false;
  1769.                                 b->Dir = DIR_RIGHTUP;
  1770.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1771.                                 break;
  1772.                             }
  1773.                             case DIR_RUU:
  1774.                             {
  1775.                                 b->Angular = false;
  1776.                                 b->Dir = DIR_RIGHTDOWN;
  1777.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1778.                                 break;
  1779.                             }
  1780.                             case DIR_RDD:
  1781.                             {
  1782.                                 b->Angular = false;
  1783.                                 b->Dir = DIR_RIGHTUP;
  1784.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1785.                                 break;
  1786.                             }
  1787.                             case DIR_LLU:
  1788.                             {
  1789.                                 b->Angular = false;
  1790.                                 b->Dir = DIR_RIGHTDOWN;
  1791.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1792.                                 break;
  1793.                             }
  1794.                             case DIR_LUU:
  1795.                             {
  1796.                                 b->Angular = false;
  1797.                                 b->Dir = DIR_RIGHTDOWN;
  1798.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1799.                                 break;
  1800.                             }
  1801.                             case DIR_LLD:
  1802.                             {
  1803.                                 b->Angular = false;
  1804.                                 b->Dir = DIR_RIGHTUP;
  1805.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1806.                                 break;
  1807.                             }
  1808.                             case DIR_LDD:
  1809.                             {
  1810.                                 b->Angular = false;
  1811.                                 b->Dir = DIR_RIGHTUP;
  1812.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1813.                                 break;
  1814.                             }
  1815.                            
  1816.                         }
  1817.                     }
  1818.                     else
  1819.                     {
  1820.                         switch(b->Dir)
  1821.                         {
  1822.                             case DIR_DOWNRIGHT:
  1823.                             {
  1824.                                 b->Angular = false;
  1825.                                 b->Dir = DIR_UPLEFT;
  1826.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1827.                                 break;
  1828.                             }
  1829.                             case DIR_DOWNLEFT:
  1830.                             {
  1831.                                 b->Angular = false;
  1832.                                 b->Dir = DIR_UPRIGHT;
  1833.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1834.                                 break;
  1835.                             }
  1836.                             case DIR_UPRIGHT:
  1837.                             {
  1838.                                 b->Angular = false;
  1839.                                 b->Dir = DIR_DOWNLEFT;
  1840.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1841.                                 break;
  1842.                             }
  1843.                             case DIR_UPLEFT:
  1844.                             {
  1845.                                 b->Angular = false;
  1846.                                 b->Dir = DIR_DOWNRIGHT;
  1847.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1848.                                 break;
  1849.                             }  
  1850.                            
  1851.                         }
  1852.                     }
  1853.                    
  1854.                 }//end lower-left corner
  1855.                
  1856.                 else if ( hit_right(a,b) )
  1857.                     //lower-right corner
  1858.                 {
  1859.                    
  1860.                     if ( b->Angular )
  1861.                     {
  1862.                         switch(b->Angle)
  1863.                         {
  1864.                             case DIR_LLU:
  1865.                             {
  1866.                                 b->Angular = false;
  1867.                                 b->Dir = DIR_RIGHTDOWN;
  1868.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1869.                                 break;
  1870.                             }
  1871.                             case DIR_LLD:
  1872.                             {
  1873.                                 b->Angular = false;
  1874.                                 b->Dir = DIR_RIGHTDOWN;
  1875.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1876.                                 break;
  1877.                             }
  1878.                             case DIR_RUU:
  1879.                             {
  1880.                                 b->Angular = false;
  1881.                                 b->Dir = DIR_RIGHTDOWN;
  1882.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1883.                                 break;
  1884.                             }
  1885.                             case DIR_RDD:
  1886.                             {
  1887.                                 b->Angular = false;
  1888.                                 b->Dir = DIR_LEFTUP;
  1889.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1890.                                 break;
  1891.                             }
  1892.                             case DIR_LLU:
  1893.                             {
  1894.                                 b->Angular = false;
  1895.                                 b->Dir = DIR_RIGHTDOWN;
  1896.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1897.                                 break;
  1898.                             }
  1899.                             case DIR_LUU:
  1900.                             {
  1901.                                 b->Angular = false;
  1902.                                 b->Dir = DIR_RIGHTDOWN;
  1903.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1904.                                 break;
  1905.                             }
  1906.                             case DIR_LLD:
  1907.                             {
  1908.                                 b->Angular = false;
  1909.                                 b->Dir = DIR_LEFTUP;
  1910.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1911.                                 break;
  1912.                             }
  1913.                             case DIR_LDD:
  1914.                             {
  1915.                                 b->Angular = false;
  1916.                                 b->Dir = DIR_LEFTUP;
  1917.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1918.                                 break;
  1919.                             }
  1920.                            
  1921.                         }
  1922.                     }
  1923.                     else
  1924.                     {
  1925.                         switch(b->Dir)
  1926.                         {
  1927.                             case DIR_DOWNRIGHT:
  1928.                             {
  1929.                                 b->Angular = false;
  1930.                                 b->Dir = DIR_UPLEFT;
  1931.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1932.                                 break;
  1933.                             }
  1934.                             case DIR_DOWNLEFT:
  1935.                             {
  1936.                                 b->Angular = false;
  1937.                                 b->Dir = DIR_UPRIGHT;
  1938.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1939.                                 break;
  1940.                             }
  1941.                             case DIR_UPRIGHT:
  1942.                             {
  1943.                                 b->Angular = false;
  1944.                                 b->Dir = DIR_DOWNLEFT;
  1945.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1946.                                 break;
  1947.                             }
  1948.                             case DIR_UPLEFT:
  1949.                             {
  1950.                                 b->Angular = false;
  1951.                                 b->Dir = DIR_DOWNRIGHT;
  1952.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1953.                                 break;
  1954.                             }  
  1955.                            
  1956.                         }
  1957.                     }
  1958.                    
  1959.                    
  1960.                 }//end lower-right corner
  1961.                
  1962.                
  1963.                 else
  1964.                 {
  1965.                
  1966.                     if ( b->Angular )
  1967.                     {
  1968.                         switch(b->Angle)
  1969.                         {
  1970.                             case DIR_LLU:
  1971.                             {
  1972.                                 b->Angular = false;
  1973.                                 b->Dir = DIR_LEFTDOWN;
  1974.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1975.                                 break;
  1976.                             }
  1977.                             case DIR_LUU:
  1978.                             {
  1979.                                 b->Angular = false;
  1980.                                 b->Dir = DIR_LEFTDOWN;
  1981.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1982.                                 break;
  1983.                             }
  1984.                             case DIR_RRU:
  1985.                             {
  1986.                                 b->Angular = false;
  1987.                                 b->Dir = DIR_RIGHTDOWN;
  1988.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1989.                                 break;
  1990.                             }
  1991.                             case DIR_RUU:
  1992.                             {
  1993.                                 b->Angular = false;
  1994.                                 b->Dir = DIR_RIGHTDOWN;
  1995.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  1996.                                 break;
  1997.                             }
  1998.                            
  1999.                         }
  2000.                     }
  2001.                     else
  2002.                     {
  2003.                         switch(b->Dir)
  2004.                         {
  2005.                             case DIR_RIGHTUP: { b->Dir = DIR_RIGHTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2006.                             case DIR_LEFTUP: { b->Dir = DIR_LEFTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2007.                             default: { TraceNL(); TraceS("Ball direction invalid for brick.take_hit(hit_below()).");
  2008.                                 TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  2009.                                 b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2010.                         }
  2011.                     }
  2012.                 }
  2013.                 /*
  2014.                 switch ( v->Dir )
  2015.                 {
  2016.                     case DIR_UPRIGHT: { v->Dir = DIR_DOWNRIGHT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  2017.                     case DIR_UPLEFT: { v->Dir = DIR_DOWNLEFT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  2018.                     default: { TraceS("hit_below() found an illegal ball direction"); break; }
  2019.                 }
  2020.                 */
  2021.                 if ( a->HP <= 0 )
  2022.                 {
  2023.                     //TraceS("Brick is dead. "); TraceNL();
  2024.                     //TraceS("a->Misc[NPCM_AWARDED_POINTS] is: "); Trace(a->Misc[NPCM_AWARDED_POINTS]); TraceNL();
  2025.                     if ( !a->Misc[NPCM_AWARDED_POINTS] )
  2026.                     {
  2027.                         //TraceS("Can award points!"); TraceNL();
  2028.                         a->Misc[18] = 1;
  2029.                         //TraceS("The points for this brick are: "); Trace(a->Attributes[NPC_ATTRIB_POINTS]); TraceNL();
  2030.                         Game->Counter[CR_SCRIPT1] += a->Attributes[NPC_ATTRIB_POINTS];
  2031.                         drop_capsule(a);
  2032.                     }
  2033.                 }
  2034.             }
  2035.            
  2036.             else if ( hit_above(a,b) )
  2037.             {
  2038.                 //upper-left corner
  2039.                 if ( hit_left(a,b) )
  2040.                 {
  2041.                    
  2042.                     if ( b->Angular )
  2043.                     {
  2044.                         switch(b->Angle)
  2045.                         {
  2046.                             case DIR_RRD:
  2047.                             {
  2048.                                 b->Angular = false;
  2049.                                 b->Dir = DIR_LEFTDOWN;
  2050.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2051.                                 break;
  2052.                             }
  2053.                             case DIR_RDD:
  2054.                             {
  2055.                                 b->Angular = false;
  2056.                                 b->Dir = DIR_LEFTDOWN;
  2057.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2058.                                 break;
  2059.                             }
  2060.                             case DIR_RUU:
  2061.                             {
  2062.                                 b->Angular = false;
  2063.                                 b->Dir = DIR_LEFTUP;
  2064.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2065.                                 break;
  2066.                             }
  2067.                             case DIR_RDD:
  2068.                             {
  2069.                                 b->Angular = false;
  2070.                                 b->Dir = DIR_LEFTUP;
  2071.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2072.                                 break;
  2073.                             }
  2074.                             case DIR_LLU:
  2075.                             {
  2076.                                 b->Angular = false;
  2077.                                 b->Dir = DIR_LEFTDOWN;
  2078.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2079.                                 break;
  2080.                             }
  2081.                             case DIR_LUU:
  2082.                             {
  2083.                                 b->Angular = false;
  2084.                                 b->Dir = DIR_LEFTDOWN;
  2085.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2086.                                 break;
  2087.                             }
  2088.                             case DIR_LLD:
  2089.                             {
  2090.                                 b->Angular = false;
  2091.                                 b->Dir = DIR_RIGHTDOWN;
  2092.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2093.                                 break;
  2094.                             }
  2095.                             case DIR_LDD:
  2096.                             {
  2097.                                 b->Angular = false;
  2098.                                 b->Dir = DIR_RIGHTDOWN;
  2099.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2100.                                 break;
  2101.                             }
  2102.                            
  2103.                         }
  2104.                     }
  2105.                     else
  2106.                     {
  2107.                         switch(b->Dir)
  2108.                         {
  2109.                             case DIR_DOWNRIGHT:
  2110.                             {
  2111.                                 b->Angular = false;
  2112.                                 b->Dir = DIR_UPLEFT;
  2113.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2114.                                 break;
  2115.                             }
  2116.                             case DIR_DOWNLEFT:
  2117.                             {
  2118.                                 b->Angular = false;
  2119.                                 b->Dir = DIR_UPRIGHT;
  2120.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2121.                                 break;
  2122.                             }
  2123.                             case DIR_UPRIGHT:
  2124.                             {
  2125.                                 b->Angular = false;
  2126.                                 b->Dir = DIR_DOWNLEFT;
  2127.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2128.                                 break;
  2129.                             }
  2130.                             case DIR_UPLEFT:
  2131.                             {
  2132.                                 b->Angular = false;
  2133.                                 b->Dir = DIR_DOWNRIGHT;
  2134.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2135.                                 break;
  2136.                             }
  2137.                            
  2138.                         }
  2139.                     }
  2140.                    
  2141.                 }//end upper-left corner
  2142.                
  2143.                 //upper-right corner
  2144.                 else if ( hit_right(a,b) )
  2145.                 {
  2146.                    
  2147.                     if ( b->Angular )
  2148.                     {
  2149.                         switch(b->Angle)
  2150.                         {
  2151.                             case DIR_RRD:
  2152.                             {
  2153.                                 b->Angular = false;
  2154.                                 b->Dir = DIR_RIGHTUP;
  2155.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2156.                                 break;
  2157.                             }
  2158.                             case DIR_RDD:
  2159.                             {
  2160.                                 b->Angular = false;
  2161.                                 b->Dir = DIR_RIGHTUP;
  2162.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2163.                                 break;
  2164.                             }
  2165.                             case DIR_RUU:
  2166.                             {
  2167.                                 b->Angular = false;
  2168.                                 b->Dir = DIR_RIGHTDOWN;
  2169.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2170.                                 break;
  2171.                             }
  2172.                             case DIR_RDD:
  2173.                             {
  2174.                                 b->Angular = false;
  2175.                                 b->Dir = DIR_RIGHTDOWN;
  2176.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2177.                                 break;
  2178.                             }
  2179.                             case DIR_LLU:
  2180.                             {
  2181.                                 b->Angular = false;
  2182.                                 b->Dir = DIR_RIGHTUP;
  2183.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2184.                                 break;
  2185.                             }
  2186.                             case DIR_LUU:
  2187.                             {
  2188.                                 b->Angular = false;
  2189.                                 b->Dir = DIR_RIGHTUP;
  2190.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2191.                                 break;
  2192.                             }
  2193.                             case DIR_LLD:
  2194.                             {
  2195.                                 b->Angular = false;
  2196.                                 b->Dir = DIR_LEFTUP;
  2197.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2198.                                 break;
  2199.                             }
  2200.                             case DIR_LDD:
  2201.                             {
  2202.                                 b->Angular = false;
  2203.                                 b->Dir = DIR_LEFTUP;
  2204.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2205.                                 break;
  2206.                             }
  2207.                            
  2208.                         }
  2209.                     }
  2210.                     else
  2211.                     {
  2212.                         switch(b->Dir)
  2213.                         {
  2214.                             case DIR_DOWNRIGHT:
  2215.                             {
  2216.                                 b->Angular = false;
  2217.                                 b->Dir = DIR_UPLEFT;
  2218.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2219.                                 break;
  2220.                             }
  2221.                             case DIR_DOWNLEFT:
  2222.                             {
  2223.                                 b->Angular = false;
  2224.                                 b->Dir = DIR_UPRIGHT;
  2225.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2226.                                 break;
  2227.                             }
  2228.                             case DIR_UPRIGHT:
  2229.                             {
  2230.                                 b->Angular = false;
  2231.                                 b->Dir = DIR_DOWNLEFT;
  2232.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2233.                                 break;
  2234.                             }
  2235.                             case DIR_UPLEFT:
  2236.                             {
  2237.                                 b->Angular = false;
  2238.                                 b->Dir = DIR_DOWNRIGHT;
  2239.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2240.                                 break;
  2241.                             }
  2242.                            
  2243.                         }
  2244.                     }
  2245.                    
  2246.                 }
  2247.                 //end upper-right corners
  2248.                
  2249.                 //
  2250.                 else
  2251.                 {
  2252.                     if ( b->Angular )
  2253.                     {
  2254.                         switch(b->Angle)
  2255.                         {
  2256.                             case DIR_LLD:
  2257.                             {
  2258.                                 b->Angular = false;
  2259.                                 b->Dir = DIR_LEFTUP;
  2260.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2261.                                 break;
  2262.                             }
  2263.                             case DIR_LDD:
  2264.                             {
  2265.                                 b->Angular = false;
  2266.                                 b->Dir = DIR_LEFTUP;
  2267.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2268.                                 break;
  2269.                             }
  2270.                             case DIR_RRD:
  2271.                             {
  2272.                                 b->Angular = false;
  2273.                                 b->Dir = DIR_RIGHTUP;
  2274.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2275.                                 break;
  2276.                             }
  2277.                             case DIR_RDD:
  2278.                             {
  2279.                                 b->Angular = false;
  2280.                                 b->Dir = DIR_RIGHTUP;
  2281.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2282.                                 break;
  2283.                             }
  2284.                            
  2285.                         }
  2286.                     }
  2287.                     else
  2288.                     {
  2289.                         switch(b->Dir)
  2290.                         {
  2291.                             case DIR_DOWNLEFT: { b->Dir = DIR_UPLEFT; b->Step = bound(b->Step+2, 0, MAX_BALL_SPEED); break; }
  2292.                             case DIR_DOWNRIGHT: { b ->Dir = DIR_UPRIGHT; b->Step = bound(b->Step+2, 0, MAX_BALL_SPEED); break; }
  2293.                             default: {
  2294.                                 TraceNL(); TraceS("Ball direction invalid for brick.take_hit(hit_above()).");
  2295.                                 TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  2296.                                
  2297.                                 b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2298.                         }
  2299.                     }
  2300.                    
  2301.                     if ( a->HP <= 0 )
  2302.                     {
  2303.                         if ( !a->Misc[NPCM_AWARDED_POINTS] )
  2304.                         {
  2305.                             a->Misc[NPCM_AWARDED_POINTS] = 1;
  2306.                             Game->Counter[CR_SCRIPT1] += a->Attributes[NPC_ATTRIB_POINTS];
  2307.                             drop_capsule(a);
  2308.                         }
  2309.                     }
  2310.                 }
  2311.             }
  2312.            
  2313.             else if ( hit_left(a,b) )
  2314.             {
  2315.                 //upper corners
  2316.                
  2317.                 //upper-left corner
  2318.                 if ( hit_above(a,b) )
  2319.                 {
  2320.                    
  2321.                     if ( b->Angular )
  2322.                     {
  2323.                         switch(b->Angle)
  2324.                         {
  2325.                             case DIR_RRD:
  2326.                             {
  2327.                                 b->Angular = false;
  2328.                                 b->Dir = DIR_LEFTDOWN;
  2329.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2330.                                 break;
  2331.                             }
  2332.                             case DIR_RDD:
  2333.                             {
  2334.                                 b->Angular = false;
  2335.                                 b->Dir = DIR_LEFTDOWN;
  2336.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2337.                                 break;
  2338.                             }
  2339.                             case DIR_RUU:
  2340.                             {
  2341.                                 b->Angular = false;
  2342.                                 b->Dir = DIR_LEFTUP;
  2343.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2344.                                 break;
  2345.                             }
  2346.                             case DIR_RDD:
  2347.                             {
  2348.                                 b->Angular = false;
  2349.                                 b->Dir = DIR_LEFTUP;
  2350.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2351.                                 break;
  2352.                             }
  2353.                             case DIR_LLU:
  2354.                             {
  2355.                                 b->Angular = false;
  2356.                                 b->Dir = DIR_LEFTDOWN;
  2357.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2358.                                 break;
  2359.                             }
  2360.                             case DIR_LUU:
  2361.                             {
  2362.                                 b->Angular = false;
  2363.                                 b->Dir = DIR_LEFTDOWN;
  2364.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2365.                                 break;
  2366.                             }
  2367.                             case DIR_LLD:
  2368.                             {
  2369.                                 b->Angular = false;
  2370.                                 b->Dir = DIR_RIGHTDOWN;
  2371.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2372.                                 break;
  2373.                             }
  2374.                             case DIR_LDD:
  2375.                             {
  2376.                                 b->Angular = false;
  2377.                                 b->Dir = DIR_RIGHTDOWN;
  2378.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2379.                                 break;
  2380.                             }
  2381.                            
  2382.                         }
  2383.                     }
  2384.                     else
  2385.                     {
  2386.                         switch(b->Dir)
  2387.                         {
  2388.                             case DIR_DOWNRIGHT:
  2389.                             {
  2390.                                 b->Angular = false;
  2391.                                 b->Dir = DIR_UPLEFT;
  2392.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2393.                                 break;
  2394.                             }
  2395.                             case DIR_DOWNLEFT:
  2396.                             {
  2397.                                 b->Angular = false;
  2398.                                 b->Dir = DIR_UPRIGHT;
  2399.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2400.                                 break;
  2401.                             }
  2402.                             case DIR_UPRIGHT:
  2403.                             {
  2404.                                 b->Angular = false;
  2405.                                 b->Dir = DIR_DOWNLEFT;
  2406.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2407.                                 break;
  2408.                             }
  2409.                             case DIR_UPLEFT:
  2410.                             {
  2411.                                 b->Angular = false;
  2412.                                 b->Dir = DIR_DOWNRIGHT;
  2413.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2414.                                 break;
  2415.                             }
  2416.                            
  2417.                         }
  2418.                     }
  2419.                    
  2420.                 }//end upper-left corner
  2421.                
  2422.                 else if ( hit_below(a,b) )
  2423.                     //lower-left corner
  2424.                 {
  2425.                    
  2426.                     if ( b->Angular )
  2427.                     {
  2428.                         switch(b->Angle)
  2429.                         {
  2430.                             case DIR_RRU:
  2431.                             {
  2432.                                 b->Angular = false;
  2433.                                 b->Dir = DIR_RIGHTDOWN;
  2434.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2435.                                 break;
  2436.                             }
  2437.                             case DIR_RRD:
  2438.                             {
  2439.                                 b->Angular = false;
  2440.                                 b->Dir = DIR_RIGHTUP;
  2441.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2442.                                 break;
  2443.                             }
  2444.                             case DIR_RUU:
  2445.                             {
  2446.                                 b->Angular = false;
  2447.                                 b->Dir = DIR_RIGHTDOWN;
  2448.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2449.                                 break;
  2450.                             }
  2451.                             case DIR_RDD:
  2452.                             {
  2453.                                 b->Angular = false;
  2454.                                 b->Dir = DIR_RIGHTUP;
  2455.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2456.                                 break;
  2457.                             }
  2458.                             case DIR_LLU:
  2459.                             {
  2460.                                 b->Angular = false;
  2461.                                 b->Dir = DIR_RIGHTDOWN;
  2462.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2463.                                 break;
  2464.                             }
  2465.                             case DIR_LUU:
  2466.                             {
  2467.                                 b->Angular = false;
  2468.                                 b->Dir = DIR_RIGHTDOWN;
  2469.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2470.                                 break;
  2471.                             }
  2472.                             case DIR_LLD:
  2473.                             {
  2474.                                 b->Angular = false;
  2475.                                 b->Dir = DIR_RIGHTUP;
  2476.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2477.                                 break;
  2478.                             }
  2479.                             case DIR_LDD:
  2480.                             {
  2481.                                 b->Angular = false;
  2482.                                 b->Dir = DIR_RIGHTUP;
  2483.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2484.                                 break;
  2485.                             }
  2486.                            
  2487.                         }
  2488.                     }
  2489.                     else
  2490.                     {
  2491.                         switch(b->Dir)
  2492.                         {
  2493.                             case DIR_DOWNRIGHT:
  2494.                             {
  2495.                                 b->Angular = false;
  2496.                                 b->Dir = DIR_UPLEFT;
  2497.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2498.                                 break;
  2499.                             }
  2500.                             case DIR_DOWNLEFT:
  2501.                             {
  2502.                                 b->Angular = false;
  2503.                                 b->Dir = DIR_UPRIGHT;
  2504.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2505.                                 break;
  2506.                             }
  2507.                             case DIR_UPRIGHT:
  2508.                             {
  2509.                                 b->Angular = false;
  2510.                                 b->Dir = DIR_DOWNLEFT;
  2511.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2512.                                 break;
  2513.                             }
  2514.                             case DIR_UPLEFT:
  2515.                             {
  2516.                                 b->Angular = false;
  2517.                                 b->Dir = DIR_DOWNRIGHT;
  2518.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2519.                                 break;
  2520.                             }  
  2521.                            
  2522.                         }
  2523.                     }
  2524.                                    
  2525.                 }//end lower-left corner
  2526.                
  2527.                 else
  2528.                 {
  2529.                     if ( b->Angular )
  2530.                     {
  2531.                         switch(b->Angle)
  2532.                         {
  2533.                             case DIR_LLU:
  2534.                             {
  2535.                                 b->Angular = false;
  2536.                                 b->Dir = DIR_RIGHTUP;
  2537.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2538.                                 break;
  2539.                             }
  2540.                             case DIR_LUU:
  2541.                             {
  2542.                                 b->Angular = false;
  2543.                                 b->Dir = DIR_RIGHTUP;
  2544.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2545.                                 break;
  2546.                             }
  2547.                             case DIR_LLD:
  2548.                             {
  2549.                                 b->Angular = false;
  2550.                                 b->Dir = DIR_RIGHTDOWN;
  2551.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2552.                                 break;
  2553.                             }
  2554.                             case DIR_LDD:
  2555.                             {
  2556.                                 b->Angular = false;
  2557.                                 b->Dir = DIR_RIGHTDOWN;
  2558.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2559.                                 break;
  2560.                             }
  2561.                            
  2562.                         }
  2563.                     }
  2564.                     else
  2565.                     {
  2566.                         switch(b->Dir)
  2567.                         {
  2568.                             case DIR_RIGHTDOWN: { b->Dir = DIR_LEFTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2569.                             case DIR_RIGHTUP: { b->Dir = DIR_LEFTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2570.                             default: {
  2571.                                 TraceNL(); TraceS("Ball direction invalid for brick.take_hit(hit(left)).");
  2572.                                 TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  2573.                                 b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2574.                         }
  2575.                     }
  2576.                     /*
  2577.                     switch ( v->Dir )
  2578.                     {
  2579.                         case DIR_UPRIGHT: { v->Dir = DIR_UPLEFT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  2580.                         case DIR_DOWNRIGHT: { v->Dir = DIR_DOWNLEFT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED);  break; }
  2581.                         default: { TraceS("hit_left() found an illegal ball direction"); break; }
  2582.                     }
  2583.                     */
  2584.                 }
  2585.                 if ( a->HP <= 0 )
  2586.                 {
  2587.                     if ( !a->Misc[NPCM_AWARDED_POINTS] )
  2588.                     {
  2589.                         a->Misc[NPCM_AWARDED_POINTS] = 1;
  2590.                         Game->Counter[CR_SCRIPT1] += a->Attributes[NPC_ATTRIB_POINTS];
  2591.                         drop_capsule(a);
  2592.                     }
  2593.                 }
  2594.             }
  2595.             else if ( hit_right(a,b) )
  2596.             {
  2597.                 //lower-right corners
  2598.                 if ( hit_below(a,b) )
  2599.                     //lower-right corner
  2600.                 {
  2601.                    
  2602.                     if ( b->Angular )
  2603.                     {
  2604.                         switch(b->Angle)
  2605.                         {
  2606.                             case DIR_LLU:
  2607.                             {
  2608.                                 b->Angular = false;
  2609.                                 b->Dir = DIR_RIGHTDOWN;
  2610.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2611.                                 break;
  2612.                             }
  2613.                             case DIR_LLD:
  2614.                             {
  2615.                                 b->Angular = false;
  2616.                                 b->Dir = DIR_RIGHTDOWN;
  2617.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2618.                                 break;
  2619.                             }
  2620.                             case DIR_RUU:
  2621.                             {
  2622.                                 b->Angular = false;
  2623.                                 b->Dir = DIR_RIGHTDOWN;
  2624.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2625.                                 break;
  2626.                             }
  2627.                             case DIR_RDD:
  2628.                             {
  2629.                                 b->Angular = false;
  2630.                                 b->Dir = DIR_LEFTUP;
  2631.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2632.                                 break;
  2633.                             }
  2634.                             case DIR_LLU:
  2635.                             {
  2636.                                 b->Angular = false;
  2637.                                 b->Dir = DIR_RIGHTDOWN;
  2638.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2639.                                 break;
  2640.                             }
  2641.                             case DIR_LUU:
  2642.                             {
  2643.                                 b->Angular = false;
  2644.                                 b->Dir = DIR_RIGHTDOWN;
  2645.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2646.                                 break;
  2647.                             }
  2648.                             case DIR_LLD:
  2649.                             {
  2650.                                 b->Angular = false;
  2651.                                 b->Dir = DIR_LEFTUP;
  2652.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2653.                                 break;
  2654.                             }
  2655.                             case DIR_LDD:
  2656.                             {
  2657.                                 b->Angular = false;
  2658.                                 b->Dir = DIR_LEFTUP;
  2659.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2660.                                 break;
  2661.                             }
  2662.                            
  2663.                         }
  2664.                     }
  2665.                     else
  2666.                     {
  2667.                         switch(b->Dir)
  2668.                         {
  2669.                             case DIR_DOWNRIGHT:
  2670.                             {
  2671.                                 b->Angular = false;
  2672.                                 b->Dir = DIR_UPLEFT;
  2673.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2674.                                 break;
  2675.                             }
  2676.                             case DIR_DOWNLEFT:
  2677.                             {
  2678.                                 b->Angular = false;
  2679.                                 b->Dir = DIR_UPRIGHT;
  2680.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2681.                                 break;
  2682.                             }
  2683.                             case DIR_UPRIGHT:
  2684.                             {
  2685.                                 b->Angular = false;
  2686.                                 b->Dir = DIR_DOWNLEFT;
  2687.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2688.                                 break;
  2689.                             }
  2690.                             case DIR_UPLEFT:
  2691.                             {
  2692.                                 b->Angular = false;
  2693.                                 b->Dir = DIR_DOWNRIGHT;
  2694.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2695.                                 break;
  2696.                             }  
  2697.                            
  2698.                         }
  2699.                     }
  2700.                    
  2701.                 }//end lower-right corner
  2702.                
  2703.                 //upper-right corner
  2704.                 else if ( hit_above(a,b) )
  2705.                 {
  2706.                    
  2707.                     if ( b->Angular )
  2708.                     {
  2709.                         switch(b->Angle)
  2710.                         {
  2711.                             case DIR_RRD:
  2712.                             {
  2713.                                 b->Angular = false;
  2714.                                 b->Dir = DIR_RIGHTUP;
  2715.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2716.                                 break;
  2717.                             }
  2718.                             case DIR_RDD:
  2719.                             {
  2720.                                 b->Angular = false;
  2721.                                 b->Dir = DIR_RIGHTUP;
  2722.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2723.                                 break;
  2724.                             }
  2725.                             case DIR_RUU:
  2726.                             {
  2727.                                 b->Angular = false;
  2728.                                 b->Dir = DIR_RIGHTDOWN;
  2729.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2730.                                 break;
  2731.                             }
  2732.                             case DIR_RDD:
  2733.                             {
  2734.                                 b->Angular = false;
  2735.                                 b->Dir = DIR_RIGHTDOWN;
  2736.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2737.                                 break;
  2738.                             }
  2739.                             case DIR_LLU:
  2740.                             {
  2741.                                 b->Angular = false;
  2742.                                 b->Dir = DIR_RIGHTUP;
  2743.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2744.                                 break;
  2745.                             }
  2746.                             case DIR_LUU:
  2747.                             {
  2748.                                 b->Angular = false;
  2749.                                 b->Dir = DIR_RIGHTUP;
  2750.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2751.                                 break;
  2752.                             }
  2753.                             case DIR_LLD:
  2754.                             {
  2755.                                 b->Angular = false;
  2756.                                 b->Dir = DIR_LEFTUP;
  2757.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2758.                                 break;
  2759.                             }
  2760.                             case DIR_LDD:
  2761.                             {
  2762.                                 b->Angular = false;
  2763.                                 b->Dir = DIR_LEFTUP;
  2764.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2765.                                 break;
  2766.                             }
  2767.                            
  2768.                         }
  2769.                     }
  2770.                     else
  2771.                     {
  2772.                         switch(b->Dir)
  2773.                         {
  2774.                             case DIR_DOWNRIGHT:
  2775.                             {
  2776.                                 b->Angular = false;
  2777.                                 b->Dir = DIR_UPLEFT;
  2778.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2779.                                 break;
  2780.                             }
  2781.                             case DIR_DOWNLEFT:
  2782.                             {
  2783.                                 b->Angular = false;
  2784.                                 b->Dir = DIR_UPRIGHT;
  2785.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2786.                                 break;
  2787.                             }
  2788.                             case DIR_UPRIGHT:
  2789.                             {
  2790.                                 b->Angular = false;
  2791.                                 b->Dir = DIR_DOWNLEFT;
  2792.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2793.                                 break;
  2794.                             }
  2795.                             case DIR_UPLEFT:
  2796.                             {
  2797.                                 b->Angular = false;
  2798.                                 b->Dir = DIR_DOWNRIGHT;
  2799.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2800.                                 break;
  2801.                             }
  2802.                            
  2803.                         }
  2804.                     }
  2805.                 }
  2806.                 //end upper-right corners
  2807.                 else
  2808.                 {
  2809.                     if ( b->Angular )
  2810.                     {
  2811.                         switch(b->Angle)
  2812.                         {
  2813.                             case DIR_RRD:
  2814.                             {
  2815.                                 b->Angular = false;
  2816.                                 b->Dir = DIR_LEFTDOWN;
  2817.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2818.                                 break;
  2819.                             }
  2820.                             case DIR_RDD:
  2821.                             {
  2822.                                 b->Angular = false;
  2823.                                 b->Dir = DIR_LEFTDOWN;
  2824.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2825.                                 break;
  2826.                             }
  2827.                             case DIR_RRU:
  2828.                             {
  2829.                                 b->Angular = false;
  2830.                                 b->Dir = DIR_LEFTUP;
  2831.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2832.                                 break;
  2833.                             }
  2834.                             case DIR_RUU:
  2835.                             {
  2836.                                 b->Angular = false;
  2837.                                 b->Dir = DIR_LEFTUP;
  2838.                                 b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED);
  2839.                                 break;
  2840.                             }
  2841.                            
  2842.                         }
  2843.                     }
  2844.                     else
  2845.                     {
  2846.                         switch(b->Dir)
  2847.                         {
  2848.                             case DIR_LEFTDOWN: { b->Dir = DIR_RIGHTDOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2849.                             case DIR_LEFTUP: { b->Dir = DIR_RIGHTUP; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2850.                             default: {
  2851.                                 TraceNL(); TraceS("Ball direction invalid for brick.take_hit(hit_right()).");
  2852.                                 TraceNL(); TraceS("Ball Dir is: "); Trace(b->Dir); TraceNL();
  2853.                                 b->Dir = DIR_DOWN; b->Step = bound(b->Step+1, 0, MAX_BALL_SPEED); break; }
  2854.                         }
  2855.                     }
  2856.                     /*
  2857.                     switch ( v->Dir )
  2858.                     {
  2859.                         case DIR_UPLEFT: { v->Dir = DIR_UPRIGHT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  2860.                         case DIR_DOWNLEFT: { v->Dir = DIR_DOWNRIGHT; v->Step = bound(v->Step+2, 0, MAX_BALL_SPEED); break; }
  2861.                         default: { TraceS("hit_below() found an illegal ball direction"); break; }
  2862.                     }
  2863.                     */
  2864.                     if ( a->HP <= 0 )
  2865.                     {
  2866.                         if ( !a->Misc[NPCM_AWARDED_POINTS] )
  2867.                         {
  2868.                             a->Misc[NPCM_AWARDED_POINTS] = 1;
  2869.                             Game->Counter[CR_SCRIPT1] += a->Attributes[NPC_ATTRIB_POINTS];
  2870.                             drop_capsule(a);
  2871.                         }
  2872.                     }
  2873.                 }
  2874.             }
  2875.            
  2876.             else
  2877.             {
  2878.                 TraceS("brick.hit() returned true, but couldn't determine a valid ball location!");
  2879.                 return;
  2880.             }
  2881.         }
  2882.                    
  2883.            
  2884.     }
  2885.     //turns layer objects into npc bricks.
  2886.     void setup()
  2887.     {
  2888.         int tempenem; npc bricks[1024]; int temp;
  2889.         for ( int q = 0; q < 176; ++q )
  2890.         {
  2891.             //bricks on layer 1
  2892.             //Trace(GetLayerComboD(1,q));
  2893.             //while(!Input->Press[CB_A]) Waitframe();
  2894.             tempenem = brick_to_npc(GetLayerComboD(1,q),false);
  2895.             //TraceS("tempenem is: "); Trace(tempenem);
  2896.             //while(!Input->Press[CB_A]) Waitframe();
  2897.             if ( tempenem )
  2898.             {
  2899.                 bricks[temp] = Screen->CreateNPC(tempenem);
  2900.                 //TraceS("Created npc: "); Trace(tempenem);
  2901.                 bricks[temp]->X = ComboX(q);
  2902.                 bricks[temp]->Y = ComboY(q);
  2903.                 //TraceS("Brick defence is: "); Trace(bricks[temp]->Defense[20]);
  2904.                 tempenem = 0; ++temp;
  2905.                
  2906.             }
  2907.             //bricks on layer 2, Y+8px
  2908.             tempenem = brick_to_npc(GetLayerComboD(2,q),true);
  2909.             //Trace(tempenem);
  2910.             if ( tempenem )
  2911.             {
  2912.                 bricks[temp] = Screen->CreateNPC(tempenem);
  2913.                 //TraceS("Created npc: "); Trace(tempenem);
  2914.                 bricks[temp]->X = ComboX(q);
  2915.                 bricks[temp]->Y = ComboY(q)+8;
  2916.                 //TraceS("Brick defence is: "); Trace(bricks[temp]->Defense[20]);
  2917.                 tempenem = 0; ++temp;
  2918.             }
  2919.         }
  2920.        
  2921.     }
  2922.     void clear_combos()
  2923.     {
  2924.         templayer[0] = Screen->LayerOpacity[0];
  2925.         templayer[1] = Screen->LayerOpacity[1];
  2926.         templayer[2] = Screen->LayerMap[0];
  2927.         templayer[3] = Screen->LayerMap[1];
  2928.         Screen->LayerOpacity[0] = 0;
  2929.         Screen->LayerOpacity[1] = 0;
  2930.         Screen->LayerMap[0] = 0;
  2931.         Screen->LayerMap[1] = 0;
  2932.     }
  2933.    
  2934.     int brick_to_npc(int combo_id, bool layer2)
  2935.     {
  2936.        
  2937.         if ( !layer2 )
  2938.         {
  2939.             int brick_to_enemy[BRICK_MAX*2] =
  2940.             {   CMB_BRICK_RED, CMB_BRICK_WHITE, CMB_BRICK_BLUE, CMB_BRICK_ORANGE, CMB_BRICK_TEAL,
  2941.                 CMB_BRICK_VIOLET, CMB_BRICK_GREEN, CMB_BRICK_YELLOW, CMB_BRICK_SILVER1, CMB_BRICK_SILVER2,
  2942.                 CMB_BRICK_SILVER3, CMB_BRICK_SILVER4, CMB_BRICK_GOLD,
  2943.  
  2944.                 NPC_BRICK_RED, NPC_BRICK_WHITE, NPC_BRICK_BLUE, NPC_BRICK_ORANGE, NPC_BRICK_TEAL,
  2945.                 NPC_BRICK_VIOLET, NPC_BRICK_GREEN, NPC_BRICK_YELLOW, NPC_BRICK_SILVER1, NPC_BRICK_SILVER2,
  2946.                 NPC_BRICK_SILVER3, NPC_BRICK_SILVER4, NPC_BRICK_GOLD
  2947.             };
  2948.             for ( int q = 0; q < BRICK_MAX; ++q )
  2949.             {
  2950.                 if ( brick_to_enemy[q] == combo_id )
  2951.                 {
  2952.                     //  TraceS("brick_to_npc : combo input: "); Trace(combo_id);
  2953.                     //TraceS("brick_to_npc : enemy output: "); Trace(brick_to_enemy[BRICK_MAX+q]);
  2954.                    
  2955.                     return ( brick_to_enemy[BRICK_MAX+q-1] );
  2956.                 }
  2957.             }
  2958.         }
  2959.         else
  2960.         {
  2961.             int brick_to_enemy2[BRICK_MAX*2] =
  2962.             {   CMB_BRICK_RED_LOW, CMB_BRICK_WHITE_LOW, CMB_BRICK_BLUE_LOW, CMB_BRICK_ORANGE_LOW, CMB_BRICK_TEAL_LOW,
  2963.                 CMB_BRICK_VIOLET_LOW, CMB_BRICK_GREEN_LOW, CMB_BRICK_YELLOW_LOW, CMB_BRICK_SILVER1_LOW, CMB_BRICK_SILVER2_LOW,
  2964.                 CMB_BRICK_SILVER3_LOW, CMB_BRICK_SILVER4_LOW, CMB_BRICK_GOLD_LOW,
  2965.  
  2966.                 NPC_BRICK_RED, NPC_BRICK_WHITE, NPC_BRICK_BLUE, NPC_BRICK_ORANGE, NPC_BRICK_TEAL,
  2967.                 NPC_BRICK_VIOLET, NPC_BRICK_GREEN, NPC_BRICK_YELLOW, NPC_BRICK_SILVER1, NPC_BRICK_SILVER2,
  2968.                 NPC_BRICK_SILVER3, NPC_BRICK_SILVER4, NPC_BRICK_GOLD
  2969.             };
  2970.             for ( int q = 0; q < BRICK_MAX; ++q )
  2971.             {
  2972.                 if ( brick_to_enemy2[q] == combo_id )
  2973.                 {
  2974.                     //TraceS("brick_to_npc : combo input: "); Trace(combo_id);
  2975.                     //TraceS("brick_to_npc : enemy output: "); Trace(brick_to_enemy2[BRICK_MAX+q-1]);
  2976.                     return ( brick_to_enemy2[BRICK_MAX+q-1] );
  2977.                 }
  2978.             }
  2979.         }
  2980.         return 0; //error
  2981.     }
  2982. }
  2983.  
  2984. global script onExit
  2985. {
  2986.     void run()
  2987.     {
  2988.         Screen->LayerOpacity[0] = templayer[0];
  2989.         Screen->LayerOpacity[1] = templayer[1];
  2990.         Screen->LayerMap[0] = templayer[2];
  2991.         Screen->LayerMap[1] = templayer[3];
  2992.         newstage = true;
  2993.         //vaus->Misc[MISC_DEAD] = 0;
  2994.  
  2995.     }
  2996. }  
  2997.  
  2998. global script init
  2999. {
  3000.     void run()
  3001.     {
  3002.         quit = 0;
  3003.         frame = -1;
  3004.         cur_stage = 1;
  3005.         Game->Counter[CR_LIVES] = STARTING_LIVES;
  3006.         Link->CollDetection = false;
  3007.         Link->DrawYOffset = -32768;
  3008.     }
  3009. }
  3010.  
  3011. global script Init
  3012. {
  3013.     void run()
  3014.     {
  3015.         quit = 0;
  3016.         frame = -1;
  3017.         cur_stage = 1;
  3018.         Game->Counter[CR_LIVES] = STARTING_LIVES;
  3019.         Link->CollDetection = false;
  3020.         Link->DrawYOffset = -32768;
  3021.     }
  3022. }
  3023.  
  3024. global script onContinue
  3025. {
  3026.     void run()
  3027.     {
  3028.         quit = 0;
  3029.         frame = -1;
  3030.         //cur_stage = 1;
  3031.         Game->Counter[CR_LIVES] = STARTING_LIVES;
  3032.         Link->Invisible = true;
  3033.         Link->CollDetection = false;
  3034.         Link->DrawYOffset = -32768;
  3035.     }
  3036. }
  3037.  
  3038. /////////////////////////
  3039. /// DEAD Script Bugs: ///
  3040. /////////////////////////
  3041.  
  3042. /*
  3043. //FIXED with ball.clamp().
  3044. //There's a step speed at which the ball phases *through* the vaus!
  3045.                     //Perhaps we should make the vaus an enemy, too? An invisible enemy to act as a failsafe?
  3046.                     //if the ball hits the vaus, it bounces.
  3047.                     //Or just scrap the vaus ffc, and use an npc for it in general?
  3048.  
  3049. //BALL NEEDS TO HAVE A 6PX BY 6PX HITBOX, AND THUS A HIT OFFSET OF -1,-1, so that ->HitBy[] returns when the ball hits a block, and
  3050. //the ball is still not yet inside that object
  3051. */
  3052.  
  3053. //////////////////////
  3054. /// DEAD ZC Issues //////////////////////////////////////////////////////////////////////////////
  3055. /// I fixed these issues, in specific Alphas of ZC 2.54, noted below for historical purposes: ///
  3056. /////////////////////////////////////////////////////////////////////////////////////////////////
  3057.  
  3058.  
  3059. /*
  3060. FIXED in Alpha 32
  3061. I forgot to expand ->Misc[] in sprite.cpp, which should be fixed int he source for Alpha 32.
  3062.     This meant that r/w to ptr->Misc[>15] would use invalid data, or overwrite other data. bad, bad, bad.
  3063.    
  3064.     FIXED in Alpha 32
  3065.     //Note: We also need to store the UID of each ball, as HitBy[] works from the UID, not the pointer.
  3066.    
  3067. */
  3068.  
  3069. ffc script TestGetPixel
  3070. {
  3071.     void run()
  3072.     {
  3073.         while(1)
  3074.         {
  3075.            
  3076.             if ( Input->Key[KEY_8] )
  3077.             {
  3078.                 bitmap bmp = Game->LoadBitmapID(RT_SCREEN);
  3079.                 int col[20];
  3080.                 for ( int q = 0; q < 20; ++ q )
  3081.                 {
  3082.                     col[q] = bmp->GetPixel(40, 0+q*8);
  3083.                 }
  3084.                 TraceNL();
  3085.                 for ( int q = 0; q < 20; ++q )
  3086.                 {
  3087.                     TraceS("Bitmap col: "); Trace(col[q]);
  3088.                 }
  3089.                
  3090.                 Screen->SetRenderTarget(2);
  3091.                 Screen->Rectangle(0, 0, 0, 256, 256, 0x55, 100, 0, 0, 0, true, 128);
  3092.                 Screen->SetRenderTarget(RT_SCREEN);
  3093.                 Waitframe();
  3094.                
  3095.                 bitmap offscreen = Game->LoadBitmapID(2);
  3096.                 int col2[20];
  3097.                 for ( int q = 0; q < 20; ++ q )
  3098.                 {
  3099.                     col2[q] = offscreen->GetPixel(10+q*8,10+q*8);
  3100.                 }
  3101.                 TraceNL();
  3102.                 for ( int q = 0; q < 20; ++q )
  3103.                 {
  3104.                     TraceS("Offscreen Bitmap col: "); Trace(col2[q]);
  3105.                 }
  3106.             }  
  3107.             Waitframe();
  3108.         }
  3109.     }
  3110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement