1 #include "g_local.h"
2 #include "m_player.h"
3 #include "bot.h"
4 
ClientTeam(edict_t * ent)5 char *ClientTeam (edict_t *ent)
6 {
7 	char		*p;
8 	static char	value[512];
9 
10 	value[0] = 0;
11 
12 	if (!ent->client)
13 		return value;
14 
15 	strcpy(value, Info_ValueForKey (ent->client->pers.userinfo, "skin"));
16 	p = strchr(value, '/');
17 	if (!p)
18 		return value;
19 
20 	if ((int)(dmflags->value) & DF_MODELTEAMS)
21 	{
22 		*p = 0;
23 		return value;
24 	}
25 
26 	// if ((int)(dmflags->value) & DF_SKINTEAMS)
27 	return ++p;
28 }
29 
OnSameTeam(edict_t * ent1,edict_t * ent2)30 qboolean OnSameTeam (edict_t *ent1, edict_t *ent2)
31 {
32 	char	ent1Team [512];
33 	char	ent2Team [512];
34 
35 	if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
36 		return false;
37 
38 	strcpy (ent1Team, ClientTeam (ent1));
39 	strcpy (ent2Team, ClientTeam (ent2));
40 
41 	if (strcmp(ent1Team, ent2Team) == 0)
42 		return true;
43 	return false;
44 }
45 
46 
SelectNextItem(edict_t * ent,int itflags)47 void SelectNextItem (edict_t *ent, int itflags)
48 {
49 	gclient_t	*cl;
50 	int			i, index;
51 	gitem_t		*it;
52 
53 	cl = ent->client;
54 
55 //ZOID
56 	if (cl->chase_target) {
57 		ChaseNext(ent);
58 		return;
59 	}
60 
61 /*	if (cl->menu) {
62 		PMenu_Next(ent);
63 		return;
64 	} else if (cl->chase_target) {
65 		ChaseNext(ent);
66 		return;
67 	}*/
68 //ZOID
69 
70 	// scan  for the next valid one
71 	for (i=1 ; i<=MAX_ITEMS ; i++)
72 	{
73 		index = (cl->pers.selected_item + i)%MAX_ITEMS;
74 		if (!cl->pers.inventory[index])
75 			continue;
76 		it = &itemlist[index];
77 		if (!it->use)
78 			continue;
79 		if (!(it->flags & itflags))
80 			continue;
81 
82 		cl->pers.selected_item = index;
83 		return;
84 	}
85 
86 	cl->pers.selected_item = -1;
87 }
88 
SelectPrevItem(edict_t * ent,int itflags)89 void SelectPrevItem (edict_t *ent, int itflags)
90 {
91 	gclient_t	*cl;
92 	int			i, index;
93 	gitem_t		*it;
94 
95 	cl = ent->client;
96 
97 //ZOID
98 	if (cl->menu) {
99 		PMenu_Prev(ent);
100 		return;
101 	} else if (cl->chase_target) {
102 		ChasePrev(ent);
103 		return;
104 	}
105 //ZOID
106 
107 	// scan  for the next valid one
108 	for (i=1 ; i<=MAX_ITEMS ; i++)
109 	{
110 		index = (cl->pers.selected_item + MAX_ITEMS - i)%MAX_ITEMS;
111 		if (!cl->pers.inventory[index])
112 			continue;
113 		it = &itemlist[index];
114 		if (!it->use)
115 			continue;
116 		if (!(it->flags & itflags))
117 			continue;
118 
119 		cl->pers.selected_item = index;
120 		return;
121 	}
122 
123 	cl->pers.selected_item = -1;
124 }
125 
ValidateSelectedItem(edict_t * ent)126 void ValidateSelectedItem (edict_t *ent)
127 {
128 	gclient_t	*cl;
129 
130 	cl = ent->client;
131 
132 	if (cl->pers.inventory[cl->pers.selected_item])
133 		return;		// valid
134 
135 	SelectNextItem (ent, -1);
136 }
137 
138 
139 //=================================================================================
140 
141 /*
142 ==================
143 Cmd_Give_f
144 
145 Give items to a client
146 ==================
147 */
Cmd_Give_f(edict_t * ent)148 void Cmd_Give_f (edict_t *ent)
149 {
150 	char		*name;
151 	gitem_t		*it;
152 	int			index;
153 	int			i;
154 	qboolean	give_all;
155 	edict_t		*it_ent;
156 
157 	if (deathmatch->value && !sv_cheats->value)
158 	{
159 		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
160 		return;
161 	}
162 
163 	name = gi.args();
164 
165 	if (Q_stricmp(name, "all") == 0)
166 		give_all = true;
167 	else
168 		give_all = false;
169 
170 	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
171 	{
172 		if (gi.argc() == 3)
173 			ent->health = atoi(gi.argv(2));
174 		else
175 			ent->health = ent->max_health;
176 		if (!give_all)
177 			return;
178 	}
179 
180 	if (give_all || Q_stricmp(name, "weapons") == 0)
181 	{
182 		for (i=0 ; i<game.num_items ; i++)
183 		{
184 			it = itemlist + i;
185 			if (!it->pickup)
186 				continue;
187 			if (!(it->flags & IT_WEAPON))
188 				continue;
189 			ent->client->pers.inventory[i] += 1;
190 		}
191 		if (!give_all)
192 			return;
193 	}
194 
195 	if (give_all || Q_stricmp(name, "ammo") == 0)
196 	{
197 		for (i=0 ; i<game.num_items ; i++)
198 		{
199 			it = itemlist + i;
200 			if (!it->pickup)
201 				continue;
202 			if (!(it->flags & IT_AMMO))
203 				continue;
204 			Add_Ammo (ent, it, 1000);
205 		}
206 		if (!give_all)
207 			return;
208 	}
209 
210 	if (give_all || Q_stricmp(name, "armor") == 0)
211 	{
212 		gitem_armor_t	*info;
213 
214 		it = FindItem("Jacket Armor");
215 		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
216 
217 		it = FindItem("Combat Armor");
218 		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
219 
220 		it = FindItem("Body Armor");
221 		info = (gitem_armor_t *)it->info;
222 		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;
223 
224 		if (!give_all)
225 			return;
226 	}
227 
228 	if (give_all || Q_stricmp(name, "Power Shield") == 0)
229 	{
230 		it = FindItem("Power Shield");
231 		it_ent = G_Spawn();
232 		it_ent->classname = it->classname;
233 		SpawnItem (it_ent, it);
234 		Touch_Item (it_ent, ent, NULL, NULL);
235 		if (it_ent->inuse)
236 			G_FreeEdict(it_ent);
237 
238 		if (!give_all)
239 			return;
240 	}
241 
242 	if (give_all)
243 	{
244 		for (i=0 ; i<game.num_items ; i++)
245 		{
246 			it = itemlist + i;
247 			if (!it->pickup)
248 				continue;
249 			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
250 				continue;
251 			ent->client->pers.inventory[i] = 1;
252 		}
253 		return;
254 	}
255 
256 	it = FindItem (name);
257 	if (!it)
258 	{
259 		name = gi.argv(1);
260 		it = FindItem (name);
261 		if (!it)
262 		{
263 			gi.dprintf ("unknown item\n");
264 			return;
265 		}
266 	}
267 
268 	if (!it->pickup)
269 	{
270 		gi.dprintf ("non-pickup item\n");
271 		return;
272 	}
273 
274 	index = ITEM_INDEX(it);
275 
276 	if (it->flags & IT_AMMO)
277 	{
278 		if (gi.argc() == 3)
279 			ent->client->pers.inventory[index] = atoi(gi.argv(2));
280 		else
281 			ent->client->pers.inventory[index] += it->quantity;
282 	}
283 	else
284 	{
285 		it_ent = G_Spawn();
286 		it_ent->classname = it->classname;
287 		SpawnItem (it_ent, it);
288 		Touch_Item (it_ent, ent, NULL, NULL);
289 		if (it_ent->inuse)
290 			G_FreeEdict(it_ent);
291 	}
292 }
293 
294 
295 /*
296 ==================
297 Cmd_God_f
298 
299 Sets client to godmode
300 
301 argv(0) god
302 ==================
303 */
Cmd_God_f(edict_t * ent)304 void Cmd_God_f (edict_t *ent)
305 {
306 	char	*msg;
307 
308 	if (deathmatch->value && !sv_cheats->value)
309 	{
310 		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
311 		return;
312 	}
313 
314 	ent->flags ^= FL_GODMODE;
315 	if (!(ent->flags & FL_GODMODE) )
316 		msg = "godmode OFF\n";
317 	else
318 		msg = "godmode ON\n";
319 
320 	gi.cprintf (ent, PRINT_HIGH, msg);
321 }
322 
323 
324 /*
325 ==================
326 Cmd_Notarget_f
327 
328 Sets client to notarget
329 
330 argv(0) notarget
331 ==================
332 */
Cmd_Notarget_f(edict_t * ent)333 void Cmd_Notarget_f (edict_t *ent)
334 {
335 	char	*msg;
336 
337 	if (deathmatch->value && !sv_cheats->value)
338 	{
339 		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
340 		return;
341 	}
342 
343 	ent->flags ^= FL_NOTARGET;
344 	if (!(ent->flags & FL_NOTARGET) )
345 		msg = "notarget OFF\n";
346 	else
347 		msg = "notarget ON\n";
348 
349 	gi.cprintf (ent, PRINT_HIGH, msg);
350 }
351 
352 
353 /*
354 ==================
355 Cmd_Noclip_f
356 
357 argv(0) noclip
358 ==================
359 */
Cmd_Noclip_f(edict_t * ent)360 void Cmd_Noclip_f (edict_t *ent)
361 {
362 	char	*msg;
363 
364 	if (deathmatch->value && !sv_cheats->value)
365 	{
366 		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
367 		return;
368 	}
369 
370 	if (ent->movetype == MOVETYPE_NOCLIP)
371 	{
372 		ent->movetype = MOVETYPE_WALK;
373 		msg = "noclip OFF\n";
374 	}
375 	else
376 	{
377 		ent->movetype = MOVETYPE_NOCLIP;
378 		msg = "noclip ON\n";
379 	}
380 
381 	gi.cprintf (ent, PRINT_HIGH, msg);
382 }
383 
384 
385 /*
386 ==================
387 Cmd_Use_f
388 
389 Use an inventory item
390 ==================
391 */
Cmd_Use_f(edict_t * ent)392 void Cmd_Use_f (edict_t *ent)
393 {
394 	int			index;
395 	gitem_t		*it;
396 	char		*s;
397 
398 	s = gi.args();
399 	it = FindItem (s);
400 	if (!it)
401 	{
402 		gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s);
403 		return;
404 	}
405 	if (!it->use)
406 	{
407 		gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n");
408 		return;
409 	}
410 	index = ITEM_INDEX(it);
411 	if (!ent->client->pers.inventory[index])
412 	{
413 		// RAFAEL
414 		if (strcmp (it->pickup_name, "HyperBlaster") == 0)
415 		{
416 			it = Fdi_BOOMER;//FindItem ("Ionripper");
417 			index = ITEM_INDEX (it);
418 			if (!ent->client->pers.inventory[index])
419 			{
420 				gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
421 				return;
422 			}
423 		}
424 		// RAFAEL
425 		else if (strcmp (it->pickup_name, "Railgun") == 0)
426 		{
427 			it = Fdi_PHALANX;//FindItem ("Phalanx");
428 			index = ITEM_INDEX (it);
429 			if (!ent->client->pers.inventory[index])
430 			{
431 				gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
432 				return;
433 			}
434 		}
435 		else
436 		{
437 			gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
438 			return;
439 		}
440 	}
441 
442 	it->use (ent, it);
443 }
444 
445 
446 /*
447 ==================
448 Cmd_Drop_f
449 
450 Drop an inventory item
451 ==================
452 */
Cmd_Drop_f(edict_t * ent)453 void Cmd_Drop_f (edict_t *ent)
454 {
455 	int			index;
456 	gitem_t		*it;
457 	char		*s;
458 
459 //ZOID--special case for tech powerups
460 	if (Q_stricmp(gi.args(), "tech") == 0 && (it = CTFWhat_Tech(ent)) != NULL) {
461 		it->drop (ent, it);
462 		return;
463 	}
464 //ZOID
465 
466 	s = gi.args();
467 	it = FindItem (s);
468 	if (!it)
469 	{
470 		gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s);
471 		return;
472 	}
473 	if (!it->drop)
474 	{
475 		gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n");
476 		return;
477 	}
478 	index = ITEM_INDEX(it);
479 	if (!ent->client->pers.inventory[index])
480 	{
481 		// RAFAEL
482 		if (strcmp (it->pickup_name, "HyperBlaster") == 0)
483 		{
484 			it = Fdi_BOOMER;//FindItem ("Ionripper");
485 			index = ITEM_INDEX (it);
486 			if (!ent->client->pers.inventory[index])
487 			{
488 				gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
489 				return;
490 			}
491 		}
492 		// RAFAEL
493 		else if (strcmp (it->pickup_name, "Railgun") == 0)
494 		{
495 			it = Fdi_PHALANX;//FindItem ("Phalanx");
496 			index = ITEM_INDEX (it);
497 			if (!ent->client->pers.inventory[index])
498 			{
499 				gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
500 				return;
501 			}
502 		}
503 		else
504 		{
505 			gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
506 			return;
507 		}
508 	}
509 
510 	it->drop (ent, it);
511 }
512 
513 
514 /*
515 =================
516 Cmd_Inven_f
517 =================
518 */
Cmd_Inven_f(edict_t * ent)519 void Cmd_Inven_f (edict_t *ent)
520 {
521 	int			i;
522 	gclient_t	*cl;
523 
524 	if(ent->svflags & SVF_MONSTER) return;
525 
526 	cl = ent->client;
527 
528 	cl->showscores = false;
529 	cl->showhelp = false;
530 
531 //ZOID
532 	if (ent->client->menu) {
533 		PMenu_Close(ent);
534 		ent->client->update_chase = true;
535 		return;
536 	}
537 //ZOID
538 
539 	if (cl->showinventory)
540 	{
541 		cl->showinventory = false;
542 		return;
543 	}
544 
545 //ZOID
546 	if (ctf->value && cl->resp.ctf_team == CTF_NOTEAM) {
547 		CTFOpenJoinMenu(ent);
548 		return;
549 	}
550 //ZOID
551 
552 	cl->showinventory = true;
553 
554 	gi.WriteByte (svc_inventory);
555 	for (i=0 ; i<MAX_ITEMS ; i++)
556 	{
557 		gi.WriteShort (cl->pers.inventory[i]);
558 	}
559 	gi.unicast (ent, true);
560 }
561 
562 /*
563 =================
564 Cmd_InvUse_f
565 =================
566 */
Cmd_InvUse_f(edict_t * ent)567 void Cmd_InvUse_f (edict_t *ent)
568 {
569 	gitem_t		*it;
570 
571 //ZOID
572 	if (ent->client->menu) {
573 		PMenu_Select(ent);
574 		return;
575 	}
576 //ZOID
577 
578 	ValidateSelectedItem (ent);
579 
580 	if (ent->client->pers.selected_item == -1)
581 	{
582 		gi.cprintf (ent, PRINT_HIGH, "No item to use.\n");
583 		return;
584 	}
585 
586 	it = &itemlist[ent->client->pers.selected_item];
587 	if (!it->use)
588 	{
589 		gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n");
590 		return;
591 	}
592 	it->use (ent, it);
593 }
594 
595 //ZOID
596 /*
597 =================
598 Cmd_LastWeap_f
599 =================
600 */
Cmd_LastWeap_f(edict_t * ent)601 void Cmd_LastWeap_f (edict_t *ent)
602 {
603 	gclient_t	*cl;
604 
605 	cl = ent->client;
606 
607 	if (!cl->pers.weapon || !cl->pers.lastweapon)
608 		return;
609 
610 	cl->pers.lastweapon->use (ent, cl->pers.lastweapon);
611 }
612 //ZOID
613 
614 
615 /*
616 =================
617 Cmd_WeapPrev_f
618 =================
619 */
Cmd_WeapPrev_f(edict_t * ent)620 void Cmd_WeapPrev_f (edict_t *ent)
621 {
622 	gclient_t	*cl;
623 	int			i, index;
624 	gitem_t		*it;
625 	int			selected_weapon;
626 
627 	cl = ent->client;
628 
629 	if (!cl->pers.weapon)
630 		return;
631 
632 	selected_weapon = ITEM_INDEX(cl->pers.weapon);
633 
634 	// scan  for the next valid one
635 	for (i=1 ; i<=MAX_ITEMS ; i++)
636 	{
637 		index = (selected_weapon + i)%MAX_ITEMS;
638 		if (!cl->pers.inventory[index])
639 			continue;
640 		it = &itemlist[index];
641 		if (!it->use)
642 			continue;
643 		if (! (it->flags & IT_WEAPON) )
644 			continue;
645 		it->use (ent, it);
646 		if (cl->pers.weapon == it)
647 			return;	// successful
648 	}
649 }
650 
651 /*
652 =================
653 Cmd_WeapNext_f
654 =================
655 */
Cmd_WeapNext_f(edict_t * ent)656 void Cmd_WeapNext_f (edict_t *ent)
657 {
658 	gclient_t	*cl;
659 	int			i, index;
660 	gitem_t		*it;
661 	int			selected_weapon;
662 
663 	cl = ent->client;
664 
665 	if (!cl->pers.weapon)
666 		return;
667 
668 	selected_weapon = ITEM_INDEX(cl->pers.weapon);
669 
670 	// scan  for the next valid one
671 	for (i=1 ; i<=MAX_ITEMS ; i++)
672 	{
673 		index = (selected_weapon + MAX_ITEMS - i)%MAX_ITEMS;
674 		if (!cl->pers.inventory[index])
675 			continue;
676 		it = &itemlist[index];
677 		if (!it->use)
678 			continue;
679 		if (! (it->flags & IT_WEAPON) )
680 			continue;
681 		it->use (ent, it);
682 		if (cl->pers.weapon == it)
683 			return;	// successful
684 	}
685 }
686 
687 /*
688 =================
689 Cmd_WeapLast_f
690 =================
691 */
Cmd_WeapLast_f(edict_t * ent)692 void Cmd_WeapLast_f (edict_t *ent)
693 {
694 	gclient_t	*cl;
695 	int			index;
696 	gitem_t		*it;
697 
698 	cl = ent->client;
699 
700 	if (!cl->pers.weapon || !cl->pers.lastweapon)
701 		return;
702 
703 	index = ITEM_INDEX(cl->pers.lastweapon);
704 	if (!cl->pers.inventory[index])
705 		return;
706 	it = &itemlist[index];
707 	if (!it->use)
708 		return;
709 	if (! (it->flags & IT_WEAPON) )
710 		return;
711 	it->use (ent, it);
712 }
713 
714 /*
715 =================
716 Cmd_InvDrop_f
717 =================
718 */
Cmd_InvDrop_f(edict_t * ent)719 void Cmd_InvDrop_f (edict_t *ent)
720 {
721 	gitem_t		*it;
722 
723 	ValidateSelectedItem (ent);
724 
725 	if (ent->client->pers.selected_item == -1)
726 	{
727 		gi.cprintf (ent, PRINT_HIGH, "No item to drop.\n");
728 		return;
729 	}
730 
731 	it = &itemlist[ent->client->pers.selected_item];
732 	if (!it->drop)
733 	{
734 		gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n");
735 		return;
736 	}
737 	it->drop (ent, it);
738 }
739 
740 /*
741 =================
742 Cmd_Kill_f
743 =================
744 */
Cmd_Kill_f(edict_t * ent)745 void Cmd_Kill_f (edict_t *ent)
746 {
747 //ZOID
748 	if (ent->solid == SOLID_NOT)
749 		return;
750 //ZOID
751 
752 	if((level.time - ent->client->respawn_time) < 5)
753 		return;
754 	ent->flags &= ~FL_GODMODE;
755 	ent->health = 0;
756 	meansOfDeath = MOD_SUICIDE;
757 	player_die (ent, ent, ent, 100000, vec3_origin);
758 	// don't even bother waiting for death frames
759 	ent->deadflag = DEAD_DEAD;
760 	respawn (ent);
761 }
762 
763 /*
764 =================
765 Cmd_PutAway_f
766 =================
767 */
Cmd_PutAway_f(edict_t * ent)768 void Cmd_PutAway_f (edict_t *ent)
769 {
770 	ent->client->showscores = false;
771 	ent->client->showhelp = false;
772 	ent->client->showinventory = false;
773 //ZOID
774 	if (ent->client->menu)
775 		PMenu_Close(ent);
776 	ent->client->update_chase = true;
777 //ZOID
778 }
779 
780 
PlayerSort(void const * a,void const * b)781 int PlayerSort (void const *a, void const *b)
782 {
783 	int		anum, bnum;
784 
785 	anum = *(int *)a;
786 	bnum = *(int *)b;
787 
788 	anum = game.clients[anum].ps.stats[STAT_FRAGS];
789 	bnum = game.clients[bnum].ps.stats[STAT_FRAGS];
790 
791 	if (anum < bnum)
792 		return -1;
793 	if (anum > bnum)
794 		return 1;
795 	return 0;
796 }
797 
798 /*
799 =================
800 Cmd_Players_f
801 =================
802 */
Cmd_Players_f(edict_t * ent)803 void Cmd_Players_f (edict_t *ent)
804 {
805 	int		i;
806 	int		count;
807 	char	small[64];
808 	char	large[1280];
809 	int		index[256];
810 
811 	count = 0;
812 	for (i = 0 ; i < maxclients->value ; i++)
813 		if (game.clients[i].pers.connected)
814 		{
815 			index[count] = i;
816 			count++;
817 		}
818 
819 	// sort by frags
820 	qsort (index, count, sizeof(index[0]), PlayerSort);
821 
822 	// print information
823 	large[0] = 0;
824 
825 	for (i = 0 ; i < count ; i++)
826 	{
827 		Com_sprintf (small, sizeof(small), "%3i %s\n",
828 			game.clients[index[i]].ps.stats[STAT_FRAGS],
829 			game.clients[index[i]].pers.netname);
830 		if (strlen (small) + strlen(large) > sizeof(large) - 100 )
831 		{	// can't print all of them in one packet
832 			strcat (large, "...\n");
833 			break;
834 		}
835 		strcat (large, small);
836 	}
837 
838 	gi.cprintf (ent, PRINT_HIGH, "%s\n%i players\n", large, count);
839 }
840 
841 /*
842 =================
843 Cmd_Wave_f
844 =================
845 */
Cmd_Wave_f(edict_t * ent)846 void Cmd_Wave_f (edict_t *ent)
847 {
848 	int		i;
849 
850 	i = atoi (gi.argv(1));
851 
852 	// can't wave when ducked
853 	if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
854 		return;
855 
856 	if (ent->client->anim_priority > ANIM_WAVE)
857 		return;
858 
859 	ent->client->anim_priority = ANIM_WAVE;
860 
861 	switch (i)
862 	{
863 	case 0:
864 		gi.cprintf (ent, PRINT_HIGH, "flipoff\n");
865 		ent->s.frame = FRAME_flip01-1;
866 		ent->client->anim_end = FRAME_flip12;
867 		break;
868 	case 1:
869 		gi.cprintf (ent, PRINT_HIGH, "salute\n");
870 		ent->s.frame = FRAME_salute01-1;
871 		ent->client->anim_end = FRAME_salute11;
872 		break;
873 	case 2:
874 		gi.cprintf (ent, PRINT_HIGH, "taunt\n");
875 		ent->s.frame = FRAME_taunt01-1;
876 		ent->client->anim_end = FRAME_taunt17;
877 		break;
878 	case 3:
879 		gi.cprintf (ent, PRINT_HIGH, "wave\n");
880 		ent->s.frame = FRAME_wave01-1;
881 		ent->client->anim_end = FRAME_wave11;
882 		break;
883 	case 4:
884 	default:
885 		gi.cprintf (ent, PRINT_HIGH, "point\n");
886 		ent->s.frame = FRAME_point01-1;
887 		ent->client->anim_end = FRAME_point12;
888 		break;
889 	}
890 }
891 
892 /*
893 ==================
894 Cmd_Say_f
895 ==================
896 */
Cmd_Say_f(edict_t * ent,qboolean team,qboolean arg0)897 void Cmd_Say_f (edict_t *ent, qboolean team, qboolean arg0)
898 {
899 	int		j;
900 	edict_t	*other;
901 	char	*p;
902 	char	text[2048];
903 
904 	if (gi.argc () < 2 && !arg0)
905 		return;
906 
907 	if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
908 		team = false;
909 
910 	if (team)
911 		Com_sprintf (text, sizeof(text), "(%s): ", ent->client->pers.netname);
912 	else
913 		Com_sprintf (text, sizeof(text), "%s: ", ent->client->pers.netname);
914 
915 	if (arg0)
916 	{
917 		strcat (text, gi.argv(0));
918 		strcat (text, " ");
919 		strcat (text, gi.args());
920 	}
921 	else
922 	{
923 		p = gi.args();
924 
925 		if (*p == '"')
926 		{
927 			p++;
928 			p[strlen(p)-1] = 0;
929 		}
930 		strcat(text, p);
931 	}
932 
933 	// don't let text be too long for malicious reasons
934 	if (strlen(text) > 150)
935 		text[150] = 0;
936 
937 	strcat(text, "\n");
938 
939 	if (dedicated->value)
940 		gi.cprintf(NULL, PRINT_CHAT, "%s", text);
941 
942 	for (j = 1; j <= game.maxclients; j++)
943 	{
944 		other = &g_edicts[j];
945 		if (!other->inuse)
946 			continue;
947 		if (!other->client)
948 			continue;
949 		if (team)
950 		{
951 			if (!OnSameTeam(ent, other))
952 				continue;
953 		}
954 		if (other->svflags & SVF_MONSTER) continue;
955 
956 		gi.cprintf(other, PRINT_CHAT, "%s", text);
957 	}
958 }
959 //�X�i�C�p�[�pZoomIn Out
Cmd_ZoomIn(edict_t * ent)960 void Cmd_ZoomIn(edict_t *ent)
961 {
962 	if( ent->client->zc.autozoom )
963 	{
964 		gi.cprintf(ent,PRINT_HIGH,"autozoom has been selected.\n");
965 		return;
966 	}
967 
968 //	if(	ent->client->pers.weapon != FindItem("Railgun")) return;
969 
970 	if( ent->client->zc.aiming != 1 && ent->client->zc.aiming != 3) return;
971 
972 	if(ent->client->zc.distance < 15 || ent->client->zc.distance > 90)
973 	{
974 		ent->client->zc.distance = 90;
975 		ent->client->ps.fov = 90;
976 	}
977 
978 	if(ent->client->zc.distance > 15)
979 	{
980 		gi.sound (ent, CHAN_AUTO, gi.soundindex("3zb/zoom.wav"), 1, ATTN_NORM, 0);
981 		if(ent->client->zc.distance == 90 ) ent->client->zc.distance = 65;
982 		else if(ent->client->zc.distance == 65 ) ent->client->zc.distance = 40;
983 		else ent->client->zc.distance = 15;
984 		ent->client->ps.fov = ent->client->zc.distance;
985 	}
986 }
Cmd_ZoomOut(edict_t * ent)987 void Cmd_ZoomOut(edict_t *ent)
988 {
989 	if( ent->client->zc.autozoom )
990 	{
991 		gi.cprintf(ent,PRINT_HIGH,"autozoom has been selected.\n");
992 		return;
993 	}
994 
995 //	if(	ent->client->pers.weapon != FindItem("Railgun")) return;
996 
997 	if(ent->client->zc.aiming != 1 && ent->client->zc.aiming != 3) return;
998 
999 	if(ent->client->zc.distance < 15 || ent->client->zc.distance > 90)
1000 	{
1001 		ent->client->zc.distance = 90;
1002 		ent->client->ps.fov = 90;
1003 	}
1004 
1005 	if(ent->client->zc.distance < 90)
1006 	{
1007 		gi.sound (ent, CHAN_AUTO, gi.soundindex("3zb/zoom.wav"), 1, ATTN_NORM, 0);
1008 		if(ent->client->zc.distance == 15 ) ent->client->zc.distance = 40;
1009 		else if(ent->client->zc.distance == 40 ) ent->client->zc.distance = 65;
1010 		else ent->client->zc.distance = 90;
1011 		ent->client->ps.fov = ent->client->zc.distance;
1012 	}
1013 }
1014 
Cmd_AutoZoom(edict_t * ent)1015 void Cmd_AutoZoom(edict_t *ent)
1016 {
1017 	if( ent->client->zc.autozoom )
1018 	{
1019 		gi.cprintf(ent,PRINT_HIGH,"autozoom off.\n");
1020 		ent->client->zc.autozoom = false;
1021 	}
1022 	else
1023 	{
1024 		gi.cprintf(ent,PRINT_HIGH,"autozoom on.\n");
1025 		ent->client->zc.autozoom = true;
1026 	}
1027 }
1028 
1029 //chain �� undo
UndoChain(edict_t * ent,int step)1030 void UndoChain(edict_t *ent ,int step)
1031 {
1032 	int	count,i;
1033 	trace_t	rs_trace;
1034 
1035 	if(step < 2) count = 2;
1036 	else count = step;
1037 
1038 	if(chedit->value && !ent->deadflag && ent == &g_edicts[1])
1039 	{
1040 		for(i = CurrentIndex - 1;i > 0 ;i--)
1041 		{
1042 			if(Route[i].state == GRS_NORMAL)
1043 			{
1044 				rs_trace = gi.trace(Route[i].Pt,ent->mins,ent->maxs,Route[i].Pt,ent,MASK_BOTSOLID);
1045 
1046 				if(--count <= 0 && !rs_trace.allsolid && !rs_trace.startsolid) break;
1047 			}
1048 		}
1049 
1050 		gi.cprintf(ent,PRINT_HIGH,"backed %i %i steps.\n",CurrentIndex - i,step);
1051 		CurrentIndex = i;
1052 		VectorCopy(Route[CurrentIndex].Pt,ent->s.origin);
1053 		VectorCopy(Route[CurrentIndex].Pt,ent->s.old_origin);
1054 
1055 		memset(&Route[CurrentIndex],0,sizeof(route_t));
1056 		if(CurrentIndex > 0) Route[CurrentIndex].index = Route[CurrentIndex - 1].index + 1;
1057 	}
1058 }
1059 
1060 /*
1061 =================
1062 ClientCommand
1063 =================
1064 */
ClientCommand(edict_t * ent)1065 void ClientCommand (edict_t *ent)
1066 {
1067 	char	*cmd;
1068 
1069 	if (!ent->client)
1070 		return;		// not fully in game yet
1071 
1072 	cmd = gi.argv(0);
1073 
1074 	if (Q_stricmp (cmd, "players") == 0)
1075 	{
1076 		Cmd_Players_f (ent);
1077 		return;
1078 	}
1079 	if (Q_stricmp (cmd, "say") == 0)
1080 	{
1081 		Cmd_Say_f (ent, false, false);
1082 		return;
1083 	}
1084 	if (Q_stricmp (cmd, "say_team") == 0)
1085 	{
1086 		Cmd_Say_f (ent, true, false);
1087 		return;
1088 	}
1089 	if (Q_stricmp (cmd, "score") == 0)
1090 	{
1091 		Cmd_Score_f (ent);
1092 		return;
1093 	}
1094 	if (Q_stricmp (cmd, "help") == 0)
1095 	{
1096 		Cmd_Help_f (ent);
1097 		return;
1098 	}
1099 
1100 	if (level.intermissiontime)
1101 		return;
1102 
1103 	if (Q_stricmp (cmd, "use") == 0)
1104 		Cmd_Use_f (ent);
1105 	else if (Q_stricmp (cmd, "drop") == 0)
1106 		Cmd_Drop_f (ent);
1107 	else if (Q_stricmp (cmd, "give") == 0)
1108 		Cmd_Give_f (ent);
1109 	else if (Q_stricmp (cmd, "god") == 0)
1110 		Cmd_God_f (ent);
1111 	else if (Q_stricmp (cmd, "notarget") == 0)
1112 		Cmd_Notarget_f (ent);
1113 	else if (Q_stricmp (cmd, "noclip") == 0)
1114 		Cmd_Noclip_f (ent);
1115 	else if (Q_stricmp (cmd, "inven") == 0)
1116 		Cmd_Inven_f (ent);
1117 	else if (Q_stricmp (cmd, "invnext") == 0)
1118 		SelectNextItem (ent, -1);
1119 	else if (Q_stricmp (cmd, "invprev") == 0)
1120 		SelectPrevItem (ent, -1);
1121 	else if (Q_stricmp (cmd, "invnextw") == 0)
1122 		SelectNextItem (ent, IT_WEAPON);
1123 	else if (Q_stricmp (cmd, "invprevw") == 0)
1124 		SelectPrevItem (ent, IT_WEAPON);
1125 	else if (Q_stricmp (cmd, "invnextp") == 0)
1126 		SelectNextItem (ent, IT_POWERUP);
1127 	else if (Q_stricmp (cmd, "invprevp") == 0)
1128 		SelectPrevItem (ent, IT_POWERUP);
1129 	else if (Q_stricmp (cmd, "invuse") == 0)
1130 		Cmd_InvUse_f (ent);
1131 	else if (Q_stricmp (cmd, "invdrop") == 0)
1132 		Cmd_InvDrop_f (ent);
1133 	else if (Q_stricmp (cmd, "weapprev") == 0)
1134 		Cmd_WeapPrev_f (ent);
1135 	else if (Q_stricmp (cmd, "weapnext") == 0)
1136 		Cmd_WeapNext_f (ent);
1137 	else if (Q_stricmp (cmd, "weaplast") == 0)
1138 		Cmd_WeapLast_f (ent);
1139 	else if (Q_stricmp (cmd, "kill") == 0)
1140 		Cmd_Kill_f (ent);
1141 	else if (Q_stricmp (cmd, "putaway") == 0)
1142 		Cmd_PutAway_f (ent);
1143 	else if (Q_stricmp (cmd, "wave") == 0)
1144 		Cmd_Wave_f (ent);
1145 	else if (Q_stricmp (cmd, "zoomin") == 0)		//zoom
1146 		Cmd_ZoomIn(ent);
1147 	else if (Q_stricmp (cmd, "zoomout") == 0)
1148 		Cmd_ZoomOut(ent);
1149 	else if (Q_stricmp (cmd, "autozoom") == 0)
1150 		Cmd_AutoZoom(ent);
1151 	else if (Q_stricmp (cmd, "air") == 0)
1152 		Cmd_AirStrike(ent);
1153 	else if (Q_stricmp (cmd, "undo") == 0)
1154 	{
1155 		if(gi.argc() <= 1) UndoChain(ent,1);
1156 		else UndoChain (ent,atoi(gi.argv(1)));
1157 	}
1158 //ZOID
1159 	else if (Q_stricmp (cmd, "team") == 0)
1160 	{
1161 		CTFTeam_f (ent);
1162 	} else if (Q_stricmp(cmd, "id") == 0) {
1163 		CTFID_f (ent);
1164 	}
1165 //ZOID
1166 	else	// anything that doesn't match a command will be a chat
1167 		Cmd_Say_f (ent, false, true);
1168 }
1169