2013-05-01 08:43:49 +00:00
|
|
|
/* =======================================================================
|
|
|
|
*
|
|
|
|
* Game command processing.
|
|
|
|
*
|
|
|
|
* =======================================================================
|
|
|
|
*/
|
|
|
|
|
2011-10-11 11:40:43 +00:00
|
|
|
#include "header/local.h"
|
|
|
|
#include "monster/misc/player.h"
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
char *
|
|
|
|
ClientTeam(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
char *p;
|
|
|
|
static char value[512];
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
value[0] = 0;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!ent->client)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return value;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
strcpy(value, Info_ValueForKey(ent->client->pers.userinfo, "skin"));
|
2009-03-12 20:03:41 +00:00
|
|
|
p = strchr(value, '/');
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!p)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return value;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if ((int)(dmflags->value) & DF_MODELTEAMS)
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ++p;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
qboolean
|
|
|
|
OnSameTeam(edict_t *ent1, edict_t *ent2)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
char ent1Team[512];
|
|
|
|
char ent2Team[512];
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent1 || !ent2)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return false;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
strcpy(ent1Team, ClientTeam(ent1));
|
|
|
|
strcpy(ent2Team, ClientTeam(ent2));
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if (strcmp(ent1Team, ent2Team) == 0)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return true;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
SelectNextItem(edict_t *ent, int itflags)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gclient_t *cl;
|
|
|
|
int i, index;
|
|
|
|
gitem_t *it;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
cl = ent->client;
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (cl->chase_target)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
ChaseNext(ent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* scan for the next valid one */
|
|
|
|
for (i = 1; i <= MAX_ITEMS; i++)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
index = (cl->pers.selected_item + i) % MAX_ITEMS;
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!cl->pers.inventory[index])
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
it = &itemlist[index];
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->use)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!(it->flags & itflags))
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
cl->pers.selected_item = index;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->pers.selected_item = -1;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
SelectPrevItem(edict_t *ent, int itflags)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gclient_t *cl;
|
|
|
|
int i, index;
|
|
|
|
gitem_t *it;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
cl = ent->client;
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (cl->chase_target)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
ChasePrev(ent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* scan for the next valid one */
|
|
|
|
for (i = 1; i <= MAX_ITEMS; i++)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
index = (cl->pers.selected_item + MAX_ITEMS - i) % MAX_ITEMS;
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!cl->pers.inventory[index])
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
it = &itemlist[index];
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->use)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!(it->flags & itflags))
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
cl->pers.selected_item = index;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->pers.selected_item = -1;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
ValidateSelectedItem(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gclient_t *cl;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
cl = ent->client;
|
|
|
|
|
|
|
|
if (cl->pers.inventory[cl->pers.selected_item])
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
|
|
|
return; /* valid */
|
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
SelectNextItem(ent, -1);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* ================================================================================= */
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
/*
|
2013-05-01 08:43:49 +00:00
|
|
|
* Give items to a client
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Cmd_Give_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
char *name;
|
|
|
|
gitem_t *it;
|
|
|
|
int index;
|
|
|
|
int i;
|
|
|
|
qboolean give_all;
|
|
|
|
edict_t *it_ent;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-31 09:18:35 +00:00
|
|
|
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH,
|
|
|
|
"You must run the server with '+set cheats 1' to enable this command.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
name = gi.args();
|
|
|
|
|
|
|
|
if (Q_stricmp(name, "all") == 0)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
give_all = true;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
else
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
give_all = false;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (give_all || (Q_stricmp(gi.argv(1), "health") == 0))
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
|
|
|
if (gi.argc() == 3)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
ent->health = atoi(gi.argv(2));
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
else
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
ent->health = ent->max_health;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!give_all)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (give_all || (Q_stricmp(name, "weapons") == 0))
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
for (i = 0; i < game.num_items; i++)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
|
|
|
it = itemlist + i;
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->pickup)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!(it->flags & IT_WEAPON))
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
ent->client->pers.inventory[i] += 1;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!give_all)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (give_all || (Q_stricmp(name, "ammo") == 0))
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
for (i = 0; i < game.num_items; i++)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
|
|
|
it = itemlist + i;
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->pickup)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!(it->flags & IT_AMMO))
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Add_Ammo(ent, it, 1000);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!give_all)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (give_all || (Q_stricmp(name, "armor") == 0))
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gitem_armor_t *info;
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
it = FindItem("Jacket Armor");
|
|
|
|
ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
|
|
|
|
|
|
|
|
it = FindItem("Combat Armor");
|
|
|
|
ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
|
|
|
|
|
|
|
|
it = FindItem("Body Armor");
|
|
|
|
info = (gitem_armor_t *)it->info;
|
|
|
|
ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;
|
|
|
|
|
|
|
|
if (!give_all)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (give_all || (Q_stricmp(name, "Power Shield") == 0))
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
|
|
|
it = FindItem("Power Shield");
|
|
|
|
it_ent = G_Spawn();
|
|
|
|
it_ent->classname = it->classname;
|
2013-05-01 08:43:49 +00:00
|
|
|
SpawnItem(it_ent, it);
|
|
|
|
Touch_Item(it_ent, ent, NULL, NULL);
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (it_ent->inuse)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
G_FreeEdict(it_ent);
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if (!give_all)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (give_all)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
for (i = 0; i < game.num_items; i++)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
|
|
|
it = itemlist + i;
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->pickup)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (it->flags & IT_NOT_GIVEABLE)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (it->flags & (IT_ARMOR | IT_WEAPON | IT_AMMO))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
ent->client->pers.inventory[i] = 1;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
it = FindItem(name);
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it)
|
|
|
|
{
|
|
|
|
name = gi.argv(1);
|
2013-05-01 08:43:49 +00:00
|
|
|
it = FindItem(name);
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "unknown item\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!it->pickup)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "non-pickup item\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (it->flags & IT_NOT_GIVEABLE)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.dprintf("item cannot be given\n");
|
|
|
|
return;
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
index = ITEM_INDEX(it);
|
|
|
|
|
|
|
|
if (it->flags & IT_AMMO)
|
|
|
|
{
|
|
|
|
if (gi.argc() == 3)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
ent->client->pers.inventory[index] = atoi(gi.argv(2));
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
else
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
ent->client->pers.inventory[index] += it->quantity;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
it_ent = G_Spawn();
|
|
|
|
it_ent->classname = it->classname;
|
2013-05-01 08:43:49 +00:00
|
|
|
SpawnItem(it_ent, it);
|
|
|
|
|
|
|
|
/* since some items don't actually spawn when you say to .. */
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it_ent->inuse)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Touch_Item(it_ent, ent, NULL, NULL);
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (it_ent->inuse)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
G_FreeEdict(it_ent);
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-05-01 08:43:49 +00:00
|
|
|
* Sets client to godmode
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Cmd_God_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
char *msg;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-31 09:18:35 +00:00
|
|
|
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH,
|
|
|
|
"You must run the server with '+set cheats 1' to enable this command.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->flags ^= FL_GODMODE;
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
if (!(ent->flags & FL_GODMODE))
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
msg = "godmode OFF\n";
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
else
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
msg = "godmode ON\n";
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, msg);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-05-01 08:43:49 +00:00
|
|
|
* Sets client to notarget
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Cmd_Notarget_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
char *msg;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-31 09:18:35 +00:00
|
|
|
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH,
|
|
|
|
"You must run the server with '+set cheats 1' to enable this command.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->flags ^= FL_NOTARGET;
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
if (!(ent->flags & FL_NOTARGET))
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
msg = "notarget OFF\n";
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
else
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
msg = "notarget ON\n";
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, msg);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_Noclip_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
char *msg;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-31 09:18:35 +00:00
|
|
|
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH,
|
|
|
|
"You must run the server with '+set cheats 1' to enable this command.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ent->movetype == MOVETYPE_NOCLIP)
|
|
|
|
{
|
|
|
|
ent->movetype = MOVETYPE_WALK;
|
|
|
|
msg = "noclip OFF\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ent->movetype = MOVETYPE_NOCLIP;
|
|
|
|
msg = "noclip ON\n";
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, msg);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-05-01 08:43:49 +00:00
|
|
|
* Use an inventory item
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Cmd_Use_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
int index;
|
|
|
|
gitem_t *it;
|
|
|
|
char *s;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
s = gi.args();
|
2013-05-01 08:43:49 +00:00
|
|
|
it = FindItem(s);
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "unknown item: %s\n", s);
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->use)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "Item is not usable.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
index = ITEM_INDEX(it);
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!ent->client->pers.inventory[index])
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "Out of item: %s\n", s);
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
it->use(ent, it);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-05-01 08:43:49 +00:00
|
|
|
* Drop an inventory item
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Cmd_Drop_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
int index;
|
|
|
|
gitem_t *it;
|
|
|
|
char *s;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
s = gi.args();
|
2013-05-01 08:43:49 +00:00
|
|
|
it = FindItem(s);
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "unknown item: %s\n", s);
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->drop)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "Item is not dropable.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
index = ITEM_INDEX(it);
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!ent->client->pers.inventory[index])
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "Out of item: %s\n", s);
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
it->drop(ent, it);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 12:14:02 +00:00
|
|
|
void
|
|
|
|
Cmd_Score_f(edict_t *ent)
|
|
|
|
{
|
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->client->showinventory = false;
|
|
|
|
ent->client->showhelp = false;
|
|
|
|
|
|
|
|
if (!deathmatch->value && !coop->value)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ent->client->showscores)
|
|
|
|
{
|
|
|
|
ent->client->showscores = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->client->showscores = true;
|
|
|
|
DeathmatchScoreboardMessage(ent, ent->enemy);
|
|
|
|
gi.unicast(ent, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Cmd_Help_f(edict_t *ent)
|
|
|
|
{
|
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is for backwards compatability */
|
|
|
|
if (deathmatch->value)
|
|
|
|
{
|
|
|
|
Cmd_Score_f(ent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->client->showinventory = false;
|
|
|
|
ent->client->showscores = false;
|
|
|
|
|
|
|
|
if (ent->client->showhelp)
|
|
|
|
{
|
|
|
|
ent->client->showhelp = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->client->showhelp = true;
|
|
|
|
ent->client->pers.helpchanged = 0;
|
|
|
|
HelpComputerMessage(ent);
|
|
|
|
gi.unicast(ent, true);
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_Inven_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gclient_t *cl;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
cl = ent->client;
|
|
|
|
|
|
|
|
cl->showscores = false;
|
|
|
|
cl->showhelp = false;
|
|
|
|
|
|
|
|
if (cl->showinventory)
|
|
|
|
{
|
|
|
|
cl->showinventory = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->showinventory = true;
|
2014-02-22 12:14:02 +00:00
|
|
|
|
|
|
|
InventoryMessage(ent);
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.unicast(ent, true);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_InvUse_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gitem_t *it;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
ValidateSelectedItem(ent);
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if (ent->client->pers.selected_item == -1)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "No item to use.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
it = &itemlist[ent->client->pers.selected_item];
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->use)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "Item is not usable.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
it->use(ent, it);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_WeapPrev_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gclient_t *cl;
|
|
|
|
int i, index;
|
|
|
|
gitem_t *it;
|
|
|
|
int selected_weapon;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
cl = ent->client;
|
|
|
|
|
|
|
|
if (!cl->pers.weapon)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
selected_weapon = ITEM_INDEX(cl->pers.weapon);
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* scan for the next valid one */
|
|
|
|
for (i = 1; i <= MAX_ITEMS; i++)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
/* prevent scrolling through ALL weapons */
|
|
|
|
index = (selected_weapon + MAX_ITEMS - i) % MAX_ITEMS;
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!cl->pers.inventory[index])
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
it = &itemlist[index];
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->use)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(it->flags & IT_WEAPON))
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
it->use(ent, it);
|
|
|
|
|
|
|
|
/* prevent scrolling through ALL weapons */
|
2009-03-12 20:03:41 +00:00
|
|
|
if (cl->newweapon == it)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_WeapNext_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gclient_t *cl;
|
|
|
|
int i, index;
|
|
|
|
gitem_t *it;
|
|
|
|
int selected_weapon;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
cl = ent->client;
|
|
|
|
|
|
|
|
if (!cl->pers.weapon)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
selected_weapon = ITEM_INDEX(cl->pers.weapon);
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* scan for the next valid one */
|
|
|
|
for (i = 1; i <= MAX_ITEMS; i++)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
/* prevent scrolling through ALL weapons */
|
|
|
|
index = (selected_weapon + i) % MAX_ITEMS;
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!cl->pers.inventory[index])
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
it = &itemlist[index];
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->use)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(it->flags & IT_WEAPON))
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
it->use(ent, it);
|
|
|
|
|
|
|
|
/* prevent scrolling through ALL weapons */
|
2009-03-12 20:03:41 +00:00
|
|
|
if (cl->newweapon == it)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_WeapLast_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gclient_t *cl;
|
|
|
|
int index;
|
|
|
|
gitem_t *it;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
cl = ent->client;
|
|
|
|
|
|
|
|
if (!cl->pers.weapon || !cl->pers.lastweapon)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
index = ITEM_INDEX(cl->pers.lastweapon);
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!cl->pers.inventory[index])
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
it = &itemlist[index];
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->use)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(it->flags & IT_WEAPON))
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
it->use(ent, it);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_InvDrop_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gitem_t *it;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
ValidateSelectedItem(ent);
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if (ent->client->pers.selected_item == -1)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "No item to drop.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
it = &itemlist[ent->client->pers.selected_item];
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!it->drop)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "Item is not dropable.\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
it->drop(ent, it);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_Kill_f(edict_t *ent)
|
2014-02-22 12:20:22 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if ((level.time - ent->client->respawn_time) < 5)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
ent->flags &= ~FL_GODMODE;
|
|
|
|
ent->health = 0;
|
|
|
|
meansOfDeath = MOD_SUICIDE;
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* make sure no trackers are still hurting us. */
|
|
|
|
if (ent->client->tracker_pain_framenum)
|
|
|
|
{
|
|
|
|
RemoveAttackingPainDaemons(ent);
|
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if (ent->client->owned_sphere)
|
|
|
|
{
|
|
|
|
G_FreeEdict(ent->client->owned_sphere);
|
|
|
|
ent->client->owned_sphere = NULL;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
player_die(ent, ent, ent, 100000, vec3_origin);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_PutAway_f(edict_t *ent)
|
2014-02-22 12:20:22 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
ent->client->showscores = false;
|
|
|
|
ent->client->showhelp = false;
|
|
|
|
ent->client->showinventory = false;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
int
|
|
|
|
PlayerSort(void const *a, void const *b)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
int anum, bnum;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!a || !b)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
anum = *(int *)a;
|
|
|
|
bnum = *(int *)b;
|
|
|
|
|
|
|
|
anum = game.clients[anum].ps.stats[STAT_FRAGS];
|
|
|
|
bnum = game.clients[bnum].ps.stats[STAT_FRAGS];
|
|
|
|
|
|
|
|
if (anum < bnum)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return -1;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (anum > bnum)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return 1;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_Players_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
int i;
|
|
|
|
int count;
|
|
|
|
char small[64];
|
|
|
|
char large[1280];
|
|
|
|
int index[256];
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
count = 0;
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
for (i = 0; i < maxclients->value; i++)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
if (game.clients[i].pers.connected)
|
|
|
|
{
|
|
|
|
index[count] = i;
|
|
|
|
count++;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* sort by frags */
|
|
|
|
qsort(index, count, sizeof(index[0]), PlayerSort);
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* print information */
|
2009-03-12 20:03:41 +00:00
|
|
|
large[0] = 0;
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
for (i = 0; i < count; i++)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
Com_sprintf(small, sizeof(small), "%3i %s\n",
|
|
|
|
game.clients[index[i]].ps.stats[STAT_FRAGS],
|
|
|
|
game.clients[index[i]].pers.netname);
|
|
|
|
|
|
|
|
if (strlen(small) + strlen(large) > sizeof(large) - 100)
|
2014-02-22 12:20:22 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
/* can't print all of them in one packet */
|
|
|
|
strcat(large, "...\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
strcat(large, small);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "%s\n%i players\n", large, count);
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_Wave_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
int i;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
i = atoi(gi.argv(1));
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* can't wave when ducked */
|
2009-03-12 20:03:41 +00:00
|
|
|
if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if (ent->client->anim_priority > ANIM_WAVE)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
ent->client->anim_priority = ANIM_WAVE;
|
|
|
|
|
|
|
|
switch (i)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
case 0:
|
|
|
|
gi.cprintf(ent, PRINT_HIGH, "flipoff\n");
|
|
|
|
ent->s.frame = FRAME_flip01 - 1;
|
|
|
|
ent->client->anim_end = FRAME_flip12;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
gi.cprintf(ent, PRINT_HIGH, "salute\n");
|
|
|
|
ent->s.frame = FRAME_salute01 - 1;
|
|
|
|
ent->client->anim_end = FRAME_salute11;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
gi.cprintf(ent, PRINT_HIGH, "taunt\n");
|
|
|
|
ent->s.frame = FRAME_taunt01 - 1;
|
|
|
|
ent->client->anim_end = FRAME_taunt17;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
gi.cprintf(ent, PRINT_HIGH, "wave\n");
|
|
|
|
ent->s.frame = FRAME_wave01 - 1;
|
|
|
|
ent->client->anim_end = FRAME_wave11;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
default:
|
|
|
|
gi.cprintf(ent, PRINT_HIGH, "point\n");
|
|
|
|
ent->s.frame = FRAME_point01 - 1;
|
|
|
|
ent->client->anim_end = FRAME_point12;
|
|
|
|
break;
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
int i, j;
|
|
|
|
edict_t *other;
|
|
|
|
char *p;
|
|
|
|
char text[2048];
|
2009-03-12 20:03:41 +00:00
|
|
|
gclient_t *cl;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if ((gi.argc() < 2) && !arg0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
team = false;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if (team)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
|
|
|
Com_sprintf(text, sizeof(text), "(%s): ", ent->client->pers.netname);
|
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
else
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
|
|
|
Com_sprintf(text, sizeof(text), "%s: ", ent->client->pers.netname);
|
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
if (arg0)
|
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
strcat(text, gi.argv(0));
|
|
|
|
strcat(text, " ");
|
|
|
|
strcat(text, gi.args());
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p = gi.args();
|
|
|
|
|
|
|
|
if (*p == '"')
|
|
|
|
{
|
|
|
|
p++;
|
2013-05-01 08:43:49 +00:00
|
|
|
p[strlen(p) - 1] = 0;
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
strcat(text, p);
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* don't let text be too long for malicious reasons */
|
2009-03-12 20:03:41 +00:00
|
|
|
if (strlen(text) > 150)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
text[150] = 0;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
strcat(text, "\n");
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (flood_msgs->value)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
cl = ent->client;
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (level.time < cl->flood_locktill)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "You can't talk for %d more seconds\n",
|
2013-05-01 08:43:49 +00:00
|
|
|
(int)(cl->flood_locktill - level.time));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = cl->flood_whenhead - flood_msgs->value + 1;
|
|
|
|
|
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
i = (sizeof(cl->flood_when) / sizeof(cl->flood_when[0])) + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cl->flood_when[i] &&
|
|
|
|
(level.time - cl->flood_when[i] < flood_persecond->value))
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
cl->flood_locktill = level.time + flood_waitdelay->value;
|
2013-05-01 08:43:49 +00:00
|
|
|
gi.cprintf(ent, PRINT_CHAT,
|
|
|
|
"Flood protection: You can't talk for %d seconds.\n",
|
|
|
|
(int)flood_waitdelay->value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->flood_whenhead = (cl->flood_whenhead + 1) % (sizeof(cl->flood_when) /
|
|
|
|
sizeof(cl->flood_when[0]));
|
2009-03-12 20:03:41 +00:00
|
|
|
cl->flood_when[cl->flood_whenhead] = level.time;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dedicated->value)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
gi.cprintf(NULL, PRINT_CHAT, "%s", text);
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
for (j = 1; j <= game.maxclients; j++)
|
|
|
|
{
|
|
|
|
other = &g_edicts[j];
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!other->inuse)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!other->client)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (team)
|
|
|
|
{
|
|
|
|
if (!OnSameTeam(ent, other))
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
gi.cprintf(other, PRINT_CHAT, "%s", text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_Ent_Count_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
int x;
|
|
|
|
edict_t *e;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
x = 0;
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
for (e = g_edicts; e < &g_edicts[globals.num_edicts]; e++)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
if (e->inuse)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
x++;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gi.dprintf("%d entites active\n", x);
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
Cmd_PlayerList_f(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char st[80];
|
|
|
|
char text[1400];
|
|
|
|
edict_t *e2;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
/* connect time, ping, score, name */
|
2009-03-12 20:03:41 +00:00
|
|
|
*text = 0;
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
for (i = 0, e2 = g_edicts + 1; i < maxclients->value; i++, e2++)
|
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!e2->inuse)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
continue;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
Com_sprintf(st, sizeof(st), "%02d:%02d %4d %3d %s%s\n",
|
2013-05-01 08:43:49 +00:00
|
|
|
(level.framenum - e2->client->resp.enterframe) / 600,
|
|
|
|
((level.framenum - e2->client->resp.enterframe) % 600) / 10,
|
|
|
|
e2->client->ping, e2->client->resp.score,
|
|
|
|
e2->client->pers.netname,
|
|
|
|
e2->client->resp.spectator ? " (spectator)" : "");
|
|
|
|
|
|
|
|
if (strlen(text) + strlen(st) > sizeof(text) - 50)
|
|
|
|
{
|
|
|
|
sprintf(text + strlen(text), "And more...\n");
|
2009-03-12 20:03:41 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "%s", text);
|
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
strcat(text, st);
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
gi.cprintf(ent, PRINT_HIGH, "%s", text);
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
void
|
|
|
|
ClientCommand(edict_t *ent)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
char *cmd;
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (!ent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-02-22 12:20:22 +00:00
|
|
|
|
2009-03-12 20:03:41 +00:00
|
|
|
if (!ent->client)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
|
|
|
return; /* not fully in game yet */
|
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
|
|
|
cmd = gi.argv(0);
|
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (Q_stricmp(cmd, "players") == 0)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
Cmd_Players_f(ent);
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
if (Q_stricmp(cmd, "say") == 0)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
Cmd_Say_f(ent, false, false);
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
if (Q_stricmp(cmd, "say_team") == 0)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
Cmd_Say_f(ent, true, false);
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
if (Q_stricmp(cmd, "score") == 0)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
Cmd_Score_f(ent);
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
|
|
|
|
if (Q_stricmp(cmd, "help") == 0)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
2013-05-01 08:43:49 +00:00
|
|
|
Cmd_Help_f(ent);
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level.intermissiontime)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
return;
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
|
2013-05-01 08:43:49 +00:00
|
|
|
if (Q_stricmp(cmd, "use") == 0)
|
|
|
|
{
|
|
|
|
Cmd_Use_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "drop") == 0)
|
|
|
|
{
|
|
|
|
Cmd_Drop_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "give") == 0)
|
|
|
|
{
|
|
|
|
Cmd_Give_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "god") == 0)
|
|
|
|
{
|
|
|
|
Cmd_God_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "notarget") == 0)
|
|
|
|
{
|
|
|
|
Cmd_Notarget_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "noclip") == 0)
|
|
|
|
{
|
|
|
|
Cmd_Noclip_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "inven") == 0)
|
|
|
|
{
|
|
|
|
Cmd_Inven_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "invnext") == 0)
|
|
|
|
{
|
|
|
|
SelectNextItem(ent, -1);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "invprev") == 0)
|
|
|
|
{
|
|
|
|
SelectPrevItem(ent, -1);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "invnextw") == 0)
|
|
|
|
{
|
|
|
|
SelectNextItem(ent, IT_WEAPON);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "invprevw") == 0)
|
|
|
|
{
|
|
|
|
SelectPrevItem(ent, IT_WEAPON);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "invnextp") == 0)
|
|
|
|
{
|
|
|
|
SelectNextItem(ent, IT_POWERUP);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "invprevp") == 0)
|
|
|
|
{
|
|
|
|
SelectPrevItem(ent, IT_POWERUP);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "invuse") == 0)
|
|
|
|
{
|
|
|
|
Cmd_InvUse_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "invdrop") == 0)
|
|
|
|
{
|
|
|
|
Cmd_InvDrop_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "weapprev") == 0)
|
|
|
|
{
|
|
|
|
Cmd_WeapPrev_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "weapnext") == 0)
|
|
|
|
{
|
|
|
|
Cmd_WeapNext_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "weaplast") == 0)
|
|
|
|
{
|
|
|
|
Cmd_WeapLast_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "kill") == 0)
|
|
|
|
{
|
|
|
|
Cmd_Kill_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "putaway") == 0)
|
|
|
|
{
|
|
|
|
Cmd_PutAway_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "wave") == 0)
|
|
|
|
{
|
|
|
|
Cmd_Wave_f(ent);
|
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
else if (Q_stricmp(cmd, "playerlist") == 0)
|
2013-05-01 08:43:49 +00:00
|
|
|
{
|
2009-03-12 20:03:41 +00:00
|
|
|
Cmd_PlayerList_f(ent);
|
2013-05-01 08:43:49 +00:00
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "entcount") == 0)
|
|
|
|
{
|
|
|
|
Cmd_Ent_Count_f(ent);
|
|
|
|
}
|
|
|
|
else if (Q_stricmp(cmd, "disguise") == 0)
|
2009-03-12 20:03:41 +00:00
|
|
|
{
|
|
|
|
ent->flags |= FL_DISGUISED;
|
|
|
|
}
|
2013-05-01 08:43:49 +00:00
|
|
|
else /* anything that doesn't match a command will be a chat */
|
|
|
|
{
|
|
|
|
Cmd_Say_f(ent, false, true);
|
|
|
|
}
|
2009-03-12 20:03:41 +00:00
|
|
|
}
|
2009-03-31 09:18:35 +00:00
|
|
|
|