spectate.qc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. spectate.qc
  3. spectator functions
  4. PURPOSE
  5. Copyright (C) 1996-1997 Id Software, Inc.
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. See the GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to:
  16. Free Software Foundation, Inc.
  17. 59 Temple Place - Suite 330
  18. Boston, MA 02111-1307, USA
  19. */
  20. // Added Aug11'97 by Zoid <zoid@idsoftware.com>
  21. //
  22. // These functions are called from the server if they exist.
  23. // Note that Spectators only have one think since they movement code doesn't
  24. // track them much. Impulse commands work as usual, but don't call
  25. // the regular ImpulseCommand handler in weapons.qc since Spectators don't
  26. // have any weapons and things can explode.
  27. //
  28. // --- Zoid.
  29. /*
  30. ===========
  31. SpectatorConnect
  32. called when a spectator connects to a server
  33. ============
  34. */
  35. void() SpectatorConnect =
  36. {
  37. bprint (PRINT_MEDIUM, "Spectator ");
  38. bprint (PRINT_MEDIUM, self.netname);
  39. bprint (PRINT_MEDIUM, " entered the game\n");
  40. self.goalentity = world; // used for impulse 1 below
  41. };
  42. /*
  43. ===========
  44. SpectatorDisconnect
  45. called when a spectator disconnects from a server
  46. ============
  47. */
  48. void() SpectatorDisconnect =
  49. {
  50. bprint (PRINT_MEDIUM, "Spectator ");
  51. bprint (PRINT_MEDIUM, self.netname);
  52. bprint (PRINT_MEDIUM, " left the game\n");
  53. };
  54. /*
  55. ================
  56. SpectatorImpulseCommand
  57. Called by SpectatorThink if the spectator entered an impulse
  58. ================
  59. */
  60. void() SpectatorImpulseCommand =
  61. {
  62. if (self.impulse == 1) {
  63. // teleport the spectator to the next spawn point
  64. // note that if the spectator is tracking, this doesn't do
  65. // much
  66. self.goalentity = find(self.goalentity, classname, "info_player_deathmatch");
  67. if (self.goalentity == world)
  68. self.goalentity = find(self.goalentity, classname, "info_player_deathmatch");
  69. if (self.goalentity != world) {
  70. setorigin(self, self.goalentity.origin);
  71. self.angles = self.goalentity.angles;
  72. self.fixangle = TRUE; // turn this way immediately
  73. }
  74. }
  75. self.impulse = 0;
  76. };
  77. /*
  78. ================
  79. SpectatorThink
  80. Called every frame after physics are run
  81. ================
  82. */
  83. void() SpectatorThink =
  84. {
  85. // self.origin, etc contains spectator position, so you could
  86. // do some neat stuff here
  87. if (self.impulse)
  88. SpectatorImpulseCommand();
  89. };