Advertisement
Guest User

Untitled

a guest
May 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #using scripts\shared\ai_shared;
  2. #using scripts\zm\_zm_attackables;
  3.  
  4.  
  5. // EXAMPLE
  6. // #precache( "model",  "p7_zm_vending_revive" );
  7. // attack_thing = create_attackable( "test", "p7_zm_vending_revive", ( 0, 0, 0 ), ( 0, 0, 0 ), 10, 50, 1000, 1, "attackable_symbo_test", &attackable_callback );
  8.  
  9.  
  10.  
  11.  
  12. function attack_stuff()
  13. {
  14.     self endon( "death" );
  15.  
  16.     while ( isDefined( self ) && isAlive( self ) )
  17.     {
  18.         b_attribute_active = self ai::get_behavior_attribute( "use_attackable" );
  19.        
  20.         if ( !IS_TRUE( b_attribute_active ) )
  21.             ai::set_behavior_attribute( "use_attackable", true );
  22.        
  23.         WAIT_SERVER_FRAME;
  24.     }
  25. }
  26.  
  27. function create_attackable( str_targetname, str_model_name, v_origin, v_angles, n_number_of_attack_spots, n_distance_to_attack_point, n_attackable_max_health, b_attackable_active, str_script_bundle_name, ptr_function_to_thread )
  28. {
  29.     DEFAULT( level.attackables, [] );
  30.  
  31.     e_model = spawn( "script_model", v_origin );
  32.     e_model.angles = v_angles;
  33.     e_model setModel( str_model_name );
  34.     e_model.targetname = str_targetname;
  35.     e_model enableLinkTo();
  36.    
  37.     a_slots = [];
  38.  
  39.     f_incriment = 360 / n_number_of_attack_spots;
  40.     f_offset = randomFloat( f_incriment );
  41.    
  42.     for ( i = 0; i < n_number_of_attack_spots; i++ )
  43.     {
  44.         f_new_angle = f_offset + ( f_incriment * i );
  45.  
  46.         n_forward_velocity = ( cos( f_new_angle ) * n_distance_to_attack_point, sin( f_new_angle ) * n_distance_to_attack_point, 0 );
  47.  
  48.         e_origin = spawn( "script_origin", v_origin + n_forward_velocity );
  49.         e_origin.targetname = str_targetname + "_slots";
  50.         e_origin.angles = vectorToAngles( e_model.origin - e_origin.origin );
  51.        
  52.         v_ground_trace = playerPhysicsTrace( e_origin.origin + ( 0, 0, 50 ), e_origin.origin - ( 0, 0, 50 ) ); // groundTrace( e_origin.origin, e_origin.origin - ( 0, 0, 50 ), 1 );
  53.         n_z_distance = v_ground_trace[ 2 ] - e_model.origin[ 2 ];
  54.        
  55.         if ( n_z_distance > 20 || n_z_distance < -20 )
  56.         {
  57.             e_origin delete();
  58.             continue;
  59.         }
  60.        
  61.         e_origin linkTo( e_model );
  62.         a_slots[ a_slots.size ] = e_origin;
  63.     }
  64.    
  65.     e_model.target = str_targetname + "_slots";
  66.     e_model.bundle = struct::get_script_bundle( "attackables", level.attackables[ 0 ].scriptbundlename );
  67.     e_model.is_active = b_attackable_active;
  68.     e_model.health = n_attackable_max_health;
  69.  
  70.     e_model.slot = a_slots;
  71.  
  72.     if ( isDefined( ptr_function_to_thread ) )
  73.         e_model thread [ [ ptr_function_to_thread ] ]();
  74.  
  75.     ARRAY_ADD( level.attackables, e_model );
  76.  
  77.     return e_model;
  78. }
  79.  
  80. function delete_attackable()
  81. {
  82.     if ( isDefined( self.slot ) && isArray( self.slot ) && self.slot.size > 0 )
  83.     {
  84.         for ( i = 0; i < self.slot; i++ )
  85.             self.slot[ i ] delete();
  86.        
  87.     }
  88.    
  89.     arrayRemoveValue( level.attackables, self );
  90.     self delete();
  91. }
  92.  
  93. function attackable_callback()
  94. {
  95.     self endon( "entityshutdown" );
  96.     while ( isDefined( self ) )
  97.     {
  98.         str_notify_caught = self util::waittill_any_return( "attackable_damaged", "attackable_deactivated" );
  99.  
  100.         if ( str_notify_caught == "attackable_damaged" )
  101.         {
  102.             // SOMEONE HIT ME!!!!!! DO YOU CODE
  103.             iPrintLnBold( "^1HEALTH REMAINING : " + self.health );
  104.         }
  105.         if ( str_notify_caught == "attackable_deactivated" )
  106.         {
  107.             self zm_attackables::deactivate();
  108.             iPrintLnBold( "^1ATTACKABLE DEACTIVATED" );
  109.             self delete_attackable();
  110.         }
  111.     }
  112. }
  113.  
  114. function activate_attackables( a_attackables )
  115. {
  116.     for ( i = 0; i < a_attackables.size; i++ )
  117.     {
  118.         a_attackables[ i ].health = 1000;
  119.      a_attackables[ i ] zm_attackables::activate();
  120.      a_attackables[ i ] thread symbos_attackable_stuff();
  121.     }
  122. }
  123.  
  124. function symbos_attackable_stuff()
  125. {
  126.     self endon( "entityshutdown" );
  127.     while ( isDefined( self ) )
  128.     {
  129.         str_notify_caught = self util::waittill_any_return( "attackable_damaged", "attackable_deactivated" );
  130.        
  131.         if ( str_notify_caught == "attackable_damaged" )
  132.         {
  133.             // SOMEONE HIT ME!!!!!! DO YOU CODE
  134.             iPrintLnBold( "HEALTH REMAINING : " + self.health );
  135.         }
  136.         if ( str_notify_caught == "attackable_deactivated" )
  137.         {
  138.             self zm_attackables::deactivate();
  139.             iPrintLnBold( "ATTACKABLE DEACTIVATED" );
  140.         }
  141.        
  142.     }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement