• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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===========
14SpectatorConnect
15
16called when a spectator connects to a server
17============
18*/
19void() SpectatorConnect =
20{
21	bprint (PRINT_MEDIUM, "Spectator ");
22	bprint (PRINT_MEDIUM, self.netname);
23	bprint (PRINT_MEDIUM, " entered the game\n");
24
25	self.goalentity = world; // used for impulse 1 below
26};
27
28/*
29===========
30SpectatorDisconnect
31
32called when a spectator disconnects from a server
33============
34*/
35void() SpectatorDisconnect =
36{
37	bprint (PRINT_MEDIUM, "Spectator ");
38	bprint (PRINT_MEDIUM, self.netname);
39	bprint (PRINT_MEDIUM, " left the game\n");
40};
41
42/*
43================
44SpectatorImpulseCommand
45
46Called by SpectatorThink if the spectator entered an impulse
47================
48*/
49void() SpectatorImpulseCommand =
50{
51	if (self.impulse == 1) {
52		// teleport the spectator to the next spawn point
53		// note that if the spectator is tracking, this doesn't do
54		// much
55		self.goalentity = find(self.goalentity, classname, "info_player_deathmatch");
56		if (self.goalentity == world)
57			self.goalentity = find(self.goalentity, classname, "info_player_deathmatch");
58		if (self.goalentity != world) {
59			setorigin(self, self.goalentity.origin);
60			self.angles = self.goalentity.angles;
61			self.fixangle = TRUE;           // turn this way immediately
62		}
63	}
64
65	self.impulse = 0;
66};
67
68/*
69================
70SpectatorThink
71
72Called every frame after physics are run
73================
74*/
75void() SpectatorThink =
76{
77	// self.origin, etc contains spectator position, so you could
78	// do some neat stuff here
79
80	if (self.impulse)
81		SpectatorImpulseCommand();
82};
83
84
85