burc_2004

_zm_ai_mechz_booster.gsc

Oct 22nd, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.60 KB | None | 0 0
  1. #include maps/mp/zombies/_zm_spawner;
  2. #include maps/mp/animscripts/zm_shared;
  3. #include maps/mp/zombies/_zm_ai_mechz;
  4. #include maps/mp/zombies/_zm_ai_mechz_dev;
  5. #include maps/mp/zm_tomb_tank;
  6. #include maps/mp/animscripts/zm_utility;
  7. #include maps/mp/zombies/_zm_utility;
  8. #include maps/mp/zombies/_zm_net;
  9. #include maps/mp/_utility;
  10. #include common_scripts/utility;
  11. #include maps/mp/zombies/_zm_zonemgr;
  12.  
  13. #using_animtree( "mechz_claw" );
  14.  
  15. mechz_in_range_for_jump()
  16. {
  17.     if ( !isDefined( self.jump_pos ) )
  18.     {
  19. /#
  20.         iprintln( "\nMZ Error: Trying to jump without valid jump_pos\n" );
  21. #/
  22.         self.jump_requested = 0;
  23.         return 0;
  24.     }
  25.     dist = distancesquared( self.origin, self.jump_pos.origin );
  26.     if ( dist <= 100 )
  27.     {
  28.         return 1;
  29.     }
  30.     return 0;
  31. }
  32.  
  33. mechz_jump_think( spawn_pos )
  34. {
  35.     self endon( "death" );
  36.     self endon( "stop_jump_think" );
  37.     self.closest_jump_point = spawn_pos;
  38.     self.goal_pos = self.origin;
  39.     self setgoalpos( self.goal_pos );
  40.     self thread mechz_jump_stuck_watcher();
  41.     while ( 1 )
  42.     {
  43.         while ( isDefined( self.jump_requested ) && self.jump_requested )
  44.         {
  45.             if ( !self mechz_should_jump() )
  46.             {
  47.                 self.jump_requested = 0;
  48.                 self.jump_pos = undefined;
  49.             }
  50.             wait 1;
  51.         }
  52.         while ( !isDefined( self.ai_state ) || self.ai_state != "find_flesh" )
  53.         {
  54.             wait 0,05;
  55.         }
  56.         while ( isDefined( self.not_interruptable ) && self.not_interruptable )
  57.         {
  58.             wait 0,05;
  59.         }
  60. /#
  61.         while ( isDefined( self.force_behavior ) && self.force_behavior )
  62.         {
  63.             wait 0,05;
  64. #/
  65.         }
  66.         if ( self mechz_should_jump() )
  67.         {
  68.             self.jump_requested = 1;
  69.             self.jump_pos = get_closest_mechz_spawn_pos( self.origin );
  70.             if ( !isDefined( self.jump_pos ) )
  71.             {
  72.                 self.jump_requested = 0;
  73.             }
  74.         }
  75.         wait 1;
  76.     }
  77. }
  78.  
  79. watch_for_riot_shield_melee()
  80. {
  81.     self endon( "new_stuck_watcher" );
  82.     self endon( "death" );
  83.     while ( 1 )
  84.     {
  85.         self waittill( "item_attack" );
  86. /#
  87.         if ( getDvarInt( #"E7121222" ) > 1 )
  88.         {
  89.             println( "\n\tMZ: Resetting fail count because of item attack\n" );
  90. #/
  91.         }
  92.         self.fail_count = 0;
  93.     }
  94. }
  95.  
  96. watch_for_valid_melee()
  97. {
  98.     self endon( "new_stuck_watcher" );
  99.     self endon( "death" );
  100.     while ( 1 )
  101.     {
  102.         self waittillmatch( "melee_anim" );
  103.         return "end";
  104.         if ( isDefined( self.favoriteenemy ) && distancesquared( self.origin, self.favoriteenemy.origin ) < 16384 )
  105.         {
  106. /#
  107.             if ( getDvarInt( #"E7121222" ) > 1 )
  108.             {
  109.                 println( "\n\tMZ: Resetting fail count because of melee\n" );
  110. #/
  111.             }
  112.             self.fail_count = 0;
  113.         }
  114.     }
  115. }
  116.  
  117. mechz_jump_stuck_watcher()
  118. {
  119.     self notify( "new_stuck_watcher" );
  120.     self endon( "death" );
  121.     self endon( "new_stuck_watcher" );
  122.     self.fail_count = 0;
  123.     self thread watch_for_valid_melee();
  124.     self thread watch_for_riot_shield_melee();
  125.     while ( 1 )
  126.     {
  127.         while ( !isDefined( self.goal_pos ) )
  128.         {
  129.             wait 0,05;
  130.         }
  131.         while ( isDefined( self.not_interruptable ) && self.not_interruptable )
  132.         {
  133.             wait 0,05;
  134.         }
  135.         while ( isDefined( self.ai_state ) && self.ai_state != "find_flesh" )
  136.         {
  137.             wait 0,05;
  138.         }
  139. /#
  140.         while ( isDefined( self.force_behavior ) && self.force_behavior )
  141.         {
  142.             wait 0,05;
  143. #/
  144.         }
  145.         if ( !findpath( self.origin, self.goal_pos, self, 0, 0 ) )
  146.         {
  147. /#
  148.             if ( getDvarInt( #"E7121222" ) > 1 )
  149.             {
  150.                 println( "\n\tMZ: Incrementing fail count\n" );
  151. #/
  152.             }
  153. /#
  154.             println( "Mechz could not path to goal_pos " + self.goal_pos );
  155. #/
  156.             self.fail_count++;
  157.         }
  158.         else
  159.         {
  160. /#
  161.             if ( getDvarInt( #"E7121222" ) > 1 )
  162.             {
  163.                 println( "\n\tMZ: Resetting fail count because of good path\n" );
  164. #/
  165.             }
  166.             self.fail_count = 0;
  167.         }
  168.         wait 1;
  169.     }
  170. }
  171.  
  172. mechz_should_jump()
  173. {
  174. /#
  175.     if ( getDvarInt( #"E7121222" ) > 1 )
  176.     {
  177.         println( "\n\tMZ: Checking should jump\n" );
  178. #/
  179.     }
  180.     if ( !isDefined( self.favoriteenemy ) )
  181.     {
  182. /#
  183.         if ( getDvarInt( #"E7121222" ) > 1 )
  184.         {
  185.             println( "\n\t\tMZ: Not doing jump because has no enemy\n" );
  186. #/
  187.         }
  188.         return 0;
  189.     }
  190.     dist = distancesquared( self.origin, self.favoriteenemy.origin );
  191.     if ( dist >= level.mechz_jump_dist_threshold )
  192.     {
  193. /#
  194.         if ( getDvarInt( #"E7121222" ) > 1 )
  195.         {
  196.             println( "\n\t\tMZ: Doing jump because target is too far\n" );
  197. #/
  198.         }
  199.         return 1;
  200.     }
  201.     if ( self.fail_count >= level.mechz_failed_paths_to_jump )
  202.     {
  203. /#
  204.         if ( getDvarInt( #"E7121222" ) > 1 )
  205.         {
  206.             println( "\n\t\tMZ: Doing jump because has failed too many pathfind checks\n" );
  207. #/
  208.         }
  209.         return 1;
  210.     }
  211.     return 0;
  212. }
  213.  
  214. mechz_do_jump( wait_for_stationary_tank )
  215. {
  216.     self endon( "death" );
  217.     self endon( "kill_jump" );
  218. /#
  219.     if ( getDvarInt( #"E7121222" ) > 0 )
  220.     {
  221.         println( "\nMZ: Doing Jump-Teleport\n" );
  222. #/
  223.     }
  224. /#
  225.     if ( getDvarInt( #"E7121222" ) > 1 )
  226.     {
  227.         println( "\nMZ: Jump setting not interruptable\n" );
  228. #/
  229.     }
  230.     self.not_interruptable = 1;
  231.     self setfreecameralockonallowed( 0 );
  232.     self thread mechz_jump_vo();
  233.     self animscripted( self.origin, self.angles, "zm_fly_out" );
  234.     self maps/mp/animscripts/zm_shared::donotetracks( "jump_anim" );
  235.     self ghost();
  236.     self.mechz_hidden = 1;
  237.     if ( isDefined( self.m_claw ) )
  238.     {
  239.         self.m_claw ghost();
  240.     }
  241.     if ( self.fx_field )
  242.     {
  243.         self.fx_field_old = self.fx_field;
  244.     }
  245.     self thread maps/mp/zombies/_zm_spawner::zombie_eye_glow_stop();
  246.     self fx_cleanup();
  247.     self animscripted( self.origin, self.angles, "zm_fly_hover" );
  248.     wait level.mechz_jump_delay;
  249.     if ( isDefined( wait_for_stationary_tank ) && wait_for_stationary_tank )
  250.     {
  251.         level.vh_tank ent_flag_waitopen( "tank_moving" );
  252.     }
  253.     self notsolid();
  254.     closest_jump_point = get_best_mechz_spawn_pos( 1 );
  255.     if ( isDefined( closest_jump_point ) )
  256.     {
  257.         self.closest_jump_point = closest_jump_point;
  258.     }
  259.     if ( !isDefined( self.closest_jump_point.angles ) )
  260.     {
  261.         self.closest_jump_point.angles = ( 0, 0, 0 );
  262.     }
  263.     self animscripted( self.closest_jump_point.origin, self.closest_jump_point.angles, "zm_fly_in" );
  264.     self solid();
  265.     self.mechz_hidden = 0;
  266.     self show();
  267.     self.fx_field = self.fx_field_old;
  268.     self.fx_field_old = undefined;
  269.     self setclientfield( "mechz_fx", self.fx_field );
  270.     self thread maps/mp/zombies/_zm_spawner::zombie_eye_glow();
  271.     if ( isDefined( self.m_claw ) )
  272.     {
  273.         self.m_claw show();
  274.     }
  275.     self maps/mp/animscripts/zm_shared::donotetracks( "jump_anim" );
  276.     self.not_interruptable = 0;
  277.     self setfreecameralockonallowed( 1 );
  278. /#
  279.     if ( getDvarInt( #"E7121222" ) > 1 )
  280.     {
  281.         println( "\nMZ: Jump clearing not interruptable\n" );
  282. #/
  283.     }
  284.     mechz_jump_cleanup();
  285. }
  286.  
  287. mechz_kill_jump_watcher()
  288. {
  289.     self endon( "jump_complete" );
  290.     self waittill_either( "death", "kill_jump" );
  291.     self mechz_jump_cleanup();
  292. }
  293.  
  294. mechz_jump_cleanup()
  295. {
  296.     self.fx_field &= 128;
  297.     self setclientfield( "mechz_fx", self.fx_field );
  298.     self stopanimscripted();
  299.     self notify( "jump_complete" );
  300. }
Advertisement
Add Comment
Please, Sign In to add comment