- Put Client Commands in a seperate file
[divverent/nexuiz.git] / TeamNexuiz / game / gamec / tfgrenades.c
1 entity msg_entity;\r
2 void () TeamFortress_GrenadePrimed;\r
3 .float grenade_timer;\r
4 .float FlashTime;\r
5 void () CP_Timer;\r
6 \r
7 /*=======================\r
8  General grenade explode\r
9  ======================*/\r
10 void () GrenadeExplode =\r
11 {\r
12 /*      if (self.voided)\r
13         {\r
14                 return;\r
15         }\r
16         self.voided = 1;\r
17         if ((self.classname == "pipebomb"))\r
18         {\r
19                 num_world_pipebombs = (num_world_pipebombs - 1);\r
20                 decrement_team_pipebombs (self.team_no);\r
21                 if (!(self.flags & 512))\r
22                 {\r
23                         self.weapon = 40;\r
24                 }\r
25         }*/\r
26         if ((self.owner.has_disconnected != 1))\r
27         {\r
28                 deathmsg = self.weapon;\r
29                 T_RadiusDamage (self, self.owner, 120, world);\r
30         }\r
31 /*      local entity te;\r
32         if ((self.no_active_nail_grens != 0))\r
33         {\r
34                 self.no_active_nail_grens = 0;\r
35                 self.owner.no_active_nail_grens = (self.owner.no_active_nail_grens - 1);\r
36                 te = find (world, classname, "grenade");\r
37                 while (te)\r
38                 {\r
39                         if (((te.owner == self.owner) && (te.no_active_nail_grens != 0)))\r
40                         {\r
41                                 te.no_active_nail_grens = (te.no_active_nail_grens - 1);\r
42                         }\r
43                         te = find (te, classname, "grenade");\r
44                 }\r
45         }*/\r
46         WriteByte (0, 23);\r
47         WriteByte (0, 3);\r
48         WriteCoord (0, self.origin_x);\r
49         WriteCoord (0, self.origin_y);\r
50         WriteCoord (0, self.origin_z);\r
51         BecomeExplosion ();\r
52 };\r
53 \r
54 // TF Recoil? Anyhoo, this entity causes oddities :/\r
55 void(float psize, entity p) KickPlayer = \r
56 {\r
57         return;                 // temp\r
58         msg_entity = p;\r
59         if (psize > -3)\r
60         {\r
61                 WriteByte(1, 34);\r
62         }\r
63         else\r
64         {\r
65                 WriteByte(1, 35);\r
66         }\r
67 };\r
68 \r
69 /* ================\r
70  Flash grenade\r
71   ===============*/\r
72 void () FlashGrenadeTouch =\r
73 {\r
74         sound (self, 1, "weapons/bounce.wav", 1, 1);\r
75         if ((self.velocity == '0 0 0'))\r
76         {\r
77                 self.avelocity = '0 0 0';\r
78         }\r
79 };\r
80 \r
81 void () FlashTimer =\r
82 {\r
83         local entity te;\r
84         local string st;\r
85 \r
86         te = self.owner;\r
87         te.FlashTime = (te.FlashTime - 0.100000);\r
88         if ((te.FlashTime <= 0.000000))\r
89         {\r
90                 te.FlashTime = 0.000000;\r
91                 stuffcmd (te, "v_cshift 0\n");\r
92                 if (te.uses_bloom)\r
93                 {\r
94                         stuffcmd (te, "r_bloom_power 2\n");\r
95                         stuffcmd (te, "r_bloom_intensity 1.5\n");\r
96                 }\r
97                 remove (self);\r
98                 return;\r
99         }\r
100         if ((te.FlashTime < 1.700000))\r
101         {\r
102                 st = ftos ((te.FlashTime * 150.000000));        \r
103                 stuffcmd (te, "v_cshift ");\r
104                 stuffcmd (te, st);\r
105                 stuffcmd (te, " ");\r
106                 stuffcmd (te, st);\r
107                 stuffcmd (te, " ");\r
108                 stuffcmd (te, st);\r
109                 stuffcmd (te, " ");\r
110                 stuffcmd (te, st);\r
111                 stuffcmd (te, "\n");\r
112 \r
113                 // BLOOM!!! :D\r
114                 if (te.uses_bloom)\r
115                 {\r
116                         stuffcmd (te, "r_bloom_power 1\n");\r
117                         st = ftos(2 + (te.FlashTime * 10));\r
118                         stuffcmd (te, "r_bloom_intensity ");\r
119                         stuffcmd (te, st);\r
120                         stuffcmd (te, "\n");\r
121                 }\r
122                 \r
123         }\r
124         if ((te.FlashTime >= 1.700000))\r
125         {\r
126                 stuffcmd (te, "v_cshift 255 255 255 255\n");\r
127         }\r
128         if ((te.FlashTime <= 0.000000))\r
129         {\r
130                 te.FlashTime = 0.000000;\r
131                 stuffcmd (te, "v_cshift 0\n");\r
132                 stuffcmd (te, "r_bloom_power 2\n");\r
133                 stuffcmd (te, "r_bloom_intensity 1.5\n");\r
134                 remove (self);\r
135                 return;\r
136         }\r
137         self.nextthink = (time + 0.100000);\r
138 };\r
139 \r
140 void () FlashGrenadeExplode =\r
141 {\r
142         local entity te;\r
143 \r
144         self.effects = (self.effects | 4);\r
145         WriteByte (0, 23);\r
146         WriteByte (0, 4);\r
147         WriteCoord (0, self.origin_x);\r
148         WriteCoord (0, self.origin_y);\r
149         WriteCoord (0, self.origin_z);\r
150         te = findradius (self.origin, 300);\r
151         while (te)\r
152         {\r
153                 if ((te.classname == "player" && te.team_no != self.owner.team_no || te == self.owner))\r
154                 {\r
155                         traceline (self.origin, te.origin, 1, self);\r
156                         if ((trace_fraction == 1))\r
157                         {\r
158                                 if ((vlen ((self.origin - te.origin)) <= 200))\r
159                                 {\r
160                                         deathmsg = 35;\r
161                                         TF_T_Damage (te, self, self.owner, 60, 2, (16 | 4));\r
162                                 }\r
163                                 if (te.health > TF_FLARE_LIT)\r
164                                 {\r
165                                         if (te.FlashTime == TF_FLARE_LIT)\r
166                                         {\r
167                                                 newmis = spawn ();\r
168                                                 newmis.classname = "timer";\r
169                                                 newmis.netname = "flashtimer";\r
170                                                 newmis.team_no = self.owner.team_no;\r
171                                                 newmis.owner = te;\r
172                                                 newmis.think = FlashTimer;\r
173                                                 newmis.nextthink = (time + 0.100000);\r
174                                                 stuffcmd(te, "cmd check_val r_bloom $r_bloom\n");               // checks if the client has bloom enabled\r
175                                         }\r
176                                         te.FlashTime = 4.500000;\r
177                                         stuffcmd (te, "v_cshift 255 255 255 255\n");\r
178                                 }\r
179                         }\r
180                 }\r
181                 te = te.chain;\r
182         }\r
183         BecomeExplosion ();\r
184 };\r
185 \r
186 /*=============\r
187  Nail Grenade\r
188  ============*/\r
189 void() NailGrenadeTouch;\r
190 void() NailGrenadeExplode;\r
191 void() NailGrenadeNailEm;\r
192 void() NailGrenadeLaunchNail;\r
193 void() GrenadeExplode;\r
194 \r
195 void() NailGrenadeTouch = \r
196 {\r
197         if (other == self.owner)\r
198         {\r
199                 return;\r
200         }\r
201         sound(self, TF_FLARE_OFF, "weapons/bounce.wav", TF_FLARE_OFF, TF_FLARE_OFF);\r
202         if (self.velocity == '0 0 0')\r
203         {\r
204                 self.avelocity = '0 0 0';\r
205         }\r
206 };\r
207 \r
208 void() NailGrenadeExplode = \r
209 {\r
210         self.movetype = 5;\r
211         setorigin(self, self.origin + '0 0 32');\r
212         self.avelocity = '0 500 0';\r
213         self.nextthink = time + 0.7;\r
214         self.think = NailGrenadeNailEm;\r
215 };\r
216 \r
217 void() NailGrenadeNailEm = \r
218 {\r
219         self.velocity = '0 0 0';\r
220         self.nextthink = time + 0.1;\r
221         self.think = NailGrenadeLaunchNail;\r
222         self.playerclass = TF_FLARE_LIT;\r
223 };\r
224 \r
225 void() NailGrenadeLaunchNail = \r
226 {\r
227         local float i;\r
228         local float j;\r
229         i = TF_FLARE_LIT;\r
230         while (i < TF_FLARE_OFF)\r
231         {\r
232                 j = (random() + 2) * 5;\r
233                 current_yaw = anglemod(self.angles_y + j);\r
234                 self.angles_y = current_yaw;\r
235                 self.angles_x = TF_FLARE_LIT;\r
236                 self.angles_z = TF_FLARE_LIT;\r
237                 makevectors(self.angles);\r
238                 deathmsg = 99;                  //temp\r
239                 launch_spike(self.origin, v_forward);\r
240                 newmis.touch = superspike_touch;\r
241                 newmis.weapon = 9;\r
242                 i = i + TF_FLARE_OFF;\r
243         }\r
244         self.playerclass = self.playerclass + TF_FLARE_OFF;\r
245         self.nextthink = time + 0.1;\r
246         if (self.playerclass > 40)\r
247         {\r
248                 self.weapon = 9;\r
249                 self.think = GrenadeExplode;\r
250         }\r
251 };\r
252 \r
253 /*=====================\r
254   TF Gren Prime Code\r
255   ===================*/\r
256 \r
257 void() TeamFortress_ExplodePerson = \r
258 {\r
259 //      local entity te;\r
260         self.owner.tfstate = self.owner.tfstate - (self.owner.tfstate & 1);\r
261         KickPlayer(-2, self.owner);             // Doesnt wanna work right\r
262         newmis = spawn();\r
263         newmis.movetype = 10;\r
264         newmis.solid = 2;\r
265         newmis.classname = "grenade";\r
266         newmis.team_no = self.owner.team_no;\r
267         newmis.owner = self.owner;\r
268         newmis.velocity = '0 0 0';\r
269         newmis.angles = vectoangles(newmis.velocity);\r
270         newmis.think = SUB_Null;\r
271 //      newmis.think = NormalGrenadeExplode;\r
272         newmis.nextthink = time + 0.1;\r
273         if (self.weapon == 1)\r
274         {\r
275                 newmis.touch = NormalGrenadeTouch;\r
276                 newmis.think = NormalGrenadeExplode;\r
277                 newmis.skin = 0;\r
278                 newmis.avelocity = '300 300 300';\r
279                 self.owner.velocity = (((v_forward * 900) + '0 0 250') + (v_up * 100)); // Shoot the player hehe\r
280 //              setmodel(newmis, "progs/hgren2.mdl");\r
281                 setmodel(newmis, "models/grenades/fragnade.md3");\r
282                 \r
283         }\r
284         else\r
285 /*      {\r
286                 if (self.weapon == 2)\r
287                 {\r
288                         newmis.touch = ConcussionGrenadeTouch;\r
289                         newmis.think = ConcussionGrenadeExplode;\r
290                         newmis.skin = 1;\r
291                         newmis.avelocity = '300 300 300';\r
292                         setmodel(newmis, "progs/hgren2.mdl");\r
293                 }\r
294                 else\r
295                 {*/\r
296                         if (self.weapon == 3)\r
297                         {\r
298                                 newmis.touch = NailGrenadeTouch;\r
299                                 newmis.think = NailGrenadeExplode;\r
300                                 newmis.skin = 1;\r
301                                 newmis.avelocity = '0 300 0';\r
302                                 setmodel(newmis, "progs/biggren.mdl");\r
303                         }/*\r
304                         else\r
305                         {\r
306                                 if (self.weapon == 4)\r
307                                 {\r
308                                         newmis.touch = MirvGrenadeTouch;\r
309                                         newmis.think = MirvGrenadeExplode;\r
310                                         newmis.skin = 0;\r
311                                         newmis.avelocity = '0 300 0';\r
312                                         setmodel(newmis, "progs/biggren.mdl");\r
313                                 }\r
314                                 else\r
315                                 {\r
316                                         if (self.weapon == 5)\r
317                                         {\r
318                                                 newmis.touch = NapalmGrenadeTouch;\r
319                                                 newmis.think = NapalmGrenadeExplode;\r
320                                                 newmis.skin = 2;\r
321                                                 newmis.avelocity = '0 300 0';\r
322                                                 setmodel(newmis, "progs/biggren.mdl");\r
323                                         }\r
324                                         else\r
325                                         {\r
326                                                 if (self.weapon == 6)\r
327                                                 {\r
328                                                         sprint(self.owner, "Flare lit.\n");\r
329                                                         te = spawn();\r
330                                                         te.touch = SUB_Null;\r
331                                                         te.think = RemoveFlare;\r
332                                                         te.nextthink = time + 25;\r
333                                                         te.owner = self.owner;\r
334                                                         te.solid = 0;\r
335                                                         self.owner.effects = self.owner.effects | 4;\r
336                                                         dremove(self);\r
337                                                         dremove(newmis);\r
338                                                         return;\r
339                                                 }\r
340                                                 else\r
341                                                 {\r
342                                                         if (self.weapon == 7)\r
343                                                         {\r
344                                                                 newmis.touch = GasGrenadeTouch;\r
345                                                                 newmis.think = GasGrenadeExplode;\r
346                                                                 newmis.skin = 2;\r
347                                                                 newmis.avelocity = '300 300 300';\r
348                                                                 setmodel(newmis, "progs/grenade2.mdl");\r
349                                                         }\r
350                                                         else\r
351                                                         {\r
352                                                                 if (self.weapon == 8)\r
353                                                                 {\r
354                                                                         newmis.touch = EMPGrenadeTouch;\r
355                                                                         newmis.think = EMPGrenadeExplode;\r
356                                                                         newmis.skin = 4;\r
357                                                                         newmis.avelocity = '300 300 300';\r
358                                                                         setmodel(newmis, "progs/grenade2.mdl");\r
359                                                                 }\r
360                                                                 else\r
361                                                                 {*/\r
362                                                                         if (self.weapon == 9)\r
363                                                                         {\r
364                                                                                 newmis.touch = FlashGrenadeTouch;\r
365                                                                                 newmis.think = FlashGrenadeExplode;\r
366                                                                                 newmis.skin = 1;\r
367                                                                                 newmis.avelocity = '300 300 300';\r
368                                                                                 setmodel(newmis, "progs/grenade2.mdl");\r
369                                                                         }/*\r
370                                                                 }\r
371                                                         }\r
372                                                 }\r
373                                         }\r
374                                 }\r
375                         }\r
376                 }\r
377         }*/\r
378         setsize(newmis, '0 0 0', '0 0 0');\r
379         setorigin(newmis, self.owner.origin);\r
380         bprint("No ");\r
381         bprint(self.owner.netname);\r
382         bprint(", throw the grenade, not the pin!\n");\r
383         dremove(self);\r
384 };\r
385 \r
386 void() NormalGrenadeTouch = \r
387 {\r
388         if (other == self.owner)\r
389         {\r
390                 return;\r
391         }\r
392         sound(self, 1, "weapons/bounce.wav", 1, 1);\r
393         if (self.velocity == '0 0 0')\r
394         {\r
395                 self.avelocity = '0 0 0';\r
396         }\r
397 };\r
398 \r
399 void () NormalGrenadeExplode =\r
400 {\r
401         deathmsg = 88;\r
402         T_RadiusDamage (self, self.owner, 180, world);\r
403         WriteByte (0, 23);\r
404         WriteByte (0, 3);\r
405         WriteCoord (0, self.origin_x);\r
406         WriteCoord (0, self.origin_y);\r
407         WriteCoord (0, self.origin_z);\r
408         BecomeExplosion ();\r
409 };\r
410 \r
411 // TF Prime Grenade Function\r
412 void () TeamFortress_PrimeGrenade =\r
413 {\r
414         local float gtype;\r
415         local string gs;\r
416         local string ptime;\r
417         local entity tGrenade;\r
418 \r
419         if (((self.tfstate & 1) || (self.tfstate & 1024) || self.is_feigning == 1))\r
420         {\r
421                 return;\r
422         }\r
423         if ((self.impulse == 150))\r
424         {\r
425                 gtype = self.tp_grenades_1;\r
426                 \r
427                 if ((self.tp_grenades_1 == 2))\r
428                 {\r
429                         gs = "Concussion grenade";\r
430                 }\r
431                 else\r
432                 {\r
433                         if ((self.tp_grenades_1 == 3))\r
434                         {\r
435                                 gs = "Nail grenade";\r
436                         }\r
437                         else\r
438                         {\r
439                                 if ((self.tp_grenades_1 == 4))\r
440                                 {\r
441                                         gs = "Mirv grenade";\r
442                                 }\r
443                                 else\r
444                                 {\r
445                                         if ((self.tp_grenades_1 == 5))\r
446                                         {\r
447                                                 gs = "Napalm grenade";\r
448                                         }\r
449                                         else\r
450                                         {\r
451                                                 if ((self.tp_grenades_1 == 6))\r
452                                                 {\r
453                                                         gs = "Flare";\r
454                                                 }\r
455                                                 else\r
456                                                 {\r
457                                                         if ((self.tp_grenades_1 == 7))\r
458                                                         {\r
459                                                                 gs = "Gas grenade";\r
460                                                         }\r
461                                                         else\r
462                                                         {\r
463                                                                 if ((self.tp_grenades_1 == 8))\r
464                                                                 {\r
465                                                                         gs = "EMP grenade";\r
466                                                                 }\r
467                                                                 else\r
468                                                                 {\r
469                                                                         if ((self.tp_grenades_1 == 10))\r
470                                                                         {\r
471                                                                                 gs = "Caltrop canister";\r
472                                                                         }\r
473                                                                         else\r
474                                                                         {\r
475                                                                                 if ((self.tp_grenades_1 == 9))\r
476                                                                                 {\r
477                                                                                         gs = "Flash grenade";\r
478                                                                                 }\r
479                                                                                 else\r
480                                                                                 {\r
481                                                                                         gs = "Grenade";\r
482                                                                                 }\r
483                                                                         }\r
484                                                                 }\r
485                                                         }\r
486                                                 }\r
487                                         }\r
488                                 }\r
489                         }\r
490                 }\r
491 //              gs = "Grenade";\r
492 \r
493                 if ((self.no_grenades_1 > 0))\r
494                 {\r
495                         self.no_grenades_1 = (self.no_grenades_1 - 1);\r
496                         /*if ((gtype == 6))\r
497                         {\r
498                                 newmis = spawn ();\r
499                                 newmis.owner = self;\r
500                                 newmis.movetype = 6;\r
501                                 newmis.solid = 2;\r
502                                 newmis.classname = "grenade";\r
503                                 makevectors (self.v_angle);\r
504                                 newmis.velocity = ((v_forward * 600) + (v_up * 25));\r
505                                 newmis.velocity = (newmis.velocity * 700);\r
506                                 newmis.angles = vectoangles (newmis.velocity);\r
507                                 newmis.weapon = self.team_no;\r
508                                 newmis.think = FlareGrenadeExplode;\r
509                                 newmis.nextthink = (time + 0.8);\r
510                                 newmis.touch = FlareGrenadeTouch;\r
511                                 newmis.skin = 1;\r
512                                 newmis.mdl = "flare";\r
513                                 setmodel (newmis, "progs/flare.mdl");\r
514                                 setsize (newmis, '0 0 0', '0 0 0');\r
515                                 setorigin (newmis, self.origin);\r
516                                 return;\r
517                         }*/\r
518                         if ((gtype == 10))\r
519                         {\r
520                                 ptime = ftos (0.5);\r
521                                 sprint (self, "Opening ");\r
522                                 sprint (self, gs);\r
523                                 sprint (self, "...\n");\r
524                         }\r
525                         else\r
526                         {\r
527                                 sound (self, CHAN_WEAPON, "weapons/prime.wav", 1, ATTN_STATIC);\r
528                                 sound (self, CHAN_AUTO, "weapons/gren.wav", 1, ATTN_STATIC);\r
529                                 ptime = ftos (3);\r
530                                 sprint (self, gs);\r
531                                 sprint (self, " primed, ");\r
532                                 sprint (self, ptime);\r
533                                 sprint (self, " seconds...\n");\r
534                                 TeamNexuiz_HUD_ShowSign(self, HUD_PRIME_GREN);\r
535                         }\r
536                 }\r
537                 else\r
538                 {\r
539                         sprint (self, "No ");\r
540                         sprint (self, gs);\r
541                         sprint (self, "s left.\n");\r
542                         return;\r
543                 }\r
544         }\r
545         if ((self.impulse == 151))\r
546         {\r
547                 if (self.tp_grenades_2 == 0)\r
548                         return;\r
549                 gtype = self.tp_grenades_2;\r
550 /*              if ((self.tp_grenades_2 == 2))\r
551                 {\r
552                         gs = "Concussion grenade";\r
553                 }\r
554                 else\r
555                 {*/\r
556                         if ((self.tp_grenades_2 == 3))\r
557                         {\r
558                                 gs = "Nail grenade";\r
559                         }/*\r
560                         else\r
561                         {\r
562                                 if ((self.tp_grenades_2 == 4))\r
563                                 {\r
564                                         gs = "Mirv grenade";\r
565                                 }\r
566                                 else\r
567                                 {\r
568                                         if ((self.tp_grenades_2 == 5))\r
569                                         {\r
570                                                 gs = "Napalm grenade";\r
571                                         }\r
572                                         else\r
573                                         {\r
574                                                 if ((self.tp_grenades_2 == 6))\r
575                                                 {\r
576                                                         gs = "Flare";\r
577                                                 }\r
578                                                 else\r
579                                                 {\r
580                                                         if ((self.tp_grenades_2 == 7))\r
581                                                         {\r
582                                                                 gs = "Gas grenade";\r
583                                                         }\r
584                                                         else\r
585                                                         {\r
586                                                                 if ((self.tp_grenades_2 == 8))\r
587                                                                 {\r
588                                                                         gs = "EMP grenade";\r
589                                                                 }\r
590                                                                 else\r
591                                                                 {\r
592                                                                         if ((self.tp_grenades_2 == 9))\r
593                                                                         {\r
594                                                                                 gs = "Flash grenade";\r
595                                                                         }*/\r
596                                                                         else\r
597                                                                         {\r
598                                                                                 gs = "Grenade";\r
599                                                                         }/*\r
600                                                                 }\r
601                                                         }\r
602                                                 }\r
603                                         }\r
604                                 }\r
605                         }\r
606                 }*/\r
607                 if ((self.no_grenades_2 > 0))\r
608                 {\r
609                         self.no_grenades_2 = (self.no_grenades_2 - 1);\r
610 /*                      if ((gtype == 6))\r
611                         {\r
612                                 newmis = spawn ();\r
613                                 newmis.owner = self;\r
614                                 newmis.movetype = 6;\r
615                                 newmis.solid = 2;\r
616                                 newmis.classname = "grenade";\r
617                                 makevectors (self.v_angle);\r
618                                 if (self.v_angle_x)\r
619                                 {\r
620                                         newmis.velocity = ((v_forward * 1200) + (v_up * 200));\r
621                                 }\r
622                                 else\r
623                                 {\r
624                                         newmis.velocity = aim (self, 10000);\r
625                                         newmis.velocity = (newmis.velocity * 1200);\r
626                                         newmis.velocity_z = 75;\r
627                                 }\r
628                                 newmis.angles = vectoangles (newmis.velocity);\r
629                                 newmis.weapon = self.team_no;\r
630                                 newmis.think = FlareGrenadeExplode;\r
631                                 newmis.nextthink = (time + 0.8);\r
632                                 newmis.touch = FlareGrenadeTouch;\r
633                                 newmis.skin = 1;\r
634                                 newmis.mdl = "flare";\r
635                                 setmodel (newmis, "progs/flare.mdl");\r
636                                 setsize (newmis, '0 0 0', '0 0 0');\r
637                                 setorigin (newmis, self.origin);\r
638                                 return;\r
639                         }*/\r
640                         if ((gtype == 10))\r
641                         {\r
642                                 ptime = ftos (0.5);\r
643                                 sprint (self, "Opening ");\r
644                                 sprint (self, gs);\r
645                                 sprint (self, "...\n");\r
646                         }\r
647                         else\r
648                         {\r
649                                 ptime = ftos (3);\r
650                                 sprint (self, gs);\r
651                                 sprint (self, " primed, ");\r
652                                 sprint (self, ptime);\r
653                                 sprint (self, " seconds...\n");\r
654                         }\r
655                 }\r
656                 else\r
657                 {\r
658                         sprint (self, "No ");\r
659                         sprint (self, gs);\r
660                         sprint (self, "s left.\n");\r
661                         return;\r
662                 }\r
663         }\r
664         self.tfstate = (self.tfstate | 1);\r
665         tGrenade = spawn ();\r
666         tGrenade.owner = self;\r
667         tGrenade.weapon = gtype;\r
668         tGrenade.classname = "primer";\r
669         tGrenade.impulse = self.impulse;\r
670         tGrenade.nextthink = (time + 0.8);\r
671         tGrenade.heat = time + 4;\r
672 \r
673 /*      // Make Centerprint timer                       // Taken out due to the fact that the function sucked\r
674         newmis = spawn ();\r
675         newmis.owner = self;\r
676         newmis.classname = "primedtimer";\r
677         newmis.think = CP_Timer;\r
678         newmis.nextthink = (time);\r
679         self.grenade_timer = time;              */\r
680         /*if ((gtype == 10))\r
681         {\r
682                 tGrenade.heat = ((time + 0.5) + 0.5);\r
683         }\r
684         else\r
685         {\r
686                 tGrenade.heat = ((time + 3) + 0.8);\r
687         }*/\r
688         tGrenade.think = TeamFortress_GrenadePrimed;\r
689 };\r
690 \r
691 void () TeamFortress_GrenadePrimed =\r
692 {\r
693         local entity user;\r
694         local entity oldself;\r
695 \r
696         user = self.owner;\r
697         if ((!(user.tfstate & 1024) && !user.deadflag))\r
698         {\r
699                 self.nextthink = (time + 0.1);\r
700                 if (!self.think)\r
701                 {\r
702                         dremove (self);\r
703                 }\r
704                 if ((time > self.heat))\r
705                 {\r
706                         TeamFortress_ExplodePerson ();\r
707                 }\r
708                 return;\r
709         }\r
710         if (!(user.tfstate & 1))\r
711         {\r
712                 dprint ("GrenadePrimed logic error\n");\r
713         }\r
714         user.tfstate = (user.tfstate - (user.tfstate & 1));\r
715         user.tfstate = (user.tfstate - (user.tfstate & 1024));\r
716 //      sound (user, 1, "weapons/grenade.wav", 1, 1);\r
717         KickPlayer (-1, user);\r
718         newmis = spawn ();\r
719         newmis.owner = user;\r
720         newmis.movetype = 10;\r
721         newmis.solid = 2;\r
722         newmis.classname = "grenade";\r
723         makevectors (user.v_angle);\r
724         if (user.deadflag)\r
725         {\r
726                 newmis.velocity = '0 0 200';\r
727         }\r
728         else\r
729         {\r
730                 if (user.v_angle_x)\r
731                 {\r
732                         newmis.velocity = ((((v_forward * 600) + (v_up * 200)) + ((crandom () * v_right) * 10)) + ((crandom () * v_up) * 10));\r
733                 }\r
734                 else\r
735                 {\r
736                         newmis.velocity = aim (user, 10000);\r
737                         newmis.velocity = (newmis.velocity * 600);\r
738                         newmis.velocity_z = 200;\r
739                 }\r
740         }\r
741         newmis.angles = vectoangles (newmis.velocity);\r
742         newmis.think = SUB_Null;\r
743         newmis.nextthink = self.heat;\r
744         if ((self.weapon == 1))\r
745         {\r
746                 newmis.touch = NormalGrenadeTouch;\r
747                 newmis.think = NormalGrenadeExplode;\r
748                 newmis.skin = 0;\r
749                 newmis.avelocity = '300 300 300';\r
750 //              setmodel (newmis, "progs/hgren2.mdl");\r
751                 setmodel(newmis, "models/grenades/fragnade.md3");\r
752         }\r
753         else if ((self.weapon == 9))\r
754         {\r
755                 newmis.touch = FlashGrenadeTouch;\r
756                 newmis.think = FlashGrenadeExplode;\r
757                 newmis.skin = 2;\r
758                 newmis.avelocity = '300 300 300';\r
759                 setmodel (newmis, "progs/hgren2.mdl");\r
760         }\r
761 /*      else\r
762         {\r
763                 if ((self.weapon == 2))\r
764                 {\r
765                         newmis.touch = ConcussionGrenadeTouch;\r
766                         newmis.think = ConcussionGrenadeExplode;\r
767                         newmis.skin = 1;\r
768                         newmis.avelocity = '300 300 300';\r
769                         setmodel (newmis, "progs/hgren2.mdl");\r
770                 }\r
771                 else\r
772                 {*/\r
773                         if ((self.weapon == 3))\r
774                         {\r
775                                 newmis.touch = NailGrenadeTouch;\r
776                                 newmis.think = NailGrenadeExplode;\r
777                                 newmis.skin = 1;\r
778                                 newmis.avelocity = '0 300 0';\r
779                                 setmodel (newmis, "progs/biggren.mdl");\r
780                         }/*\r
781                         else\r
782                         {\r
783                                 if ((self.weapon == 4))\r
784                                 {\r
785                                         newmis.touch = MirvGrenadeTouch;\r
786                                         newmis.think = MirvGrenadeExplode;\r
787                                         newmis.skin = 0;\r
788                                         newmis.avelocity = '0 300 0';\r
789                                         setmodel (newmis, "progs/biggren.mdl");\r
790                                 }\r
791                                 else\r
792                                 {\r
793                                         if ((self.weapon == 5))\r
794                                         {\r
795                                                 newmis.touch = NapalmGrenadeTouch;\r
796                                                 newmis.think = NapalmGrenadeExplode;\r
797                                                 newmis.skin = 2;\r
798                                                 newmis.avelocity = '0 300 0';\r
799                                                 setmodel (newmis, "progs/biggren.mdl");\r
800                                         }\r
801                                         else\r
802                                         {\r
803                                                 if ((self.weapon == 6))\r
804                                                 {\r
805                                                         newmis.touch = FlareGrenadeTouch;\r
806                                                         newmis.weapon = self.team_no;\r
807                                                         newmis.think = FlareGrenadeExplode;\r
808                                                         newmis.skin = 1;\r
809                                                         newmis.avelocity = '300 300 300';\r
810                                                         newmis.mdl = "flare";\r
811                                                         setmodel (newmis, "progs/flare.mdl");\r
812                                                 }\r
813                                                 else\r
814                                                 {\r
815                                                         if ((self.weapon == 7))\r
816                                                         {\r
817                                                                 newmis.touch = GasGrenadeTouch;\r
818                                                                 newmis.think = GasGrenadeExplode;\r
819                                                                 newmis.skin = 3;\r
820                                                                 newmis.avelocity = '300 300 300';\r
821                                                                 setmodel (newmis, "progs/grenade2.mdl");\r
822                                                         }\r
823                                                         else\r
824                                                         {\r
825                                                                 if ((self.weapon == 8))\r
826                                                                 {\r
827                                                                         newmis.touch = EMPGrenadeTouch;\r
828                                                                         newmis.think = EMPGrenadeExplode;\r
829                                                                         newmis.skin = 4;\r
830                                                                         newmis.avelocity = '300 300 300';\r
831                                                                         setmodel (newmis, "progs/grenade2.mdl");\r
832                                                                 }\r
833                                                                 else\r
834                                                                 {\r
835                                                                         if ((self.weapon == 10))\r
836                                                                         {\r
837                                                                                 newmis.touch = CanisterTouch;\r
838                                                                                 newmis.think = ScatterCaltrops;\r
839                                                                                 newmis.skin = 0;\r
840                                                                                 newmis.avelocity = '0 0 0';\r
841                                                                         }\r
842                                                                         else\r
843                                                                         {\r
844                                                                                 if ((self.weapon == 9))\r
845                                                                                 {\r
846                                                                                         newmis.touch = FlashGrenadeTouch;\r
847                                                                                         newmis.think = FlashGrenadeExplode;\r
848                                                                                         newmis.skin = 2;\r
849                                                                                         newmis.avelocity = '300 300 300';\r
850                                                                                         setmodel (newmis, "progs/hgren2.mdl");\r
851                                                                                 }\r
852                                                                         }\r
853                                                                 }\r
854                                                         }\r
855                                                 }\r
856                                         }\r
857                                 }\r
858                         }\r
859                 }\r
860         }*/\r
861         setsize (newmis, '0 0 0', '0 0 0');\r
862         setorigin (newmis, user.origin);\r
863         oldself = self;\r
864         self = self.owner;\r
865         self = oldself;\r
866         dremove (self);\r
867 };\r
868 \r
869 void () TeamFortress_ThrowGrenade =\r
870 {\r
871         if (!(self.tfstate & 1))\r
872         {\r
873                 return;\r
874         }\r
875         sound(self, 3, "weapons/throw.wav", 1, 1);\r
876         self.tfstate = (self.tfstate | 1024);\r
877 };\r
878 \r
879 // TF Grenade CenterPrint Timer - it sucks so I took it out:x\r
880 void () CP_Timer =\r
881 {\r
882         local float countdown;\r
883 \r
884         countdown = (time - self.owner.grenade_timer);\r
885 \r
886         if (countdown > 0)\r
887         {\r
888                 CenterPrint (self.owner, "^7\80\81\81\81\81\81\81\81\81\81\81\81\81\82^1\n");\r
889         }\r
890         if (countdown > .25)\r
891         {\r
892                 CenterPrint (self.owner, "^1\80^7\81\81\81\81\81\81\81\81\81\81\81\81\82\n");\r
893         }\r
894         if (countdown > .5)\r
895         {\r
896                 CenterPrint (self.owner, "^1\80\81^7\81\81\81\81\81\81\81\81\81\81\81\82\n");\r
897         }\r
898         if (countdown > .75)\r
899         {\r
900                 CenterPrint (self.owner, "^1\80\81\81^7\81\81\81\81\81\81\81\81\81\81\82\n");\r
901         }\r
902         if (countdown > 1)\r
903         {\r
904                 CenterPrint (self.owner, "^1\80\81\81\81^7\81\81\81\81\81\81\81\81\81\82\n");\r
905         }\r
906         if (countdown > 1.25)\r
907         {\r
908                 CenterPrint (self.owner, "^1\80\81\81\81\81^7\81\81\81\81\81\81\81\81\82\n");\r
909         }\r
910         if (countdown > 1.5)\r
911         {\r
912                 CenterPrint (self.owner, "^1\80\81\81\81\81\81^7\81\81\81\81\81\81\81\82\n");\r
913         }\r
914         if (countdown > 1.75)\r
915         {\r
916                 CenterPrint (self.owner, "^1\80\81\81\81\81\81\81^7\81\81\81\81\81\81\82\n");\r
917         }\r
918         if (countdown > 2)\r
919         {\r
920                 CenterPrint (self.owner, "^1\80\81\81\81\81\81\81\81^7\81\81\81\81\81\82\n");\r
921         }\r
922         if (countdown > 2.25)\r
923         {\r
924                 CenterPrint (self.owner, "^1\80\81\81\81\81\81\81\81\81^7\81\81\81\81\82\n");\r
925         }\r
926         if (countdown > 2.5)\r
927         {\r
928                 CenterPrint (self.owner, "^1\80\81\81\81\81\81\81\81\81\81^7\81\81\81\82\n");\r
929         }\r
930         if (countdown > 2.75)\r
931         {\r
932                 CenterPrint (self.owner, "^1\80\81\81\81\81\81\81\81\81\81\81^7\81\81\82\n");\r
933         }\r
934         if (countdown > 3)\r
935         {\r
936                 CenterPrint (self.owner, "^1\80\81\81\81\81\81\81\81\81\81\81\81^7\81\82\n");\r
937         }\r
938         if (countdown > 3.25)\r
939         {\r
940                 CenterPrint (self.owner, "^1\80\81\81\81\81\81\81\81\81\81\81\81\81^7\82\n");\r
941         }\r
942         if (countdown > 3.5)\r
943         {\r
944                 CenterPrint (self.owner, "^1\80\81\81\81\81\81\81\81\81\81\81\81\81\82^7\n");\r
945         }\r
946         if (countdown > 3.75)\r
947         {\r
948                 CenterPrint (self.owner, "^3\80\81\81\81\81\81\81\81\81\81\81\81\81\82^7\n");\r
949         }\r
950         if (countdown > 4)\r
951         {\r
952                 CenterPrint (self.owner, "\n");\r
953                 dremove(self);\r
954         }\r
955         else\r
956         {\r
957                 self.nextthink = (time + .25);\r
958         }\r
959 };