burc_2004

_zm_ai_zloth_buildables.gsc

Oct 22nd, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 21.26 KB | None | 0 0
  1. #include maps/mp/zombies/_zm_unitrigger;
  2. #include maps/mp/zm_buried_buildables;
  3. #include maps/mp/zm_buried;
  4. #include maps/mp/zombies/_zm_zonemgr;
  5. #include maps/mp/zombies/_zm_equipment;
  6. #include maps/mp/animscripts/zm_shared;
  7. #include maps/mp/zombies/_zm_buildables;
  8. #include maps/mp/zombies/_zm_ai_sloth;
  9. #include maps/mp/zombies/_zm_ai_sloth_utility;
  10. #include maps/mp/zombies/_zm_utility;
  11. #include maps/mp/_utility;
  12. #include common_scripts/utility;
  13.  
  14. build_buildable_condition()
  15. {
  16.     while ( level.sloth_buildable_zones.size > 0 )
  17.     {
  18.         i = 0;
  19.         while ( i < level.sloth_buildable_zones.size )
  20.         {
  21.             zone = level.sloth_buildable_zones[ i ];
  22.             if ( is_true( zone.built ) )
  23.             {
  24.                 remove_zone = zone;
  25.                 i++;
  26.                 continue;
  27.             }
  28.             else piece_remaining = 0;
  29.             pieces = zone.pieces;
  30.             j = 0;
  31.             while ( j < pieces.size )
  32.             {
  33.                 if ( isDefined( pieces[ j ].unitrigger ) && !is_true( pieces[ j ].built ) )
  34.                 {
  35.                     piece_remaining = 1;
  36.                     break;
  37.                 }
  38.                 else
  39.                 {
  40.                     j++;
  41.                 }
  42.             }
  43.             if ( !piece_remaining )
  44.             {
  45.                 i++;
  46.                 continue;
  47.             }
  48.             else
  49.             {
  50.                 dist = distancesquared( zone.stub.origin, self.origin );
  51.                 if ( dist < 32400 )
  52.                 {
  53.                     self.buildable_zone = zone;
  54.                     return 1;
  55.                 }
  56.             }
  57.             i++;
  58.         }
  59.     }
  60.     if ( isDefined( remove_zone ) )
  61.     {
  62.         arrayremovevalue( level.sloth_buildable_zones, remove_zone );
  63.     }
  64.     return 0;
  65. }
  66.  
  67. common_move_to_table( stub, table, asd_name, check_pickup )
  68. {
  69.     if ( !isDefined( table ) )
  70.     {
  71. /#
  72.         assertmsg( "Table not found for " + self.buildable_zone.buildable_name );
  73. #/
  74.         self.context_done = 1;
  75.         return 0;
  76.     }
  77.     anim_id = self getanimfromasd( asd_name, 0 );
  78.     start_org = getstartorigin( table.origin, table.angles, anim_id );
  79.     start_ang = getstartangles( table.origin, table.angles, anim_id );
  80.     self setgoalpos( start_org );
  81.     while ( 1 )
  82.     {
  83.         if ( is_true( check_pickup ) )
  84.         {
  85.             if ( self.candy_player is_player_equipment( stub.weaponname ) )
  86.             {
  87. /#
  88.                 sloth_print( stub.weaponname + " was picked up" );
  89. #/
  90.                 self.context_done = 1;
  91.                 return 0;
  92.             }
  93.         }
  94.         if ( isDefined( self.buildable_zone ) && stub != self.buildable_zone.stub )
  95.         {
  96. /#
  97.             sloth_print( "location change during pathing" );
  98. #/
  99.             stub = self.buildable_zone.stub;
  100.             table = getent( stub.model.target, "targetname" );
  101.             if ( !isDefined( table ) )
  102.             {
  103. /#
  104.                 assertmsg( "Table not found for " + self.buildable_zone.buildable_name );
  105. #/
  106.                 self.context_done = 1;
  107.                 return 0;
  108.             }
  109.             start_org = getstartorigin( table.origin, table.angles, anim_id );
  110.             start_ang = getstartangles( table.origin, table.angles, anim_id );
  111.             self setgoalpos( start_org );
  112.         }
  113.         dist = distancesquared( self.origin, start_org );
  114.         if ( dist < 1024 )
  115.         {
  116.             break;
  117.         }
  118.         else
  119.         {
  120.             wait 0,1;
  121.         }
  122.     }
  123.     self setgoalpos( self.origin );
  124.     self sloth_face_object( table, "angle", start_ang[ 1 ], 0,9 );
  125.     return 1;
  126. }
  127.  
  128. build_buildable_action()
  129. {
  130.     self endon( "death" );
  131.     self endon( "stop_action" );
  132.     self maps/mp/zombies/_zm_ai_sloth::common_context_action();
  133.     stub = self.buildable_zone.stub;
  134.     table = getent( stub.model.target, "targetname" );
  135.     if ( !self common_move_to_table( stub, table, "zm_make_buildable_intro" ) )
  136.     {
  137.         return;
  138.     }
  139.     self maps/mp/zombies/_zm_ai_sloth::action_animscripted( "zm_make_buildable_intro", "make_buildable_intro_anim", table.origin, table.angles );
  140. /#
  141.     sloth_print( "looking for " + self.buildable_zone.buildable_name + " pieces" );
  142. #/
  143.     store = getstruct( "sloth_general_store", "targetname" );
  144.     self setgoalpos( store.origin );
  145.     self waittill( "goal" );
  146.     self.pieces = [];
  147.     while ( isDefined( self.buildable_zone ) )
  148.     {
  149.         pieces = self.buildable_zone.pieces;
  150.         if ( pieces.size == 0 )
  151.         {
  152. /#
  153.             sloth_print( "no pieces available" );
  154. #/
  155.             self.context_done = 1;
  156.             return;
  157.         }
  158.         i = 0;
  159.         while ( i < pieces.size )
  160.         {
  161.             if ( isDefined( pieces[ i ].unitrigger ) && !is_true( pieces[ i ].built ) )
  162.             {
  163. /#
  164.                 if ( getDvarInt( #"B6252E7C" ) == 2 )
  165.                 {
  166.                     line( self.origin, pieces[ i ].start_origin, ( 1, 1, 1 ), 1, 0, 1000 );
  167. #/
  168.                 }
  169.                 self maps/mp/zombies/_zm_buildables::player_take_piece( pieces[ i ] );
  170.                 self.pieces[ self.pieces.size ] = pieces[ i ];
  171.             }
  172.             i++;
  173.         }
  174.     }
  175.     self animscripted( self.origin, self.angles, "zm_pickup_part" );
  176.     maps/mp/animscripts/zm_shared::donotetracks( "pickup_part_anim" );
  177. /#
  178.     sloth_print( "took " + self.pieces.size + " pieces" );
  179. #/
  180.     if ( !self common_move_to_table( stub, table, "zm_make_buildable" ) )
  181.     {
  182.         return;
  183.     }
  184.     self.buildable_zone.stub.bound_to_buildable = self.buildable_zone.stub;
  185.     if ( stub != self.buildable_zone.stub )
  186.     {
  187.         stub = self.buildable_zone.stub;
  188.         table = getent( stub.model.target, "targetname" );
  189.     }
  190.     self thread build_buildable_fx( table );
  191.     self animscripted( table.origin, table.angles, "zm_make_buildable" );
  192.     wait 2,5;
  193.     self notify( "stop_buildable_fx" );
  194.     self maps/mp/zombies/_zm_buildables::player_build( self.buildable_zone, self.pieces );
  195.     if ( isDefined( self.buildable_zone.stub.onuse ) )
  196.     {
  197.         self.buildable_zone.stub [[ self.buildable_zone.stub.onuse ]]( self );
  198.     }
  199.     self.pieces = undefined;
  200.     self.context_done = 1;
  201. }
  202.  
  203. build_buildable_fx( table )
  204. {
  205.     self endon( "death" );
  206.     self notify( "stop_buildable_fx" );
  207.     self endon( "stop_buildable_fx" );
  208.     while ( 1 )
  209.     {
  210.         playfx( level._effect[ "fx_buried_sloth_building" ], table.origin );
  211.         wait 0,25;
  212.     }
  213. }
  214.  
  215. build_buildable_interrupt()
  216. {
  217.     while ( isDefined( self.pieces ) && self.pieces.size > 0 )
  218.     {
  219.         _a238 = self.pieces;
  220.         _k238 = getFirstArrayKey( _a238 );
  221.         while ( isDefined( _k238 ) )
  222.         {
  223.             piece = _a238[ _k238 ];
  224.             piece maps/mp/zombies/_zm_buildables::piece_spawn_at();
  225.             _k238 = getNextArrayKey( _a238, _k238 );
  226.         }
  227.     }
  228. }
  229.  
  230. fetch_buildable_condition()
  231. {
  232.     self.turbine = undefined;
  233.     turbines = [];
  234.     equipment = maps/mp/zombies/_zm_equipment::get_destructible_equipment_list();
  235.     _a254 = equipment;
  236.     _k254 = getFirstArrayKey( _a254 );
  237.     while ( isDefined( _k254 ) )
  238.     {
  239.         item = _a254[ _k254 ];
  240.         if ( !isDefined( item.equipname ) )
  241.         {
  242.         }
  243.         else
  244.         {
  245.             if ( item.equipname == "equip_turbine_zm" )
  246.             {
  247. /#
  248.                 self sloth_debug_context( item, sqrt( 32400 ) );
  249. #/
  250.                 dist = distancesquared( item.origin, self.origin );
  251.                 if ( dist < 32400 )
  252.                 {
  253.                     self.power_stubs = get_power_stubs( self.candy_player );
  254.                     if ( self.power_stubs.size > 0 )
  255.                     {
  256.                         self.turbine = item;
  257.                         return 1;
  258.                     }
  259.                     else
  260.                     {
  261.                         localpower = item.owner.localpower;
  262.                         if ( check_localpower_list( localpower.added_list ) || check_localpower_list( localpower.enabled_list ) )
  263.                         {
  264.                             self.turbine = item;
  265.                             return 1;
  266.                         }
  267.                     }
  268.                 }
  269.                 turbines[ turbines.size ] = item;
  270.             }
  271.         }
  272.         _k254 = getNextArrayKey( _a254, _k254 );
  273.     }
  274.     _a290 = equipment;
  275.     _k290 = getFirstArrayKey( _a290 );
  276.     while ( isDefined( _k290 ) )
  277.     {
  278.         item = _a290[ _k290 ];
  279.         if ( !isDefined( item.equipname ) )
  280.         {
  281.         }
  282.         else
  283.         {
  284.             while ( item.equipname != "equip_turret_zm" || item.equipname == "equip_electrictrap_zm" && item.equipname == "equip_subwoofer_zm" )
  285.             {
  286. /#
  287.                 self sloth_debug_context( item, sqrt( 32400 ) );
  288. #/
  289.                 dist = distancesquared( item.origin, self.origin );
  290.                 while ( dist < 32400 )
  291.                 {
  292.                     while ( is_true( item.power_on ) )
  293.                     {
  294.                         _a307 = turbines;
  295.                         _k307 = getFirstArrayKey( _a307 );
  296.                         while ( isDefined( _k307 ) )
  297.                         {
  298.                             turbine = _a307[ _k307 ];
  299.                             if ( is_turbine_powering_item( turbine, item ) )
  300.                             {
  301.                                 self.turbine = turbine;
  302.                                 return 1;
  303.                             }
  304.                             _k307 = getNextArrayKey( _a307, _k307 );
  305.                         }
  306.                     }
  307.                 }
  308.             }
  309.         }
  310.         _k290 = getNextArrayKey( _a290, _k290 );
  311.     }
  312.     _a320 = equipment;
  313.     _k320 = getFirstArrayKey( _a320 );
  314.     while ( isDefined( _k320 ) )
  315.     {
  316.         item = _a320[ _k320 ];
  317.         if ( !isDefined( item.equipname ) )
  318.         {
  319.         }
  320.         else if ( item.equipname != "equip_turret_zm" || item.equipname == "equip_electrictrap_zm" && item.equipname == "equip_subwoofer_zm" )
  321.         {
  322. /#
  323.             self sloth_debug_context( item, sqrt( 32400 ) );
  324. #/
  325.             dist = distancesquared( item.origin, self.origin );
  326.             if ( dist < 32400 )
  327.             {
  328.                 if ( is_true( level.turbine_zone.built ) )
  329.                 {
  330.                     self.power_item = item;
  331.                     return 1;
  332.                 }
  333.                 else
  334.                 {
  335. /#
  336.                     sloth_print( "turbine not built" );
  337. #/
  338.                 }
  339.             }
  340.         }
  341.         _k320 = getNextArrayKey( _a320, _k320 );
  342.     }
  343.     return 0;
  344. }
  345.  
  346. is_turbine_powering_item( turbine, item )
  347. {
  348.     localpower = turbine.owner.localpower;
  349.     while ( isDefined( localpower.added_list ) )
  350.     {
  351.         _a358 = localpower.added_list;
  352.         _k358 = getFirstArrayKey( _a358 );
  353.         while ( isDefined( _k358 ) )
  354.         {
  355.             added = _a358[ _k358 ];
  356.             if ( added == item )
  357.             {
  358.                 return 1;
  359.             }
  360.             _k358 = getNextArrayKey( _a358, _k358 );
  361.         }
  362.     }
  363.     while ( isDefined( localpower.enabled_list ) )
  364.     {
  365.         _a368 = localpower.enabled_list;
  366.         _k368 = getFirstArrayKey( _a368 );
  367.         while ( isDefined( _k368 ) )
  368.         {
  369.             enabled = _a368[ _k368 ];
  370.             if ( enabled == item )
  371.             {
  372.                 return 1;
  373.             }
  374.             _k368 = getNextArrayKey( _a368, _k368 );
  375.         }
  376.     }
  377.     return 0;
  378. }
  379.  
  380. get_power_stubs( player )
  381. {
  382.     power_stubs = [];
  383.     _a382 = level.power_zones;
  384.     _k382 = getFirstArrayKey( _a382 );
  385.     while ( isDefined( _k382 ) )
  386.     {
  387.         zone = _a382[ _k382 ];
  388.         if ( is_true( zone.built ) )
  389.         {
  390.             if ( !player has_player_equipment( zone.stub.weaponname ) )
  391.             {
  392.                 power_stubs[ power_stubs.size ] = zone.stub;
  393.             }
  394.         }
  395.         _k382 = getNextArrayKey( _a382, _k382 );
  396.     }
  397.     return power_stubs;
  398. }
  399.  
  400. fetch_buildable_start()
  401. {
  402. /#
  403.     sloth_print( self.context.name );
  404. #/
  405.     self.context_done = 0;
  406.     self.pi_origin = undefined;
  407.     if ( isDefined( self.turbine ) )
  408.     {
  409.         localpower = self.turbine.owner.localpower;
  410.         if ( check_localpower_list( localpower.added_list ) || check_localpower_list( localpower.enabled_list ) )
  411.         {
  412. /#
  413.             sloth_print( "has powered item, go get turbine" );
  414. #/
  415.             self thread fetch_buildable_action( "turbine" );
  416.             return;
  417.         }
  418. /#
  419.         sloth_print( "find a power item" );
  420. #/
  421.         self thread fetch_buildable_action( "power_item" );
  422.     }
  423.     else
  424.     {
  425.         if ( isDefined( self.power_item ) )
  426.         {
  427. /#
  428.             sloth_print( "power item needs turbine" );
  429. #/
  430.             self.pi_origin = self.power_item.origin;
  431.             self thread fetch_buildable_action( "turbine" );
  432.         }
  433.     }
  434. }
  435.  
  436. check_localpower_list( list )
  437. {
  438.     while ( isDefined( list ) )
  439.     {
  440.         _a436 = list;
  441.         _k436 = getFirstArrayKey( _a436 );
  442.         while ( isDefined( _k436 ) )
  443.         {
  444.             item = _a436[ _k436 ];
  445.             item_name = item.target.name;
  446.             if ( !isDefined( item_name ) )
  447.             {
  448.             }
  449.             else
  450.             {
  451.                 if ( item_name != "equip_turret_zm" || item_name == "equip_electrictrap_zm" && item_name == "equip_subwoofer_zm" )
  452.                 {
  453.                     return 1;
  454.                 }
  455.             }
  456.             _k436 = getNextArrayKey( _a436, _k436 );
  457.         }
  458.     }
  459.     return 0;
  460. }
  461.  
  462. fetch_buildable_action( item )
  463. {
  464.     self endon( "death" );
  465.     self endon( "stop_action" );
  466.     self maps/mp/zombies/_zm_ai_sloth::common_context_action();
  467.     player = self.candy_player;
  468.     if ( item == "turbine" )
  469.     {
  470.         if ( isDefined( self.turbine ) )
  471.         {
  472.             plant_origin = self.turbine.origin;
  473.             plant_angles = self.turbine.angles;
  474.         }
  475.         stub = level.turbine_zone.stub;
  476.     }
  477.     else
  478.     {
  479.         if ( item == "power_item" )
  480.         {
  481.             self.power_stubs = array_randomize( self.power_stubs );
  482.             stub = self.power_stubs[ 0 ];
  483.         }
  484.     }
  485.     append_name = "equipment";
  486.     pickup_asd = "zm_pickup_" + append_name;
  487.     table = getent( stub.model.target, "targetname" );
  488.     if ( !self common_move_to_table( stub, table, pickup_asd, 1 ) )
  489.     {
  490.         return;
  491.     }
  492.     self.buildable_item = item;
  493.     self animscripted( table.origin, table.angles, pickup_asd );
  494.     maps/mp/animscripts/zm_shared::donotetracks( "pickup_equipment_anim", ::pickup_notetracks, stub );
  495.     if ( player is_player_equipment( stub.weaponname ) )
  496.     {
  497. /#
  498.         sloth_print( "during anim player picked up " + stub.weaponname );
  499. #/
  500.         self.context_done = 1;
  501.         return;
  502.     }
  503.     if ( !player has_deployed_equipment( stub.weaponname ) )
  504.     {
  505.         player.deployed_equipment[ player.deployed_equipment.size ] = stub.weaponname;
  506.     }
  507. /#
  508.     sloth_print( "got " + stub.equipname );
  509. #/
  510.     if ( isDefined( self.turbine ) )
  511.     {
  512.         ground_pos = self.turbine.origin;
  513.     }
  514.     else if ( isDefined( self.power_item ) )
  515.     {
  516.         ground_pos = self.power_item.origin;
  517.     }
  518.     else
  519.     {
  520.         ground_pos = self.pi_origin;
  521.     }
  522.     run_asd = "run_holding_" + append_name;
  523.     self.ignore_common_run = 1;
  524.     self set_zombie_run_cycle( run_asd );
  525.     self.locomotion = run_asd;
  526.     self setgoalpos( ground_pos );
  527.     range = 10000;
  528.     if ( item == "power_item" || isDefined( self.power_item ) )
  529.     {
  530.         range = 25600;
  531.     }
  532.     while ( 1 )
  533.     {
  534.         while ( self sloth_is_traversing() )
  535.         {
  536.             wait 0,1;
  537.         }
  538.         dist = distancesquared( self.origin, ground_pos );
  539.         if ( dist < range )
  540.         {
  541.             break;
  542.         }
  543.         else
  544.         {
  545.             wait 0,1;
  546.         }
  547.     }
  548.     if ( item == "turbine" )
  549.     {
  550.         if ( isDefined( self.turbine ) )
  551.         {
  552.             self orientmode( "face point", self.turbine.origin );
  553.             self animscripted( self.origin, flat_angle( vectorToAngle( self.turbine.origin - self.origin ) ), "zm_kick_equipment" );
  554.             maps/mp/animscripts/zm_shared::donotetracks( "kick_equipment_anim", ::destroy_item, self.turbine );
  555.             self orientmode( "face default" );
  556.             self animscripted( self.origin, self.angles, "zm_idle_equipment" );
  557.             wait 3;
  558.         }
  559.     }
  560.     if ( !isDefined( plant_origin ) )
  561.     {
  562.         plant_origin = self.origin;
  563.         plant_angles = self.angles;
  564.     }
  565.     drop_asd = "zm_drop_" + append_name;
  566.     self maps/mp/zombies/_zm_ai_sloth::action_animscripted( drop_asd, "drop_equipment_anim" );
  567.     if ( player has_player_equipment( stub.weaponname ) )
  568.     {
  569.         player equipment_take( stub.weaponname );
  570.     }
  571.     player player_set_equipment_damage( stub.weaponname, 0 );
  572.     if ( !player has_deployed_equipment( stub.weaponname ) )
  573.     {
  574.         player.deployed_equipment[ player.deployed_equipment.size ] = stub.weaponname;
  575.     }
  576.     if ( isDefined( self.buildable_model ) )
  577.     {
  578.         self.buildable_model unlink();
  579.         self.buildable_model delete();
  580.     }
  581.     equipment = stub.weaponname;
  582.     plant_origin = self gettagorigin( "tag_weapon_right" );
  583.     plant_angles = self gettagangles( "tag_weapon_right" );
  584.     replacement = player [[ level.zombie_equipment[ equipment ].place_fn ]]( plant_origin, plant_angles );
  585.     if ( isDefined( replacement ) )
  586.     {
  587.         replacement.owner = player;
  588.         replacement.original_owner = player;
  589.         replacement.name = equipment;
  590.         player notify( "equipment_placed" );
  591.         if ( isDefined( level.equipment_planted ) )
  592.         {
  593.             player [[ level.equipment_planted ]]( replacement, equipment, self );
  594.         }
  595.     }
  596.     self.context_done = 1;
  597. }
  598.  
  599. pickup_notetracks( note, stub )
  600. {
  601.     if ( note == "pickup" )
  602.     {
  603.         tag_name = "tag_stowed_back";
  604.         twr_origin = self gettagorigin( tag_name );
  605.         twr_angles = self gettagangles( tag_name );
  606.         self.buildable_model = spawn( "script_model", twr_origin );
  607.         self.buildable_model.angles = twr_angles;
  608.         if ( self.buildable_item == "turbine" )
  609.         {
  610.             self.buildable_model setmodel( level.small_turbine );
  611.         }
  612.         else
  613.         {
  614.             self.buildable_model setmodel( stub.model.model );
  615.         }
  616.         self.buildable_model linkto( self, tag_name );
  617.     }
  618. }
  619.  
  620. destroy_item( note, item )
  621. {
  622.     if ( note == "kick" )
  623.     {
  624.         if ( isDefined( item ) )
  625.         {
  626.             if ( isDefined( item.owner ) )
  627.             {
  628.                 item.owner thread maps/mp/zombies/_zm_equipment::player_damage_equipment( item.equipname, 1001, item.origin );
  629.                 return;
  630.             }
  631.             else
  632.             {
  633.                 item thread maps/mp/zombies/_zm_equipment::dropped_equipment_destroy( 1 );
  634.             }
  635.         }
  636.     }
  637. }
  638.  
  639. fetch_buildable_interrupt()
  640. {
  641.     if ( isDefined( self.buildable_model ) )
  642.     {
  643.         self.buildable_model unlink();
  644.         self.buildable_model delete();
  645.     }
  646. }
  647.  
  648. wallbuy_condition()
  649. {
  650.     if ( !wallbuy_get_stub_array().size )
  651.     {
  652.         return 0;
  653.     }
  654.     if ( !wallbuy_get_piece_array().size )
  655.     {
  656.         return 0;
  657.     }
  658.     if ( isDefined( level.gunshop_zone ) )
  659.     {
  660.         if ( self istouching( level.gunshop_zone ) )
  661.         {
  662. /#
  663.             sloth_print( "using new gunshop zone" );
  664. #/
  665.             return 1;
  666.         }
  667.     }
  668.     else
  669.     {
  670.         if ( self maps/mp/zombies/_zm_zonemgr::entity_in_zone( "zone_gun_store" ) )
  671.         {
  672.             return 1;
  673.         }
  674.     }
  675.     return 0;
  676. }
  677.  
  678. wallbuy_get_stub_array()
  679. {
  680.     stubs = [];
  681.     i = 0;
  682.     while ( i < level.sloth_wallbuy_stubs.size )
  683.     {
  684.         stub = level.sloth_wallbuy_stubs[ i ];
  685.         if ( !isDefined( stub.in_zone ) )
  686.         {
  687. /#
  688.             iprintln( "WALLBUY NOT IN VALID ZONE" );
  689. #/
  690.             i++;
  691.             continue;
  692.         }
  693.         else if ( !level.zones[ stub.in_zone ].is_enabled )
  694.         {
  695.             i++;
  696.             continue;
  697.         }
  698.         else if ( is_true( stub.built ) )
  699.         {
  700.             remove_stub = stub;
  701.             i++;
  702.             continue;
  703.         }
  704.         else if ( stub.in_zone == "zone_general_store" )
  705.         {
  706.             if ( !is_general_store_open() )
  707.             {
  708.                 i++;
  709.                 continue;
  710.             }
  711.         }
  712.         else if ( stub.in_zone == "zone_underground_courthouse2" )
  713.         {
  714.             if ( !maps/mp/zm_buried::is_courthouse_open() )
  715.             {
  716.                 i++;
  717.                 continue;
  718.             }
  719.         }
  720.         else if ( stub.in_zone == "zone_tunnels_center" )
  721.         {
  722.             if ( !maps/mp/zm_buried::is_tunnel_open() )
  723.             {
  724.                 i++;
  725.                 continue;
  726.             }
  727.         }
  728.         else
  729.         {
  730.             stubs[ stubs.size ] = stub;
  731.         }
  732.         i++;
  733.     }
  734.     if ( isDefined( remove_stub ) )
  735.     {
  736.         arrayremovevalue( level.sloth_wallbuy_stubs, remove_stub );
  737.     }
  738.     return stubs;
  739. }
  740.  
  741. wallbuy_get_piece_array()
  742. {
  743.     pieces = [];
  744.     i = 0;
  745.     while ( i < level.chalk_pieces.size )
  746.     {
  747.         piece = level.chalk_pieces[ i ];
  748.         if ( isDefined( piece.unitrigger ) && !is_true( piece.built ) )
  749.         {
  750.             pieces[ pieces.size ] = piece;
  751.         }
  752.         i++;
  753.     }
  754.     return pieces;
  755. }
  756.  
  757. wallbuy_action()
  758. {
  759.     self endon( "death" );
  760.     self endon( "stop_action" );
  761.     self maps/mp/zombies/_zm_ai_sloth::common_context_action();
  762.     wallbuy_struct = getstruct( "sloth_allign_gunshop", "targetname" );
  763.     asd_name = "zm_wallbuy_remove";
  764.     anim_id = self getanimfromasd( asd_name, 0 );
  765.     start_org = getstartorigin( wallbuy_struct.origin, wallbuy_struct.angles, anim_id );
  766.     start_ang = getstartangles( wallbuy_struct.origin, wallbuy_struct.angles, anim_id );
  767.     self setgoalpos( start_org );
  768.     self waittill( "goal" );
  769.     self setgoalpos( self.origin );
  770.     self sloth_face_object( undefined, "angle", start_ang[ 1 ], 0,9 );
  771.     self animscripted( wallbuy_struct.origin, wallbuy_struct.angles, asd_name );
  772.     maps/mp/animscripts/zm_shared::donotetracks( "wallbuy_remove_anim", ::wallbuy_grab_pieces );
  773.     if ( !self.wallbuy_stubs.size || !self.wallbuy_pieces.size )
  774.     {
  775.         self.context_done = 1;
  776.         return;
  777.     }
  778.     i = 0;
  779.     while ( i < self.pieces_needed )
  780.     {
  781.         stub = self.wallbuy_stubs[ i ];
  782.         vec_right = vectornormalize( anglesToRight( stub.angles ) );
  783.         org = stub.origin - ( vec_right * 60 );
  784.         org = groundpos( org );
  785.         self setgoalpos( org );
  786.         skip_piece = 0;
  787.         while ( 1 )
  788.         {
  789.             if ( is_true( stub.built ) )
  790.             {
  791. /#
  792.                 sloth_print( "stub was built during pathing" );
  793. #/
  794.                 skip_piece = 1;
  795.                 break;
  796.             }
  797.             else dist = distancesquared( self.origin, org );
  798.             if ( dist < 576 )
  799.             {
  800.                 break;
  801.             }
  802.             else
  803.             {
  804.                 wait 0,1;
  805.             }
  806.         }
  807.         if ( !skip_piece )
  808.         {
  809.             self setgoalpos( self.origin );
  810.             chalk_angle = vectorToAngle( vec_right );
  811.             self sloth_face_object( stub, "angle", chalk_angle[ 1 ], 0,9 );
  812.             if ( is_true( stub.built ) )
  813.             {
  814. /#
  815.                 sloth_print( "stub was built during facing" );
  816. #/
  817.                 skip_piece = 1;
  818.             }
  819.         }
  820.         self player_set_buildable_piece( self.wallbuy_pieces[ i ], 1 );
  821.         current_piece = self player_get_buildable_piece( 1 );
  822.         if ( skip_piece )
  823.         {
  824.             arrayremovevalue( self.wallbuy_pieces_taken, current_piece );
  825.             current_piece maps/mp/zm_buried_buildables::ondrop_chalk( self );
  826.             self orientmode( "face default" );
  827.             i++;
  828.             continue;
  829.         }
  830.         else
  831.         {
  832.             self thread player_draw_chalk( stub );
  833.             self maps/mp/zombies/_zm_ai_sloth::action_animscripted( "zm_wallbuy_add", "wallbuy_add_anim", org, chalk_angle );
  834.             self notify( "end_chalk_dust" );
  835.             playsoundatposition( "zmb_cha_ching_loud", stub.origin );
  836.             if ( is_true( stub.built ) )
  837.             {
  838.                 current_piece maps/mp/zm_buried_buildables::ondrop_chalk( self );
  839. /#
  840.                 sloth_print( "stub was built during anim" );
  841. #/
  842.             }
  843.             else
  844.             {
  845.                 stub maps/mp/zm_buried_buildables::onuseplantobject_chalk( self );
  846.                 stub buildablestub_finish_build( self );
  847.                 stub buildablestub_remove();
  848.                 thread maps/mp/zombies/_zm_unitrigger::unregister_unitrigger( stub );
  849. /#
  850.                 sloth_print( "built " + self player_get_buildable_piece( 1 ).script_noteworthy );
  851. #/
  852.             }
  853.             arrayremovevalue( self.wallbuy_pieces_taken, self player_get_buildable_piece( 1 ) );
  854.             self orientmode( "face default" );
  855.         }
  856.         i++;
  857.     }
  858.     self.context_done = 1;
  859. }
  860.  
  861. wallbuy_grab_pieces( note )
  862. {
  863.     while ( note == "pulled" )
  864.     {
  865.         self.wallbuy_stubs = wallbuy_get_stub_array();
  866.         self.wallbuy_pieces = wallbuy_get_piece_array();
  867.         self.pieces_needed = self.wallbuy_stubs.size;
  868.         if ( self.pieces_needed > self.wallbuy_pieces.size )
  869.         {
  870.             self.pieces_needed = self.wallbuy_pieces.size;
  871.         }
  872.         self.wallbuy_pieces = array_randomize( self.wallbuy_pieces );
  873.         self.wallbuy_pieces_taken = [];
  874.         i = 0;
  875.         while ( i < self.pieces_needed )
  876.         {
  877.             self.wallbuy_pieces_taken[ i ] = self.wallbuy_pieces[ i ];
  878.             self.wallbuy_pieces[ i ] maps/mp/zombies/_zm_buildables::piece_unspawn();
  879.             i++;
  880.         }
  881.     }
  882. }
  883.  
  884. wallbuy_interrupt()
  885. {
  886.     while ( isDefined( self.wallbuy_pieces_taken ) && self.wallbuy_pieces_taken.size > 0 )
  887.     {
  888.         _a920 = self.wallbuy_pieces_taken;
  889.         _k920 = getFirstArrayKey( _a920 );
  890.         while ( isDefined( _k920 ) )
  891.         {
  892.             wallbuy = _a920[ _k920 ];
  893.             wallbuy maps/mp/zm_buried_buildables::ondrop_chalk( self );
  894.             _k920 = getNextArrayKey( _a920, _k920 );
  895.         }
  896.     }
  897. }
Advertisement
Add Comment
Please, Sign In to add comment