burc_2004

_zm_weap_one_inch_punch.gsc

Oct 22nd, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.90 KB | None | 0 0
  1. #include maps/mp/animscripts/zm_shared;
  2. #include maps/mp/zombies/_zm_weap_staff_lightning;
  3. #include maps/mp/zombies/_zm_score;
  4. #include maps/mp/zombies/_zm_weap_staff_water;
  5. #include maps/mp/zombies/_zm_weap_staff_fire;
  6. #include maps/mp/zombies/_zm_spawner;
  7. #include maps/mp/zombies/_zm_audio;
  8. #include maps/mp/zombies/_zm_net;
  9. #include maps/mp/zombies/_zm_utility;
  10. #include common_scripts/utility;
  11. #include maps/mp/_utility;
  12.  
  13. one_inch_precache()
  14. {
  15.     precacheitem( "one_inch_punch_zm" );
  16.     precacheitem( "one_inch_punch_fire_zm" );
  17.     precacheitem( "one_inch_punch_air_zm" );
  18.     precacheitem( "one_inch_punch_ice_zm" );
  19.     precacheitem( "one_inch_punch_lightning_zm" );
  20.     precacheitem( "one_inch_punch_upgraded_zm" );
  21.     precacheitem( "zombie_one_inch_punch_flourish" );
  22.     precacheitem( "zombie_one_inch_punch_upgrade_flourish" );
  23.     level._effect[ "oneinch_impact" ] = loadfx( "maps/zombie_tomb/fx_tomb_perk_one_inch_punch" );
  24.     level._effect[ "punch_knockdown_ground" ] = loadfx( "weapon/thunder_gun/fx_thundergun_knockback_ground" );
  25. }
  26.  
  27. one_inch_punch_melee_attack()
  28. {
  29.     self endon( "disconnect" );
  30.     self endon( "stop_one_inch_punch_attack" );
  31.     if ( isDefined( self.one_inch_punch_flag_has_been_init ) && !self.one_inch_punch_flag_has_been_init )
  32.     {
  33.         self ent_flag_init( "melee_punch_cooldown" );
  34.     }
  35.     self.one_inch_punch_flag_has_been_init = 1;
  36.     current_melee_weapon = self get_player_melee_weapon();
  37.     self takeweapon( current_melee_weapon );
  38.     if ( isDefined( self.b_punch_upgraded ) && self.b_punch_upgraded )
  39.     {
  40.         str_weapon = self getcurrentweapon();
  41.         self disable_player_move_states( 1 );
  42.         self giveweapon( "zombie_one_inch_punch_upgrade_flourish" );
  43.         self switchtoweapon( "zombie_one_inch_punch_upgrade_flourish" );
  44.         self waittill_any( "player_downed", "weapon_change_complete" );
  45.         self switchtoweapon( str_weapon );
  46.         self enable_player_move_states();
  47.         self takeweapon( "zombie_one_inch_punch_upgrade_flourish" );
  48.         if ( self.str_punch_element == "air" )
  49.         {
  50.             self giveweapon( "one_inch_punch_air_zm" );
  51.             self set_player_melee_weapon( "one_inch_punch_air_zm" );
  52.         }
  53.         else if ( self.str_punch_element == "fire" )
  54.         {
  55.             self giveweapon( "one_inch_punch_fire_zm" );
  56.             self set_player_melee_weapon( "one_inch_punch_fire_zm" );
  57.         }
  58.         else if ( self.str_punch_element == "ice" )
  59.         {
  60.             self giveweapon( "one_inch_punch_ice_zm" );
  61.             self set_player_melee_weapon( "one_inch_punch_ice_zm" );
  62.         }
  63.         else if ( self.str_punch_element == "lightning" )
  64.         {
  65.             self giveweapon( "one_inch_punch_lightning_zm" );
  66.             self set_player_melee_weapon( "one_inch_punch_lightning_zm" );
  67.         }
  68.         else
  69.         {
  70.             self giveweapon( "one_inch_punch_upgraded_zm" );
  71.             self set_player_melee_weapon( "one_inch_punch_upgraded_zm" );
  72.         }
  73.     }
  74.     else
  75.     {
  76.         str_weapon = self getcurrentweapon();
  77.         self disable_player_move_states( 1 );
  78.         self giveweapon( "zombie_one_inch_punch_flourish" );
  79.         self switchtoweapon( "zombie_one_inch_punch_flourish" );
  80.         self waittill_any( "player_downed", "weapon_change_complete" );
  81.         self switchtoweapon( str_weapon );
  82.         self enable_player_move_states();
  83.         self takeweapon( "zombie_one_inch_punch_flourish" );
  84.         self giveweapon( "one_inch_punch_zm" );
  85.         self set_player_melee_weapon( "one_inch_punch_zm" );
  86.         self thread maps/mp/zombies/_zm_audio::create_and_play_dialog( "perk", "one_inch" );
  87.     }
  88.     self thread monitor_melee_swipe();
  89. }
  90.  
  91. monitor_melee_swipe()
  92. {
  93.     self endon( "disconnect" );
  94.     self notify( "stop_monitor_melee_swipe" );
  95.     self endon( "stop_monitor_melee_swipe" );
  96.     self endon( "bled_out" );
  97.     while ( 1 )
  98.     {
  99.         while ( !self ismeleeing() )
  100.         {
  101.             wait 0,05;
  102.         }
  103.         while ( self getcurrentweapon() == level.riotshield_name )
  104.         {
  105.             wait 0,1;
  106.         }
  107.         range_mod = 1;
  108.         self setclientfield( "oneinchpunch_impact", 1 );
  109.         wait_network_frame();
  110.         self setclientfield( "oneinchpunch_impact", 0 );
  111.         v_punch_effect_fwd = anglesToForward( self getplayerangles() );
  112.         v_punch_yaw = get2dyaw( ( 0, 0, 0 ), v_punch_effect_fwd );
  113.         if ( isDefined( self.b_punch_upgraded ) && self.b_punch_upgraded && isDefined( self.str_punch_element ) && self.str_punch_element == "air" )
  114.         {
  115.             range_mod *= 2;
  116.         }
  117.         a_zombies = getaispeciesarray( level.zombie_team, "all" );
  118.         a_zombies = get_array_of_closest( self.origin, a_zombies, undefined, undefined, 100 );
  119.         _a147 = a_zombies;
  120.         _k147 = getFirstArrayKey( _a147 );
  121.         while ( isDefined( _k147 ) )
  122.         {
  123.             zombie = _a147[ _k147 ];
  124.             if ( self is_player_facing( zombie, v_punch_yaw ) && distancesquared( self.origin, zombie.origin ) <= ( 4096 * range_mod ) )
  125.             {
  126.                 self thread zombie_punch_damage( zombie, 1 );
  127.             }
  128.             else
  129.             {
  130.                 if ( self is_player_facing( zombie, v_punch_yaw ) )
  131.                 {
  132.                     self thread zombie_punch_damage( zombie, 0,5 );
  133.                 }
  134.             }
  135.             _k147 = getNextArrayKey( _a147, _k147 );
  136.         }
  137.         while ( self ismeleeing() )
  138.         {
  139.             wait 0,05;
  140.         }
  141.         wait 0,05;
  142.     }
  143. }
  144.  
  145. is_player_facing( zombie, v_punch_yaw )
  146. {
  147.     v_player_to_zombie_yaw = get2dyaw( self.origin, zombie.origin );
  148.     yaw_diff = v_player_to_zombie_yaw - v_punch_yaw;
  149.     if ( yaw_diff < 0 )
  150.     {
  151.         yaw_diff *= -1;
  152.     }
  153.     if ( yaw_diff < 35 )
  154.     {
  155.         return 1;
  156.     }
  157.     else
  158.     {
  159.         return 0;
  160.     }
  161. }
  162.  
  163. is_oneinch_punch_damage()
  164. {
  165.     if ( isDefined( self.damageweapon ) )
  166.     {
  167.         return self.damageweapon == "one_inch_punch_zm";
  168.     }
  169. }
  170.  
  171. gib_zombies_head( player )
  172. {
  173.     player endon( "disconnect" );
  174.     self maps/mp/zombies/_zm_spawner::zombie_head_gib();
  175. }
  176.  
  177. punch_cooldown()
  178. {
  179.     wait 1;
  180.     self ent_flag_set( "melee_punch_cooldown" );
  181. }
  182.  
  183. zombie_punch_damage( ai_zombie, n_mod )
  184. {
  185.     self endon( "disconnect" );
  186.     ai_zombie.punch_handle_pain_notetracks = ::handle_punch_pain_notetracks;
  187.     if ( isDefined( n_mod ) )
  188.     {
  189.         if ( isDefined( self.b_punch_upgraded ) && self.b_punch_upgraded )
  190.         {
  191.             n_base_damage = 11275;
  192.         }
  193.         else
  194.         {
  195.             n_base_damage = 2250;
  196.         }
  197.         n_damage = int( n_base_damage * n_mod );
  198.         if ( isDefined( ai_zombie.is_mechz ) && !ai_zombie.is_mechz )
  199.         {
  200.             if ( n_damage >= ai_zombie.health )
  201.             {
  202.                 self thread zombie_punch_death( ai_zombie );
  203.                 self do_player_general_vox( "kill", "one_inch_punch" );
  204.                 if ( isDefined( self.b_punch_upgraded ) && self.b_punch_upgraded && isDefined( self.str_punch_element ) )
  205.                 {
  206.                     switch( self.str_punch_element )
  207.                     {
  208.                         case "fire":
  209.                             ai_zombie thread maps/mp/zombies/_zm_weap_staff_fire::flame_damage_fx( self.current_melee_weapon, self, n_mod );
  210.                             break;
  211.                         case "ice":
  212.                             ai_zombie thread maps/mp/zombies/_zm_weap_staff_water::ice_affect_zombie( self.current_melee_weapon, self, 0, n_mod );
  213.                             break;
  214.                         case "lightning":
  215.                             if ( isDefined( ai_zombie.is_mechz ) && ai_zombie.is_mechz )
  216.                             {
  217.                                 return;
  218.                             }
  219.                             if ( isDefined( ai_zombie.is_electrocuted ) && ai_zombie.is_electrocuted )
  220.                             {
  221.                                 return;
  222.                             }
  223.                             tag = "J_SpineUpper";
  224.                             network_safe_play_fx_on_tag( "lightning_impact", 2, level._effect[ "lightning_impact" ], ai_zombie, tag );
  225.                             ai_zombie thread maps/mp/zombies/_zm_audio::do_zombies_playvocals( "electrocute", ai_zombie.animname );
  226.                             break;
  227.                     }
  228.                 }
  229.                 break;
  230.         }
  231.         else self maps/mp/zombies/_zm_score::player_add_points( "damage_light" );
  232.         if ( isDefined( self.b_punch_upgraded ) && self.b_punch_upgraded && isDefined( self.str_punch_element ) )
  233.         {
  234.             switch( self.str_punch_element )
  235.             {
  236.                 case "fire":
  237.                     ai_zombie thread maps/mp/zombies/_zm_weap_staff_fire::flame_damage_fx( self.current_melee_weapon, self, n_mod );
  238.                     break;
  239.                 case "ice":
  240.                     ai_zombie thread maps/mp/zombies/_zm_weap_staff_water::ice_affect_zombie( self.current_melee_weapon, self, 0, n_mod );
  241.                     break;
  242.                 case "lightning":
  243.                     ai_zombie thread maps/mp/zombies/_zm_weap_staff_lightning::stun_zombie();
  244.                     break;
  245.             }
  246.         }
  247.     }
  248.     ai_zombie dodamage( n_damage, ai_zombie.origin, self, self, 0, "MOD_MELEE", 0, self.current_melee_weapon );
  249. }
  250. }
  251.  
  252. zombie_punch_death( ai_zombie )
  253. {
  254.     ai_zombie thread gib_zombies_head( self );
  255.     if ( isDefined( level.ragdoll_limit_check ) && !( [[ level.ragdoll_limit_check ]]() ) )
  256.     {
  257.         return;
  258.     }
  259.     if ( isDefined( ai_zombie ) )
  260.     {
  261.         ai_zombie startragdoll();
  262.         ai_zombie setclientfield( "oneinchpunch_physics_launchragdoll", 1 );
  263.     }
  264.     wait_network_frame();
  265.     if ( isDefined( ai_zombie ) )
  266.     {
  267.         ai_zombie setclientfield( "oneinchpunch_physics_launchragdoll", 0 );
  268.     }
  269. }
  270.  
  271. handle_punch_pain_notetracks( note )
  272. {
  273.     if ( note == "zombie_knockdown_ground_impact" )
  274.     {
  275.         playfx( level._effect[ "punch_knockdown_ground" ], self.origin, anglesToForward( self.angles ), anglesToUp( self.angles ) );
  276.     }
  277. }
  278.  
  279. knockdown_zombie_animate()
  280. {
  281.     self notify( "end_play_punch_pain_anim" );
  282.     self endon( "killanimscript" );
  283.     self endon( "death" );
  284.     self endon( "end_play_punch_pain_anim" );
  285.     if ( isDefined( self.marked_for_death ) && self.marked_for_death )
  286.     {
  287.         return;
  288.     }
  289.     self.allowpain = 0;
  290.     animation_direction = undefined;
  291.     animation_legs = "";
  292.     animation_side = undefined;
  293.     animation_duration = "_default";
  294.     v_forward = vectordot( anglesToForward( self.angles ), vectornormalize( self.v_punched_from - self.origin ) );
  295.     if ( v_forward > 0,6 )
  296.     {
  297.         animation_direction = "back";
  298.         if ( isDefined( self.has_legs ) && !self.has_legs )
  299.         {
  300.             animation_legs = "_crawl";
  301.         }
  302.         if ( randomint( 100 ) > 75 )
  303.         {
  304.             animation_side = "belly";
  305.         }
  306.         else
  307.         {
  308.             animation_side = "back";
  309.         }
  310.     }
  311.     else if ( self.damageyaw > 75 && self.damageyaw < 135 )
  312.     {
  313.         animation_direction = "left";
  314.         animation_side = "belly";
  315.     }
  316.     else
  317.     {
  318.         if ( self.damageyaw > -135 && self.damageyaw < -75 )
  319.         {
  320.             animation_direction = "right";
  321.             animation_side = "belly";
  322.         }
  323.         else
  324.         {
  325.             animation_direction = "front";
  326.             animation_side = "belly";
  327.         }
  328.     }
  329.     self thread knockdown_zombie_animate_state();
  330.     self setanimstatefromasd( "zm_punch_fall_" + animation_direction + animation_legs );
  331.     self maps/mp/animscripts/zm_shared::donotetracks( "punch_fall_anim", self.punch_handle_pain_notetracks );
  332.     if ( isDefined( self.has_legs ) || !self.has_legs && isDefined( self.marked_for_death ) && self.marked_for_death )
  333.     {
  334.         return;
  335.     }
  336.     if ( isDefined( self.a.gib_ref ) )
  337.     {
  338.         if ( self.a.gib_ref != "no_legs" && self.a.gib_ref != "no_arms" && self.a.gib_ref != "left_leg" && self.a.gib_ref == "right_leg" || randomint( 100 ) > 25 && self.a.gib_ref != "left_arm" && self.a.gib_ref == "right_arm" && randomint( 100 ) > 75 )
  339.         {
  340.             animation_duration = "_late";
  341.         }
  342.         else
  343.         {
  344.             if ( randomint( 100 ) > 75 )
  345.             {
  346.                 animation_duration = "_early";
  347.             }
  348.         }
  349.     }
  350.     else
  351.     {
  352.         if ( randomint( 100 ) > 25 )
  353.         {
  354.             animation_duration = "_early";
  355.         }
  356.     }
  357.     self setanimstatefromasd( "zm_punch_getup_" + animation_side + animation_duration );
  358.     self maps/mp/animscripts/zm_shared::donotetracks( "punch_getup_anim" );
  359.     self.allowpain = 1;
  360.     self notify( "back_up" );
  361. }
  362.  
  363. knockdown_zombie_animate_state()
  364. {
  365.     self endon( "death" );
  366.     self.is_knocked_down = 1;
  367.     self waittill_any( "damage", "back_up" );
  368.     self.is_knocked_down = 0;
  369. }
Advertisement
Add Comment
Please, Sign In to add comment