Guest User

Untitled

a guest
Oct 21st, 2019
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function quadrotor_collision()
  2. {
  3. self endon( "change_state" );
  4. self endon( "crash_done" );
  5. self endon( "death" );
  6.  
  7. if( !IsAlive( self ) )
  8. {
  9. self thread quadrotor_predicted_collision();
  10. }
  11.  
  12. while( 1 )
  13. {
  14. self waittill( "veh_collision", velocity, normal );
  15. ang_vel = self GetAngularVelocity() * 0.5;
  16. self SetAngularVelocity( ang_vel );
  17.  
  18. // bounce off walls
  19. if( normal[2] < 0.6 || ( IsAlive( self ) && !isdefined( self.emped ) ) )
  20. {
  21. self SetVehVelocity( self.velocity + normal * 90 );
  22. self PlaySound( "veh_wasp_wall_imp" );
  23. if( normal[2] < 0.6 )
  24. {
  25. fx_origin = self.origin - normal * 28;
  26. }
  27. else
  28. {
  29. fx_origin = self.origin - normal * 10;
  30. }
  31. PlayFX( level._effect[ "quadrotor_nudge" ], fx_origin, normal );
  32. }
  33. else
  34. {
  35.  
  36. if( isdefined( self.emped ) )
  37. {
  38. if( isdefined( self.bounced ) )
  39. {
  40. self playsound( "veh_wasp_wall_imp" );
  41. self SetVehVelocity( (0,0,0) );
  42. self SetAngularVelocity( (0,0,0) );
  43. if( self.angles[0] < 0 )
  44. {
  45. if( self.angles[0] < -15 )
  46. {
  47. self.angles = ( -15, self.angles[1], self.angles[2] );
  48. }
  49. else if( self.angles[0] > -10 )
  50. {
  51. self.angles = ( -10, self.angles[1], self.angles[2] );
  52. }
  53. }
  54. else
  55. {
  56. if( self.angles[0] > 15 )
  57. {
  58. self.angles = ( 15, self.angles[1], self.angles[2] );
  59. }
  60. else if( self.angles[0] < 10 )
  61. {
  62. self.angles = ( 10, self.angles[1], self.angles[2] );
  63. }
  64. }
  65.  
  66. self.bounced = undefined;
  67. self notify( "landed" );
  68. return;
  69. }
  70. else
  71. {
  72. self.bounced = true;
  73. self SetVehVelocity( self.velocity + normal * 120 );
  74. self playsound( "veh_wasp_wall_imp" );
  75. if( normal[2] < 0.6 )
  76. {
  77. fx_origin = self.origin - normal * 28;
  78. }
  79. else
  80. {
  81. fx_origin = self.origin - normal * 10;
  82. }
  83. PlayFX( level._effect[ "quadrotor_nudge" ], fx_origin, normal );
  84. }
  85. }
  86. else
  87. {
  88. //CreateDynEntAndLaunch( self.deathmodel, self.origin, self.angles, self.origin, self.velocity * 0.01, level._effect[ "quadrotor_crash" ] );
  89. self playsound( "veh_qrdrone_explo" );
  90. self thread death_fire_loop_audio();
  91. self notify( "crash_done" );
  92. }
  93. }
  94. }
  95. }
RAW Paste Data