burc_2004

_zm_ai_sloth_magicbox.gsc

Oct 22nd, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.93 KB | None | 0 0
  1. #include maps/mp/zombies/_zm_unitrigger;
  2. #include maps/mp/zombies/_zm_hackables_box;
  3. #include maps/mp/zombies/_zm_magicbox;
  4. #include maps/mp/zm_buried;
  5. #include maps/mp/animscripts/zm_shared;
  6. #include maps/mp/zombies/_zm_ai_sloth;
  7. #include maps/mp/zombies/_zm_ai_sloth_utility;
  8. #include maps/mp/zombies/_zm_utility;
  9. #include maps/mp/_utility;
  10. #include common_scripts/utility;
  11.  
  12. box_lock_condition()
  13. {
  14.     box = level.chests[ level.chest_index ];
  15.     if ( !isDefined( box ) )
  16.     {
  17.         return 0;
  18.     }
  19. /#
  20.     self sloth_debug_context( box, sqrt( 32400 ) );
  21. #/
  22.     if ( flag( "moving_chest_now" ) )
  23.     {
  24.         return 0;
  25.     }
  26.     if ( is_true( box._box_open ) || is_true( box._box_opened_by_fire_sale ) )
  27.     {
  28.         return 0;
  29.     }
  30.     dist = distancesquared( self.origin, box.origin );
  31.     if ( dist < 32400 )
  32.     {
  33.         return 1;
  34.     }
  35.     return 0;
  36. }
  37.  
  38. box_get_ground_offset()
  39. {
  40.     vec_right = vectornormalize( anglesToRight( self.angles ) );
  41.     box_pos = self.origin - ( vec_right * 36 );
  42.     ground_pos = groundpos( box_pos );
  43.     return ground_pos;
  44. }
  45.  
  46. common_abort_box( box )
  47. {
  48.     if ( flag( "moving_chest_now" ) )
  49.     {
  50.         self.context_done = 1;
  51.         return 1;
  52.     }
  53.     if ( isDefined( box ) )
  54.     {
  55.         if ( is_true( box._box_open ) || is_true( box._box_opened_by_fire_sale ) )
  56.         {
  57. /#
  58.             sloth_print( "box was opened...abort" );
  59. #/
  60.             self.context_done = 1;
  61.             return 1;
  62.         }
  63.     }
  64.     return 0;
  65. }
  66.  
  67. common_move_to_maze( box )
  68. {
  69.     self endon( "death" );
  70.     while ( 1 )
  71.     {
  72.         if ( self common_abort_box( box ) )
  73.         {
  74.             return 0;
  75.         }
  76.         if ( self maps/mp/zombies/_zm_ai_sloth::sloth_behind_mansion() )
  77.         {
  78.             break;
  79.         }
  80.         else
  81.         {
  82.             self maps/mp/zombies/_zm_ai_sloth::action_navigate_mansion( level.maze_depart, level.maze_arrive );
  83.             wait 0,2;
  84.         }
  85.     }
  86.     return 1;
  87. }
  88.  
  89. common_move_to_courtyard( box )
  90. {
  91.     self endon( "death" );
  92.     while ( 1 )
  93.     {
  94.         if ( self common_abort_box( box ) )
  95.         {
  96.             return 0;
  97.         }
  98.         if ( !self maps/mp/zombies/_zm_ai_sloth::sloth_behind_mansion() )
  99.         {
  100.             break;
  101.         }
  102.         else
  103.         {
  104.             self maps/mp/zombies/_zm_ai_sloth::action_navigate_mansion( level.courtyard_depart, level.courtyard_arrive );
  105.             wait 0,2;
  106.         }
  107.     }
  108.     return 1;
  109. }
  110.  
  111. common_move_to_box( box, range, ignore_open, asd_name )
  112. {
  113.     if ( isDefined( asd_name ) )
  114.     {
  115.         anim_id = self getanimfromasd( asd_name, 0 );
  116.         start_org = getstartorigin( box.origin, box.angles, anim_id );
  117.         start_ang = getstartangles( box.origin, box.angles, anim_id );
  118.         self setgoalpos( start_org );
  119.         ground_pos = start_org;
  120.     }
  121.     else
  122.     {
  123.         vec_right = vectornormalize( anglesToRight( box.angles ) );
  124.         box_pos = box.origin - ( vec_right * 36 );
  125.         ground_pos = groundpos( box_pos );
  126.         self setgoalpos( ground_pos );
  127.     }
  128.     while ( 1 )
  129.     {
  130.         if ( flag( "moving_chest_now" ) )
  131.         {
  132.             self.context_done = 1;
  133.             return 0;
  134.         }
  135.         if ( !is_true( ignore_open ) || is_true( box._box_open ) && is_true( box._box_opened_by_fire_sale ) )
  136.         {
  137. /#
  138.             sloth_print( "box was opened...abort" );
  139. #/
  140.             self.context_done = 1;
  141.             return 0;
  142.         }
  143.         dist = distancesquared( self.origin, ground_pos );
  144.         if ( dist < range )
  145.         {
  146.             break;
  147.         }
  148.         else
  149.         {
  150.             wait 0,1;
  151.         }
  152.     }
  153.     if ( isDefined( asd_name ) )
  154.     {
  155.         self setgoalpos( self.origin );
  156.         self sloth_face_object( box, "angle", start_ang[ 1 ], 0,9 );
  157.     }
  158.     else
  159.     {
  160.         angles = vectorToAngle( vec_right );
  161.         self.anchor.origin = self.origin;
  162.         self.anchor.angles = angles;
  163.         self orientmode( "face angle", angles[ 1 ] );
  164.         wait 0,2;
  165.     }
  166.     if ( flag( "moving_chest_now" ) )
  167.     {
  168.         self.context_done = 1;
  169.         return 0;
  170.     }
  171.     return 1;
  172. }
  173.  
  174. box_lock_action()
  175. {
  176.     self endon( "death" );
  177.     self endon( "stop_action" );
  178.     self maps/mp/zombies/_zm_ai_sloth::common_context_action();
  179.     box = level.chests[ level.chest_index ];
  180.     if ( !self common_move_to_box( box, 1024 ) )
  181.     {
  182.         return;
  183.     }
  184.     self animscripted( box.origin, box.angles, "zm_lock_magicbox" );
  185.     maps/mp/animscripts/zm_shared::donotetracks( "lock_magicbox_anim", ::box_notetracks, box );
  186.     if ( flag( "moving_chest_now" ) )
  187.     {
  188.         self.context_done = 1;
  189.         return;
  190.     }
  191.     setdvar( "magic_chest_movable", "0" );
  192. /#
  193.     sloth_print( "box will not move" );
  194. #/
  195.     maps/mp/zombies/_zm_ai_sloth::unregister_candy_context( "box_lock" );
  196.     maps/mp/zombies/_zm_ai_sloth::unregister_candy_context( "box_move" );
  197.     self.context_done = 1;
  198. }
  199.  
  200. box_move_condition()
  201. {
  202.     if ( flag( "moving_chest_now" ) )
  203.     {
  204.         return 0;
  205.     }
  206.     self.box_move = undefined;
  207.     self.box_current = undefined;
  208.     self.box_current_in_maze = 0;
  209.     box_current = level.chests[ level.chest_index ];
  210.     if ( is_true( box_current._box_open ) || is_true( box_current._box_opened_by_fire_sale ) )
  211.     {
  212.         return 0;
  213.     }
  214.     if ( box_current.script_noteworthy == "courtroom_chest1" )
  215.     {
  216.         if ( !maps/mp/zm_buried::is_courthouse_open() )
  217.         {
  218.             return 0;
  219.         }
  220.     }
  221.     if ( box_current.script_noteworthy == "tunnels_chest1" )
  222.     {
  223.         if ( !maps/mp/zm_buried::is_tunnel_open() )
  224.         {
  225.             return 0;
  226.         }
  227.     }
  228.     if ( box_current.script_noteworthy == "maze_chest1" || box_current.script_noteworthy == "maze_chest2" )
  229.     {
  230.         self.box_current_in_maze = 1;
  231.         if ( !is_maze_open() )
  232.         {
  233.             return 0;
  234.         }
  235.     }
  236.     i = 0;
  237.     while ( i < level.chests.size )
  238.     {
  239.         if ( i == level.chest_index )
  240.         {
  241.             i++;
  242.             continue;
  243.         }
  244.         else
  245.         {
  246.             box = level.chests[ i ];
  247.             if ( box.script_noteworthy != "maze_chest1" )
  248.             {
  249.                 self.box_move_in_maze = box.script_noteworthy == "maze_chest2";
  250.             }
  251.             dist = distancesquared( self.origin, box.origin );
  252.             if ( dist < 32400 )
  253.             {
  254.                 self.box_move_index = i;
  255.                 self.box_move = box;
  256.                 self.box_current = box_current;
  257.                 return 1;
  258.             }
  259.         }
  260.         i++;
  261.     }
  262.     return 0;
  263. }
  264.  
  265. box_move_action()
  266. {
  267.     self endon( "death" );
  268.     self endon( "stop_action" );
  269.     self maps/mp/zombies/_zm_ai_sloth::common_context_action();
  270. /#
  271.     sloth_print( "moving box from: " + self.box_current.script_noteworthy + " to: " + self.box_move.script_noteworthy );
  272. #/
  273.     if ( !self common_move_to_box( self.box_move, 1024, 0, "zm_magicbox_point" ) )
  274.     {
  275.         return;
  276.     }
  277.     self maps/mp/zombies/_zm_ai_sloth::action_animscripted( "zm_magicbox_point", "magicbox_point_anim", self.box_move.origin, self.box_move.angles );
  278.     if ( is_true( self.box_current_in_maze ) )
  279.     {
  280.         if ( !is_true( self.box_move_in_maze ) )
  281.         {
  282.             if ( !self common_move_to_maze( self.box_current ) )
  283.             {
  284.                 return;
  285.             }
  286.         }
  287.     }
  288.     else
  289.     {
  290.         if ( is_true( self.box_move_in_maze ) )
  291.         {
  292.             if ( !self common_move_to_courtyard( self.box_current ) )
  293.             {
  294.                 return;
  295.             }
  296.         }
  297.     }
  298.     if ( !self common_move_to_box( self.box_current, 1024, 0, "zm_pull_magicbox" ) )
  299.     {
  300.         return;
  301.     }
  302.     self animscripted( self.box_current.origin, self.box_current.angles, "zm_pull_magicbox" );
  303.     maps/mp/animscripts/zm_shared::donotetracks( "pull_magicbox_anim", ::box_notetracks, self.box_current );
  304.     if ( self common_abort_box( self.box_current ) )
  305.     {
  306.         self box_move_interrupt();
  307.         return;
  308.     }
  309.     if ( isDefined( level.sloth.custom_box_move_func ) )
  310.     {
  311.         self thread [[ level.sloth.custom_box_move_func ]]( 0 );
  312.     }
  313.     level.sloth_moving_box = 1;
  314.     self.ignore_common_run = 1;
  315.     self set_zombie_run_cycle( "run_holding_magicbox" );
  316.     self.locomotion = "run_holding_magicbox";
  317.     if ( is_true( self.box_current_in_maze ) )
  318.     {
  319.         if ( !is_true( self.box_move_in_maze ) )
  320.         {
  321.             if ( !self common_move_to_courtyard( undefined ) )
  322.             {
  323.                 self box_move_interrupt();
  324.                 return;
  325.             }
  326.         }
  327.     }
  328.     else
  329.     {
  330.         if ( is_true( self.box_move_in_maze ) )
  331.         {
  332.             if ( !self common_move_to_maze( undefined ) )
  333.             {
  334.                 self box_move_interrupt();
  335.                 return;
  336.             }
  337.         }
  338.     }
  339.     if ( !self common_move_to_box( self.box_move, 1024, 0, "zm_place_magicbox" ) )
  340.     {
  341.         self box_move_interrupt();
  342.         return;
  343.     }
  344.     self animscripted( self.box_move.origin, self.box_move.angles, "zm_place_magicbox" );
  345.     maps/mp/animscripts/zm_shared::donotetracks( "place_magicbox_anim", ::box_notetracks, self.box_move );
  346.     self.box_current = undefined;
  347.     self.context_done = 1;
  348.     level.sloth_moving_box = undefined;
  349.     if ( isDefined( level.sloth.custom_box_move_func ) )
  350.     {
  351.         self thread [[ level.sloth.custom_box_move_func ]]( 1 );
  352.     }
  353. }
  354.  
  355. box_notetracks( note, box )
  356. {
  357.     if ( !flag( "moving_chest_now" ) || is_true( box._box_open ) && is_true( box._box_opened_by_fire_sale ) )
  358.     {
  359.         return 0;
  360.     }
  361.     if ( note == "pulled" )
  362.     {
  363.         playfx( level._effect[ "fx_buried_sloth_box_slam" ], box.origin );
  364.         tag_name = "tag_stowed_back";
  365.         twr_origin = self gettagorigin( tag_name );
  366.         twr_angles = self gettagangles( tag_name );
  367.         if ( !isDefined( self.box_model ) )
  368.         {
  369.             self.box_model = spawn( "script_model", twr_origin );
  370.             self.box_model.angles = twr_angles;
  371.             self.box_model setmodel( level.small_magic_box );
  372.             self.box_model linkto( self, tag_name );
  373.             self.box_model_visible = 1;
  374.         }
  375.         else
  376.         {
  377.             self.box_model show();
  378.             self.box_model_visible = 1;
  379.         }
  380.         self.box_current maps/mp/zombies/_zm_magicbox::hide_chest();
  381.     }
  382.     else if ( note == "placed" )
  383.     {
  384.         playfx( level._effect[ "fx_buried_sloth_box_slam" ], box.origin );
  385.         self box_model_hide();
  386.         if ( isDefined( self.box_move.zbarrier ) )
  387.         {
  388.             self.box_move.zbarrier maps/mp/zombies/_zm_magicbox::set_magic_box_zbarrier_state( "initial" );
  389.             self.box_move.hidden = 0;
  390.             self.box_move thread [[ level.pandora_show_func ]]();
  391.             level.chest_index = self.box_move_index;
  392.         }
  393.     }
  394.     else
  395.     {
  396.         if ( note == "locked" )
  397.         {
  398.             playfx( level._effect[ "fx_buried_sloth_box_slam" ], box.origin );
  399.         }
  400.     }
  401. }
  402.  
  403. box_model_hide()
  404. {
  405.     if ( isDefined( self.box_model ) )
  406.     {
  407.         self.box_model ghost();
  408.         self.box_model_visible = 0;
  409.     }
  410. }
  411.  
  412. box_move_interrupt()
  413. {
  414.     if ( isDefined( self.box_current ) )
  415.     {
  416.         if ( isDefined( self.box_current.zbarrier ) )
  417.         {
  418.             self.box_current.zbarrier maps/mp/zombies/_zm_magicbox::set_magic_box_zbarrier_state( "initial" );
  419.             self.box_current.hidden = 0;
  420.             self.box_current thread [[ level.pandora_show_func ]]();
  421.         }
  422.     }
  423.     if ( isDefined( level.sloth.custom_box_move_func ) )
  424.     {
  425.         self thread [[ level.sloth.custom_box_move_func ]]( 1 );
  426.     }
  427.     level.sloth_moving_box = undefined;
  428.     self box_model_hide();
  429. }
  430.  
  431. box_spin_condition()
  432. {
  433.     if ( flag( "moving_chest_now" ) )
  434.     {
  435.         return 0;
  436.     }
  437.     box = level.chests[ level.chest_index ];
  438.     if ( is_true( box._box_open ) || is_true( box._box_opened_by_fire_sale ) )
  439.     {
  440.         ground_pos = groundpos( box.origin );
  441.         dist = distancesquared( self.origin, ground_pos );
  442.         if ( dist < 32400 )
  443.         {
  444.             return 1;
  445.         }
  446.     }
  447.     return 0;
  448. }
  449.  
  450. box_spin_action()
  451. {
  452.     self endon( "death" );
  453.     self endon( "stop_action" );
  454.     self maps/mp/zombies/_zm_ai_sloth::common_context_action();
  455.     box = level.chests[ level.chest_index ];
  456.     hackable = spawnstruct();
  457.     hackable.chest = box;
  458.     if ( !self common_move_to_box( box, 1024, 1, "zm_cycle_magicbox" ) )
  459.     {
  460.         return;
  461.     }
  462.     if ( !self box_spin_qualifier( hackable ) )
  463.     {
  464.         return;
  465.     }
  466.     self animscripted( box.origin, box.angles, "zm_cycle_magicbox" );
  467.     maps/mp/animscripts/zm_shared::donotetracks( "cycle_magicbox_anim", ::box_kick, hackable );
  468.     self.context_done = 1;
  469. }
  470.  
  471. box_kick( note, hackable )
  472. {
  473.     if ( note == "kick" )
  474.     {
  475.         if ( !self box_spin_qualifier( hackable ) )
  476.         {
  477.             return;
  478.         }
  479.         if ( !flag( "moving_chest_now" ) )
  480.         {
  481.             hackable thread box_trigger();
  482.             hackable maps/mp/zombies/_zm_hackables_box::respin_box( self.candy_player );
  483.         }
  484.     }
  485. }
  486.  
  487. box_trigger()
  488. {
  489.     if ( isDefined( self.chest ) )
  490.     {
  491.         thread maps/mp/zombies/_zm_unitrigger::unregister_unitrigger( self.chest.unitrigger_stub );
  492.         self.chest.zbarrier waittill( "randomization_done" );
  493.         if ( !flag( "moving_chest_now" ) )
  494.         {
  495.             thread maps/mp/zombies/_zm_unitrigger::register_static_unitrigger( self.chest.unitrigger_stub, ::maps/mp/zombies/_zm_magicbox::magicbox_unitrigger_think );
  496.         }
  497.     }
  498. }
  499.  
  500. box_spin_qualifier( hackable )
  501. {
  502.     if ( isDefined( hackable.chest ) )
  503.     {
  504.         if ( !isDefined( hackable.chest.chest_user ) )
  505.         {
  506.             self.context_done = 1;
  507.             return 0;
  508.         }
  509.     }
  510.     if ( !hackable maps/mp/zombies/_zm_hackables_box::hack_box_qualifier( self.candy_player ) )
  511.     {
  512. /#
  513.         sloth_print( "hack_box_qualifier failed" );
  514. #/
  515.         self.context_done = 1;
  516.         return 0;
  517.     }
  518.     return 1;
  519. }
Advertisement
Add Comment
Please, Sign In to add comment