]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/client.qc
added todds new hagar fire sounds
[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, 70);
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         float mdlrandom;
70
71         spot = SelectSpawnPoint ();
72
73         self.classname = "player";
74         self.movetype = MOVETYPE_WALK;
75         self.solid = SOLID_SLIDEBOX;
76         self.flags = FL_CLIENT;
77         self.takedamage = DAMAGE_YES;
78         self.effects = 0;
79         self.health = 150;
80         self.damageforcescale = 2;
81         self.death_time = 0;
82         self.dead_time = 0;
83         self.dead_frame = 0;
84         self.die_frame = 0;
85         self.alpha = 0;
86         self.scale = 0;
87         self.fade_time = 0;
88         self.pain_frame = 0;
89         self.pain_finished = 0;
90
91         self.deadflag = DEAD_NO;
92
93         self.view_ofs = PL_VIEW_OFS;
94         self.angles = spot.angles;
95
96         self.viewzoom = 0.6;
97
98         mdlrandom = crandom();
99         if (mdlrandom>-0.9)
100                 setmodel (self, "models/player/insurrectionist.zym");
101         if (mdlrandom>-0.8)
102                 setmodel (self, "models/player/mulder.zym");
103         if (mdlrandom>-0.6)
104                 setmodel (self, "models/player/lurk.zym");
105         if (mdlrandom>-0.4)
106                 setmodel (self, "models/player/grunt.zym");
107         if (mdlrandom>-0.3)
108                 setmodel (self, "models/player/pyria.zym");
109         if (mdlrandom>-0.2)
110                 setmodel (self, "models/player/headhunter.zym");
111         if (mdlrandom>0.0)
112                 setmodel (self, "models/player/jeandarc.zym");
113         if (mdlrandom>0.1)
114                 setmodel (self, "models/player/marine.zym");
115         if (mdlrandom>0.2)
116                 setmodel (self, "models/player/robot.zym");
117         if (mdlrandom>0.4)
118                 setmodel (self, "models/player/pyria.zym");
119         if (mdlrandom>0.6)
120                 setmodel (self, "models/player/shock.zym");
121         if (mdlrandom>0.7)
122                 setmodel (self, "models/player/lycanthrope.zym");
123         if (mdlrandom>0.8)
124                 setmodel (self, "models/player/specop.zym");
125         if (mdlrandom>0.9)
126                 setmodel (self, "models/player/visitant.zym");
127
128
129         setsize (self, PL_MIN, PL_MAX);
130         setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24));
131         // don't reset back to last position, even if new position is stuck in solid
132         self.oldorigin = self.origin;
133
134 //      self.items = IT_LASER | IT_UZI| IT_SHOTGUN | IT_GRENADE_LAUNCHER | IT_ELECTRO | IT_CRYLINK | IT_NEX | IT_HAGAR | IT_ROCKET_LAUNCHER;
135 //      self.weapon = IT_UZI;
136
137         if (game & GAME_INSTAGIB)
138         {
139                 self.items = IT_NEX;
140                 self.weapon = IT_NEX;
141                 self.ammo_shells = 0;
142                 self.ammo_nails = 0;
143                 self.ammo_rockets = 0;
144                 self.ammo_cells = 999;
145         }
146         else if (game & GAME_ROCKET_ARENA)
147         {
148                 self.items = IT_ROCKET_LAUNCHER;
149                 self.weapon = IT_ROCKET_LAUNCHER;
150                 self.ammo_shells = 0;
151                 self.ammo_nails = 0;
152                 self.ammo_rockets = 999;
153                 self.ammo_cells = 0;
154         }
155         else
156         {
157                 self.items = IT_LASER | IT_UZI;
158                 self.weapon = IT_UZI;
159                 self.ammo_shells = 0;
160                 self.ammo_nails = 25;
161                 self.ammo_rockets = 0;
162                 self.ammo_cells = 0;
163         }
164
165         if (game & GAME_FULLBRIGHT_PLAYERS)
166                 self.effects = EF_FULLBRIGHT;
167
168         self.event_damage = PlayerDamage;
169
170         self.statdraintime = time + 5;
171         self.button0 = self.button1 = self.button2 = self.button3 = 0;
172
173         W_UpdateWeapon ();
174         W_UpdateAmmo ();
175
176         //stuffcmd(self, "chase_active 0");
177 }
178
179 /*
180 =============
181 SetNewParms
182 =============
183 */
184 void SetNewParms (void)
185 {
186
187 }
188
189 /*
190 =============
191 SetChangeParms
192 =============
193 */
194 void SetChangeParms (void)
195 {
196
197 }
198
199 /*
200 =============
201 ClientKill
202
203 Called when a client types 'kill' in the console
204 =============
205 */
206 void ClientKill (void)
207 {
208
209 }
210
211 /*
212 =============
213 ClientConnect
214
215 Called when a client connects to the server
216 =============
217 */
218 void ClientConnect (void)
219 {
220         ClientInRankings();
221         bprint (self.netname);
222         bprint (" connected\n");
223 }
224
225 /*
226 =============
227 ClientDisconnect
228
229 Called when a client disconnects from the server
230 =============
231 */
232 void ClientDisconnect (void)
233 {
234         ClientDisconnected();
235         bprint (self.netname);
236         bprint (" disconnected\n");
237 }
238
239 /*
240 =============
241 PlayerJump
242
243 When you press the jump key
244 =============
245 */
246 void PlayerJump (void)
247 {
248         if (!(self.flags & FL_ONGROUND))
249                 return;
250         if (!(self.flags & FL_JUMPRELEASED))
251                 return;
252
253         self.velocity_z = self.velocity_z + 250;
254
255         self.flags = self.flags - FL_ONGROUND;
256         self.flags = self.flags - FL_JUMPRELEASED;
257 }
258
259 void respawn(void)
260 {
261         CopyBody();
262         PutClientInServer();
263 }
264
265 /*
266 =============
267 PlayerPreThink
268
269 Called every frame for each client before the physics are run
270 =============
271 */
272 .float attack_finished;
273 void PlayerPreThink (void)
274 {
275         if (BotPreFrame())
276                 return;
277         if (!self.hasaliases)
278             DoAliases();
279
280         if (self.deadflag != DEAD_NO)
281         {
282                 player_anim ();
283                 if (self.deadflag == DEAD_DYING)
284                 {
285                         if (time > self.dead_time)
286                                 self.deadflag = DEAD_DEAD;
287                 }
288                 else if (self.deadflag == DEAD_DEAD)
289                 {
290                         if (!self.button0 && !self.button2 && !self.button3)
291                                 self.deadflag = DEAD_RESPAWNABLE;
292                 }
293                 else if (self.deadflag == DEAD_RESPAWNABLE)
294                 {
295                         if (self.button0 || self.button2 || self.button3  || self.button4)
296                                 respawn();
297                 }
298                 return;
299         }
300
301         if (self.button4)
302         {
303                 if (self.weapon == IT_ROCKET_LAUNCHER)
304                         W_ThirdAttack ();
305                 if (!(game & GAME_INSANE))
306                 if (self.attack_finished < time && !self.button0 && !self.button3)
307                         W_ThirdAttack ();
308         }
309
310         if (self.button3)
311         {
312                 if (self.weapon == IT_GRENADE_LAUNCHER)
313                         W_SecondaryAttack ();
314                 if (self.weapon == IT_ROCKET_LAUNCHER)
315                         W_SecondaryAttack ();
316                 if (!(game & GAME_INSANE))
317                         if (self.attack_finished < time && !self.button0)
318                                 W_SecondaryAttack ();
319         }
320         
321         if (!(game & GAME_INSANE))
322         if (self.attack_finished < time)
323         if (self.button0)
324                 W_Attack ();
325         
326         if (self.button2)
327                 PlayerJump ();
328         else
329                 self.flags = self.flags | FL_JUMPRELEASED;
330
331         if (self.button3)
332         {
333                 if (self.weapon == IT_NEX)
334                         if (self.viewzoom > 0.4)
335                                 self.viewzoom = max (0.4, self.viewzoom - frametime * 2);
336         }
337         else if (self.viewzoom < 1.0)
338                 self.viewzoom = min (1.0, self.viewzoom + frametime);
339
340         if (self.statdraintime < time)
341         {
342                 // GAME_REGENERATION does fast health regeneration up to 200. Note that your armour doesn't rot anymore either.
343                 // Sajt - go ahead and tweak this, I just guessed some values :)
344                 if (game & GAME_REGENERATION)
345                 {
346                         if (self.health < 200)
347                                 self.health = self.health + 2;
348
349                         self.statdraintime = time + 0.25;
350                 }
351                 else
352                 {
353                         if (self.health < 25)
354                                 self.health = self.health + 3;
355                         if (self.health < 50)
356                                 self.health = self.health + 2;
357                         if (self.health < 100)
358                                 self.health = self.health + 1;
359                         if (self.health > 100)
360                                 self.health = self.health - 1;
361                         if (self.health > 150)
362                                 self.health = self.health - 2;
363                         if (self.health > 200)
364                                 self.health = self.health - 4;
365                         if (self.health > 250)
366                                 self.health = self.health - 6;
367                         if (self.armorvalue > 100)
368                                 self.armorvalue = self.armorvalue - 1;
369
370                         self.statdraintime = time + 1;
371                 }
372         }
373         player_anim ();
374         weapon_anim ();
375
376         if (TetrisPreFrame()) return;
377         self.angles_y=self.v_angle_y + 90;   // temp
378
379 }
380
381 /*
382 =============
383 PlayerPostThink
384
385 Called every frame for each client after the physics are run
386 =============
387 */
388 void PlayerPostThink (void)
389 {
390         if (BotPostFrame())
391                 return;
392         if (self.health > 0)
393         if (self.impulse)
394                 ImpulseCommands ();
395         if (TetrisPostFrame()) return;
396 }