burc_2004

zm_shared.gsc

Oct 21st, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.88 KB | None | 0 0
  1. #include maps/mp/animscripts/zm_utility;
  2. #include maps/mp/animscripts/utility;
  3. #include maps/mp/animscripts/shared;
  4.  
  5. deleteatlimit()
  6. {
  7.     wait 30;
  8.     self delete();
  9. }
  10.  
  11. lookatentity( looktargetentity, lookduration, lookspeed, eyesonly, interruptothers )
  12. {
  13.     return;
  14. }
  15.  
  16. lookatposition( looktargetpos, lookduration, lookspeed, eyesonly, interruptothers )
  17. {
  18. /#
  19.     assert( isai( self ), "Can only call this function on an AI character" );
  20. #/
  21. /#
  22.     assert( self.a.targetlookinitilized == 1, "LookAtPosition called on AI that lookThread was not called on" );
  23. #/
  24. /#
  25.     if ( lookspeed != "casual" )
  26.     {
  27.         assert( lookspeed == "alert", "lookSpeed must be casual or alert" );
  28.     }
  29. #/
  30.     if ( isDefined( interruptothers ) || interruptothers == "interrupt others" && getTime() > self.a.lookendtime )
  31.     {
  32.         self.a.looktargetpos = looktargetpos;
  33.         self.a.lookendtime = getTime() + ( lookduration * 1000 );
  34.         if ( lookspeed == "casual" )
  35.         {
  36.             self.a.looktargetspeed = 800;
  37.         }
  38.         else
  39.         {
  40.             self.a.looktargetspeed = 1600;
  41.         }
  42.         if ( isDefined( eyesonly ) && eyesonly == "eyes only" )
  43.         {
  44.             self notify( "eyes look now" );
  45.             return;
  46.         }
  47.         else
  48.         {
  49.             self notify( "look now" );
  50.         }
  51.     }
  52. }
  53.  
  54. lookatanimations( leftanim, rightanim )
  55. {
  56.     self.a.lookanimationleft = leftanim;
  57.     self.a.lookanimationright = rightanim;
  58. }
  59.  
  60. handledogsoundnotetracks( note )
  61. {
  62.     if ( note != "sound_dogstep_run_default" || note == "dogstep_rf" && note == "dogstep_lf" )
  63.     {
  64.         self playsound( "fly_dog_step_run_default" );
  65.         return 1;
  66.     }
  67.     prefix = getsubstr( note, 0, 5 );
  68.     if ( prefix != "sound" )
  69.     {
  70.         return 0;
  71.     }
  72.     alias = "aml" + getsubstr( note, 5 );
  73.     if ( isalive( self ) )
  74.     {
  75.         self thread play_sound_on_tag_endon_death( alias, "tag_eye" );
  76.     }
  77.     else
  78.     {
  79.         self thread play_sound_in_space( alias, self gettagorigin( "tag_eye" ) );
  80.     }
  81.     return 1;
  82. }
  83.  
  84. growling()
  85. {
  86.     return isDefined( self.script_growl );
  87. }
  88.  
  89. registernotetracks()
  90. {
  91.     anim.notetracks[ "anim_pose = "stand"" ] = ::notetrackposestand;
  92.     anim.notetracks[ "anim_pose = "crouch"" ] = ::notetrackposecrouch;
  93.     anim.notetracks[ "anim_movement = "stop"" ] = ::notetrackmovementstop;
  94.     anim.notetracks[ "anim_movement = "walk"" ] = ::notetrackmovementwalk;
  95.     anim.notetracks[ "anim_movement = "run"" ] = ::notetrackmovementrun;
  96.     anim.notetracks[ "anim_alertness = causal" ] = ::notetrackalertnesscasual;
  97.     anim.notetracks[ "anim_alertness = alert" ] = ::notetrackalertnessalert;
  98.     anim.notetracks[ "gravity on" ] = ::notetrackgravity;
  99.     anim.notetracks[ "gravity off" ] = ::notetrackgravity;
  100.     anim.notetracks[ "gravity code" ] = ::notetrackgravity;
  101.     anim.notetracks[ "bodyfall large" ] = ::notetrackbodyfall;
  102.     anim.notetracks[ "bodyfall small" ] = ::notetrackbodyfall;
  103.     anim.notetracks[ "footstep" ] = ::notetrackfootstep;
  104.     anim.notetracks[ "step" ] = ::notetrackfootstep;
  105.     anim.notetracks[ "footstep_right_large" ] = ::notetrackfootstep;
  106.     anim.notetracks[ "footstep_right_small" ] = ::notetrackfootstep;
  107.     anim.notetracks[ "footstep_left_large" ] = ::notetrackfootstep;
  108.     anim.notetracks[ "footstep_left_small" ] = ::notetrackfootstep;
  109.     anim.notetracks[ "footscrape" ] = ::notetrackfootscrape;
  110.     anim.notetracks[ "land" ] = ::notetrackland;
  111.     anim.notetracks[ "start_ragdoll" ] = ::notetrackstartragdoll;
  112. }
  113.  
  114. notetrackstopanim( note, flagname )
  115. {
  116. }
  117.  
  118. notetrackstartragdoll( note, flagname )
  119. {
  120.     if ( isDefined( self.noragdoll ) )
  121.     {
  122.         return;
  123.     }
  124.     self unlink();
  125.     self startragdoll();
  126. }
  127.  
  128. notetrackmovementstop( note, flagname )
  129. {
  130.     if ( issentient( self ) )
  131.     {
  132.         self.a.movement = "stop";
  133.     }
  134. }
  135.  
  136. notetrackmovementwalk( note, flagname )
  137. {
  138.     if ( issentient( self ) )
  139.     {
  140.         self.a.movement = "walk";
  141.     }
  142. }
  143.  
  144. notetrackmovementrun( note, flagname )
  145. {
  146.     if ( issentient( self ) )
  147.     {
  148.         self.a.movement = "run";
  149.     }
  150. }
  151.  
  152. notetrackalertnesscasual( note, flagname )
  153. {
  154.     if ( issentient( self ) )
  155.     {
  156.         self.a.alertness = "casual";
  157.     }
  158. }
  159.  
  160. notetrackalertnessalert( note, flagname )
  161. {
  162.     if ( issentient( self ) )
  163.     {
  164.         self.a.alertness = "alert";
  165.     }
  166. }
  167.  
  168. notetrackposestand( note, flagname )
  169. {
  170.     self.a.pose = "stand";
  171.     self notify( "entered_pose" + "stand" );
  172. }
  173.  
  174. notetrackposecrouch( note, flagname )
  175. {
  176.     self.a.pose = "crouch";
  177.     self notify( "entered_pose" + "crouch" );
  178.     if ( self.a.crouchpain )
  179.     {
  180.         self.a.crouchpain = 0;
  181.         self.health = 150;
  182.     }
  183. }
  184.  
  185. notetrackgravity( note, flagname )
  186. {
  187.     if ( issubstr( note, "on" ) )
  188.     {
  189.         self animmode( "gravity" );
  190.     }
  191.     else if ( issubstr( note, "off" ) )
  192.     {
  193.         self animmode( "nogravity" );
  194.         self.nogravity = 1;
  195.     }
  196.     else
  197.     {
  198.         if ( issubstr( note, "code" ) )
  199.         {
  200.             self animmode( "none" );
  201.             self.nogravity = undefined;
  202.         }
  203.     }
  204. }
  205.  
  206. notetrackbodyfall( note, flagname )
  207. {
  208.     if ( isDefined( self.groundtype ) )
  209.     {
  210.         groundtype = self.groundtype;
  211.     }
  212.     else
  213.     {
  214.         groundtype = "dirt";
  215.     }
  216.     if ( issubstr( note, "large" ) )
  217.     {
  218.         self playsound( "fly_bodyfall_large_" + groundtype );
  219.     }
  220.     else
  221.     {
  222.         if ( issubstr( note, "small" ) )
  223.         {
  224.             self playsound( "fly_bodyfall_small_" + groundtype );
  225.         }
  226.     }
  227. }
  228.  
  229. notetrackfootstep( note, flagname )
  230. {
  231.     if ( issubstr( note, "left" ) )
  232.     {
  233.         playfootstep( "J_Ball_LE" );
  234.     }
  235.     else
  236.     {
  237.         playfootstep( "J_BALL_RI" );
  238.     }
  239.     if ( !level.clientscripts )
  240.     {
  241.         self playsound( "fly_gear_run" );
  242.     }
  243. }
  244.  
  245. notetrackfootscrape( note, flagname )
  246. {
  247.     if ( isDefined( self.groundtype ) )
  248.     {
  249.         groundtype = self.groundtype;
  250.     }
  251.     else
  252.     {
  253.         groundtype = "dirt";
  254.     }
  255.     self playsound( "fly_step_scrape_" + groundtype );
  256. }
  257.  
  258. notetrackland( note, flagname )
  259. {
  260.     if ( isDefined( self.groundtype ) )
  261.     {
  262.         groundtype = self.groundtype;
  263.     }
  264.     else
  265.     {
  266.         groundtype = "dirt";
  267.     }
  268.     self playsound( "fly_land_npc_" + groundtype );
  269. }
  270.  
  271. handlenotetrack( note, flagname, customfunction, var1 )
  272. {
  273.     if ( isai( self ) && self.isdog )
  274.     {
  275.         if ( handledogsoundnotetracks( note ) )
  276.         {
  277.             return;
  278.         }
  279.     }
  280.     else
  281.     {
  282.         notetrackfunc = anim.notetracks[ note ];
  283.         if ( isDefined( notetrackfunc ) )
  284.         {
  285.             return [[ notetrackfunc ]]( note, flagname );
  286.         }
  287.     }
  288.     switch( note )
  289.     {
  290.         case "end":
  291.         case "finish":
  292.         case "undefined":
  293.             if ( isai( self ) && self.a.pose == "back" )
  294.             {
  295.             }
  296.             return note;
  297.         case "swish small":
  298.             self thread play_sound_in_space( "fly_gear_enemy", self gettagorigin( "TAG_WEAPON_RIGHT" ) );
  299.             break;
  300.         case "swish large":
  301.             self thread play_sound_in_space( "fly_gear_enemy_large", self gettagorigin( "TAG_WEAPON_RIGHT" ) );
  302.             break;
  303.         case "no death":
  304.             self.a.nodeath = 1;
  305.             break;
  306.         case "no pain":
  307.             self.allowpain = 0;
  308.             break;
  309.         case "allow pain":
  310.             self.allowpain = 1;
  311.             break;
  312.         case "anim_melee = "right"":
  313.         case "anim_melee = right":
  314.             self.a.meleestate = "right";
  315.             break;
  316.         case "anim_melee = "left"":
  317.         case "anim_melee = left":
  318.             self.a.meleestate = "left";
  319.             break;
  320.         case "swap taghelmet to tagleft":
  321.             if ( isDefined( self.hatmodel ) )
  322.             {
  323.                 if ( isDefined( self.helmetsidemodel ) )
  324.                 {
  325.                     self detach( self.helmetsidemodel, "TAG_HELMETSIDE" );
  326.                     self.helmetsidemodel = undefined;
  327.                 }
  328.                 self detach( self.hatmodel, "" );
  329.                 self attach( self.hatmodel, "TAG_WEAPON_LEFT" );
  330.                 self.hatmodel = undefined;
  331.             }
  332.             break;
  333.         default:
  334.             if ( isDefined( customfunction ) )
  335.             {
  336.                 if ( !isDefined( var1 ) )
  337.                 {
  338.                     return [[ customfunction ]]( note );
  339.                 }
  340.                 else
  341.                 {
  342.                     return [[ customfunction ]]( note, var1 );
  343.                 }
  344.             }
  345.         }
  346.     }
  347. }
  348.  
  349. donotetracks( flagname, customfunction, var1 )
  350. {
  351.     for ( ;; )
  352.     {
  353.         self waittill( flagname, note );
  354.         if ( !isDefined( note ) )
  355.         {
  356.             note = "undefined";
  357.         }
  358.         val = self handlenotetrack( note, flagname, customfunction, var1 );
  359.         if ( isDefined( val ) )
  360.         {
  361.             return val;
  362.         }
  363.     }
  364. }
  365.  
  366. donotetracksforeverproc( notetracksfunc, flagname, killstring, customfunction, var1 )
  367. {
  368.     if ( isDefined( killstring ) )
  369.     {
  370.         self endon( killstring );
  371.     }
  372.     self endon( "killanimscript" );
  373.     for ( ;; )
  374.     {
  375.         time = getTime();
  376.         returnednote = [[ notetracksfunc ]]( flagname, customfunction, var1 );
  377.         timetaken = getTime() - time;
  378.         if ( timetaken < 0,05 )
  379.         {
  380.             time = getTime();
  381.             returnednote = [[ notetracksfunc ]]( flagname, customfunction, var1 );
  382.             timetaken = getTime() - time;
  383.             if ( timetaken < 0,05 )
  384.             {
  385. /#
  386.                 println( getTime() + " mapsmpanimscriptsshared::DoNoteTracksForever is trying to cause an infinite loop on anim " + flagname + ", returned " + returnednote + "." );
  387. #/
  388.                 wait ( 0,05 - timetaken );
  389.             }
  390.         }
  391.     }
  392. }
  393.  
  394. donotetracksforever( flagname, killstring, customfunction, var1 )
  395. {
  396.     donotetracksforeverproc( ::donotetracks, flagname, killstring, customfunction, var1 );
  397. }
  398.  
  399. donotetracksfortimeproc( donotetracksforeverfunc, time, flagname, customfunction, ent, var1 )
  400. {
  401.     ent endon( "stop_notetracks" );
  402.     [[ donotetracksforeverfunc ]]( flagname, undefined, customfunction, var1 );
  403. }
  404.  
  405. donotetracksfortime( time, flagname, customfunction, var1 )
  406. {
  407.     ent = spawnstruct();
  408.     ent thread donotetracksfortimeendnotify( time );
  409.     donotetracksfortimeproc( ::donotetracksforever, time, flagname, customfunction, ent, var1 );
  410. }
  411.  
  412. donotetracksfortimeendnotify( time )
  413. {
  414.     wait time;
  415.     self notify( "stop_notetracks" );
  416. }
  417.  
  418. playfootstep( foot )
  419. {
  420.     if ( !level.clientscripts )
  421.     {
  422.         if ( !isai( self ) )
  423.         {
  424.             self playsound( "fly_step_run_dirt" );
  425.             return;
  426.         }
  427.     }
  428.     groundtype = undefined;
  429.     if ( !isDefined( self.groundtype ) )
  430.     {
  431.         if ( !isDefined( self.lastgroundtype ) )
  432.         {
  433.             if ( !level.clientscripts )
  434.             {
  435.                 self playsound( "fly_step_run_dirt" );
  436.             }
  437.             return;
  438.         }
  439.         groundtype = self.lastgroundtype;
  440.     }
  441.     else
  442.     {
  443.         groundtype = self.groundtype;
  444.         self.lastgroundtype = self.groundtype;
  445.     }
  446.     if ( !level.clientscripts )
  447.     {
  448.         self playsound( "fly_step_run_" + groundtype );
  449.     }
  450.     [[ anim.optionalstepeffectfunction ]]( foot, groundtype );
  451. }
  452.  
  453. playfootstepeffect( foot, groundtype )
  454. {
  455.     if ( level.clientscripts )
  456.     {
  457.         return;
  458.     }
  459.     i = 0;
  460.     while ( i < anim.optionalstepeffects.size )
  461.     {
  462.         if ( isDefined( self.fire_footsteps ) && self.fire_footsteps )
  463.         {
  464.             groundtype = "fire";
  465.         }
  466.         if ( groundtype != anim.optionalstepeffects[ i ] )
  467.         {
  468.             i++;
  469.             continue;
  470.         }
  471.         else
  472.         {
  473.             org = self gettagorigin( foot );
  474.             playfx( level._effect[ "step_" + anim.optionalstepeffects[ i ] ], org, org + vectorScale( ( 0, 0, 1 ), 100 ) );
  475.             return;
  476.         }
  477.         i++;
  478.     }
  479. }
  480.  
  481. movetooriginovertime( origin, time )
  482. {
  483.     self endon( "killanimscript" );
  484.     if ( distancesquared( self.origin, origin ) > 256 && !self maymovetopoint( origin ) )
  485.     {
  486. /#
  487.         println( "^1Warning: AI starting behavior for node at " + origin + " but could not move to that point." );
  488. #/
  489.         return;
  490.     }
  491.     self.keepclaimednodeingoal = 1;
  492.     offset = self.origin - origin;
  493.     frames = int( time * 20 );
  494.     offsetreduction = vectorScale( offset, 1 / frames );
  495.     i = 0;
  496.     while ( i < frames )
  497.     {
  498.         offset -= offsetreduction;
  499.         self teleport( origin + offset );
  500.         wait 0,05;
  501.         i++;
  502.     }
  503.     self.keepclaimednodeingoal = 0;
  504. }
  505.  
  506. returntrue()
  507. {
  508.     return 1;
  509. }
Advertisement
Add Comment
Please, Sign In to add comment