Advertisement
burc_2004

zombiemode_utility

May 27th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    
  2.  
  3.     #include maps\_utility;
  4.     #include common_scripts\utility;
  5.      
  6.     init_utility()
  7.     {
  8.     //      level thread edge_fog_start();
  9.      
  10.     //      level thread hudelem_count();
  11.     }
  12.      
  13.      
  14.     // self is Ai and chunk is selected piece
  15.     lerp( chunk )
  16.     {
  17.             // anim_reach_aligned
  18.             link = Spawn( "script_origin", self GetOrigin() ); // link is a new origin of the ai
  19.             link.angles = self.first_node.angles ; // link now has the angles of itself, perhaps these angles aren't coming over..
  20.             self LinkTo(link); // link ai + origin to chunk + origin
  21.      
  22.             // link RotateTo(chunk.origin GetTagAngles("Tag_bottom"), level._CONTEXTUAL_GRAB_LERP_TIME); // this should angle him to spot
  23.             // link MoveTo(chunk.origin GetTagOrigin("Tag_bottom"), level._CONTEXTUAL_GRAB_LERP_TIME); // this should move him over to spot
  24.            
  25.             // I need to have the offest for the bar
  26.             link RotateTo(self.first_node.angles , level._CONTEXTUAL_GRAB_LERP_TIME); // this should angle him to spot
  27.      
  28.             link MoveTo(self.attacking_spot , level._CONTEXTUAL_GRAB_LERP_TIME); // this should move him over to spot
  29.             //link RotateTo(self GetTagAngles ("Tag_player"), level._CONTEXTUAL_GRAB_LERP_TIME); // this should angle him to spot
  30.             //link MoveTo(self GetTagOrigin ("Tag_player"), level._CONTEXTUAL_GRAB_LERP_TIME); // this should move him over to spot
  31.            
  32.             link waittill_multiple("rotatedone", "movedone");
  33.      
  34.             self Unlink();
  35.             link Delete();
  36.            
  37.             return;
  38.     }
  39.      
  40.     // DCS 091610: delete any designated mature blood patches if set to mature.
  41.     clear_mature_blood()
  42.     {
  43.             blood_patch = GetEntArray("mature_blood", "targetname");
  44.            
  45.             if(IsDefined(blood_patch) && !is_mature())
  46.             {
  47.                     for (i = 0; i < blood_patch.size; i++)
  48.                     {
  49.                             blood_patch[i] Delete();
  50.                     }      
  51.             }
  52.     }      
  53.     get_enemy_count()
  54.     {
  55.             enemies = [];
  56.             valid_enemies = [];
  57.             enemies = GetAiSpeciesArray( "axis", "all" );
  58.             for( i = 0; i < enemies.size; i++ )
  59.             {
  60.                     if( isDefined( enemies[i].animname ) && enemies[i].animname != "boss_zombie" && enemies[i].animname != "ape_zombie" )
  61.                     {
  62.                             valid_enemies = array_add( valid_enemies, enemies[i] );
  63.                     }
  64.             }
  65.             return valid_enemies.size;
  66.     }
  67.      
  68.     spawn_zombie( spawner, target_name )
  69.     {
  70.             if( !isdefined( spawner ) )
  71.             {
  72.                     return undefined;
  73.             }
  74.            
  75.             spawner.script_moveoverride = true;
  76.      
  77.             if( IsDefined( spawner.script_forcespawn ) && spawner.script_forcespawn )
  78.             {
  79.                     guy = spawner StalingradSpawn();  
  80.             }
  81.             else
  82.             {
  83.                     guy = spawner DoSpawn();  
  84.             }
  85.      
  86.             spawner.count = 666;
  87.      
  88.     //      // sometimes we want to ensure a zombie will go to a particular door node
  89.     //      // so we target the spawner at a struct and put the struct near the entry point
  90.     //      if( isdefined( spawner.target ) )
  91.     //      {
  92.     //              guy.forced_entry = getstruct( spawner.target, "targetname" );
  93.     //      }
  94.      
  95.             if( !spawn_failed( guy ) )
  96.             {
  97.                     if( IsDefined( target_name ) )
  98.                     {
  99.                             guy.targetname = target_name;
  100.                     }
  101.      
  102.                     return guy;  
  103.             }
  104.      
  105.             return undefined;  
  106.     }
  107.      
  108.     create_simple_hud( client )
  109.     {
  110.             if( IsDefined( client ) )
  111.             {
  112.                     hud = NewClientHudElem( client );
  113.             }
  114.             else
  115.             {
  116.                     hud = NewHudElem();
  117.             }
  118.      
  119.             level.hudelem_count++;
  120.      
  121.             hud.foreground = true;
  122.             hud.sort = 1;
  123.             hud.hidewheninmenu = false;
  124.      
  125.             return hud;
  126.     }
  127.      
  128.     destroy_hud()
  129.     {
  130.             level.hudelem_count--;
  131.             self Destroy();
  132.     }
  133.      
  134.      
  135.     // self = exterior_goal which is barrier_chunks
  136.     all_chunks_intact( barrier_chunks )
  137.     {
  138.             for( i = 0; i < barrier_chunks.size; i++ ) // Count up barrier_chunks total size
  139.             {
  140.                     if( barrier_chunks[i] get_chunk_state() != "repaired" ) // if any piece has the state of not repaired then return false
  141.                     {
  142.                             return false;
  143.                     }
  144.             }
  145.      
  146.             return true; // if the board has been repaired then return true
  147.     }
  148.      
  149.      
  150.     // self = exterior_goal which is barrier_chunks
  151.     no_valid_repairable_boards( barrier_chunks )
  152.     {
  153.      
  154.             for( i = 0; i < barrier_chunks.size; i++ ) // Count up barrier_chunks total size
  155.             {
  156.                     if( barrier_chunks[i] get_chunk_state() == "destroyed" ) // if any piece has been destroyed return false
  157.                     {
  158.                             return false;
  159.                     }
  160.             }
  161.      
  162.             return true; // if any piece is not destroyed then return true
  163.     }
  164.      
  165.     all_chunks_destroyed( barrier_chunks )
  166.     {
  167.             ASSERT( IsDefined(barrier_chunks), "_zombiemode_utility::all_chunks_destroyed - Barrier chunks undefined" );
  168.             for( i = 0; i < barrier_chunks.size; i++ )
  169.             {
  170.                     if( barrier_chunks[i] get_chunk_state() != "destroyed" )
  171.                     {
  172.                             return false;
  173.                     }
  174.             }
  175.      
  176.             return true;
  177.     }
  178.      
  179.     check_point_in_playable_area( origin )
  180.     {
  181.             playable_area = getentarray("player_volume","script_noteworthy");
  182.             check_model = spawn ("script_model", origin + (0,0,40));
  183.            
  184.             valid_point = false;
  185.             for (i = 0; i < playable_area.size; i++)
  186.             {
  187.                     if (check_model istouching(playable_area[i]))
  188.                     {
  189.                             valid_point = true;
  190.                     }
  191.             }
  192.            
  193.             check_model delete();
  194.             return valid_point;
  195.     }
  196.      
  197.     check_point_in_active_zone( origin )
  198.     {
  199.             player_zones = getentarray("player_volume","script_noteworthy");
  200.             if( !isDefined( level.zones ) || !isDefined( player_zones ) )
  201.             {
  202.                     return true;
  203.             }
  204.            
  205.             scr_org = spawn( "script_origin", origin+(0, 0, 40) );
  206.            
  207.             one_valid_zone = false;
  208.             for( i = 0; i < player_zones.size; i++ )
  209.             {
  210.                     if( scr_org isTouching( player_zones[i] ) )
  211.                     {
  212.                             if( isDefined( level.zones[player_zones[i].targetname] ) &&
  213.                                     is_true( level.zones[player_zones[i].targetname].is_enabled ) )
  214.                             {
  215.                                     one_valid_zone = true;
  216.                             }
  217.                     }
  218.             }
  219.            
  220.             scr_org delete();
  221.             return one_valid_zone;
  222.     }
  223.      
  224.     round_up_to_ten( score )
  225.     {
  226.             new_score = score - score % 10;
  227.             if( new_score < score )
  228.             {
  229.                     new_score += 10;
  230.             }
  231.             return new_score;
  232.     }
  233.      
  234.     round_up_score( score, value )
  235.     {
  236.             score = int(score);     // Make sure it's an int or modulus will die
  237.      
  238.             new_score = score - score % value;
  239.             if( new_score < score )
  240.             {
  241.                     new_score += value;
  242.             }
  243.             return new_score;
  244.     }
  245.      
  246.     random_tan()
  247.     {
  248.             rand = randomint( 100 );
  249.            
  250.             // PI_CHANGE_BEGIN - JMA - only 15% chance that we are going to spawn charred zombies in sumpf
  251.             if(isDefined(level.char_percent_override) )
  252.             {
  253.                     percentNotCharred = level.char_percent_override;
  254.             }
  255.             else
  256.             {
  257.                     percentNotCharred = 65;
  258.             }
  259.            
  260.     //      if( rand > percentNotCharred )
  261.     //      {
  262.     //              self StartTanning();
  263.     //      }
  264.             // PI_CHANGE_END
  265.     }
  266.      
  267.     // Returns the amount of places before the decimal, ie 1000 = 4, 100 = 3...
  268.     places_before_decimal( num )
  269.     {
  270.             abs_num = abs( num );
  271.             count = 0;
  272.             while( 1 )
  273.             {
  274.                     abs_num *= 0.1; // Really doing num / 10
  275.                     count += 1;
  276.      
  277.                     if( abs_num < 1 )
  278.                     {
  279.                             return count;
  280.                     }
  281.             }
  282.     }
  283.      
  284.     create_zombie_point_of_interest( attract_dist, num_attractors, added_poi_value, start_turned_on, initial_attract_func, arrival_attract_func )
  285.     {
  286.             if( !isDefined( added_poi_value ) )
  287.             {
  288.                     self.added_poi_value = 0;
  289.             }
  290.             else
  291.             {
  292.                     self.added_poi_value = added_poi_value;
  293.             }
  294.            
  295.             if( !isDefined( start_turned_on ) )
  296.             {
  297.                     start_turned_on = true;
  298.             }
  299.            
  300.             self.script_noteworthy = "zombie_poi";
  301.             self.poi_active = start_turned_on;
  302.      
  303.             if( isDefined( attract_dist ) )
  304.             {
  305.                     self.poi_radius = attract_dist * attract_dist;
  306.             }
  307.             else // This poi has no maximum attract distance, it will attract all zombies
  308.             {
  309.                     self.poi_radius = undefined;
  310.             }
  311.             self.num_poi_attracts = num_attractors;
  312.             self.attract_to_origin = true;
  313.             self.attractor_array = [];
  314.             self.initial_attract_func = undefined;
  315.             self.arrival_attract_func = undefined;
  316.            
  317.             // any special functions for initial reaction or arrival at the poi are stored here for get_zombie_point_of_intrest
  318.             if( IsDefined( initial_attract_func ) )
  319.             {
  320.                     self.initial_attract_func = initial_attract_func;
  321.             }
  322.            
  323.             if( IsDefined( arrival_attract_func ) )
  324.             {
  325.                     self.arrival_attract_func = arrival_attract_func;
  326.             }
  327.            
  328.     }
  329.      
  330.     create_zombie_point_of_interest_attractor_positions( num_attract_dists, diff_per_dist, attractor_width )
  331.     {
  332.             forward = ( 0, 1, 0 );
  333.            
  334.             if( !isDefined( self.num_poi_attracts ) || (isDefined(self.script_noteworthy) && self.script_noteworthy != "zombie_poi" ))
  335.             {
  336.                     return;
  337.             }
  338.            
  339.             if( !isDefined( num_attract_dists ) )
  340.             {
  341.                     num_attract_dists = 4;
  342.             }
  343.            
  344.             if( !isDefined( diff_per_dist ) )
  345.             {
  346.                     diff_per_dist = 45;
  347.             }
  348.            
  349.             if( !isDefined( attractor_width ) )
  350.             {
  351.                     attractor_width = 45;
  352.             }
  353.            
  354.             self.attract_to_origin = false;
  355.            
  356.             self.num_attract_dists = num_attract_dists;
  357.            
  358.             // The last index in the attractor_position arrays for each of the four distances
  359.             self.last_index = [];
  360.             for( i = 0; i < num_attract_dists; i++ )
  361.             {
  362.                     self.last_index[i] = -1;
  363.             }
  364.            
  365.             self.attract_dists = [];
  366.             for( i = 0; i < self.num_attract_dists; i++ )
  367.             {
  368.                     self.attract_dists[i] = diff_per_dist * (i+1);
  369.             }
  370.            
  371.             // Array of max positions per distance
  372.             // 0 = close, 1 = med, 2 = far, 3 = very far
  373.             max_positions = [];
  374.             for( i = 0; i < self.num_attract_dists; i++ )
  375.             {
  376.                     max_positions[i] = int(3.14*2*self.attract_dists[i]/attractor_width);
  377.             }
  378.            
  379.             num_attracts_per_dist = self.num_poi_attracts/self.num_attract_dists;
  380.            
  381.             self.max_attractor_dist = self.attract_dists[ self.attract_dists.size - 1 ] * 1.1; // Give some wiggle room for assigning nodes
  382.            
  383.             diff = 0;
  384.            
  385.             self thread debug_draw_attractor_positions();
  386.            
  387.             // Determine the ideal number of attracts based on what a distance can actually hold after any bleed from closer
  388.             // distances is added to the calculated
  389.             actual_num_positions = [];
  390.             for( i = 0; i < self.num_attract_dists; i++ )
  391.             {
  392.                     if( num_attracts_per_dist > (max_positions[i]+diff) )
  393.                     {
  394.                             actual_num_positions[i] = max_positions[i];
  395.                             diff += num_attracts_per_dist - max_positions[i];
  396.                     }
  397.                     else
  398.                     {
  399.                             actual_num_positions[i] = num_attracts_per_dist + diff;
  400.                             diff = 0;
  401.                     }      
  402.             }
  403.            
  404.             // Determine the actual positions that will be used, including failed nodes from closer distances, index zero is always the origin
  405.             self.attractor_positions = [];
  406.             failed = 0;
  407.             angle_offset = 0; // Angle offset, used to make nodes not all perfectly radial
  408.             prev_last_index = -1;
  409.             for( j = 0; j < 4; j++ )
  410.             {
  411.                     if( (actual_num_positions[j]+failed) < max_positions[j] )
  412.                     {
  413.                             actual_num_positions[j] += failed;
  414.                             failed = 0;
  415.                     }
  416.                     else if( actual_num_positions[j] < max_positions[j] )
  417.                     {
  418.                             actual_num_positions[j] = max_positions[j];
  419.                             failed = max_positions[j] - actual_num_positions[j];
  420.                     }
  421.                     failed += self generated_radius_attract_positions( forward, angle_offset, actual_num_positions[j], self.attract_dists[j] );
  422.                     angle_offset += 15;
  423.                     self.last_index[j] = int(actual_num_positions[j] - failed + prev_last_index);
  424.                     prev_last_index = self.last_index[j];
  425.             }
  426.            
  427.             self notify( "attractor_positions_generated" );
  428.             level notify( "attractor_positions_generated" );
  429.     }
  430.      
  431.     generated_radius_attract_positions( forward, offset, num_positions, attract_radius )
  432.     {
  433.             failed = 0;
  434.             degs_per_pos = 360 / num_positions;
  435.             for( i = offset; i < 360+offset; i += degs_per_pos )
  436.             {
  437.                     altforward = forward * attract_radius;
  438.                     rotated_forward = ( (cos(i)*altforward[0] - sin(i)*altforward[1]), (sin(i)*altforward[0] + cos(i)*altforward[1]), altforward[2] );
  439.                     pos = maps\_zombiemode_server_throttle::server_safe_ground_trace( "poi_trace", 10, self.origin + rotated_forward + ( 0, 0, 100 ) );
  440.                     if( abs( pos[2] - self.origin[2] ) < 60 )
  441.                     {
  442.                             pos_array = [];
  443.                             pos_array[0] = pos;
  444.                             pos_array[1] = self;
  445.                             self.attractor_positions = array_add( self.attractor_positions , pos_array );
  446.                     }
  447.                     else
  448.                     {
  449.                             failed++;
  450.                     }
  451.             }
  452.             return failed;
  453.     }
  454.      
  455.     debug_draw_attractor_positions()
  456.     {
  457.             /#
  458.             while( true )
  459.             {
  460.                     while( !isDefined( self.attractor_positions ) )
  461.                     {
  462.                             wait( 0.05 );
  463.                             continue;
  464.                     }
  465.                     for( i = 0; i < self.attractor_positions.size; i++ )
  466.                     {
  467.                             Line( self.origin, self.attractor_positions[i][0], (1, 0, 0), true, 1 );
  468.                     }
  469.                     wait( 0.05 );
  470.                     if( !IsDefined( self ) )
  471.                     {
  472.                             return;
  473.                     }
  474.             }
  475.             #/
  476.     }
  477.      
  478.      
  479.     get_zombie_point_of_interest( origin )
  480.     {
  481.             curr_radius = undefined;
  482.            
  483.             ent_array = getEntArray( "zombie_poi", "script_noteworthy" );
  484.            
  485.             best_poi = undefined;
  486.             position = undefined;
  487.             best_dist = 10000 * 10000;
  488.            
  489.             for( i = 0; i < ent_array.size; i++ )
  490.             {
  491.                     if( !isDefined( ent_array[i].poi_active ) || !ent_array[i].poi_active  )
  492.                     {
  493.                             continue;
  494.                     }
  495.      
  496.                     if ( isDefined( self.ignore_poi ) && self.ignore_poi.size > 0 )
  497.                     {
  498.                             ignore = false;
  499.                             for ( j = 0; j < self.ignore_poi.size; j++ )
  500.                             {
  501.                                     if ( self.ignore_poi[j] == ent_array[i] )
  502.                                     {
  503.                                             ignore = true;
  504.                                             break;
  505.                                     }
  506.                             }
  507.                             if ( ignore )
  508.                             {
  509.                                     continue;
  510.                             }
  511.                     }
  512.                    
  513.                     dist = distanceSquared( origin, ent_array[i].origin );
  514.                    
  515.                     dist -= ent_array[i].added_poi_value;
  516.                    
  517.                     if( isDefined( ent_array[i].poi_radius ) )
  518.                     {
  519.                             curr_radius = ent_array[i].poi_radius;
  520.                     }
  521.                    
  522.                     if( (!isDefined( curr_radius ) || dist < curr_radius) && dist < best_dist && ent_array[i] can_attract(self) )
  523.                     {
  524.                             best_poi = ent_array[i];
  525.                             best_dist = dist;
  526.                     }
  527.             }
  528.            
  529.             if( isDefined( best_poi ) )
  530.             {
  531.                     // Override, currently only used for monkeys in the air.
  532.                     if( isDefined( best_poi.attract_to_origin ) && best_poi.attract_to_origin )
  533.                     {
  534.                             position = [];
  535.                             position[0] = groundpos( best_poi.origin + (0, 0, 100) );
  536.                             position[1] = self;
  537.                     }
  538.                     else
  539.                     {
  540.                             position = self add_poi_attractor( best_poi );
  541.                     }
  542.                    
  543.                     if( IsDefined( best_poi.initial_attract_func ) )
  544.                     {
  545.                             self thread [[ best_poi.initial_attract_func ]]( best_poi );
  546.                     }
  547.                    
  548.                     if( IsDefined( best_poi.arrival_attract_func ) )
  549.                     {
  550.                             self thread [[ best_poi.arrival_attract_func ]]( best_poi );
  551.                     }
  552.             }
  553.            
  554.             return position;
  555.     }
  556.      
  557.     activate_zombie_point_of_interest()
  558.     {
  559.             if( self.script_noteworthy != "zombie_poi" )
  560.             {
  561.                     return;
  562.             }
  563.            
  564.             self.poi_active = true;
  565.     }
  566.      
  567.     deactivate_zombie_point_of_interest()
  568.     {
  569.             if( self.script_noteworthy != "zombie_poi" )
  570.             {
  571.                     return;
  572.             }
  573.      
  574.             for( i = 0; i < self.attractor_array.size; i++ )
  575.             {
  576.                     self.attractor_array[i] notify( "kill_poi" );
  577.             }
  578.      
  579.             self.attractor_array = [];
  580.             self.claimed_attractor_positions = [];
  581.            
  582.             self.poi_active = false;
  583.     }
  584.      
  585.     //PI_CHANGE_BEGIN - 6/18/09 JV This works to help set "wait" points near the stage if all players are in the process teleportation.  
  586.     //It is unlike the previous function in that you dictate the poi.
  587.     assign_zombie_point_of_interest (origin, poi)
  588.     {
  589.             position = undefined;
  590.             doremovalthread = false;
  591.      
  592.             if (IsDefined(poi) && poi can_attract(self))
  593.             {
  594.                     //don't want to touch add poi attractor, but yeah, this is kind of weird
  595.                     if (!IsDefined(poi.attractor_array) || ( IsDefined(poi.attractor_array) && array_check_for_dupes( poi.attractor_array, self ) ))
  596.                             doremovalthread = true;
  597.                    
  598.                     position = self add_poi_attractor( poi );
  599.                    
  600.                     //now that I know this is the first time they've been added, set up the thread to remove them from the array
  601.                     if (IsDefined(position) && doremovalthread && !array_check_for_dupes( poi.attractor_array, self  ))
  602.                             self thread update_on_poi_removal( poi );              
  603.             }
  604.            
  605.             return position;
  606.     }
  607.     //PI_CHANGE_END
  608.      
  609.     remove_poi_attractor( zombie_poi )
  610.     {
  611.             if( !isDefined( zombie_poi.attractor_array ) )
  612.             {
  613.                     return;
  614.             }
  615.            
  616.             for( i = 0; i < zombie_poi.attractor_array.size; i++ )
  617.             {
  618.                     if( zombie_poi.attractor_array[i] == self )
  619.                     {
  620.                             self notify( "kill_poi" );
  621.                            
  622.                             zombie_poi.attractor_array = array_remove( zombie_poi.attractor_array, zombie_poi.attractor_array[i] );
  623.                             zombie_poi.claimed_attractor_positions = array_remove( zombie_poi.claimed_attractor_positions, zombie_poi.claimed_attractor_positions[i] );
  624.                     }
  625.             }
  626.     }
  627.      
  628.     add_poi_attractor( zombie_poi )
  629.     {
  630.             if( !isDefined( zombie_poi ) )
  631.             {
  632.                     return;
  633.             }
  634.             if( !isDefined( zombie_poi.attractor_array ) )
  635.             {
  636.                     zombie_poi.attractor_array = [];
  637.             }
  638.            
  639.             // If we are not yet an attractor to this poi, claim an attractor position and start attracting to it
  640.             if( array_check_for_dupes( zombie_poi.attractor_array, self ) )
  641.             {
  642.                     if( !isDefined( zombie_poi.claimed_attractor_positions ) )
  643.                     {
  644.                             zombie_poi.claimed_attractor_positions = [];
  645.                     }
  646.                    
  647.                     if( !isDefined( zombie_poi.attractor_positions ) || zombie_poi.attractor_positions.size <= 0 )
  648.                     {
  649.                             return undefined;
  650.                     }
  651.                    
  652.                     start = -1;
  653.                     end = -1;
  654.                     last_index = -1;
  655.                     for( i = 0; i < 4; i++ )
  656.                     {
  657.                             if( zombie_poi.claimed_attractor_positions.size < zombie_poi.last_index[i] )
  658.                             {
  659.                                     start = last_index+1;
  660.                                     end = zombie_poi.last_index[i];
  661.                                     break;
  662.                             }
  663.                             last_index = zombie_poi.last_index[i];
  664.                     }
  665.                    
  666.                    
  667.                     best_dist = 10000*10000;
  668.                     best_pos = undefined;
  669.                     if( start < 0 )
  670.                     {
  671.                             start = 0;
  672.                     }
  673.                     if( end < 0 )
  674.                     {
  675.                             return undefined;
  676.                     }
  677.                     for( i = int(start); i <= int(end); i++ )
  678.                     {
  679.                             if( array_check_for_dupes( zombie_poi.claimed_attractor_positions, zombie_poi.attractor_positions[i] ) )
  680.                             {
  681.                                     if ( isDefined( zombie_poi.attractor_positions[i][0] ) && isDefined( self.origin ) )
  682.                                     {
  683.                                             dist = distancesquared( zombie_poi.attractor_positions[i][0], self.origin );
  684.                                             if( dist < best_dist || !isDefined( best_pos ) )
  685.                                             {
  686.                                                     best_dist = dist;
  687.                                                     best_pos = zombie_poi.attractor_positions[i];
  688.                                             }
  689.                                     }
  690.                             }
  691.                     }
  692.                    
  693.                     if( !isDefined( best_pos ) )
  694.                     {
  695.                             return undefined;
  696.                     }
  697.                    
  698.                     zombie_poi.attractor_array = array_add( zombie_poi.attractor_array, self );
  699.                     self thread update_poi_on_death( zombie_poi );        
  700.                    
  701.                     zombie_poi.claimed_attractor_positions = array_add( zombie_poi.claimed_attractor_positions, best_pos );
  702.                    
  703.                     return best_pos;
  704.             }
  705.             else
  706.             {
  707.                     for( i = 0; i < zombie_poi.attractor_array.size; i++ )
  708.                     {
  709.                             if( zombie_poi.attractor_array[i] == self )
  710.                             {
  711.                                     if( isDefined( zombie_poi.claimed_attractor_positions ) && isDefined( zombie_poi.claimed_attractor_positions[i] ) )
  712.                                     {
  713.                                             return zombie_poi.claimed_attractor_positions[i];
  714.                                     }
  715.                             }
  716.                     }
  717.             }
  718.            
  719.             return undefined;
  720.     }
  721.      
  722.     can_attract( attractor )
  723.     {
  724.             if( !isDefined( self.attractor_array ) )
  725.             {
  726.                     self.attractor_array = [];
  727.             }
  728.             //Raven Begin - Allow only selected zombies to be attracted
  729.             if( isDefined(self.attracted_array) && !is_in_array(self.attracted_array, attractor) )
  730.             {
  731.                     return false;
  732.             }
  733.             //Raven End
  734.             if( !array_check_for_dupes( self.attractor_array, attractor ) )
  735.             {
  736.                     return true;
  737.             }
  738.             if( isDefined(self.num_poi_attracts) && self.attractor_array.size >= self.num_poi_attracts )
  739.             {
  740.                     return false;
  741.             }
  742.      
  743.             return true;
  744.     }
  745.      
  746.     update_poi_on_death( zombie_poi )
  747.     {
  748.             self endon( "kill_poi" );
  749.            
  750.             self waittill( "death" );
  751.             self remove_poi_attractor( zombie_poi );
  752.     }
  753.      
  754.     //PI_CHANGE_BEGIN - 6/18/09 JV This was set up to work with assign_zombie_point_of_interest (which works with the teleportation in theater).
  755.     //The poi attractor array needs to be emptied when a player is teleported out of projection room (if they were all in there).  
  756.     //As a result, we wait for the poi's death (I'm sending that notify via the level script)
  757.     update_on_poi_removal (zombie_poi )
  758.     {      
  759.             zombie_poi waittill( "death" );
  760.            
  761.             if( !isDefined( zombie_poi.attractor_array ) )
  762.                     return;
  763.            
  764.             for( i = 0; i < zombie_poi.attractor_array.size; i++ )
  765.             {
  766.                     if( zombie_poi.attractor_array[i] == self )
  767.                     {      
  768.                             zombie_poi.attractor_array = array_remove_index( zombie_poi.attractor_array, i );
  769.                             zombie_poi.claimed_attractor_positions = array_remove_index( zombie_poi.claimed_attractor_positions, i );
  770.                     }
  771.             }
  772.            
  773.     }
  774.     //PI_CHANGE_END
  775.      
  776.     invalidate_attractor_pos( attractor_pos, zombie )
  777.     {
  778.             if( !isDefined( self ) || !isDefined( attractor_pos ) )
  779.             {
  780.                     wait( 0.1 );
  781.                     return undefined;
  782.             }
  783.            
  784.             if( isDefined( self.attractor_positions) && !array_check_for_dupes( self.attractor_positions, attractor_pos ) )
  785.             {
  786.                     index = 0;
  787.                     for( i = 0; i < self.attractor_positions.size; i++ )
  788.                     {
  789.                             if( self.attractor_positions[i] == attractor_pos )
  790.                             {
  791.                                     index = i;
  792.                             }
  793.                     }
  794.                    
  795.                     for( i = 0; i < self.last_index.size; i++ )
  796.                     {
  797.                             if( index <= self.last_index[i] )
  798.                             {
  799.                                     self.last_index[i]--;
  800.                             }
  801.                     }
  802.                    
  803.                     self.attractor_array = array_remove( self.attractor_array, zombie );
  804.                     self.attractor_positions = array_remove( self.attractor_positions, attractor_pos );
  805.                     for( i = 0; i < self.claimed_attractor_positions.size; i++ )
  806.                     {
  807.                             if( self.claimed_attractor_positions[i][0] == attractor_pos[0] )
  808.                             {
  809.                                     self.claimed_attractor_positions = array_remove( self.claimed_attractor_positions, self.claimed_attractor_positions[i] );
  810.                             }
  811.                     }
  812.             }
  813.             else
  814.             {
  815.                     wait( 0.1 );
  816.             }
  817.            
  818.             return get_zombie_point_of_interest( zombie.origin );
  819.     }
  820.      
  821.     remove_poi_from_ignore_list( poi )
  822.     {
  823.             if ( isDefined( self.ignore_poi ) && self.ignore_poi.size > 0 )
  824.             {
  825.                     for ( i = 0; i < self.ignore_poi.size; i++ )
  826.                     {
  827.                             if ( self.ignore_poi[i] == poi )
  828.                             {
  829.                                     self.ignore_poi = array_remove( self.ignore_poi, self.ignore_poi[i] );
  830.                                     return;
  831.                             }
  832.                     }
  833.             }
  834.     }
  835.      
  836.     add_poi_to_ignore_list( poi )
  837.     {
  838.             if ( !isDefined( self.ignore_poi ) )
  839.             {
  840.                     self.ignore_poi = [];
  841.             }
  842.      
  843.             add_poi = true;
  844.             if ( self.ignore_poi.size > 0 )
  845.             {
  846.                     for ( i = 0; i < self.ignore_poi.size; i++ )
  847.                     {
  848.                             if ( self.ignore_poi[i] == poi )
  849.                             {
  850.                                     add_poi = false;
  851.                                     break;
  852.                             }
  853.                     }
  854.             }
  855.      
  856.             if ( add_poi )
  857.             {
  858.                     self.ignore_poi[self.ignore_poi.size] = poi;
  859.             }
  860.     }
  861.      
  862.     get_path_length_to_enemy( enemy )
  863.     {
  864.             //self SetGoalPos( enemy.origin );
  865.             //wait( 0.1 );                
  866.             //path_length = self GetPathLength();
  867.            
  868.             path_length = self CalcPathLength( enemy.origin );
  869.            
  870.             return path_length;
  871.     }              
  872.      
  873.     get_closest_player_using_paths( origin, players )
  874.     {
  875.             //First check the straight line distances if we are currently tracking someone
  876.     //      if( IsDefined( self.favoriteenemy ) )
  877.     //      {
  878.     //              player = GetClosest( origin, players );
  879.     //              if( player == self.favoriteenemy )
  880.     //              {
  881.     //                      return player;
  882.     //              }
  883.     //      }
  884.            
  885.             min_length_to_player = 9999999;
  886.             player_to_return = undefined;//players[0];
  887.             for(i = 0; i < players.size; i++ )
  888.             {
  889.                     player = players[i];
  890.                     length_to_player = get_path_length_to_enemy( player );
  891.                    
  892.             //      Print3d(self.origin+(0,0,70+i*20), length_to_player, ( 1, 0.8, 0.5), 1, 1, 1);
  893.      
  894.      
  895.                     if( length_to_player < min_length_to_player )
  896.                     {
  897.                             min_length_to_player = length_to_player;
  898.                             player_to_return = player;
  899.                     }
  900.             }
  901.            
  902.             return player_to_return;
  903.     }
  904.      
  905.     get_closest_valid_player( origin, ignore_player )
  906.     {
  907.             valid_player_found = false;
  908.            
  909.             players = get_players();
  910.      
  911.             if( IsDefined( ignore_player ) )
  912.             {
  913.                     //PI_CHANGE_BEGIN - 7/2/2009 JV Reenabling change 274916 (from DLC3)
  914.                     for(i = 0; i < ignore_player.size; i++ )
  915.                     {
  916.                             players = array_remove( players, ignore_player[i] );
  917.                     }
  918.                     //PI_CHANGE_END
  919.             }
  920.      
  921.             while( !valid_player_found )
  922.             {
  923.                     // find the closest player
  924.                     if( is_true(level.calc_closest_player_using_paths) )
  925.                     {
  926.                             player = get_closest_player_using_paths( origin, players );
  927.                     }
  928.                     else
  929.                     {
  930.                             player = GetClosest( origin, players );
  931.                     }
  932.      
  933.                     if( !isdefined( player ) )
  934.                     {
  935.                             return undefined;
  936.                     }
  937.                    
  938.                     // make sure they're not a zombie or in last stand
  939.                     if( !is_player_valid( player, true ) )
  940.                     {
  941.                             players = array_remove( players, player );
  942.                             continue;
  943.                     }
  944.                     return player;
  945.             }
  946.     }
  947.      
  948.     is_player_valid( player, checkIgnoreMeFlag )
  949.     {
  950.             if( !IsDefined( player ) )
  951.             {
  952.                     return false;
  953.             }
  954.      
  955.             if( !IsAlive( player ) )
  956.             {
  957.                     return false;
  958.             }
  959.      
  960.             if( !IsPlayer( player ) )
  961.             {
  962.                     return false;
  963.             }
  964.      
  965.             if( player.is_zombie == true )
  966.             {
  967.                     return false;
  968.             }
  969.      
  970.             if( player.sessionstate == "spectator" )
  971.             {
  972.                     return false;
  973.             }
  974.      
  975.             if( player.sessionstate == "intermission" )
  976.             {
  977.                     return false;
  978.             }
  979.      
  980.             if(  player maps\_laststand::player_is_in_laststand() )
  981.             {
  982.                     return false;
  983.             }
  984.      
  985.             if ( player isnotarget() )
  986.             {
  987.                     return false;
  988.             }
  989.            
  990.             //We only want to check this from the zombie attack script
  991.             if( isdefined(checkIgnoreMeFlag) && player.ignoreme )
  992.             {
  993.                     //IPrintLnBold(" ignore me ");
  994.                     return false;
  995.             }
  996.            
  997.             return true;
  998.     }
  999.      
  1000.     get_number_of_valid_players()
  1001.     {
  1002.      
  1003.             players = get_players();
  1004.             num_player_valid = 0;
  1005.             for( i = 0 ; i < players.size; i++ )
  1006.             {
  1007.                     if( is_player_valid( players[i] ) )
  1008.                             num_player_valid += 1;
  1009.             }
  1010.      
  1011.            
  1012.             return num_player_valid;
  1013.      
  1014.      
  1015.      
  1016.     }
  1017.      
  1018.     in_revive_trigger()
  1019.     {
  1020.             players = get_players();
  1021.             for( i = 0; i < players.size; i++ )
  1022.             {
  1023.                     if( !IsDefined( players[i] ) || !IsAlive( players[i] ) )
  1024.                     {
  1025.                             continue;
  1026.                     }
  1027.            
  1028.                     if( IsDefined( players[i].revivetrigger ) )
  1029.                     {
  1030.                             if( self IsTouching( players[i].revivetrigger ) )
  1031.                             {
  1032.                                     return true;
  1033.                             }
  1034.                     }
  1035.             }
  1036.      
  1037.             return false;
  1038.     }
  1039.      
  1040.     get_closest_node( org, nodes )
  1041.     {
  1042.             return getClosest( org, nodes );
  1043.     }
  1044.      
  1045.     // bars are not damaged pull them off now.
  1046.     non_destroyed_bar_board_order( origin, chunks )
  1047.     {
  1048.             //bars = getentarray("bar","script_parameters");
  1049.             first_bars = []; // first set of 2 bars to be removed
  1050.             first_bars1 = []; // Added single check when combined with wood
  1051.             first_bars2 = []; // Added single check when combined with wood
  1052.      
  1053.             //-------------------------BOARDS----------------------------------------------------------
  1054.             // If all boards do the old system
  1055.             for( i=0;i<chunks.size;i++ ) // Go through the array
  1056.             {
  1057.                     if (IsDefined ( chunks[i].script_team ) && ( chunks[i].script_team == "classic_boards" ) )
  1058.                     {
  1059.                             if (IsDefined (chunks[i].script_parameters) && (chunks[i].script_parameters == "board") )      
  1060.                             {      
  1061.                                     return get_closest_2d( origin, chunks );
  1062.                             }                              
  1063.                             // I need to add a script name team regular boards
  1064.                             else if (IsDefined ( chunks[i].script_team ) && chunks[i].script_team == "bar_board_variant1" || chunks[i].script_team == "bar_board_variant2" ||
  1065.                             chunks[i].script_team == "bar_board_variant4" || chunks[i].script_team == "bar_board_variant5" )
  1066.                             {      
  1067.                                     return undefined;
  1068.                             }
  1069.                     }
  1070.                     // DCS: adding new variable to start with like new condition repaired with boards.
  1071.                     else if(IsDefined(chunks[i].script_team ) && chunks[i].script_team == "new_barricade")
  1072.                     {
  1073.                             if(IsDefined(chunks[i].script_parameters) && chunks[i].script_parameters == "repair_board")
  1074.                             {
  1075.                                     return get_closest_2d( origin, chunks );
  1076.                             }                                                      
  1077.                     }
  1078.             }
  1079.             //-------------------------BOARDS----------------------------------------------------------
  1080.      
  1081.             //-------------------------BARS------------------------------------------------------------
  1082.             for(i=0;i<chunks.size;i++) // Go through the array
  1083.             {
  1084.                     if ( IsDefined (chunks[i].script_team ) && ( chunks[i].script_team == "6_bars_bent" )  || ( chunks[i].script_team == "6_bars_prestine" ) )
  1085.                     {
  1086.                             if (IsDefined (chunks[i].script_parameters) && (chunks[i].script_parameters == "bar") )
  1087.                             {      
  1088.                                     if(isDefined(chunks[i].script_noteworthy))
  1089.                                     {
  1090.                                             if(chunks[i].script_noteworthy == "4" || chunks[i].script_noteworthy == "6" ) // this two are defined create a new array that just keeps track of them
  1091.                                             {
  1092.                                                     first_bars[first_bars.size] = chunks[i]; // In total this should be a size of two
  1093.                                             }
  1094.                                     }
  1095.                             }
  1096.                     }
  1097.             }
  1098.            
  1099.             for(i=0;i<first_bars.size;i++) // Jl added second check if there is only peace
  1100.             {
  1101.                     if ( IsDefined (chunks[i].script_team ) && ( chunks[i].script_team == "6_bars_bent" )  || ( chunks[i].script_team == "6_bars_prestine" ) )
  1102.                     {                      
  1103.                             if (IsDefined (chunks[i].script_parameters) && (chunks[i].script_parameters == "bar") )
  1104.                             {      
  1105.                                     //send back the first bars that are NOT destroyed
  1106.                                     if( !first_bars[i].destroyed )
  1107.                                     {
  1108.                                             return first_bars[i];
  1109.                                     }
  1110.                             }
  1111.                     }
  1112.             }
  1113.            
  1114.             // Grab the remaining bars that are the closest to the ai
  1115.             for(i=0;i<chunks.size;i++)
  1116.             {
  1117.                     if ( IsDefined (chunks[i].script_team ) && ( chunks[i].script_team == "6_bars_bent" )  || ( chunks[i].script_team == "6_bars_prestine" ) )
  1118.                     {      
  1119.                    
  1120.                             if (IsDefined (chunks[i].script_parameters) && (chunks[i].script_parameters == "bar") )
  1121.                             {      
  1122.                                     if( !chunks[i].destroyed )
  1123.                                     {
  1124.                                             return get_closest_2d( origin, chunks );
  1125.                                             //return chunks[i];
  1126.                                     }
  1127.                             }
  1128.                     }
  1129.             }
  1130.             //-------------------------BARS------------------------------------------------------------
  1131.     }
  1132.      
  1133.      
  1134.     non_destroyed_grate_order( origin, chunks_grate )
  1135.     {
  1136.             //-------------------------GRATES----------------------------------------------------------
  1137.             grate_order = [];
  1138.             grate_order1 =[]; // this sets up the order for the grates
  1139.             grate_order2 =[]; // this sets up the order for the grates
  1140.             grate_order3 =[]; // this sets up the order for the grates
  1141.             grate_order4 =[]; // this sets up the order for the grates
  1142.             grate_order5 =[]; // this sets up the order for the grates
  1143.             grate_order6 =[]; // this sets up the order for the grates
  1144.      
  1145.            
  1146.             if ( IsDefined ( chunks_grate ) )
  1147.             {
  1148.                     for(i=0;i<chunks_grate.size;i++) // Go through the array
  1149.                     {
  1150.                             if (IsDefined (chunks_grate[i].script_parameters) && (chunks_grate[i].script_parameters == "grate") )
  1151.                             {      
  1152.                                     //return grate_order[i];
  1153.                                    
  1154.                                     if ( IsDefined ( chunks_grate[i].script_noteworthy ) && ( chunks_grate[i].script_noteworthy == "1" ) )
  1155.                                     {
  1156.                                                     grate_order1[grate_order1.size] = chunks_grate[i];
  1157.                                                     // send back order here
  1158.                                     }
  1159.                                     if ( IsDefined ( chunks_grate[i].script_noteworthy ) && ( chunks_grate[i].script_noteworthy == "2" ) )
  1160.                                     {
  1161.                                                     grate_order2[grate_order2.size] = chunks_grate[i];
  1162.                                                             // send back order here
  1163.                                     }
  1164.                                     if ( IsDefined ( chunks_grate[i].script_noteworthy ) && ( chunks_grate[i].script_noteworthy == "3" ) )
  1165.                                     {
  1166.                                                     grate_order3[grate_order3.size] = chunks_grate[i];
  1167.                                                             // send back order here
  1168.                                     }
  1169.                                     if ( IsDefined ( chunks_grate[i].script_noteworthy ) && ( chunks_grate[i].script_noteworthy == "4" ) )
  1170.                                     {
  1171.                                                     grate_order4[grate_order4.size] = chunks_grate[i];
  1172.                                                             // send back order here
  1173.                                     }
  1174.                                     if ( IsDefined ( chunks_grate[i].script_noteworthy ) && ( chunks_grate[i].script_noteworthy == "5" ) )
  1175.                                     {
  1176.                                                     grate_order5[grate_order5.size] = chunks_grate[i];
  1177.                                                             // send back order here
  1178.                                     }
  1179.                                     if ( IsDefined ( chunks_grate[i].script_noteworthy ) && ( chunks_grate[i].script_noteworthy == "6" ) )
  1180.                                     {
  1181.                                                     grate_order6[grate_order6.size] = chunks_grate[i];
  1182.                                                             // send back order here
  1183.                                     }
  1184.                             }
  1185.                     }
  1186.                    
  1187.                    
  1188.                     // I need to make this function also tell which piece to move again.
  1189.                     for(i=0;i<chunks_grate.size;i++) // Go through the array
  1190.                     {
  1191.                             if (IsDefined ( chunks_grate[i].script_parameters ) && ( chunks_grate[i].script_parameters == "grate") )
  1192.                             {      
  1193.                                     if ( IsDefined ( grate_order1[i] ) )
  1194.                                     {
  1195.                                             if( ( grate_order1[i].state == "repaired" )  )
  1196.                                             {
  1197.                                                     grate_order2[i] thread show_grate_pull();
  1198.                                                     return grate_order1[i];
  1199.                                             }
  1200.                                             if(  ( grate_order2[i].state == "repaired" )  )
  1201.                                             {
  1202.                                                     /#
  1203.                                                     IPrintLnBold(" pull bar2 ");
  1204.                                                     #/
  1205.                                                     grate_order3[i] thread show_grate_pull();
  1206.                                                     return grate_order2[i];
  1207.                                                    
  1208.                                             }
  1209.                                             else if( ( grate_order3[i].state == "repaired" ) )
  1210.                                             {
  1211.                                                     /#
  1212.                                                     IPrintLnBold(" pull bar3 ");
  1213.                                                     #/
  1214.                                                     grate_order4[i] thread show_grate_pull();
  1215.                                                     return grate_order3[i];
  1216.                                                      
  1217.                                             }
  1218.                                             else if( ( grate_order4[i].state == "repaired" ) )
  1219.                                             {
  1220.                                                     /#
  1221.                                                     IPrintLnBold(" pull bar4 ");
  1222.                                                     #/
  1223.                                                     grate_order5[i] thread show_grate_pull();
  1224.                                                     return grate_order4[i];
  1225.                                             }
  1226.                                             else if( ( grate_order5[i].state == "repaired" ) )
  1227.                                             {
  1228.                                                     /#
  1229.                                                     IPrintLnBold(" pull bar5 ");
  1230.                                                     #/
  1231.                                                     grate_order6[i] thread show_grate_pull();
  1232.                                                     return grate_order5[i];
  1233.                                             }
  1234.                                             else if( ( grate_order6[i].state == "repaired" ) )
  1235.                                             {
  1236.                                                     // I need to return nothing here.
  1237.                                                     //return undefined();
  1238.                                                     return grate_order6[i];
  1239.                                             }
  1240.                                     }
  1241.                             }
  1242.                     }
  1243.             }
  1244.             //-------------------------GRATES----------------------------------------------------------
  1245.     }
  1246.      
  1247.     //////////////////////////////////////////////////////////////////////////////////////////////
  1248.     //
  1249.     // A seperate function is needed for each variant because there are different pull down and repair orders for each
  1250.     // Also I had to add extra strings to idetify combined pieces that used the same script_noteworthy
  1251.     //
  1252.     //////////////////////////////////////////////////////////////////////////////////////////////
  1253.     // variant1
  1254.     non_destroyed_variant1_order( origin, chunks_variant1 )
  1255.     {
  1256.             //-------------------------VARIANT1----------------------------------------------------------
  1257.             variant1_order = [];
  1258.             variant1_order1 =[]; // this sets up the order for the grates
  1259.             variant1_order2 =[]; // this sets up the order for the grates
  1260.             variant1_order3 =[]; // this sets up the order for the grates
  1261.             variant1_order4 =[]; // this sets up the order for the grates
  1262.             variant1_order5 =[]; // this sets up the order for the grates
  1263.             variant1_order6 =[]; // this sets up the order for the grates
  1264.      
  1265.            
  1266.             if ( IsDefined ( chunks_variant1 ) )
  1267.             {
  1268.                     for(i=0;i<chunks_variant1.size;i++) // Go through the array
  1269.                     {
  1270.                             if (IsDefined (chunks_variant1[i].script_team) && (chunks_variant1[i].script_team == "bar_board_variant1") )
  1271.                             {      
  1272.                                     //return grate_order[i];
  1273.                                    
  1274.                                     if ( IsDefined ( chunks_variant1[i].script_noteworthy ) )
  1275.                                     {
  1276.                                             if ( chunks_variant1[i].script_noteworthy == "1" )
  1277.                                             {
  1278.                                                     variant1_order1[variant1_order1.size] = chunks_variant1[i];
  1279.                                             }
  1280.                                             if ( chunks_variant1[i].script_noteworthy == "2" )
  1281.                                             {
  1282.                                                     variant1_order2[variant1_order2.size] = chunks_variant1[i];
  1283.                                             }
  1284.                                             if ( chunks_variant1[i].script_noteworthy == "3" )
  1285.                                             {
  1286.                                                     variant1_order3[variant1_order3.size] = chunks_variant1[i];
  1287.                                             }
  1288.                                             if ( chunks_variant1[i].script_noteworthy == "4" )
  1289.                                             {
  1290.                                                     variant1_order4[variant1_order4.size] = chunks_variant1[i];
  1291.                                             }
  1292.                                             if ( chunks_variant1[i].script_noteworthy == "5" )
  1293.                                             {
  1294.                                                     variant1_order5[variant1_order5.size] = chunks_variant1[i];
  1295.                                             }
  1296.                                             if ( chunks_variant1[i].script_noteworthy == "6" )
  1297.                                             {
  1298.                                                     variant1_order6[variant1_order6.size] = chunks_variant1[i];                                            
  1299.                                             }
  1300.                                     }
  1301.                             }
  1302.                     }
  1303.                    
  1304.                    
  1305.                     // This needs a different order
  1306.                     for(i=0;i<chunks_variant1.size;i++) // Go through the array
  1307.                     {
  1308.                             if (IsDefined ( chunks_variant1[i].script_team ) && ( chunks_variant1[i].script_team == "bar_board_variant1") )
  1309.                             {      
  1310.                                     if( IsDefined ( variant1_order2[i] ) )
  1311.                                     {
  1312.                                             if( ( variant1_order2[i].state == "repaired" )  )
  1313.                                             {
  1314.                                                     return variant1_order2[i];
  1315.                                             }
  1316.                                             else if(  ( variant1_order3[i].state == "repaired" ) )
  1317.                                             {
  1318.                                                     return variant1_order3[i];
  1319.                                             }
  1320.                                             else if( ( variant1_order4[i].state == "repaired" ) )
  1321.                                             {
  1322.                                                     return variant1_order4[i];
  1323.                                             }
  1324.                                             else if( ( variant1_order6[i].state == "repaired" ) )
  1325.                                             {
  1326.                                                     return variant1_order6[i];
  1327.                                             }
  1328.                                             else if( ( variant1_order5[i].state == "repaired" ) )
  1329.                                             {
  1330.                                                     return variant1_order5[i];
  1331.                                             }
  1332.                                             else if( ( variant1_order1[i].state == "repaired" ) )
  1333.                                             {
  1334.                                                     return variant1_order1[i];
  1335.                                             }
  1336.                                     }
  1337.                             }
  1338.                     }
  1339.             }
  1340.            
  1341.             //if( chunks_variant1.size == 0 )
  1342.             //{
  1343.             //      return undefined; // If there are no more pieces left then don't allow it to continue
  1344.             //}
  1345.             //-------------------------VARIANT1----------------------------------------------------------
  1346.     }
  1347.      
  1348.     // variant2
  1349.     non_destroyed_variant2_order( origin, chunks_variant2 )
  1350.     {
  1351.             //-------------------------VARIENT2----------------------------------------------------------
  1352.             variant2_order = [];
  1353.             variant2_order1 =[]; // this sets up the order for the grates
  1354.             variant2_order2 =[]; // this sets up the order for the grates
  1355.             variant2_order3 =[]; // this sets up the order for the grates
  1356.             variant2_order4 =[]; // this sets up the order for the grates
  1357.             variant2_order5 =[]; // this sets up the order for the grates
  1358.             variant2_order6 =[]; // this sets up the order for the grates
  1359.      
  1360.            
  1361.             if ( IsDefined ( chunks_variant2 ) )
  1362.             {
  1363.                     for(i=0;i<chunks_variant2.size;i++) // Go through the array
  1364.                     {
  1365.                             if (IsDefined (chunks_variant2[i].script_team) && (chunks_variant2[i].script_team == "bar_board_variant2") )
  1366.                             {      
  1367.                                     //return grate_order[i];
  1368.                                    
  1369.                                     if ( IsDefined ( chunks_variant2[i].script_noteworthy ) && ( chunks_variant2[i].script_noteworthy == "1" ) )
  1370.                                     {
  1371.                                                     variant2_order1[variant2_order1.size] = chunks_variant2[i];
  1372.                                                     // send back order here
  1373.                                     }
  1374.                                     if ( IsDefined ( chunks_variant2[i].script_noteworthy ) && ( chunks_variant2[i].script_noteworthy == "2" ) )
  1375.                                     {
  1376.                                                     variant2_order2[variant2_order2.size] = chunks_variant2[i];
  1377.                                                             // send back order here
  1378.                                     }
  1379.                                     if ( IsDefined ( chunks_variant2[i].script_noteworthy ) && ( chunks_variant2[i].script_noteworthy == "3" ) )
  1380.                                     {
  1381.                                                     variant2_order3[variant2_order3.size] = chunks_variant2[i];
  1382.                                                             // send back order here
  1383.                                     }
  1384.                                     if ( IsDefined ( chunks_variant2[i].script_noteworthy ) && ( chunks_variant2[i].script_noteworthy == "4" ) )
  1385.                                     {
  1386.                                                     variant2_order4[variant2_order4.size] = chunks_variant2[i];
  1387.                                                             // send back order here
  1388.                                     }
  1389.                                     // I had to add another string to check against out of order noteworthy when combining board and wood
  1390.                                     if ( IsDefined ( chunks_variant2[i].script_noteworthy ) && ( chunks_variant2[i].script_noteworthy == "5" ) && IsDefined( chunks_variant2[i].script_location ) && (chunks_variant2[i].script_location == "5") )
  1391.                                     {
  1392.                                                     variant2_order5[variant2_order5.size] = chunks_variant2[i];
  1393.                                                             // send back order here
  1394.                                     }
  1395.                                     if ( IsDefined ( chunks_variant2[i].script_noteworthy ) && ( chunks_variant2[i].script_noteworthy == "5" ) && IsDefined( chunks_variant2[i].script_location ) && (chunks_variant2[i].script_location == "6") )
  1396.                                     {
  1397.                                                     variant2_order6[variant2_order6.size] = chunks_variant2[i];
  1398.                                                             // send back order here
  1399.                                     }
  1400.                             }
  1401.                     }      
  1402.                    
  1403.                     // There is a different pull order for every variant
  1404.                     for(i=0;i<chunks_variant2.size;i++) // Go through the array
  1405.                     {
  1406.                             if (IsDefined ( chunks_variant2[i].script_team ) && ( chunks_variant2[i].script_team == "bar_board_variant2") )
  1407.                             {      
  1408.                                     if( IsDefined ( variant2_order1[i] ) )
  1409.                                     {      
  1410.                                             if( ( variant2_order1[i].state == "repaired" ) )
  1411.                                             {
  1412.                                                     return variant2_order1[i];
  1413.                                             }
  1414.                                             else if(  ( variant2_order2[i].state == "repaired" ) )
  1415.                                             {
  1416.                                                     return variant2_order2[i];
  1417.                                             }
  1418.                                             else if( ( variant2_order3[i].state == "repaired" ) )
  1419.                                             {
  1420.                                                     return variant2_order3[i];
  1421.                                             }
  1422.                                             else if( ( variant2_order5[i].state == "repaired" ) )
  1423.                                             {
  1424.                                                     return variant2_order5[i];
  1425.                                             }
  1426.                                             else if( ( variant2_order4[i].state == "repaired" ) )
  1427.                                             {
  1428.                                                     return variant2_order4[i];
  1429.                                             }
  1430.                                             else if( ( variant2_order6[i].state == "repaired" ) )
  1431.                                             {
  1432.                                                     return variant2_order6[i];
  1433.                                             }
  1434.                                     }
  1435.                             }
  1436.                     }
  1437.             }
  1438.             //-------------------------VARIENT2----------------------------------------------------------
  1439.     }
  1440.      
  1441.     // variant4
  1442.     non_destroyed_variant4_order( origin, chunks_variant4 )
  1443.     {
  1444.             //-------------------------VARIENT4----------------------------------------------------------
  1445.             variant4_order = [];
  1446.             variant4_order1 =[]; // this sets up the order for the grates
  1447.             variant4_order2 =[]; // this sets up the order for the grates
  1448.             variant4_order3 =[]; // this sets up the order for the grates
  1449.             variant4_order4 =[]; // this sets up the order for the grates
  1450.             variant4_order5 =[]; // this sets up the order for the grates
  1451.             variant4_order6 =[]; // this sets up the order for the grates
  1452.      
  1453.            
  1454.             if ( IsDefined ( chunks_variant4 ) )
  1455.             {
  1456.                     for(i=0;i<chunks_variant4.size;i++) // Go through the array
  1457.                     {
  1458.                             if (IsDefined (chunks_variant4[i].script_team) && (chunks_variant4[i].script_team == "bar_board_variant4") )
  1459.                             {      
  1460.                                     //return grate_order[i];
  1461.                                    
  1462.                                     if ( IsDefined ( chunks_variant4[i].script_noteworthy ) && ( chunks_variant4[i].script_noteworthy == "1" ) && !IsDefined( chunks_variant4[i].script_location ) )
  1463.                                     {
  1464.                                                     variant4_order1[variant4_order1.size] = chunks_variant4[i];
  1465.                                                     // send back order here
  1466.                                     }
  1467.                                     if ( IsDefined ( chunks_variant4[i].script_noteworthy ) && ( chunks_variant4[i].script_noteworthy == "2" ) )
  1468.                                     {
  1469.                                                     variant4_order2[variant4_order2.size] = chunks_variant4[i];
  1470.                                                             // send back order here
  1471.                                     }
  1472.                                     if ( IsDefined ( chunks_variant4[i].script_noteworthy ) && ( chunks_variant4[i].script_noteworthy == "3" ) )
  1473.                                     {
  1474.                                                     variant4_order3[variant4_order3.size] = chunks_variant4[i];
  1475.                                                             // send back order here
  1476.                                     }
  1477.                                     if ( IsDefined ( chunks_variant4[i].script_noteworthy ) && ( chunks_variant4[i].script_noteworthy == "1" ) && IsDefined( chunks_variant4[i].script_location ) && (chunks_variant4[i].script_location == "3") )
  1478.                                     {
  1479.                                                     variant4_order4[variant4_order4.size] = chunks_variant4[i];
  1480.                                                     // send back order here
  1481.                                     }
  1482.                                     // There isn't a noteworthy 4
  1483.                                     if ( IsDefined ( chunks_variant4[i].script_noteworthy ) && ( chunks_variant4[i].script_noteworthy == "5" ) )
  1484.                                     {
  1485.                                                     variant4_order5[variant4_order5.size] = chunks_variant4[i];
  1486.                                                             // send back order here
  1487.                                     }
  1488.                                     if ( IsDefined ( chunks_variant4[i].script_noteworthy ) && ( chunks_variant4[i].script_noteworthy == "6" ) )
  1489.                                     {
  1490.                                                     variant4_order6[variant4_order6.size] = chunks_variant4[i];
  1491.                                                             // send back order here
  1492.                                     }
  1493.                             }
  1494.                     }      
  1495.                    
  1496.                     // There is a different pull order for every variant
  1497.                     for(i=0;i<chunks_variant4.size;i++) // Go through the array
  1498.                     {
  1499.                             if (IsDefined ( chunks_variant4[i].script_team ) && ( chunks_variant4[i].script_team == "bar_board_variant4") )
  1500.                             {      
  1501.                                     if( IsDefined ( variant4_order1[i] ) ) // last one here
  1502.                                     {      
  1503.                                             if( ( variant4_order1[i].state == "repaired" ) )
  1504.                                             {
  1505.                                                     return variant4_order1[i];
  1506.                                             }
  1507.                                             else if(  ( variant4_order6[i].state == "repaired" ) )
  1508.                                             {
  1509.                                                     return variant4_order6[i];
  1510.                                             }
  1511.                                             else if( ( variant4_order3[i].state == "repaired" ) )
  1512.                                             {
  1513.                                                     return variant4_order3[i];
  1514.                                             }
  1515.                                             else if( ( variant4_order4[i].state == "repaired" ) ) // second one
  1516.                                             {
  1517.                                                     return variant4_order4[i];
  1518.                                             }
  1519.                                             else if( ( variant4_order2[i].state == "repaired" ) )
  1520.                                             {
  1521.                                                     return variant4_order2[i];
  1522.                                             }
  1523.                                             else if( ( variant4_order5[i].state == "repaired" ) )
  1524.                                             {
  1525.                                                     return variant4_order5[i];
  1526.                                             }
  1527.                                     }
  1528.                             }
  1529.                     }
  1530.             }
  1531.             //-------------------------Variant2----------------------------------------------------------
  1532.     }
  1533.      
  1534.     // variant5
  1535.     non_destroyed_variant5_order( origin, chunks_variant5 )
  1536.     {
  1537.             //-------------------------VARIANT5----------------------------------------------------------
  1538.             variant5_order = [];
  1539.             variant5_order1 =[]; // this sets up the order for the grates
  1540.             variant5_order2 =[]; // this sets up the order for the grates
  1541.             variant5_order3 =[]; // this sets up the order for the grates
  1542.             variant5_order4 =[]; // this sets up the order for the grates
  1543.             variant5_order5 =[]; // this sets up the order for the grates
  1544.             variant5_order6 =[]; // this sets up the order for the grates
  1545.      
  1546.            
  1547.             if ( IsDefined ( chunks_variant5 ) )
  1548.             {
  1549.                     for(i=0;i<chunks_variant5.size;i++) // Go through the array
  1550.                     {
  1551.                             if (IsDefined (chunks_variant5[i].script_team) && (chunks_variant5[i].script_team == "bar_board_variant5") )
  1552.                             {      
  1553.                                     //return grate_order[i];
  1554.                                     if ( IsDefined ( chunks_variant5[i].script_noteworthy ) )
  1555.                                     {
  1556.                                             // if ( IsDefined ( chunks_variant4[i].script_noteworthy ) && ( chunks_variant4[i].script_noteworthy == "1" ) && !IsDefined( chunks_variant4[i].script_location ) )
  1557.                                             if ( ( chunks_variant5[i].script_noteworthy == "1" ) && !IsDefined( chunks_variant5[i].script_location ) )
  1558.                                             {
  1559.                                                     variant5_order1[variant5_order1.size] = chunks_variant5[i];
  1560.                                             }
  1561.                                             if ( chunks_variant5[i].script_noteworthy == "2" )
  1562.                                             {
  1563.                                                     variant5_order2[variant5_order2.size] = chunks_variant5[i];
  1564.                                             }
  1565.                                             if ( IsDefined ( chunks_variant5[i].script_noteworthy ) && ( chunks_variant5[i].script_noteworthy == "1" ) && IsDefined( chunks_variant5[i].script_location ) && (chunks_variant5[i].script_location == "3") )
  1566.                                             {
  1567.                                                     variant5_order3[variant5_order3.size] = chunks_variant5[i];
  1568.                                             }
  1569.                                             if ( chunks_variant5[i].script_noteworthy == "4" )
  1570.                                             {
  1571.                                                     variant5_order4[variant5_order4.size] = chunks_variant5[i];
  1572.                                             }
  1573.                                             if ( chunks_variant5[i].script_noteworthy == "5" )
  1574.                                             {
  1575.                                                     variant5_order5[variant5_order5.size] = chunks_variant5[i];
  1576.                                             }
  1577.                                             if ( chunks_variant5[i].script_noteworthy == "6" )
  1578.                                             {
  1579.                                                     variant5_order6[variant5_order6.size] = chunks_variant5[i];                                            
  1580.                                             }
  1581.                                     }
  1582.                             }
  1583.                     }      
  1584.                     for(i=0;i<chunks_variant5.size;i++) // Go through the array
  1585.                     {
  1586.                             if (IsDefined ( chunks_variant5[i].script_team ) && ( chunks_variant5[i].script_team == "bar_board_variant5") )
  1587.                             {      
  1588.                                     if( IsDefined ( variant5_order1[i] ) )
  1589.                                     {
  1590.                                             if( ( variant5_order1[i].state == "repaired" )  )
  1591.                                             {
  1592.                                                     return variant5_order1[i];
  1593.                                             }
  1594.                                             else if(  ( variant5_order6[i].state == "repaired" ) )
  1595.                                             {
  1596.                                                     return variant5_order6[i];
  1597.                                             }
  1598.                                             else if( ( variant5_order3[i].state == "repaired" ) )
  1599.                                             {
  1600.                                                     return variant5_order3[i];
  1601.                                             }
  1602.                                             else if( ( variant5_order2[i].state == "repaired" ) )
  1603.                                             {
  1604.                                                     return variant5_order2[i];
  1605.                                             }
  1606.                                             else if( ( variant5_order5[i].state == "repaired" ) )
  1607.                                             {
  1608.                                                     return variant5_order5[i];
  1609.                                             }
  1610.                                             else if( ( variant5_order4[i].state == "repaired" ) )
  1611.                                             {
  1612.                                                     return variant5_order4[i];
  1613.                                             }
  1614.                                     }
  1615.                             }
  1616.                     }
  1617.             }
  1618.             //-------------------------VARIANT5----------------------------------------------------------
  1619.     }
  1620.      
  1621.     show_grate_pull()
  1622.     {
  1623.             wait(0.53);
  1624.             self Show();
  1625.             self vibrate(( 0, 270, 0 ), 0.2, 0.4, 0.4);
  1626.             // I could fx and sound from here as well.
  1627.     }
  1628.      
  1629.      
  1630.     get_closest_2d( origin, ents )
  1631.     {
  1632.             if( !IsDefined( ents ) )
  1633.             {
  1634.                     return undefined;
  1635.             }
  1636.            
  1637.             dist = Distance2d( origin, ents[0].origin );
  1638.             index = 0;
  1639.             temp_array = [];
  1640.                    
  1641.             for( i = 1; i < ents.size; i++ )
  1642.             {
  1643.                     if(IsDefined(ents[i].unbroken) && ents[i].unbroken == true)
  1644.                     {
  1645.                             ents[i].index = i;
  1646.                             temp_array = array_add(temp_array, ents[i]);
  1647.                     }
  1648.             }      
  1649.      
  1650.             if(temp_array.size > 0)
  1651.             {
  1652.                     index = temp_array[RandomIntRange(0, temp_array.size)].index; // must pick unbroken piece first!
  1653.                     return ents[index];
  1654.             }
  1655.             else
  1656.             {              
  1657.                     for( i = 1; i < ents.size; i++ )
  1658.                     {
  1659.                             temp_dist = Distance2d( origin, ents[i].origin );
  1660.                             if( temp_dist < dist )
  1661.                             {
  1662.                                     dist = temp_dist;
  1663.                                     index = i;
  1664.                             }
  1665.                     }
  1666.                     return ents[index];
  1667.             }
  1668.     }
  1669.      
  1670.     disable_trigger()
  1671.     {
  1672.             if( !IsDefined( self.disabled ) || !self.disabled )
  1673.             {
  1674.                     self.disabled = true;
  1675.                     self.origin = self.origin -( 0, 0, 10000 );
  1676.             }
  1677.     }
  1678.      
  1679.     enable_trigger()
  1680.     {
  1681.             if( !IsDefined( self.disabled ) || !self.disabled )
  1682.             {
  1683.                     return;
  1684.             }
  1685.      
  1686.             self.disabled = false;
  1687.             self.origin = self.origin +( 0, 0, 10000 );
  1688.     }
  1689.      
  1690.     //edge_fog_start()
  1691.     //{
  1692.     //      playpoint = getstruct( "edge_fog_start", "targetname" );
  1693.     //
  1694.     //      if( !IsDefined( playpoint ) )
  1695.     //      {
  1696.     //            
  1697.     //      }
  1698.     //    
  1699.     //      while( isdefined( playpoint ) )
  1700.     //      {
  1701.     //              playfx( level._effect["edge_fog"], playpoint.origin );
  1702.     //            
  1703.     //              if( !isdefined( playpoint.target ) )
  1704.     //              {
  1705.     //                      return;
  1706.     //              }
  1707.     //            
  1708.     //              playpoint = getstruct( playpoint.target, "targetname" );
  1709.     //      }
  1710.     //}
  1711.      
  1712.      
  1713.     //chris_p - fix bug with this not being an ent array!
  1714.     in_playable_area()
  1715.     {
  1716.             playable_area = getentarray("player_volume","script_noteworthy");
  1717.      
  1718.             if( !IsDefined( playable_area ) )
  1719.             {
  1720.                     println( "No playable area playable_area found! Assume EVERYWHERE is PLAYABLE" );
  1721.                     return true;
  1722.             }
  1723.            
  1724.             for(i=0;i<playable_area.size;i++)
  1725.             {
  1726.      
  1727.                     if( self IsTouching( playable_area[i] ) )
  1728.                     {
  1729.                             return true;
  1730.                     }
  1731.             }
  1732.      
  1733.             return false;
  1734.     }
  1735.      
  1736.     // I beleive this is where I can do the check to see what
  1737.     // barrier_chunks is the total amount of bars or boards that the exterior_goal was connected to.
  1738.     get_closest_non_destroyed_chunk( origin, barrier_chunks )
  1739.     {
  1740.             chunks = undefined;
  1741.             chunks_grate = undefined;
  1742.             chunks_variant1 = undefined;
  1743.             chunks_variant2 = undefined;
  1744.             chunks_variant4 = undefined;
  1745.             chunks_variant5 = undefined;
  1746.     //      wait( 0.1 );
  1747.            
  1748.             // This returns only if grate is defined
  1749.             chunks_grate = get_non_destroyed_chunks_grate( barrier_chunks );
  1750.            
  1751.             // This grabs classic boards, 6 bar prestine set and 6 bar bent set
  1752.             chunks = get_non_destroyed_chunks( barrier_chunks ); // Grab all the chunks that are repaired
  1753.            
  1754.             chunks_variant1 = get_non_destroyed_variant1( barrier_chunks );
  1755.            
  1756.             chunks_variant2 = get_non_destroyed_variant2( barrier_chunks );
  1757.            
  1758.             chunks_variant4 = get_non_destroyed_variant4( barrier_chunks );
  1759.            
  1760.             chunks_variant5 = get_non_destroyed_variant5( barrier_chunks );
  1761.            
  1762.             // This returns an array of what chunks can be pulled
  1763.            
  1764.             if( IsDefined( chunks ) ) // && IsDefined ( chunks.script_parameters ) && chunks.script_parameters == "board" )
  1765.             {
  1766.                                     // Jl This was the original call
  1767.                                     // return get_closest_2d( origin, chunks );
  1768.                     return non_destroyed_bar_board_order ( origin, chunks ); // Go through all the repaired chunk pieces
  1769.             }
  1770.            
  1771.             else if ( IsDefined ( chunks_grate ) )
  1772.             {
  1773.                     return  non_destroyed_grate_order ( origin, chunks_grate ); // Go through all the repaired chunk pices
  1774.             }
  1775.            
  1776.             //----------------------------Newly Added Variant Order Pull Downs-------------------------------------------
  1777.             else if ( IsDefined ( chunks_variant1 ) )
  1778.             {
  1779.                     return  non_destroyed_variant1_order ( origin, chunks_variant1 ); // Go through all the repaired chunk pices
  1780.             }
  1781.            
  1782.             else if ( IsDefined ( chunks_variant2 ) )
  1783.             {
  1784.                     return  non_destroyed_variant2_order ( origin, chunks_variant2 ); // Go through all the repaired chunk pices
  1785.             }
  1786.            
  1787.             else if ( IsDefined ( chunks_variant4 ) )
  1788.             {
  1789.                     return  non_destroyed_variant4_order ( origin, chunks_variant4 ); // Go through all the repaired chunk pices
  1790.             }
  1791.            
  1792.             else if ( IsDefined ( chunks_variant5 ) )
  1793.             {
  1794.                     return  non_destroyed_variant5_order ( origin, chunks_variant5 ); // Go through all the repaired chunk pices
  1795.             }
  1796.            
  1797.             //----------------------------Newly Added Varient Order Pull Downs-------------------------------------------
  1798.             return undefined;
  1799.     }
  1800.      
  1801.      
  1802.     // Jluyties barrier_chunks is the total amount of bars or boards that the exterior_goal was connected to
  1803.     // The grates do not return random
  1804.     get_random_destroyed_chunk( barrier_chunks )
  1805.     {
  1806.             chunk = undefined;
  1807.             chunks_repair_grate = undefined;
  1808.      
  1809.      
  1810.             chunks = get_destroyed_chunks( barrier_chunks );
  1811.      
  1812.             chunks_repair_grate = get_destroyed_repair_grates ( barrier_chunks );
  1813.      
  1814.     // for(i = 0; i < chunks.size; i++ )
  1815.            
  1816.             if ( IsDefined( chunks )  )
  1817.             {
  1818.                     return chunks[RandomInt( chunks.size )];
  1819.                     //return get_destroyed_chunks_without_grate ( chunks );
  1820.             }
  1821.      
  1822.             else if( IsDefined( chunks_repair_grate ) )
  1823.             {
  1824.                     return grate_order_destroyed ( chunks_repair_grate );
  1825.             }
  1826.            
  1827.             return undefined;
  1828.     }
  1829.      
  1830.     get_destroyed_repair_grates( barrier_chunks )
  1831.     {
  1832.             // I may have to do my check here
  1833.             array = []; // Setup array
  1834.             for( i = 0; i < barrier_chunks.size; i++ ) // Cycle through and grab all chunks
  1835.             {                      
  1836.                     if( IsDefined ( barrier_chunks[i] ) )
  1837.                     {
  1838.                             if( IsDefined ( barrier_chunks[i].script_parameters ) && ( barrier_chunks[i].script_parameters == "grate" ) )
  1839.                             {
  1840.                                     array[array.size] = barrier_chunks[i];  
  1841.                             }
  1842.                     }
  1843.             }
  1844.      
  1845.             if( array.size == 0 )
  1846.             {
  1847.                     return undefined; // If there are no more pieces left then don't allow it to continue
  1848.             }
  1849.      
  1850.             return array; // send back state of array so it knows if boards are full or note and which board it is.
  1851.     }
  1852.      
  1853.      
  1854.     // this is the layer I want to do the check
  1855.     // I need to define each part of
  1856.     get_non_destroyed_chunks( barrier_chunks )
  1857.     {
  1858.             array = []; // Setup array
  1859.             for( i = 0; i < barrier_chunks.size; i++ ) // Cycle through and grab all chunks
  1860.             {      
  1861.                     if(IsDefined (barrier_chunks[i].script_team) && (barrier_chunks[i].script_team == "classic_boards") )
  1862.                     {
  1863.                             if (IsDefined (barrier_chunks[i].script_parameters) && (barrier_chunks[i].script_parameters == "board") )              
  1864.                             {                              
  1865.                                     if( barrier_chunks[i] get_chunk_state() == "repaired" ) // If the state of the chunk is repaired then continue
  1866.                                     {
  1867.                                             if( barrier_chunks[i].origin == barrier_chunks[i].og_origin ) // If this chunk has its original origin then continue
  1868.                                             {
  1869.                                                     array[array.size] = barrier_chunks[i]; //
  1870.                                             }
  1871.                                     }
  1872.                             }
  1873.                     }
  1874.                     //DCS: new barricade added for pentagon.
  1875.                     if(IsDefined (barrier_chunks[i].script_team) && (barrier_chunks[i].script_team == "new_barricade") )
  1876.                     {
  1877.                             if (IsDefined (barrier_chunks[i].script_parameters) && (barrier_chunks[i].script_parameters == "repair_board"))        
  1878.                             {                              
  1879.                                     if( barrier_chunks[i] get_chunk_state() == "repaired" ) // If the state of the chunk is repaired then continue
  1880.                                     {
  1881.                                             if( barrier_chunks[i].origin == barrier_chunks[i].og_origin ) // If this chunk has its original origin then continue
  1882.                                             {
  1883.                                                     array[array.size] = barrier_chunks[i]; //
  1884.                                             }
  1885.                                     }
  1886.                             }
  1887.                     }              
  1888.                    
  1889.                     else if ( IsDefined (barrier_chunks[i].script_team ) && ( barrier_chunks[i].script_team == "6_bars_bent" ) )
  1890.                     {
  1891.                             if (IsDefined (barrier_chunks[i].script_parameters) &&  (barrier_chunks[i].script_parameters == "bar") )                      
  1892.                             {
  1893.                                     if( barrier_chunks[i] get_chunk_state() == "repaired" ) // If the state of the chunk is repaired then continue
  1894.                                     {
  1895.            
  1896.                                             if( barrier_chunks[i].origin == barrier_chunks[i].og_origin ) // If this chunk has its original origin then continue
  1897.                                             {
  1898.                                                     array[array.size] = barrier_chunks[i]; //
  1899.                                             }
  1900.                                     }
  1901.                             }
  1902.                     }
  1903.                    
  1904.                     else if ( IsDefined (barrier_chunks[i].script_team ) && ( barrier_chunks[i].script_team == "6_bars_prestine" ) )
  1905.                     {
  1906.                             if (IsDefined (barrier_chunks[i].script_parameters) &&  (barrier_chunks[i].script_parameters == "bar") )                      
  1907.                             {
  1908.                                     if( barrier_chunks[i] get_chunk_state() == "repaired" ) // If the state of the chunk is repaired then continue
  1909.                                     {
  1910.            
  1911.                                             if( barrier_chunks[i].origin == barrier_chunks[i].og_origin ) // If this chunk has its original origin then continue
  1912.                                             {
  1913.                                                     array[array.size] = barrier_chunks[i]; //
  1914.                                             }
  1915.                                     }
  1916.                             }
  1917.                     }
  1918.             }
  1919.      
  1920.             if( array.size == 0 )
  1921.             {
  1922.                     return undefined; // If there are no more pieces left then don't allow it to continue
  1923.             }
  1924.      
  1925.             return array; // send back state of array
  1926.     }
  1927.      
  1928.     get_non_destroyed_chunks_grate( barrier_chunks )
  1929.     {
  1930.             array = []; // Setup array
  1931.             for( i = 0; i < barrier_chunks.size; i++ ) // Cycle through and grab all chunks
  1932.             {
  1933.                     if (IsDefined (barrier_chunks[i].script_parameters) && (barrier_chunks[i].script_parameters == "grate") )
  1934.                     {      
  1935.                             if( IsDefined ( barrier_chunks[i] ) )
  1936.                             {
  1937.                                     array[array.size] = barrier_chunks[i]; //
  1938.                             }
  1939.                     }
  1940.             }
  1941.      
  1942.             if( array.size == 0 )
  1943.             {
  1944.                     return undefined; // If there are no more pieces left then don't allow it to continue
  1945.             }
  1946.      
  1947.             return array; // send back state of array so it knows if boards are full or note and which board it is.
  1948.     }
  1949.      
  1950.     get_non_destroyed_variant1( barrier_chunks )
  1951.     {
  1952.             array = []; // Setup array
  1953.             for( i = 0; i < barrier_chunks.size; i++ ) // Cycle through and grab all chunks
  1954.             {
  1955.                     if (IsDefined (barrier_chunks[i].script_team) && (barrier_chunks[i].script_team == "bar_board_variant1") )
  1956.                     {      
  1957.                             if( IsDefined ( barrier_chunks[i] ) )
  1958.                             {
  1959.                                     array[array.size] = barrier_chunks[i];  
  1960.                             }
  1961.                     }
  1962.             }
  1963.      
  1964.             if( array.size == 0 )
  1965.             {
  1966.                     return undefined; // If there are no more pieces left then don't allow it to continue
  1967.             }
  1968.      
  1969.             return array; // send back state of array so it knows if boards are full or note and which board it is.
  1970.     }
  1971.      
  1972.     get_non_destroyed_variant2( barrier_chunks )
  1973.     {
  1974.             array = []; // Setup array
  1975.             for( i = 0; i < barrier_chunks.size; i++ ) // Cycle through and grab all chunks
  1976.             {
  1977.                     if (IsDefined (barrier_chunks[i].script_team) && (barrier_chunks[i].script_team == "bar_board_variant2") )
  1978.                     {      
  1979.                             if( IsDefined ( barrier_chunks[i] ) )
  1980.                             {
  1981.                                     array[array.size] = barrier_chunks[i];  
  1982.                             }
  1983.                     }
  1984.             }
  1985.      
  1986.             if( array.size == 0 )
  1987.             {
  1988.                     return undefined; // If there are no more pieces left then don't allow it to continue
  1989.             }
  1990.      
  1991.             return array; // send back state of array so it knows if boards are full or note and which board it is.
  1992.     }
  1993.      
  1994.     get_non_destroyed_variant4( barrier_chunks )
  1995.     {
  1996.             array = []; // Setup array
  1997.             for( i = 0; i < barrier_chunks.size; i++ ) // Cycle through and grab all chunks
  1998.             {
  1999.                     if (IsDefined (barrier_chunks[i].script_team) && (barrier_chunks[i].script_team == "bar_board_variant4") )
  2000.                     {      
  2001.                             if( IsDefined ( barrier_chunks[i] ) )
  2002.                             {
  2003.                                     array[array.size] = barrier_chunks[i]; //
  2004.                             }
  2005.                     }
  2006.             }
  2007.      
  2008.             if( array.size == 0 )
  2009.             {
  2010.                     return undefined; // If there are no more pieces left then don't allow it to continue
  2011.             }
  2012.      
  2013.             return array; // send back state of array so it knows if boards are full or note and which board it is.
  2014.     }
  2015.      
  2016.     get_non_destroyed_variant5( barrier_chunks )
  2017.     {
  2018.             array = []; // Setup array
  2019.             for( i = 0; i < barrier_chunks.size; i++ ) // Cycle through and grab all chunks
  2020.             {
  2021.                     if (IsDefined (barrier_chunks[i].script_team) && (barrier_chunks[i].script_team == "bar_board_variant5") )
  2022.                     {      
  2023.                             if( IsDefined ( barrier_chunks[i] ) )
  2024.                             {
  2025.                                     array[array.size] = barrier_chunks[i]; //
  2026.                             }
  2027.                     }
  2028.             }
  2029.      
  2030.             if( array.size == 0 )
  2031.             {
  2032.                     return undefined; // If there are no more pieces left then don't allow it to continue
  2033.             }
  2034.      
  2035.             return array; // send back state of array so it knows if boards are full or note and which board it is.
  2036.     }
  2037.      
  2038.     get_destroyed_chunks( barrier_chunks )
  2039.     {
  2040.             array = [];
  2041.             for( i = 0; i < barrier_chunks.size; i++ )
  2042.             {
  2043.                     if( barrier_chunks[i] get_chunk_state() == "destroyed" ) // if the chunks state says it is destroyed then continue
  2044.                     {
  2045.                             if (IsDefined (barrier_chunks[i].script_parameters) && barrier_chunks[i].script_parameters == "board")
  2046.                             {                      
  2047.                                     array[array.size] = barrier_chunks[i]; // create a new array from barrier chunks
  2048.                             }
  2049.                             else if (IsDefined (barrier_chunks[i].script_parameters) && barrier_chunks[i].script_parameters == "repair_board")
  2050.                             {                      
  2051.                                     array[array.size] = barrier_chunks[i]; // create a new array from barrier chunks
  2052.                             }
  2053.                             else if (IsDefined (barrier_chunks[i].script_parameters) && (barrier_chunks[i].script_parameters == "bar") )
  2054.                             {
  2055.                                     array[array.size] = barrier_chunks[i]; // create a new array from barrier chunks
  2056.                             }      
  2057.                            
  2058.                             else if (IsDefined (barrier_chunks[i].script_parameters) && (barrier_chunks[i].script_parameters == "grate") )
  2059.                             {
  2060.                                     // This makes sure that it isn't returned
  2061.                                     return undefined;
  2062.                                     //array[array.size] = barrier_chunks[i]; // create a new array from barrier chunks
  2063.                             }      
  2064.                     }
  2065.             }
  2066.            
  2067.             if( array.size == 0 )
  2068.             {
  2069.                     return undefined;
  2070.             }
  2071.            
  2072.             return array;
  2073.            
  2074.             //if( IsDefined( barrier_chunks ) )
  2075.             //{
  2076.             //      return barrier_chunks;
  2077.             //}
  2078.     }
  2079.      
  2080.      
  2081.     grate_order_destroyed( chunks_repair_grate )
  2082.     {
  2083.             grate_repair_order = [];
  2084.             grate_repair_order1 =[]; // this sets up the order for the grates
  2085.             grate_repair_order2 =[]; // this sets up the order for the grates
  2086.             grate_repair_order3 =[]; // this sets up the order for the grates
  2087.             grate_repair_order4 =[]; // this sets up the order for the grates
  2088.             grate_repair_order5 =[]; // this sets up the order for the grates
  2089.             grate_repair_order6 =[]; // this sets up the order for the grates
  2090.            
  2091.            
  2092.             // DEBUG
  2093.             /*
  2094.             for(i=0;i<chunks_repair_grate.size;i++) // Go through the array
  2095.             {
  2096.                     if (IsDefined (chunks_repair_grate[i].script_parameters) && (chunks_repair_grate[i].script_parameters == "grate") )
  2097.                     {      
  2098.                             grate_repair_order[grate_repair_order.size] = chunks_repair_grate[i]; // now chunks is the total amount of grates connecte
  2099.                     }
  2100.             }
  2101.             */
  2102.            
  2103.             for(i=0;i<chunks_repair_grate.size;i++)
  2104.             {
  2105.                     if (IsDefined (chunks_repair_grate[i].script_parameters) && (chunks_repair_grate[i].script_parameters == "grate") )
  2106.                     {      
  2107.                             if ( IsDefined ( chunks_repair_grate[i].script_noteworthy ) && ( chunks_repair_grate[i].script_noteworthy == "1" ) )
  2108.                             {
  2109.                                             grate_repair_order1[grate_repair_order1.size] = chunks_repair_grate[i];
  2110.                                             // send back order here
  2111.                             }
  2112.                             if ( IsDefined ( chunks_repair_grate[i].script_noteworthy ) && ( chunks_repair_grate[i].script_noteworthy == "2" ) )
  2113.                             {
  2114.                                             grate_repair_order2[grate_repair_order2.size] = chunks_repair_grate[i];
  2115.                                                     // send back order here
  2116.                             }
  2117.                             if ( IsDefined ( chunks_repair_grate[i].script_noteworthy ) && ( chunks_repair_grate[i].script_noteworthy == "3" ) )
  2118.                             {
  2119.                                             grate_repair_order3[grate_repair_order3.size] = chunks_repair_grate[i];
  2120.                                                     // send back order here
  2121.                             }
  2122.                             if ( IsDefined ( chunks_repair_grate[i].script_noteworthy ) && ( chunks_repair_grate[i].script_noteworthy == "4" ) )
  2123.                             {
  2124.                                             grate_repair_order4[grate_repair_order4.size] = chunks_repair_grate[i];
  2125.                                                     // send back order here
  2126.                             }
  2127.                             if ( IsDefined ( chunks_repair_grate[i].script_noteworthy ) && ( chunks_repair_grate[i].script_noteworthy == "5" ) )
  2128.                             {
  2129.                                             grate_repair_order5[grate_repair_order5.size] = chunks_repair_grate[i];
  2130.                                                     // send back order here
  2131.                             }
  2132.                             if ( IsDefined ( chunks_repair_grate[i].script_noteworthy ) && ( chunks_repair_grate[i].script_noteworthy == "6" ) )
  2133.                             {
  2134.                                             grate_repair_order6[grate_repair_order6.size] = chunks_repair_grate[i];
  2135.                                                     // send back order here
  2136.                             }
  2137.                     }
  2138.             }
  2139.            
  2140.             for(i=0;i<chunks_repair_grate.size;i++) // Go through the array
  2141.             {
  2142.                     if (IsDefined (chunks_repair_grate[i].script_parameters) && (chunks_repair_grate[i].script_parameters == "grate") )
  2143.                     {      
  2144.                             if( IsDefined ( grate_repair_order1[i] ) ) // last one here
  2145.                             {      
  2146.                            
  2147.                                     if( ( grate_repair_order6[i].state == "destroyed" )  )
  2148.                                             {
  2149.                                                             /#
  2150.                                                             IPrintLnBold(" Fix grate6 ");
  2151.                                                             #/
  2152.                                                                     // Here I will tell the other board to replace        
  2153.                                                             return grate_repair_order6[i];
  2154.                                             }
  2155.                                             if(  ( grate_repair_order5[i].state == "destroyed" )  )
  2156.                                             {
  2157.                                                     /#
  2158.                                                     IPrintLnBold(" Fix grate5 ");
  2159.                                                     #/
  2160.                                                     grate_repair_order6[i] thread show_grate_repair();            
  2161.                                                     return grate_repair_order5[i];
  2162.                                             }
  2163.                                             else if( ( grate_repair_order4[i].state == "destroyed" ) )
  2164.                                             {
  2165.                                                     /#
  2166.                                                     IPrintLnBold(" Fix grate4 ");
  2167.                                                     #/
  2168.                                                     grate_repair_order5[i] thread show_grate_repair();    
  2169.                                                     return grate_repair_order4[i];
  2170.                                             }
  2171.                                             else if( ( grate_repair_order3[i].state == "destroyed" ) )
  2172.                                             {
  2173.                                                     /#
  2174.                                                     IPrintLnBold(" Fix grate3 ");
  2175.                                                     #/
  2176.                                                     grate_repair_order4[i] thread show_grate_repair();    
  2177.                                                     return grate_repair_order3[i];
  2178.                                             }
  2179.                                             else if( ( grate_repair_order2[i].state == "destroyed" ) )
  2180.                                             {
  2181.                                                     /#
  2182.                                                     IPrintLnBold(" Fix grate2 ");
  2183.                                                     #/
  2184.                                                     grate_repair_order3[i] thread show_grate_repair();    
  2185.                                                     return grate_repair_order2[i];
  2186.                                             }
  2187.                                             else if( ( grate_repair_order1[i].state == "destroyed" ) )
  2188.                                             {
  2189.                                                     /#
  2190.                                                     IPrintLnBold(" Fix grate1 ");
  2191.                                                     #/
  2192.                                                     grate_repair_order2[i] thread show_grate_repair();    
  2193.                                                     // I need to return nothing here.
  2194.                                                     //return undefined();
  2195.                                                     return grate_repair_order1[i];
  2196.                                             }
  2197.                             }
  2198.                     }
  2199.             }
  2200.     }
  2201.      
  2202.     // Self is grate
  2203.     show_grate_repair()
  2204.     {
  2205.             wait( 0.34 );
  2206.             self Hide();
  2207.     }
  2208.      
  2209.     get_chunk_state()
  2210.     {
  2211.             assertex( isdefined( self.state ) );
  2212.      
  2213.             return self.state;
  2214.     }
  2215.      
  2216.     is_float( num )
  2217.     {
  2218.             val = num - int( num );
  2219.      
  2220.             if( val != 0 )
  2221.             {
  2222.                     return true;
  2223.             }
  2224.             else
  2225.             {
  2226.                     return false;
  2227.             }
  2228.     }
  2229.      
  2230.     array_limiter( array, total )
  2231.     {
  2232.             new_array = [];
  2233.      
  2234.             for( i = 0; i < array.size; i++ )
  2235.             {
  2236.                     if( i < total )
  2237.                     {
  2238.                             new_array[new_array.size] = array[i];
  2239.                     }
  2240.             }
  2241.      
  2242.             return new_array;
  2243.     }
  2244.      
  2245.     array_validate( array )
  2246.     {
  2247.             if( IsDefined( array ) && array.size > 0 )
  2248.             {
  2249.                     return true;
  2250.             }
  2251.             else
  2252.             {
  2253.                     return false;
  2254.             }
  2255.     }
  2256.      
  2257.     add_spawner( spawner )
  2258.     {
  2259.             if( IsDefined( spawner.script_start ) && level.round_number < spawner.script_start )
  2260.             {
  2261.                     return;
  2262.             }
  2263.      
  2264.             if( IsDefined( spawner.is_enabled ) && !spawner.is_enabled)
  2265.             {
  2266.                     return;
  2267.             }
  2268.      
  2269.             if( IsDefined( spawner.has_been_added ) && spawner.has_been_added )
  2270.             {
  2271.                     return;
  2272.             }
  2273.      
  2274.             spawner.has_been_added = true;
  2275.      
  2276.             level.enemy_spawns[level.enemy_spawns.size] = spawner;
  2277.     }
  2278.      
  2279.     fake_physicslaunch( target_pos, power )
  2280.     {
  2281.             start_pos = self.origin;
  2282.            
  2283.             ///////// Math Section
  2284.             // Reverse the gravity so it's negative, you could change the gravity
  2285.             // by just putting a number in there, but if you keep the dvar, then the
  2286.             // user will see it change.
  2287.             gravity = GetDvarInt( #"bg_gravity" ) * -1;
  2288.      
  2289.             dist = Distance( start_pos, target_pos );
  2290.            
  2291.             time = dist / power;
  2292.             delta = target_pos - start_pos;
  2293.             drop = 0.5 * gravity *( time * time );
  2294.            
  2295.             velocity = ( ( delta[0] / time ), ( delta[1] / time ), ( delta[2] - drop ) / time );
  2296.             ///////// End Math Section
  2297.      
  2298.             level thread draw_line_ent_to_pos( self, target_pos );
  2299.             self MoveGravity( velocity, time );
  2300.             return time;
  2301.     }
  2302.      
  2303.     //
  2304.     // Spectating ===================================================================
  2305.     //
  2306.     add_to_spectate_list()
  2307.     {
  2308.             if( !IsDefined( level.spectate_list ) )
  2309.             {
  2310.                     level.spectate_list = [];
  2311.             }
  2312.      
  2313.             level.spectate_list[level.spectate_list.size] = self;
  2314.     }
  2315.      
  2316.     remove_from_spectate_list()
  2317.     {
  2318.             if( !IsDefined( level.spectate_list ) )
  2319.             {
  2320.                     return undefined;
  2321.             }
  2322.      
  2323.             level.spectate_list = array_remove( level.spectate_list, self );
  2324.     }
  2325.      
  2326.     get_next_from_spectate_list( ent )
  2327.     {
  2328.             index = 0;
  2329.             for( i = 0; i < level.spectate_list.size; i++ )
  2330.             {
  2331.                     if( ent == level.spectate_list[i] )
  2332.                     {
  2333.                             index = i;
  2334.                     }
  2335.             }
  2336.      
  2337.             index++;
  2338.      
  2339.             if( index >= level.spectate_list.size )
  2340.             {
  2341.                     index = 0;
  2342.             }
  2343.            
  2344.             return level.spectate_list[index];
  2345.     }
  2346.      
  2347.     get_random_from_spectate_list()
  2348.     {
  2349.             return level.spectate_list[RandomInt(level.spectate_list.size)];
  2350.     }
  2351.      
  2352.     //
  2353.     // STRINGS =======================================================================
  2354.     //
  2355.     add_zombie_hint( ref, text )
  2356.     {
  2357.             if( !IsDefined( level.zombie_hints ) )
  2358.             {
  2359.                     level.zombie_hints = [];
  2360.             }
  2361.      
  2362.             PrecacheString( text );
  2363.             level.zombie_hints[ref] = text;
  2364.     }
  2365.      
  2366.     get_zombie_hint( ref )
  2367.     {
  2368.             if( IsDefined( level.zombie_hints[ref] ) )
  2369.             {
  2370.                     return level.zombie_hints[ref];
  2371.             }
  2372.      
  2373.     /#
  2374.             println( "UNABLE TO FIND HINT STRING " + ref );
  2375.     #/
  2376.             return level.zombie_hints["undefined"];
  2377.     }
  2378.      
  2379.     // self is the trigger( usually spawned in on the fly )
  2380.     // ent is the entity that has the script_hint info
  2381.     set_hint_string( ent, default_ref )
  2382.     {
  2383.             if( IsDefined( ent.script_hint ) )
  2384.             {
  2385.                     self SetHintString( get_zombie_hint( ent.script_hint ) );
  2386.             }
  2387.             else
  2388.             {
  2389.                     self SetHintString( get_zombie_hint( default_ref ) );
  2390.             }
  2391.     }
  2392.      
  2393.     //
  2394.     // SOUNDS ===========================================================
  2395.     //
  2396.      
  2397.     add_sound( ref, alias )
  2398.     {
  2399.             if( !IsDefined( level.zombie_sounds ) )
  2400.             {
  2401.                     level.zombie_sounds = [];
  2402.             }
  2403.      
  2404.             level.zombie_sounds[ref] = alias;
  2405.     }
  2406.      
  2407.     play_sound_at_pos( ref, pos, ent )
  2408.     {
  2409.             if( IsDefined( ent ) )
  2410.             {
  2411.                     if( IsDefined( ent.script_soundalias ) )
  2412.                     {
  2413.                             PlaySoundAtPosition( ent.script_soundalias, pos );
  2414.                             return;
  2415.                     }
  2416.      
  2417.                     if( IsDefined( self.script_sound ) )
  2418.                     {
  2419.                             ref = self.script_sound;
  2420.                     }
  2421.             }
  2422.      
  2423.             if( ref == "none" )
  2424.             {
  2425.                     return;
  2426.             }
  2427.      
  2428.             if( !IsDefined( level.zombie_sounds[ref] ) )
  2429.             {
  2430.                     AssertMsg( "Sound \"" + ref + "\" was not put to the zombie sounds list, please use add_sound( ref, alias ) at the start of your level." );
  2431.                     return;
  2432.             }
  2433.            
  2434.             PlaySoundAtPosition( level.zombie_sounds[ref], pos );
  2435.     }
  2436.      
  2437.     play_sound_on_ent( ref )
  2438.     {
  2439.             if( IsDefined( self.script_soundalias ) )
  2440.             {
  2441.                     self PlaySound( self.script_soundalias );
  2442.                     return;
  2443.             }
  2444.      
  2445.             if( IsDefined( self.script_sound ) )
  2446.             {
  2447.                     ref = self.script_sound;
  2448.             }
  2449.      
  2450.             if( ref == "none" )
  2451.             {
  2452.                     return;
  2453.             }
  2454.      
  2455.             if( !IsDefined( level.zombie_sounds[ref] ) )
  2456.             {
  2457.                     AssertMsg( "Sound \"" + ref + "\" was not put to the zombie sounds list, please use add_sound( ref, alias ) at the start of your level." );
  2458.                     return;
  2459.             }
  2460.      
  2461.             self PlaySound( level.zombie_sounds[ref] );
  2462.     }
  2463.      
  2464.     play_loopsound_on_ent( ref )
  2465.     {
  2466.             if( IsDefined( self.script_firefxsound ) )
  2467.             {
  2468.                     ref = self.script_firefxsound;
  2469.             }
  2470.      
  2471.             if( ref == "none" )
  2472.             {
  2473.                     return;
  2474.             }
  2475.      
  2476.             if( !IsDefined( level.zombie_sounds[ref] ) )
  2477.             {
  2478.                     AssertMsg( "Sound \"" + ref + "\" was not put to the zombie sounds list, please use add_sound( ref, alias ) at the start of your level." );
  2479.                     return;
  2480.             }
  2481.      
  2482.             self PlaySound( level.zombie_sounds[ref] );
  2483.     }
  2484.      
  2485.      
  2486.     string_to_float( string )
  2487.     {
  2488.             floatParts = strTok( string, "." );
  2489.             if ( floatParts.size == 1 )
  2490.                     return int(floatParts[0]);
  2491.      
  2492.             whole = int(floatParts[0]);
  2493.             // Convert the decimal part into a floating point value
  2494.             decimal = 0;
  2495.             for ( i=floatParts[1].size-1; i>=0; i-- )
  2496.             {
  2497.                     decimal = decimal/10 + int(floatParts[1][i])/10;
  2498.             }
  2499.      
  2500.             if ( whole >= 0 )
  2501.                     return (whole + decimal);
  2502.             else
  2503.                     return (whole - decimal);
  2504.     }
  2505.      
  2506.     //
  2507.     // TABLE LOOK SECTION ============================================================
  2508.     //
  2509.      
  2510.     //      Read a value from a table and set the related level.zombie_var
  2511.     //
  2512.     set_zombie_var( var, value, is_float, column )
  2513.     {
  2514.             if ( !IsDefined( is_float ) )
  2515.             {
  2516.                     is_float = false;
  2517.             }
  2518.             if ( !IsDefined(column) )
  2519.             {
  2520.                     column = 1;
  2521.             }
  2522.      
  2523.             // First look it up in the table
  2524.             table = "mp/zombiemode.csv";
  2525.             table_value = TableLookUp( table, 0, var, column );
  2526.      
  2527.             if ( IsDefined( table_value ) && table_value != "" )
  2528.             {
  2529.                     if( is_float )
  2530.                     {
  2531.                             value = float( table_value );
  2532.                     }
  2533.                     else
  2534.                     {
  2535.                             value = int( table_value );
  2536.                     }
  2537.             }
  2538.      
  2539.             level.zombie_vars[var] = value;
  2540.             return value;
  2541.     }
  2542.      
  2543.      
  2544.     //      Read a value from a table and return the result
  2545.     //
  2546.     get_table_var( table, var_name, value, is_float, column )
  2547.     {
  2548.             if ( !IsDefined(table) )
  2549.             {
  2550.                     table = "mp/zombiemode.csv";
  2551.             }
  2552.             if ( !IsDefined(is_float) )
  2553.             {
  2554.                     is_float = false;
  2555.             }
  2556.             if ( !IsDefined(column) )
  2557.             {
  2558.                     column = 1;
  2559.             }
  2560.      
  2561.             // First look it up in the table
  2562.             table_value = TableLookUp( table, 0, var_name, column );
  2563.             if ( IsDefined( table_value ) && table_value != "" )
  2564.             {
  2565.                     if( is_float )
  2566.                     {
  2567.                             value = string_to_float( table_value );
  2568.                     }
  2569.                     else
  2570.                     {
  2571.                             value = int( table_value );
  2572.                     }
  2573.             }
  2574.      
  2575.             return value;
  2576.     }
  2577.      
  2578.      
  2579.     //
  2580.     // DEBUG SECTION =================================================================
  2581.     //
  2582.     // shameless stole from austin
  2583.     debug_ui()
  2584.     {
  2585.     /#
  2586.             wait 1;
  2587.            
  2588.             x = 510;
  2589.             y = 280;
  2590.             menu_name = "zombie debug";
  2591.      
  2592.             menu_bkg = maps\_debug::new_hud( menu_name, undefined, x, y, 1 );
  2593.             menu_bkg SetShader( "white", 160, 120 );
  2594.             menu_bkg.alignX = "left";
  2595.             menu_bkg.alignY = "top";
  2596.             menu_bkg.sort = 10;
  2597.             menu_bkg.alpha = 0.6;  
  2598.             menu_bkg.color = ( 0.0, 0.0, 0.5 );
  2599.      
  2600.             menu[0] = maps\_debug::new_hud( menu_name, "SD:",               x + 5, y + 10, 1 );
  2601.             menu[1] = maps\_debug::new_hud( menu_name, "ZH:",               x + 5, y + 20, 1 );
  2602.             menu[1] = maps\_debug::new_hud( menu_name, "ZS:",               x + 5, y + 30, 1 );
  2603.             menu[1] = maps\_debug::new_hud( menu_name, "WN:",               x + 5, y + 40, 1 );
  2604.      
  2605.             x_offset = 120;
  2606.      
  2607.             // enum
  2608.             spawn_delay                      = menu.size;
  2609.             zombie_health            = menu.size + 1;
  2610.             zombie_speed             = menu.size + 2;
  2611.             round_number                     = menu.size + 3;
  2612.      
  2613.             menu[spawn_delay]                = maps\_debug::new_hud( menu_name, "", x + x_offset, y + 10, 1 );
  2614.             menu[zombie_health]      = maps\_debug::new_hud( menu_name, "", x + x_offset, y + 20, 1 );
  2615.             menu[zombie_speed]       = maps\_debug::new_hud( menu_name, "", x + x_offset, y + 30, 1 );
  2616.             menu[round_number]       =      maps\_debug::new_hud( menu_name, "", x + x_offset, y + 40, 1 );
  2617.            
  2618.             while( true )
  2619.             {
  2620.                     wait( 0.05 );
  2621.      
  2622.                     menu[spawn_delay]               SetText( level.zombie_vars["zombie_spawn_delay"] );
  2623.                     menu[zombie_health]             SetText( level.zombie_health );
  2624.                     menu[zombie_speed]              SetText( level.zombie_move_speed );
  2625.                     menu[round_number]              SetText( level.round_number );
  2626.             }
  2627.     #/
  2628.     }
  2629.      
  2630.     hudelem_count()
  2631.     {
  2632.     /#
  2633.             max = 0;
  2634.             curr_total = 0;
  2635.             while( 1 )
  2636.             {
  2637.                     if( level.hudelem_count > max )
  2638.                     {
  2639.                             max = level.hudelem_count;
  2640.                     }
  2641.                    
  2642.                     println( "HudElems: " + level.hudelem_count + "[Peak: " + max + "]" );
  2643.                     wait( 0.05 );
  2644.             }
  2645.     #/
  2646.     }
  2647.      
  2648.     debug_round_advancer()
  2649.     {
  2650.     /#
  2651.             while( 1 )
  2652.             {
  2653.                     zombs = getaiarray( "axis" );
  2654.                    
  2655.                     for( i = 0; i < zombs.size; i++ )
  2656.                     {
  2657.                             zombs[i] dodamage( zombs[i].health * 100, ( 0, 0, 0 ) );
  2658.                             wait 0.5;
  2659.                     }
  2660.             }      
  2661.     #/
  2662.     }
  2663.      
  2664.     print_run_speed( speed )
  2665.     {
  2666.     /#
  2667.             self endon( "death" );
  2668.             while( 1 )
  2669.             {
  2670.                     print3d( self.origin +( 0, 0, 64 ), speed, ( 1, 1, 1 ) );
  2671.                     wait 0.05;
  2672.             }
  2673.     #/
  2674.     }
  2675.      
  2676.     draw_line_ent_to_ent( ent1, ent2 )
  2677.     {
  2678.     /#
  2679.             if( GetDvarInt( #"zombie_debug" ) != 1 )
  2680.             {
  2681.                     return;
  2682.             }
  2683.      
  2684.             ent1 endon( "death" );
  2685.             ent2 endon( "death" );
  2686.      
  2687.             while( 1 )
  2688.             {
  2689.                     line( ent1.origin, ent2.origin );
  2690.                     wait( 0.05 );
  2691.             }
  2692.     #/
  2693.     }
  2694.      
  2695.     draw_line_ent_to_pos( ent, pos, end_on )
  2696.     {
  2697.     /#
  2698.             if( GetDvarInt( #"zombie_debug" ) != 1 )
  2699.             {
  2700.                     return;
  2701.             }
  2702.      
  2703.             ent endon( "death" );
  2704.      
  2705.             ent notify( "stop_draw_line_ent_to_pos" );
  2706.             ent endon( "stop_draw_line_ent_to_pos" );
  2707.      
  2708.             if( IsDefined( end_on ) )
  2709.             {
  2710.                     ent endon( end_on );
  2711.             }
  2712.      
  2713.             while( 1 )
  2714.             {
  2715.                     line( ent.origin, pos );
  2716.                     wait( 0.05 );
  2717.             }
  2718.     #/
  2719.     }
  2720.      
  2721.     debug_print( msg )
  2722.     {
  2723.     /#
  2724.             if( GetDvarInt( #"zombie_debug" ) > 0 )
  2725.             {
  2726.                     println( "######### ZOMBIE: " + msg );
  2727.             }
  2728.     #/
  2729.     }
  2730.      
  2731.     debug_blocker( pos, rad, height )
  2732.     {
  2733.     /#
  2734.             self notify( "stop_debug_blocker" );
  2735.             self endon( "stop_debug_blocker" );
  2736.            
  2737.             for( ;; )
  2738.             {
  2739.                     if( GetDvarInt( #"zombie_debug" ) != 1 )
  2740.                     {
  2741.                             return;
  2742.                     }
  2743.      
  2744.                     wait( 0.05 );
  2745.                     drawcylinder( pos, rad, height );
  2746.                    
  2747.             }
  2748.     #/
  2749.     }
  2750.      
  2751.     drawcylinder( pos, rad, height )
  2752.     {
  2753.     /#
  2754.             currad = rad;
  2755.             curheight = height;
  2756.      
  2757.             for( r = 0; r < 20; r++ )
  2758.             {
  2759.                     theta = r / 20 * 360;
  2760.                     theta2 = ( r + 1 ) / 20 * 360;
  2761.      
  2762.                     line( pos +( cos( theta ) * currad, sin( theta ) * currad, 0 ), pos +( cos( theta2 ) * currad, sin( theta2 ) * currad, 0 ) );
  2763.                     line( pos +( cos( theta ) * currad, sin( theta ) * currad, curheight ), pos +( cos( theta2 ) * currad, sin( theta2 ) * currad, curheight ) );
  2764.                     line( pos +( cos( theta ) * currad, sin( theta ) * currad, 0 ), pos +( cos( theta ) * currad, sin( theta ) * currad, curheight ) );
  2765.             }
  2766.     #/
  2767.     }
  2768.      
  2769.     print3d_at_pos( msg, pos, thread_endon, offset )
  2770.     {
  2771.     /#
  2772.             self endon( "death" );
  2773.      
  2774.             if( IsDefined( thread_endon ) )
  2775.             {
  2776.                     self notify( thread_endon );
  2777.                     self endon( thread_endon );
  2778.             }
  2779.      
  2780.             if( !IsDefined( offset ) )
  2781.             {
  2782.                     offset = ( 0, 0, 0 );
  2783.             }
  2784.      
  2785.             while( 1 )
  2786.             {
  2787.                     print3d( self.origin + offset, msg );
  2788.                     wait( 0.05 );
  2789.             }
  2790.     #/
  2791.     }
  2792.      
  2793.     debug_breadcrumbs()
  2794.     {
  2795.     /#
  2796.             self endon( "disconnect" );
  2797.      
  2798.             while( 1 )
  2799.             {
  2800.                     if( GetDvarInt( #"zombie_debug" ) != 1 )
  2801.                     {
  2802.                             wait( 1 );
  2803.                             continue;
  2804.                     }
  2805.      
  2806.                     for( i = 0; i < self.zombie_breadcrumbs.size; i++ )
  2807.                     {
  2808.                             drawcylinder( self.zombie_breadcrumbs[i], 5, 5 );
  2809.                     }
  2810.      
  2811.                     wait( 0.05 );
  2812.             }
  2813.     #/
  2814.     }
  2815.      
  2816.     debug_attack_spots_taken()
  2817.     {
  2818.     // this section was totally commented out.
  2819.             while( 1 )
  2820.             {
  2821.                     if( GetDvarInt( #"zombie_debug" ) != 2 )
  2822.                     {
  2823.                             wait( 1 );
  2824.                             continue;
  2825.                     }
  2826.      
  2827.                     wait( 0.05 );
  2828.                     count = 0;
  2829.                     for( i = 0; i < self.attack_spots_taken.size; i++ )
  2830.                     {
  2831.                             if( self.attack_spots_taken[i] )
  2832.                             {
  2833.                                     count++;
  2834.                             }
  2835.                     }
  2836.      
  2837.                     msg = "" + count + " / " + self.attack_spots_taken.size;
  2838.                     print3d( self.origin, msg );
  2839.             }
  2840.      
  2841.     }
  2842.      
  2843.     float_print3d( msg, time )
  2844.     {
  2845.     /#
  2846.             self endon( "death" );
  2847.      
  2848.             time = GetTime() + ( time * 1000 );
  2849.             offset = ( 0, 0, 72 );
  2850.             while( GetTime() < time )
  2851.             {
  2852.                     offset = offset + ( 0, 0, 2 );
  2853.                     print3d( self.origin + offset, msg, ( 1, 1, 1 ) );
  2854.                     wait( 0.05 );
  2855.             }
  2856.     #/
  2857.     }
  2858.     do_player_vo(snd, variation_count)
  2859.     {
  2860.      
  2861.            
  2862.             index = maps\_zombiemode_weapons::get_player_index(self);
  2863.            
  2864.             // updated to new alias format - Steve G
  2865.             sound = "zmb_vox_plr_" + index + "_" + snd;
  2866.             if(IsDefined (variation_count))
  2867.             {
  2868.                     sound = sound + "_" + randomintrange(0, variation_count);
  2869.             }
  2870.             if(!isDefined(level.player_is_speaking))
  2871.             {
  2872.                     level.player_is_speaking = 0;
  2873.             }
  2874.            
  2875.             if (level.player_is_speaking == 0)
  2876.             {      
  2877.                     level.player_is_speaking = 1;
  2878.                     self playsound(sound, "sound_done");                  
  2879.                     self waittill("sound_done");
  2880.                     //This ensures that there is at least 3 seconds waittime before playing another VO.
  2881.                     wait(2);
  2882.                     level.player_is_speaking = 0;
  2883.             }      
  2884.     }
  2885.      
  2886.     is_magic_bullet_shield_enabled( ent )
  2887.     {
  2888.             if( !IsDefined( ent ) )
  2889.                     return false;
  2890.      
  2891.             return ( IsDefined( ent.magic_bullet_shield ) && ent.magic_bullet_shield == true );
  2892.     }
  2893.      
  2894.     really_play_2D_sound(sound)
  2895.     {
  2896.             temp_ent = spawn("script_origin", (0,0,0));
  2897.             temp_ent playsound (sound, sound + "wait");
  2898.             temp_ent waittill (sound + "wait");
  2899.             wait(0.05);
  2900.             temp_ent delete();    
  2901.      
  2902.     }
  2903.      
  2904.      
  2905.     play_sound_2D(sound)
  2906.     {
  2907.             level thread really_play_2D_sound(sound);
  2908.            
  2909.             /*
  2910.             if(!isdefined(level.playsound2dent))
  2911.             {
  2912.                     level.playsound2dent = spawn("script_origin",(0,0,0));
  2913.             }
  2914.            
  2915.             //players=getplayers();
  2916.             level.playsound2dent playsound ( sound );
  2917.             */
  2918.             /*
  2919.             temp_ent = spawn("script_origin", (0,0,0));
  2920.             temp_ent playsound (sound, sound + "wait");
  2921.             temp_ent waittill (sound + "wait");
  2922.             wait(0.05);
  2923.             temp_ent delete();    
  2924.             */    
  2925.     }
  2926.      
  2927.     include_weapon( weapon_name, in_box, collector, weighting_func )
  2928.     {
  2929.             if( !isDefined( in_box ) )
  2930.             {
  2931.                     in_box = true;
  2932.             }
  2933.             if( !isDefined( collector ) )
  2934.             {
  2935.                     collector = false;
  2936.             }
  2937.             maps\_zombiemode_weapons::include_zombie_weapon( weapon_name, in_box, collector, weighting_func );
  2938.     }
  2939.      
  2940.     include_powerup( powerup_name )
  2941.     {
  2942.             maps\_zombiemode_powerups::include_zombie_powerup( powerup_name );
  2943.     }
  2944.      
  2945.     // Allows triggers to be un/seen by players
  2946.     trigger_invisible( enable )
  2947.     {
  2948.             players = getplayers();
  2949.             for ( i = 0; i < players.size; i++ )
  2950.             {
  2951.                     if ( isdefined( players[i] ) )
  2952.                     {
  2953.                             self SetInvisibleToPlayer( players[i], enable );
  2954.                     }
  2955.             }
  2956.     }
  2957.      
  2958.      
  2959.     // Print3d
  2960.     print3d_ent( text, color, scale, offset, end_msg, overwrite )
  2961.     {
  2962.             self endon("death");
  2963.      
  2964.             if ( IsDefined(overwrite) && overwrite && IsDefined( self._debug_print3d_msg ) )
  2965.             {
  2966.                     // Kill the previous thread
  2967.                     self notify( "end_print3d" );
  2968.                     wait(0.05);
  2969.             }
  2970.      
  2971.             self endon("end_print3d");
  2972.      
  2973.             if ( !IsDefined(color) )
  2974.             {
  2975.                     color = (1,1,1);
  2976.             }
  2977.      
  2978.             if ( !IsDefined(scale) )
  2979.             {
  2980.                     scale = 1.0;
  2981.             }
  2982.      
  2983.             if ( !IsDefined(offset) )
  2984.             {
  2985.                     offset = (0,0,0);
  2986.             }
  2987.      
  2988.             if ( IsDefined(end_msg) )
  2989.             {
  2990.                     self endon(end_msg);
  2991.             }
  2992.      
  2993.             // This way you can change the message dynamically by changing the var
  2994.             self._debug_print3d_msg = text;
  2995.      
  2996.             while (1)
  2997.             {
  2998.                     print3d( self.origin+offset, self._debug_print3d_msg, color, scale );
  2999.                     wait( 0.05 );
  3000.             }
  3001.     }
  3002.      
  3003.      
  3004.     // Copied from _class
  3005.     // including grenade launcher, grenade, bazooka, betty, satchel charge
  3006.     isExplosiveDamage( meansofdeath )
  3007.     {
  3008.             explosivedamage = "MOD_GRENADE MOD_GRENADE_SPLASH MOD_PROJECTILE_SPLASH MOD_EXPLOSIVE";
  3009.      
  3010.             if( isSubstr( explosivedamage, meansofdeath ) )
  3011.                     return true;
  3012.             return false;
  3013.     }
  3014.      
  3015.     // if primary weapon damage
  3016.     isPrimaryDamage( meansofdeath )
  3017.     {
  3018.             // including pistols as well since sometimes they share ammo
  3019.             if( meansofdeath == "MOD_RIFLE_BULLET" || meansofdeath == "MOD_PISTOL_BULLET" )
  3020.                     return true;
  3021.             return false;
  3022.     }
  3023.      
  3024.     isFireDamage( weapon, meansofdeath )
  3025.     {
  3026.             if ( ( isSubStr( weapon, "flame" ) || isSubStr( weapon, "molotov_" ) || isSubStr( weapon, "napalmblob_" ) ) && ( meansofdeath == "MOD_BURNED" || meansofdeath == "MOD_GRENADE" || meansofdeath == "MOD_GRENADE_SPLASH" ) )
  3027.                     return true;
  3028.             return false;
  3029.     }
  3030.      
  3031.     isPlayerExplosiveWeapon( weapon, meansofdeath )
  3032.     {
  3033.             if ( !isExplosiveDamage( meansofdeath ) )
  3034.                     return false;
  3035.      
  3036.             if ( weapon == "artillery_mp" )
  3037.                     return false;
  3038.      
  3039.             // no tank main guns
  3040.             if ( issubstr(weapon, "turret" ) )
  3041.                     return false;
  3042.      
  3043.             return true;
  3044.     }
  3045.      
  3046.     swap_to_dissolve_models()
  3047.     {
  3048.             /*
  3049.             self SetModel( self.model + "_dslv" );
  3050.      
  3051.             modelnames = [];
  3052.             tagnames = [];
  3053.             size = self GetAttachSize();
  3054.             for( i = 0; i < size; i++ )
  3055.             {
  3056.                     modelnames[modelnames.size] = self GetAttachModelName( i );
  3057.                     tagnames[tagnames.size] = self GetAttachTagName( i );
  3058.             }
  3059.      
  3060.             for( i = 0; i < size; i++ )
  3061.             {
  3062.                     self Detach( modelnames[i] );
  3063.                     modelnames[i] = modelnames[i] + "_dslv";
  3064.                     self Attach( modelnames[i], tagnames[i] );
  3065.             }
  3066.             */
  3067.     }
  3068.      
  3069.     // used to add the team pot icon to a hint string
  3070.     add_teampot_icon()
  3071.     {
  3072.             flag_wait( "all_players_connected" );
  3073.             players = GetPlayers();
  3074.             //      Disable team money pool icon
  3075.             /*if ( players.size > 1 )
  3076.             {
  3077.                     self SetCursorHint( "HINT_TEAMPOT" );
  3078.             }
  3079.             else*/
  3080.             {
  3081.                     self SetCursorHint( "HINT_NOICON" );
  3082.             }
  3083.     }
  3084.      
  3085.      
  3086.     //
  3087.     //  Sets the counter's value to the specified number if necessary
  3088.     //      Used in conjunction with precached models
  3089.     //      self is a counter's digit model (0-9)
  3090.     set_counter( value )
  3091.     {
  3092.             if ( self.model != level.counter_model[ value ] )
  3093.             {
  3094.                     self SetModel( level.counter_model[ value ] );
  3095.             }
  3096.     }
  3097.      
  3098.      
  3099.     //
  3100.     //
  3101.     create_counter_hud( x )
  3102.     {
  3103.             if( !IsDefined( x ) )
  3104.             {
  3105.                     x = 0;
  3106.             }
  3107.      
  3108.             hud = create_simple_hud();
  3109.             hud.alignX = "left";
  3110.             hud.alignY = "top";
  3111.             hud.horzAlign = "user_left";
  3112.             hud.vertAlign = "user_top";
  3113.             hud.color = ( 1, 1, 1 );
  3114.     //      hud.color = ( 0.21, 0, 0 );
  3115.             hud.fontscale = 32;
  3116.             hud.x = x;
  3117.             hud.alpha = 0;
  3118.      
  3119.             hud SetShader( "hud_chalk_1", 64, 64 );
  3120.      
  3121.             return hud;
  3122.     }
  3123.      
  3124.      
  3125.     //
  3126.     //      Get the name of the zone that the entity is currently in
  3127.     //      self is the entity to check on
  3128.     get_current_zone()
  3129.     {
  3130.             flag_wait( "zones_initialized" );
  3131.      
  3132.             zkeys = GetArrayKeys( level.zones );
  3133.             // clear out active zone flags
  3134.             for( z=0; z<zkeys.size; z++ )
  3135.             {
  3136.                     zone_name = zkeys[z];
  3137.                     zone = level.zones[ zone_name ];
  3138.      
  3139.                     // Okay check to see if the entity is in one of the zone volumes
  3140.                     for (i = 0; i < zone.volumes.size; i++)
  3141.                     {
  3142.                             if ( self IsTouching(zone.volumes[i]) )
  3143.                             {
  3144.                                     return zone_name;
  3145.                             }
  3146.                     }
  3147.             }
  3148.      
  3149.             return undefined;
  3150.     }
  3151.      
  3152.     remove_mod_from_methodofdeath( mod )
  3153.     {
  3154.             modStrings = strtok( mod, "_" );
  3155.             modName = "";
  3156.             for ( i = 1; i < modStrings.size; i++ )//skip the MOD_
  3157.             {
  3158.                     modName += modStrings[i];
  3159.             }
  3160.            
  3161.             return modName;
  3162.     }
  3163.      
  3164.     set_fog(start_dist, half_dist, half_height, base_height, fog_r, fog_g, fog_b, fog_scale,
  3165.                     sun_col_r, sun_col_g, sun_col_b, sun_dir_x, sun_dir_y, sun_dir_z, sun_start_ang,
  3166.                     sun_stop_ang, fade_time, max_fog_opacity)
  3167.     {
  3168.             self notify("stop_fog");
  3169.             self endon("disconnect");
  3170.             self endon("stop_fog");
  3171.      
  3172.             starting_height = self.origin[2];
  3173.      
  3174.             while( 1 )
  3175.             {
  3176.                     height_offset = self.origin[2] - starting_height;
  3177.      
  3178.                     self    setVolFog(start_dist, half_dist, half_height, base_height, fog_r, fog_g, fog_b, fog_scale,
  3179.                     sun_col_r, sun_col_g, sun_col_b, sun_dir_x, sun_dir_y, sun_dir_z, sun_start_ang,
  3180.                     sun_stop_ang, fade_time, max_fog_opacity);  
  3181.                     wait( fade_time );
  3182.                     fade_time = 1;
  3183.             }
  3184.     }
  3185.      
  3186.     clear_fog_threads()
  3187.     {
  3188.             players = get_players();
  3189.      
  3190.             for( i = 0; i < players.size; i++ )
  3191.             {
  3192.                     players[i] notify( "stop_fog" );
  3193.             }
  3194.     }
  3195.      
  3196.     display_message( msg )
  3197.     {
  3198.             notifyData = spawnStruct();
  3199.             notifyData.titleText = msg;
  3200.             self thread maps\_hud_message::notifyMessage( notifyData );
  3201.     }
  3202.      
  3203.     is_quad()
  3204.     {
  3205.             return self.animname == "quad_zombie";
  3206.     }
  3207.      
  3208.     // ww: increment the is_drinking variable on a player
  3209.     increment_is_drinking()
  3210.     {
  3211.             self endon( "death" );
  3212.            
  3213.             if( self.is_drinking == 0 )
  3214.             {
  3215.                     self DisableOffhandWeapons();
  3216.                     self DisableWeaponCycling();
  3217.             }
  3218.            
  3219.             self.is_drinking++;
  3220.     }
  3221.      
  3222.     // ww: checks is_drinking
  3223.     is_drinking()
  3224.     {
  3225.             self endon( "death" );
  3226.            
  3227.             return ( self.is_drinking > 0 );
  3228.     }
  3229.      
  3230.     // to check if more than one is active at once
  3231.     is_multiple_drinking()
  3232.     {
  3233.             self endon( "death" );
  3234.            
  3235.             return ( self.is_drinking > 1 );
  3236.     }
  3237.      
  3238.     // ww: decrement drinking
  3239.     decrement_is_drinking()
  3240.     {
  3241.             self endon( "death" );
  3242.            
  3243.             if( self.is_drinking > 0 )
  3244.             {
  3245.                     self.is_drinking--;
  3246.             }
  3247.             else
  3248.             {
  3249.                     AssertMsg( "making is_drinking less than 0" );
  3250.             }
  3251.      
  3252.            
  3253.             if( self.is_drinking == 0 )
  3254.             {
  3255.                     self EnableOffhandWeapons();
  3256.                     self EnableWeaponCycling();
  3257.             }
  3258.     }
  3259.      
  3260.     // ww: clear the variable, used for players going in to last stand
  3261.     clear_is_drinking()
  3262.     {
  3263.             self endon( "death" );
  3264.            
  3265.             self.is_drinking = 0;
  3266.            
  3267.             self EnableOffhandWeapons();
  3268.             self EnableWeaponCycling();
  3269.     }
  3270.      
  3271.     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3272.     fade_out(time)
  3273.     {
  3274.             if (!isDefined(time))
  3275.             {
  3276.                     time = 1;
  3277.             }
  3278.             if( !IsDefined(level.introblack) )
  3279.             {
  3280.                     level.introblack = NewHudElem();
  3281.                     level.introblack.x = 0;
  3282.                     level.introblack.y = 0;
  3283.                     level.introblack.horzAlign = "fullscreen";
  3284.                     level.introblack.vertAlign = "fullscreen";
  3285.                     level.introblack.foreground = true;
  3286.                     level.introblack SetShader( "black", 640, 480 );
  3287.                     level.introblack.alpha = 0;
  3288.                     wait .05;
  3289.             }
  3290.      
  3291.             if( time > 0 )
  3292.             {
  3293.                     level.introblack FadeOverTime( time );
  3294.             }
  3295.             level.introblack.alpha = 1;
  3296.      
  3297.             players = get_players();
  3298.             for(i = 0; i < players.size; i++)
  3299.             {
  3300.                     players[i] freezecontrols(true);
  3301.             }
  3302.      
  3303.             wait time;
  3304.     }
  3305.      
  3306.     fade_in( hold_black_time )
  3307.     {
  3308.             if( !IsDefined(level.introblack) )
  3309.             {
  3310.                     level.introblack = NewHudElem();
  3311.                     level.introblack.x = 0;
  3312.                     level.introblack.y = 0;
  3313.                     level.introblack.horzAlign = "fullscreen";
  3314.                     level.introblack.vertAlign = "fullscreen";
  3315.                     level.introblack.foreground = true;
  3316.                     level.introblack SetShader( "black", 640, 480 );
  3317.                     level.introblack.alpha = 1;
  3318.                     wait .05;
  3319.             }
  3320.      
  3321.             level.introblack.alpha = 1;
  3322.      
  3323.             if( IsDefined( hold_black_time ) )
  3324.                     wait hold_black_time;
  3325.             else
  3326.                     wait .2;
  3327.            
  3328.             level.introblack FadeOverTime( 1.5 );
  3329.             level.introblack.alpha = 0;
  3330.            
  3331.      
  3332.             wait 1.5;
  3333.      
  3334.             players = get_players();
  3335.             for(i = 0; i < players.size; i++)
  3336.             {
  3337.                     players[i] freezecontrols(false);
  3338.             }
  3339.             level notify("fade_in_complete");
  3340.     }
  3341.      
  3342.      
  3343.     register_lethal_grenade_for_level( weaponname )
  3344.     {
  3345.             if ( is_lethal_grenade( weaponname ) )
  3346.             {
  3347.                     return;
  3348.             }
  3349.      
  3350.             if ( !isdefined( level.zombie_lethal_grenade_list ) )
  3351.             {
  3352.                     level.zombie_lethal_grenade_list = [];
  3353.             }
  3354.      
  3355.             level.zombie_lethal_grenade_list[level.zombie_lethal_grenade_list.size] = weaponname;
  3356.     }
  3357.      
  3358.      
  3359.     is_lethal_grenade( weaponname )
  3360.     {
  3361.             if ( !isdefined( weaponname ) || !isdefined( level.zombie_lethal_grenade_list ) )
  3362.             {
  3363.                     return false;
  3364.             }
  3365.      
  3366.             for ( i = 0; i < level.zombie_lethal_grenade_list.size; i++ )
  3367.             {
  3368.                     if ( weaponname == level.zombie_lethal_grenade_list[i] )
  3369.                     {
  3370.                             return true;
  3371.                     }
  3372.             }
  3373.            
  3374.             return false;
  3375.     }
  3376.      
  3377.      
  3378.     is_player_lethal_grenade( weaponname )
  3379.     {
  3380.             if ( !isdefined( weaponname ) || !isdefined( self.current_lethal_grenade ) )
  3381.             {
  3382.                     return false;
  3383.             }
  3384.      
  3385.             return self.current_lethal_grenade == weaponname;
  3386.     }
  3387.      
  3388.      
  3389.     get_player_lethal_grenade()
  3390.     {
  3391.             return self.current_lethal_grenade;
  3392.     }
  3393.      
  3394.      
  3395.     set_player_lethal_grenade( weaponname )
  3396.     {
  3397.             self.current_lethal_grenade = weaponname;
  3398.     }
  3399.      
  3400.      
  3401.     init_player_lethal_grenade()
  3402.     {
  3403.             self set_player_lethal_grenade( level.zombie_lethal_grenade_player_init );
  3404.     }
  3405.      
  3406.      
  3407.     register_tactical_grenade_for_level( weaponname )
  3408.     {
  3409.             if ( is_tactical_grenade( weaponname ) )
  3410.             {
  3411.                     return;
  3412.             }
  3413.      
  3414.             if ( !isdefined( level.zombie_tactical_grenade_list ) )
  3415.             {
  3416.                     level.zombie_tactical_grenade_list = [];
  3417.             }
  3418.      
  3419.             level.zombie_tactical_grenade_list[level.zombie_tactical_grenade_list.size] = weaponname;
  3420.     }
  3421.      
  3422.      
  3423.     is_tactical_grenade( weaponname )
  3424.     {
  3425.             if ( !isdefined( weaponname ) || !isdefined( level.zombie_tactical_grenade_list ) )
  3426.             {
  3427.                     return false;
  3428.             }
  3429.      
  3430.             for ( i = 0; i < level.zombie_tactical_grenade_list.size; i++ )
  3431.             {
  3432.                     if ( weaponname == level.zombie_tactical_grenade_list[i] )
  3433.                     {
  3434.                             return true;
  3435.                     }
  3436.             }
  3437.            
  3438.             return false;
  3439.     }
  3440.      
  3441.      
  3442.     is_player_tactical_grenade( weaponname )
  3443.     {
  3444.             if ( !isdefined( weaponname ) || !isdefined( self.current_tactical_grenade ) )
  3445.             {
  3446.                     return false;
  3447.             }
  3448.      
  3449.             return self.current_tactical_grenade == weaponname;
  3450.     }
  3451.      
  3452.      
  3453.     get_player_tactical_grenade()
  3454.     {
  3455.             return self.current_tactical_grenade;
  3456.     }
  3457.      
  3458.      
  3459.     set_player_tactical_grenade( weaponname )
  3460.     {
  3461.             self.current_tactical_grenade = weaponname;
  3462.     }
  3463.      
  3464.      
  3465.     init_player_tactical_grenade()
  3466.     {
  3467.             self set_player_tactical_grenade( level.zombie_tactical_grenade_player_init );
  3468.     }
  3469.      
  3470.      
  3471.     register_placeable_mine_for_level( weaponname )
  3472.     {
  3473.             if ( is_placeable_mine( weaponname ) )
  3474.             {
  3475.                     return;
  3476.             }
  3477.      
  3478.             if ( !isdefined( level.zombie_placeable_mine_list ) )
  3479.             {
  3480.                     level.zombie_placeable_mine_list = [];
  3481.             }
  3482.      
  3483.             level.zombie_placeable_mine_list[level.zombie_placeable_mine_list.size] = weaponname;
  3484.     }
  3485.      
  3486.      
  3487.     is_placeable_mine( weaponname )
  3488.     {
  3489.             if ( !isdefined( weaponname ) || !isdefined( level.zombie_placeable_mine_list ) )
  3490.             {
  3491.                     return false;
  3492.             }
  3493.      
  3494.             for ( i = 0; i < level.zombie_placeable_mine_list.size; i++ )
  3495.             {
  3496.                     if ( weaponname == level.zombie_placeable_mine_list[i] )
  3497.                     {
  3498.                             return true;
  3499.                     }
  3500.             }
  3501.            
  3502.             return false;
  3503.     }
  3504.      
  3505.      
  3506.     is_player_placeable_mine( weaponname )
  3507.     {
  3508.             if ( !isdefined( weaponname ) || !isdefined( self.current_placeable_mine ) )
  3509.             {
  3510.                     return false;
  3511.             }
  3512.      
  3513.             return self.current_placeable_mine == weaponname;
  3514.     }
  3515.      
  3516.      
  3517.     get_player_placeable_mine()
  3518.     {
  3519.             return self.current_placeable_mine;
  3520.     }
  3521.      
  3522.      
  3523.     set_player_placeable_mine( weaponname )
  3524.     {
  3525.             self.current_placeable_mine = weaponname;
  3526.     }
  3527.      
  3528.      
  3529.     init_player_placeable_mine()
  3530.     {
  3531.             self set_player_placeable_mine( level.zombie_placeable_mine_player_init );
  3532.     }
  3533.      
  3534.      
  3535.     register_melee_weapon_for_level( weaponname )
  3536.     {
  3537.             if ( is_melee_weapon( weaponname ) )
  3538.             {
  3539.                     return;
  3540.             }
  3541.      
  3542.             if ( !isdefined( level.zombie_melee_weapon_list ) )
  3543.             {
  3544.                     level.zombie_melee_weapon_list = [];
  3545.             }
  3546.      
  3547.             level.zombie_melee_weapon_list[level.zombie_melee_weapon_list.size] = weaponname;
  3548.     }
  3549.      
  3550.      
  3551.     is_melee_weapon( weaponname )
  3552.     {
  3553.             if ( !isdefined( weaponname ) || !isdefined( level.zombie_melee_weapon_list ) )
  3554.             {
  3555.                     return false;
  3556.             }
  3557.      
  3558.             for ( i = 0; i < level.zombie_melee_weapon_list.size; i++ )
  3559.             {
  3560.                     if ( weaponname == level.zombie_melee_weapon_list[i] )
  3561.                     {
  3562.                             return true;
  3563.                     }
  3564.             }
  3565.            
  3566.             return false;
  3567.     }
  3568.      
  3569.      
  3570.     is_player_melee_weapon( weaponname )
  3571.     {
  3572.             if ( !isdefined( weaponname ) || !isdefined( self.current_melee_weapon ) )
  3573.             {
  3574.                     return false;
  3575.             }
  3576.      
  3577.             return self.current_melee_weapon == weaponname;
  3578.     }
  3579.      
  3580.      
  3581.     get_player_melee_weapon()
  3582.     {
  3583.             return self.current_melee_weapon;
  3584.     }
  3585.      
  3586.      
  3587.     set_player_melee_weapon( weaponname )
  3588.     {
  3589.             self.current_melee_weapon = weaponname;
  3590.     }
  3591.      
  3592.      
  3593.     init_player_melee_weapon()
  3594.     {
  3595.             self set_player_melee_weapon( level.zombie_melee_weapon_player_init );
  3596.     }
  3597.      
  3598.      
  3599.     register_offhand_weapons_for_level_defaults()
  3600.     {
  3601.             if ( isdefined( level.register_offhand_weapons_for_level_defaults_override ) )
  3602.             {
  3603.                     [[ level.register_offhand_weapons_for_level_defaults_override ]]();
  3604.                     return;
  3605.             }
  3606.      
  3607.             register_lethal_grenade_for_level( "frag_grenade_zm" );
  3608.             level.zombie_lethal_grenade_player_init = "frag_grenade_zm";
  3609.      
  3610.             register_tactical_grenade_for_level( "zombie_cymbal_monkey" );
  3611.             level.zombie_tactical_grenade_player_init = undefined;
  3612.      
  3613.             register_placeable_mine_for_level( "claymore_zm" );
  3614.             level.zombie_placeable_mine_player_init = undefined;
  3615.      
  3616.             register_melee_weapon_for_level( "knife_zm" );
  3617.             register_melee_weapon_for_level( "bowie_knife_zm" );
  3618.             level.zombie_melee_weapon_player_init = "knife_zm";
  3619.     }
  3620.      
  3621.      
  3622.     init_player_offhand_weapons()
  3623.     {
  3624.             init_player_lethal_grenade();
  3625.             init_player_tactical_grenade();
  3626.             init_player_placeable_mine();
  3627.             init_player_melee_weapon();
  3628.     }
  3629.      
  3630.      
  3631.     is_offhand_weapon( weaponname )
  3632.     {
  3633.             return (is_lethal_grenade( weaponname ) || is_tactical_grenade( weaponname ) || is_placeable_mine( weaponname ) || is_melee_weapon( weaponname ) );
  3634.     }
  3635.      
  3636.      
  3637.     is_player_offhand_weapon( weaponname )
  3638.     {
  3639.             return (self is_player_lethal_grenade( weaponname ) || self is_player_tactical_grenade( weaponname ) || self is_player_placeable_mine( weaponname )  || self is_player_melee_weapon( weaponname ) );
  3640.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement