spectate.qc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Spectator functions
  2. // Added Aug11'97 by Zoid <zoid@idsoftware.com>
  3. //
  4. // These functions are called from the server if they exist.
  5. // Note that Spectators only have one think since they movement code doesn't
  6. // track them much. Impulse commands work as usual, but don't call
  7. // the regular ImpulseCommand handler in weapons.qc since Spectators don't
  8. // have any weapons and things can explode.
  9. //
  10. // --- Zoid.
  11. /*
  12. ===========
  13. SpectatorConnect
  14. called when a spectator connects to a server
  15. ============
  16. */
  17. void() SpectatorConnect =
  18. {
  19. bprint (PRINT_MEDIUM, "Spectator ");
  20. bprint (PRINT_MEDIUM, self.netname);
  21. bprint (PRINT_MEDIUM, " entered the game\n");
  22. self.goalentity = world; // used for impulse 1 below
  23. };
  24. /*
  25. ===========
  26. SpectatorDisconnect
  27. called when a spectator disconnects from a server
  28. ============
  29. */
  30. void() SpectatorDisconnect =
  31. {
  32. bprint (PRINT_MEDIUM, "Spectator ");
  33. bprint (PRINT_MEDIUM, self.netname);
  34. bprint (PRINT_MEDIUM, " left the game\n");
  35. };
  36. /*
  37. ================
  38. SpectatorImpulseCommand
  39. Called by SpectatorThink if the spectator entered an impulse
  40. ================
  41. */
  42. void() SpectatorImpulseCommand =
  43. {
  44. if (self.impulse == 1) {
  45. // teleport the spectator to the next spawn point
  46. // note that if the spectator is tracking, this doesn't do
  47. // much
  48. self.goalentity = find(self.goalentity, classname, "info_player_deathmatch");
  49. if (self.goalentity == world)
  50. self.goalentity = find(self.goalentity, classname, "info_player_deathmatch");
  51. if (self.goalentity != world) {
  52. setorigin(self, self.goalentity.origin);
  53. self.angles = self.goalentity.angles;
  54. self.fixangle = TRUE; // turn this way immediately
  55. }
  56. }
  57. self.impulse = 0;
  58. };
  59. /*
  60. ================
  61. SpectatorThink
  62. Called every frame after physics are run
  63. ================
  64. */
  65. void() SpectatorThink =
  66. {
  67. // self.origin, etc contains spectator position, so you could
  68. // do some neat stuff here
  69. if (self.impulse)
  70. SpectatorImpulseCommand();
  71. };