You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

crossbow2.sc 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // System-wide global variables
  2. $server = false;
  3. $localplayer = true;
  4. $origin = [ 0, 0, 0 ];
  5. $view_ofs = [ 0, 0, 0 ];
  6. $angles = [ 0, 0, 0 ];
  7. $gun_position [ 0, 0, 0 ];
  8. $gun_angles[ 0, 0, 0 ];
  9. $usehull = 0;
  10. $client_time = 0;
  11. //
  12. $snd = "";
  13. $model = "";
  14. $shell_origin = [ 0, 0, 0 ];
  15. $shell_velocity = [ 0, 0, 0 ];
  16. $forward = [ 0, 0, 0 ];
  17. $right = [ 0, 0, 0 ];
  18. $up = [ 0, 0, 0 ];
  19. public Fire_Glock()
  20. {
  21. // Play a sound
  22. $snd = weapons/pl_gun3.wav;
  23. $model = models/shell.mdl;
  24. Native_PlayPlayerSound( $player = $localplayer, $sound = $snd, $channel = CHAN_STATIC, $pitch = $def_pitch, $attenuation = $def_attn, $pitch = $def_pitch );
  25. // Eject shells
  26. //
  27. for ( $i = 0; $i < 2; $i++ )
  28. {
  29. $shell_origin = $origin + $view_ofs;
  30. $shell_velocity = $forward * 24 + right * 6 + $up * 20;
  31. $shell_angles = $angles;
  32. $angles[0] = 0;
  33. $angles[2] = 0;
  34. Native_CreateTempEntity
  35. (
  36. $te_origin = $shell_origin,
  37. $te_angles = $angles,
  38. $te_framemax = Native_FrameCountForModel( $model = $model ),
  39. $te_flags = FTENT_COLLIDEWORLD | FTENT_GRAVITY | FTENT_ROTATE,
  40. $te_hitSound = BOUNCE_SHELL;
  41. $te_baselineangles = Native_RandomAngles(),
  42. $te_basedirection = $shell_velocity,
  43. $te_die = $client_time + 3.5,
  44. $te_body = Native_Random( 0, $te_framemax )
  45. )
  46. // Now fire bullets
  47. $start = $origin;
  48. $end = $origin + 8192 * $gun_angles;
  49. Native_PerformTrace( $start = $start, $end = $end, $flags = PM_STUDIO_BOX );
  50. if ( $trace_fraction != 1.0 )
  51. {
  52. Native_PlaySoundAtPosition( $origin = $trace_endpos, $sound = weapons/bullet_hit1.wav );
  53. Native_ImpactParticles( $origin = $trace_endpos );
  54. Native_PlaceDecal( $origin = $trace_endpos, $decal = "{shot2", $trace_entity );
  55. }
  56. }
  57. }