SHARE
TWEET

Untitled

a guest Aug 1st, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. switch (state){
  2.    
  3.     case states.seek:
  4.         #region Seek
  5.        
  6.         charge_cooldown_counter = max(0, charge_cooldown_counter - 1 * global.move_mod);
  7.         additional_debug_info = string(charge_cooldown_counter)
  8.        
  9.         SetTarget(oTracker);
  10.        
  11.         //set state to charge if tracker is within charge distance
  12.         var in_range = collision_circle(x, y, charge_radius, oTracker, false, true)
  13.         if  (in_range) && (charge_cooldown_counter <= 0){
  14.             bonus_hp = hp_start/2;
  15.             state = states.charge;
  16.             break;
  17.            
  18.         }
  19.        
  20.         avoid_angle = 0;
  21.         target_dir = point_direction(x, y, target_x, target_y)
  22.  
  23.         with (oBigEnemy){
  24.             if (id != other.id){
  25.                 if (point_distance(x, y, other.x, other.y) < other.avoid_distance){
  26.                     if (other.avoid_angle != 0) {break;}
  27.                     other.avoid_angle = choose(-45, 45);
  28.                 }
  29.             }
  30.             //else other.avoid_angle = 0;
  31.         }
  32.  
  33.         var delta = angle_difference(target_dir, direction);
  34.  
  35.         direction += (sign(delta) * turn_rate + avoid_angle) + (sin((get_timer()+wobble_offset)/100000)*10);
  36.        
  37.         Move();
  38.        
  39.         if (target_x >= x) image_xscale = 1*size;
  40.         else image_xscale = -1*size;
  41.         if (target_y >= y) image_index = 0;
  42.         else image_index = 1;
  43.        
  44.         break;
  45.         #endregion
  46.  
  47.        
  48.     case states.charge:
  49.         #region Charge
  50.        
  51.         //SetTarget(oTracker);
  52.         CreateAlert();
  53.        
  54.         charge_counter += 1* global.move_mod;
  55.         if(bonus_hp <= 0){
  56.             charge_cooldown_counter = charge_cooldown/2;
  57.             charge_counter = 0;
  58.                
  59.             instance_destroy(my_alert);
  60.             my_alert = noone;
  61.            
  62.             state = states.seek;
  63.            
  64.             break;
  65.         }
  66.        
  67.         if (charge_counter >= charge_time){
  68.            
  69.             charge_cooldown_counter = charge_cooldown;
  70.             charge_counter = 0;
  71.             additional_debug_info = string(charge_cooldown_counter);
  72.             target_angle = point_direction(x, y, target_x, target_y)
  73.            
  74.            
  75.             instance_destroy(my_alert);
  76.             my_alert = noone;
  77.            
  78.             start_charge_x = x;
  79.             start_charge_y = y;
  80.            
  81.             state = states.attack;
  82.             break;
  83.            
  84.         }
  85.         //reduce offset
  86.         if(abs(offset_x)>0) offset_x = Approach(offset_x, 0, knockback_recovery * global.move_mod);
  87.         if(abs(offset_y)>0) offset_y = Approach(offset_y, 0, knockback_recovery * global.move_mod);    
  88.            
  89.         break; 
  90.         #endregion
  91.  
  92.     case states.attack:
  93.         #region Attack
  94.        
  95.         var dist_charged = point_distance(x, y, start_charge_x, start_charge_y);
  96.        
  97.         move_x = lengthdir_x(charge_spd, target_angle);
  98.         move_y = lengthdir_y(charge_spd, target_angle);
  99.  
  100.         x += (move_x + offset_x)*global.move_mod;
  101.         y += (move_y + offset_y)*global.move_mod;
  102.         depth = -1*y
  103.    
  104.         if(abs(offset_x)>0) offset_x = Approach(offset_x, 0, knockback_recovery * global.move_mod);
  105.         if(abs(offset_y)>0) offset_y = Approach(offset_y, 0, knockback_recovery * global.move_mod);
  106.        
  107.         if (dist_charged > charge_distance || bonus_hp <= 0){
  108.             //keep some momentum
  109.             bonus_hp = 0;
  110.            
  111.             offset_x += lengthdir_x(charge_spd, target_angle);
  112.             offset_y += lengthdir_y(charge_spd, target_angle);
  113.            
  114.             state = states.seek;
  115.            
  116.         }
  117.        
  118.         #endregion
  119.         break;
  120. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top