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