Advertisement
Guest User

Untitled

a guest
Jan 9th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. event_inherited();
  2.  
  3. if global.frozen == false
  4. {
  5.     if isFight == true
  6.     {      
  7.         checkGround();
  8.         gravityCheckGround();
  9.         generalCollision();
  10.        
  11.         switch phase
  12.         {
  13.             case 0: //Idle (standing still)
  14.                 sprite_index = sprPharaohStand;
  15.                 image_speed = 0;
  16.                
  17.                 attackTimer -= 1;
  18.                 if attackTimer <= 0
  19.                 {
  20.                     if attackTimer == -1 //It's -1 when first attacking; the first attack is always a jump 'n shoot
  21.                         phase = 2;
  22.                     else
  23.                     {
  24.                         randomize();
  25.                         phase = choose(1, 2, 3, 3); //There seems to be a higher chance of him shooting
  26.                     }
  27.                 }
  28.             break;
  29.            
  30.            
  31.            
  32.             case 1: //Jumping
  33.                 if attackTimer <= 0
  34.                 {
  35.                     attackTimer = 35;
  36.                    
  37.                     if instance_exists(objMegaman)
  38.                     {
  39.                         startXScale = image_xscale;
  40.                        
  41.                         //Calculate the time needed to jump to MM's position, and with that, calculate the horizontal speed
  42.                         var dx, initYspeed;
  43.                         dx = sprite_get_xcenter_object(objMegaman) - sprite_get_xcenter();
  44.                         initYspeed = -4.5;
  45.                        
  46.                         var time, yy, yyspeed; //time: How much time (in frames) it would take to land on Mega Man's location
  47.                         yy = bbox_bottom;
  48.                         yyspeed = initYspeed;
  49.                         time = 0;
  50.                        
  51.                         while yy < objMegaman.bbox_bottom || yyspeed < 0
  52.                         {
  53.                             yyspeed += 4.5;
  54.                             yy += yyspeed;
  55.                             time += 1;
  56.                         }
  57.                        
  58.                         startXspeed = (dx) / time;
  59.                         yspeed = initYspeed;
  60.                         ground = false;
  61.                     }
  62.                     else
  63.                     {
  64.                         startXScale = image_xscale;
  65.                         startXspeed = 0;
  66.                     }
  67.                 }
  68.                
  69.                 if !place_meeting(x+startXspeed, y, objSolid) && !place_meeting(x+startXspeed, y, prtMovingPlatformSolid)
  70.                     xspeed = startXspeed;
  71.                 else
  72.                 {
  73.                     while place_meeting(x, y, objSolid)
  74.                             x -= image_xscale;
  75.                            
  76.                     xspeed = 0;
  77.                 }
  78.                
  79.                
  80.                 //Face the player
  81.                 if instance_exists(objMegaman)
  82.                 {
  83.                     if startXScale == -1
  84.                     {
  85.                         if x > objMegaman.x
  86.                             sprite_index = sprPharaohJump;
  87.                         else
  88.                             sprite_index = sprPharaohJumpBack;
  89.                     }
  90.                     else
  91.                     {
  92.                         if x > objMegaman.x
  93.                             sprite_index = sprPharaohJumpBack;
  94.                         else
  95.                             sprite_index = sprPharaohJump;
  96.                     }
  97.                 }
  98.                
  99.                
  100.                 //When grounded, end the jump
  101.                 if ground == true
  102.                 {
  103.                     phase = 0;
  104.                     sprite_index = sprPharaohStand;
  105.                     xspeed = 0;
  106.                     yspeed = 0;
  107.                 }
  108.             break;
  109.            
  110.            
  111.            
  112.             case 2: //Jumping 'n shooting
  113.                 if attackTimer <= 0
  114.                 {
  115.                     attackTimer = 35;
  116.                     jumpTimer = 0;
  117.                    
  118.                     startXScale = image_xscale;
  119.                     yspeed = -4.5;
  120.                     sprite_index = sprPharaohJump;
  121.                     ground = false;
  122.                 }
  123.                
  124.                 if sprite_index == sprPharaohJump || sprite_index == sprPharaohJumpBack
  125.                 {
  126.                     jumpTimer += 1;
  127.                     if jumpTimer >= 10
  128.                     {
  129.                         sprite_index = sprPharaohJumpShoot;
  130.                         image_index = 0;
  131.                         image_speed = 6/60;
  132.                     }
  133.                 }
  134.                 else if sprite_index == sprPharaohJumpShoot || sprite_index == sprPharaohJumpShootBack
  135.                 {
  136.                     if floor(image_index) == 1
  137.                     {
  138.                         if canInitShoot == true
  139.                         {
  140.                             canInitShoot = false;
  141.                            
  142.                             var box;
  143.                             if image_xscale == 1
  144.                                 box = bbox_right;
  145.                             else
  146.                                 box = bbox_left;
  147.                            
  148.                             instance_create(box, y-8, objPharaohManShot);
  149.                         }
  150.                        
  151.                         image_speed = 6/60;
  152.                     }
  153.                     else if floor(image_index) == image_number-1
  154.                     {
  155.                         image_index = image_number-1;
  156.                         image_speed = 0;
  157.                     }
  158.                     else
  159.                     {
  160.                         image_speed = 6/60;
  161.                     }
  162.                 }
  163.                
  164.                 if !place_meeting(x+startXScale * 2, y, objSolid) && !place_meeting(x+startXScale * 2, y, prtMovingPlatformSolid)
  165.                     xspeed = startXScale * 1.5;
  166.                 else
  167.                 {
  168.                     while place_meeting(x, y, objSolid)
  169.                         x -= image_xscale;
  170.                        
  171.                     xspeed = 0;
  172.                 }
  173.                    
  174.                    
  175.                 //Either jump again or end the phase
  176.                 if ground == true
  177.                 {
  178.                     if jumpAmount == 0
  179.                     {
  180.                         sprite_index = sprPharaohJump;
  181.                         jumpTimer = 0;
  182.                         jumpAmount = 1;
  183.                         canInitShoot = true;
  184.                         yspeed = -4.5;
  185.                     }
  186.                     else
  187.                     {
  188.                         jumpAmount = 0;
  189.                         canInitShoot = true;
  190.                         phase = 0;
  191.                         sprite_index = sprPharaohStand;
  192.                         xspeed = 0;
  193.                         yspeed = 0;
  194.                     }
  195.                 }
  196.                    
  197.                    
  198.                 //Face the player
  199.                 if instance_exists(objMegaman)
  200.                 {
  201.                     if startXScale == -1
  202.                     {
  203.                         if sprite_index == sprPharaohJump || sprite_index == sprPharaohJumpBack
  204.                         {
  205.                             if x > objMegaman.x
  206.                                 sprite_index = sprPharaohJump;
  207.                             else
  208.                                 sprite_index = sprPharaohJumpBack;
  209.                         }
  210.                         else if sprite_index == sprPharaohJumpShoot || sprite_index == sprPharaohJumpShootBack
  211.                         {
  212.                             if x > objMegaman.x
  213.                                 sprite_index = sprPharaohJumpShoot;
  214.                             else
  215.                                 sprite_index = sprPharaohJumpShootBack;
  216.                         }
  217.                     }
  218.                     else
  219.                     {
  220.                         if sprite_index == sprPharaohJump || sprite_index == sprPharaohJumpBack
  221.                         {
  222.                             if x > objMegaman.x
  223.                                 sprite_index = sprPharaohJumpBack;
  224.                             else
  225.                                 sprite_index = sprPharaohJump;
  226.                         }
  227.                         else if sprite_index == sprPharaohJumpShoot || sprite_index == sprPharaohJumpShootBack
  228.                         {
  229.                             if x > objMegaman.x
  230.                                 sprite_index = sprPharaohJumpShootBack;
  231.                             else
  232.                                 sprite_index = sprPharaohJumpShoot;
  233.                         }
  234.                     }
  235.                 }
  236.             break;
  237.            
  238.            
  239.            
  240.             case 3: //Shooting a big shot
  241.                 if attackTimer <= 0
  242.                 {
  243.                     attackTimer = 35;
  244.                     jumpTimer = 0;
  245.                    
  246.                     sprite_index = sprPharaohCharge;
  247.                     image_speed = 0.25;
  248.                     image_index = 0;
  249.                 }
  250.                
  251.                 if sprite_index == sprPharaohCharge //This extra code is to make sure the animation resumes after pausing and unpausing
  252.                     image_speed = 0.25;
  253.                 else if sprite_index == sprPharaohCharge2
  254.                     image_speed = 0.07;
  255.                 else if sprite_index = sprPharaohCharge3
  256.                     image_speed = 1;
  257.                
  258.                 jumpTimer += 1; //It's not really a timer for jumping, but rather for releasing the shot; however, reusing this variable saves initializing a new one
  259.                 if jumpTimer >= 40
  260.                 {                    
  261.                     if jumpTimer == 40
  262.                     {
  263.                         sprite_index = sprPharaohCharge2;
  264.                         image_index = 0;
  265.                         image_speed = 0.07;
  266.                     }
  267.                     else if jumpTimer == 60
  268.                     {
  269.                         sprite_index = sprPharaohCharge3;
  270.                         image_index = 1;
  271.                         image_speed = 1;
  272.                     }
  273.                     else if jumpTimer == 70
  274.                     {
  275.                         sprite_index = sprPharaohShoot;
  276.                        
  277.                         var shootID, box;
  278.                         if image_xscale == 1
  279.                             box = bbox_right+10;
  280.                         else
  281.                             box = bbox_left-10;
  282.                            
  283.                         shootID = instance_create(box, y+2, objPharaohManShotBig);
  284.                             shootID.image_xscale = image_xscale;
  285.                     }
  286.                     else if jumpTimer == 75
  287.                     {
  288.                         phase = 0;
  289.                         sprite_index = sprPharaohStand;
  290.                         xspeed = 0;
  291.                         yspeed = 0;
  292.                     }
  293.                 }
  294.             break;
  295.         }
  296.        
  297.        
  298.         //Face the player
  299.         if instance_exists(objMegaman)
  300.         {
  301.             if x > objMegaman.x
  302.                 image_xscale = -1;
  303.             else
  304.                 image_xscale = 1;
  305.         }
  306.     }
  307. }
  308. else
  309. {
  310.     image_speed = 0;
  311. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement