]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/client.qc
added func_bobbing and func_rotating (according to q3 specs), commented out func_trai...
[divverent/nexuiz.git] / qcsrc / client.qc
1
2 void info_player_start (void)
3 {
4         self.classname = "info_player_deathmatch";
5 }
6
7 void info_player_deathmatch (void)
8 {
9 }
10
11 /*
12 =============
13 SelectSpawnPoint
14
15 Finds a point to respawn
16 =============
17 */
18 entity SelectSpawnPoint (void)
19 {
20         local entity spot, thing;
21         local float pcount;
22
23         spot = find (world, classname, "testplayerstart");
24         if (spot)
25                 return spot;
26
27         spot = lastspawn;
28         while (1)
29         {
30                 spot = find(spot, classname, "info_player_deathmatch");
31                 if (spot != world)
32                 {
33                         if (spot == lastspawn)
34                                 return lastspawn;
35                         pcount = 0;
36                         thing = findradius(spot.origin, 32);
37                         while(thing)
38                         {
39                                 if (thing.classname == "player")
40                                         pcount = pcount + 1;
41                                 thing = thing.chain;
42                         }
43                         if (pcount == 0)
44                         {
45                                 lastspawn = spot;
46                                 return spot;
47                         }
48                 }
49         }
50
51         spot = find (world, classname, "info_player_start");
52         if (!spot)
53                 error ("PutClientInServer: no info_player_start on level");
54         
55         return spot;
56 }
57
58
59 /*
60 =============
61 PutClientInServer
62
63 Called when a client spawns in the server
64 =============
65 */
66 void PutClientInServer (void)
67 {
68         entity  spot;
69
70         spot = SelectSpawnPoint ();
71
72         self.classname = "player";
73         self.movetype = MOVETYPE_WALK;
74         self.solid = SOLID_SLIDEBOX;
75         self.flags = FL_CLIENT;
76         self.takedamage = DAMAGE_YES;
77         self.health = 125;
78         self.damageforcescale = 2;
79
80         self.ammo_shells = 100;
81         self.ammo_nails = 100;
82         self.ammo_rockets = 100;
83         self.ammo_cells = 100;
84
85         self.deadflag = DEAD_NO;
86
87         self.view_ofs = PL_VIEW_OFS;
88         self.angles = spot.angles;
89         setmodel (self, "models/player/player.zym");
90         setsize (self, PL_MIN, PL_MAX);
91         setorigin (self, spot.origin);
92
93         self.items = IT_LASER | IT_UZI | IT_SHOTGUN | IT_GRENADE_LAUNCHER | IT_ELECTRO | IT_CRYLINK | IT_NEX | IT_HAGAR | IT_ROCKET_LAUNCHER;
94         self.weapon = IT_UZI;
95
96         self.event_hurt = PlayerHurt;
97         self.event_die = PlayerDie;
98
99         self.statdraintime = time + 5;
100         self.button0 = self.button1 = self.button2 = self.button3 = 0;
101
102         W_UpdateWeapon ();
103         W_UpdateAmmo ();
104
105         stuffcmd(self, "chase_active 0");
106 }
107
108 /*
109 =============
110 SetNewParms
111 =============
112 */
113 void SetNewParms (void)
114 {
115
116 }
117
118 /*
119 =============
120 SetChangeParms
121 =============
122 */
123 void SetChangeParms (void)
124 {
125
126 }
127
128 /*
129 =============
130 ClientKill
131
132 Called when a client types 'kill' in the console
133 =============
134 */
135 void ClientKill (void)
136 {
137
138 }
139
140 /*
141 =============
142 ClientConnect
143
144 Called when a client connects to the server
145 =============
146 */
147 void ClientConnect (void)
148 {
149         ClientInRankings();
150         bprint (self.netname);
151         bprint (" connected\n");
152 }
153
154 /*
155 =============
156 ClientDisconnect
157
158 Called when a client disconnects from the server
159 =============
160 */
161 void ClientDisconnect (void)
162 {
163         ClientDisconnected();
164         bprint (self.netname);
165         bprint (" disconnected\n");
166 }
167
168 /*
169 =============
170 PlayerJump
171
172 When you press the jump key
173 =============
174 */
175 void PlayerJump (void)
176 {
177         if (self.deadflag != DEAD_NO)
178         {
179                 if (self.death_time < time)
180                         PutClientInServer();
181
182                 return;
183         }
184         if (!(self.flags & FL_ONGROUND))
185                 return;
186         if (!(self.flags & FL_JUMPRELEASED))
187                 return;
188
189         self.velocity_z = self.velocity_z + 300;
190
191         self.flags = self.flags - FL_ONGROUND;
192         self.flags = self.flags - FL_JUMPRELEASED;
193 }
194
195 /*
196 =============
197 PlayerPreThink
198
199 Called every frame for each client before the physics are run
200 =============
201 */
202 .float attack_finished;
203 void PlayerPreThink (void)
204 {
205         if (BotPreFrame())
206                 return;
207
208         if (self.attack_finished < time)
209         {
210                 if (self.button0)
211                         W_Attack ();
212                 else if (self.button3)
213                         W_SecondaryAttack ();
214         }
215
216         if (self.button2)
217                 PlayerJump ();
218         else
219                 self.flags = self.flags | FL_JUMPRELEASED;
220
221         if (self.deadflag != DEAD_NO)
222         {
223                 self.angles = self.dead_angles;
224                 return;
225         }
226
227         if (self.weapon == IT_NEX && self.button3)
228                 self.viewzoom = 0.3;
229         else if (self.viewzoom != 1)
230                 self.viewzoom = 1;
231
232         if (self.statdraintime < time)
233         {
234                 if (self.health > 100)
235                         self.health = self.health - 1;
236                 if (self.armorvalue > 100)
237                         self.armorvalue = self.armorvalue - 1;
238
239                 self.statdraintime = time + 1;
240         }
241
242         self.angles_y=self.v_angle_y + 90;   // temp
243
244         player_stand ();
245 }
246
247 /*
248 =============
249 PlayerPostThink
250
251 Called every frame for each client after the physics are run
252 =============
253 */
254 void PlayerPostThink (void)
255 {
256         if (BotPostFrame())
257                 return;
258
259         ImpulseCommands ();
260 }