Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #using scripts\shared\ai_shared;
- #using scripts\zm\_zm_attackables;
- #using scripts\zm\_zm_spawner;
- // EXAMPLE
- // #precache( "model", "p7_zm_vending_revive" );
- // attack_thing = create_attackable( "test", "p7_zm_vending_revive", ( 0, 0, 0 ), ( 0, 0, 0 ), 10, 50, 1000, 1, "attackable_symbo_test", &attackable_callback );
- // zm_spawner::add_custom_zombie_spawn_logic( &attack_stuff );
- function attack_stuff()
- {
- self endon( "death" );
- while ( isDefined( self ) && isAlive( self ) )
- {
- b_attribute_active = self ai::get_behavior_attribute( "use_attackable" );
- if ( !IS_TRUE( b_attribute_active ) )
- ai::set_behavior_attribute( "use_attackable", true );
- WAIT_SERVER_FRAME;
- }
- }
- /*
- entity 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] )
- [MANDATORY] <str_targetname> The targetname assigned to the model
- [MANDATORY] <str_model_name> The model to be spawned
- [MANDATORY] <v_origin> The origin to spawn model at
- [MANDATORY] <v_angles> The angles to spawn model using
- [MANDATORY] <n_number_of_attack_spots> The number of points spaced around the model that are created. Zombies will go to these to attack
- [MANDATORY] <n_distance_to_attack_point> The distance the attack spots will be placed away from the model
- [MANDATORY] <n_attackable_max_health> The max health the model attackable is set to
- [MANDATORY] <b_attackable_active> Decides if the model should start "active" or not
- [MANDATORY] <str_script_bundle_name> The script bundle attackable asset to be assigned ( created in APE )
- [OPTIONAL] [ptr_function_to_thread] The function to thread on the model for handling it being attacked or destroyed
- CATEGORY:
- CLIENT/SERVER: Server
- SUMMARY: Creates and returns a attackable model with attack spots spawned around it
- EXAMPLE: attack_thing = create_attackable( "test", "p7_zm_vending_revive", ( 0, 0, 0 ), ( 0, 0, 0 ), 10, 50, 1000, 1, "attackable_symbo_test", &attackable_callback );
- */
- 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 )
- {
- DEFAULT( level.attackables, [] );
- e_model = spawn( "script_model", v_origin );
- e_model.angles = v_angles;
- e_model setModel( str_model_name );
- e_model.targetname = str_targetname;
- e_model enableLinkTo();
- a_slots = [];
- f_incriment = 360 / n_number_of_attack_spots;
- f_offset = randomFloat( f_incriment );
- for ( i = 0; i < n_number_of_attack_spots; i++ )
- {
- f_new_angle = f_offset + ( f_incriment * i );
- n_forward_velocity = ( cos( f_new_angle ) * n_distance_to_attack_point, sin( f_new_angle ) * n_distance_to_attack_point, 0 );
- e_origin = spawn( "script_origin", v_origin + n_forward_velocity );
- e_origin.targetname = str_targetname + "_slots";
- e_origin.angles = vectorToAngles( e_model.origin - e_origin.origin );
- 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 );
- n_z_distance = v_ground_trace[ 2 ] - e_model.origin[ 2 ];
- if ( n_z_distance > 20 || n_z_distance < -20 )
- {
- e_origin delete();
- continue;
- }
- e_origin linkTo( e_model );
- a_slots[ a_slots.size ] = e_origin;
- }
- e_model.target = str_targetname + "_slots";
- e_model.bundle = struct::get_script_bundle( "attackables", level.attackables[ 0 ].scriptbundlename );
- e_model.is_active = b_attackable_active;
- e_model.health = n_attackable_max_health;
- e_model.slot = a_slots;
- if ( isDefined( ptr_function_to_thread ) )
- e_model thread [ [ ptr_function_to_thread ] ]();
- ARRAY_ADD( level.attackables, e_model );
- return e_model;
- }
- /*
- entity delete_attackable()
- CATEGORY:
- CLIENT/SERVER: Server
- SUMMARY: Fully deletes an attackable model and will delete the attack spots attached to it
- EXAMPLE: attack_thing delete_attackable();
- */
- function delete_attackable()
- {
- if ( isDefined( self.slot ) && isArray( self.slot ) && self.slot.size > 0 )
- {
- for ( i = 0; i < self.slot; i++ )
- self.slot[ i ] delete();
- }
- arrayRemoveValue( level.attackables, self );
- self delete();
- }
- function attackable_callback()
- {
- self endon( "entityshutdown" );
- while ( isDefined( self ) )
- {
- str_notify_caught = self util::waittill_any_return( "attackable_damaged", "attackable_deactivated" );
- if ( str_notify_caught == "attackable_damaged" )
- {
- // SOMEONE HIT ME!!!!!! DO YOU CODE
- iPrintLnBold( "^1HEALTH REMAINING : " + self.health );
- }
- if ( str_notify_caught == "attackable_deactivated" )
- {
- self zm_attackables::deactivate();
- iPrintLnBold( "^1ATTACKABLE DEACTIVATED" );
- self delete_attackable();
- }
- }
- }
- function activate_attackables( a_attackables )
- {
- for ( i = 0; i < a_attackables.size; i++ )
- {
- a_attackables[ i ].health = 1000;
- a_attackables[ i ] zm_attackables::activate();
- a_attackables[ i ] thread symbos_attackable_stuff();
- }
- }
- function symbos_attackable_stuff()
- {
- self endon( "entityshutdown" );
- while ( isDefined( self ) )
- {
- str_notify_caught = self util::waittill_any_return( "attackable_damaged", "attackable_deactivated" );
- if ( str_notify_caught == "attackable_damaged" )
- {
- // SOMEONE HIT ME!!!!!! DO YOU CODE
- iPrintLnBold( "HEALTH REMAINING : " + self.health );
- }
- if ( str_notify_caught == "attackable_deactivated" )
- {
- self zm_attackables::deactivate();
- iPrintLnBold( "ATTACKABLE DEACTIVATED" );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement