mirror of
https://github.com/rehlds/rehlds.git
synced 2024-12-28 07:35:47 +03:00
Add support cheats command god,notarget,noclip
This commit is contained in:
parent
b7f6eb8023
commit
7fcec97af4
@ -761,6 +761,111 @@ void Host_Status_Formatted_f(void)
|
||||
Host_Status_Printf(conprint, log, "%i users\n", nClients);
|
||||
}
|
||||
|
||||
// Sets client to godmode
|
||||
void Host_God_f(void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
{
|
||||
Cmd_ForwardToServer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sv_cheats.value)
|
||||
return;
|
||||
|
||||
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
|
||||
if (!((int)sv_player->v.flags & FL_GODMODE))
|
||||
SV_ClientPrintf("godmode OFF\n");
|
||||
else
|
||||
SV_ClientPrintf("godmode ON\n");
|
||||
}
|
||||
|
||||
// Sets client to notarget mode
|
||||
void Host_Notarget_f(void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
{
|
||||
Cmd_ForwardToServer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sv_cheats.value)
|
||||
return;
|
||||
|
||||
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
|
||||
if (!((int)sv_player->v.flags & FL_NOTARGET))
|
||||
SV_ClientPrintf("notarget OFF\n");
|
||||
else
|
||||
SV_ClientPrintf("notarget ON\n");
|
||||
}
|
||||
|
||||
// Searches along the direction ray in steps of "step" to see if
|
||||
// the entity position is passible
|
||||
// Used for putting the player in valid space when toggling off noclip mode
|
||||
int FindPassableSpace(edict_t *pEdict, vec_t *direction, float step)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
VectorMA(pEdict->v.origin, step, direction, pEdict->v.origin);
|
||||
|
||||
if (!SV_TestEntityPosition(pEdict))
|
||||
{
|
||||
// Store old origin
|
||||
VectorCopy(pEdict->v.origin, pEdict->v.oldorigin);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Host_Noclip_f(void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
{
|
||||
Cmd_ForwardToServer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sv_cheats.value)
|
||||
return;
|
||||
|
||||
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
|
||||
{
|
||||
sv_player->v.movetype = MOVETYPE_NOCLIP;
|
||||
SV_ClientPrintf("noclip ON\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sv_player->v.movetype = MOVETYPE_WALK;
|
||||
|
||||
// Store old origin
|
||||
VectorCopy(sv_player->v.origin, sv_player->v.oldorigin);
|
||||
|
||||
SV_ClientPrintf("noclip OFF\n");
|
||||
|
||||
if (SV_TestEntityPosition(sv_player))
|
||||
{
|
||||
vec3_t forward, right, up;
|
||||
AngleVectors(sv_player->v.v_angle, forward, right, up);
|
||||
|
||||
if (!FindPassableSpace(sv_player, forward, 1.0)
|
||||
&& !FindPassableSpace(sv_player, right, 1.0)
|
||||
&& !FindPassableSpace(sv_player, right, -1.0) // left
|
||||
&& !FindPassableSpace(sv_player, up, 1.0) // up
|
||||
&& !FindPassableSpace(sv_player, up, -1.0) // down
|
||||
&& !FindPassableSpace(sv_player, forward, -1.0)) // back
|
||||
{
|
||||
Con_DPrintf("Can't find the world\n");
|
||||
}
|
||||
|
||||
VectorCopy(sv_player->v.oldorigin, sv_player->v.origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Host_Ping_f(void)
|
||||
{
|
||||
int i;
|
||||
@ -3146,11 +3251,12 @@ void Host_InitCommands(void)
|
||||
Cmd_AddCommand("setinfo", Host_SetInfo_f);
|
||||
Cmd_AddCommand("fullinfo", Host_FullInfo_f);
|
||||
|
||||
#ifndef SWDS
|
||||
Cmd_AddCommand("god", Host_God_f);
|
||||
Cmd_AddCommand("notarget", Host_Notarget_f);
|
||||
Cmd_AddCommand("fly", Host_Fly_f);
|
||||
Cmd_AddCommand("noclip", Host_Noclip_f);
|
||||
|
||||
#ifndef SWDS
|
||||
Cmd_AddCommand("fly", Host_Fly_f);
|
||||
Cmd_AddCommand("viewmodel", Host_Viewmodel_f);
|
||||
Cmd_AddCommand("viewframe", Host_Viewframe_f);
|
||||
Cmd_AddCommand("viewnext", Host_Viewnext_f);
|
||||
|
@ -42,7 +42,7 @@ edict_t *sv_player;
|
||||
qboolean nofind;
|
||||
|
||||
#if defined(SWDS) && defined(REHLDS_FIXES)
|
||||
const char *clcommands[] = { "status", "name", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "setinfo", "sendents", "fullupdate", "setpause", "unpause", NULL };
|
||||
const char *clcommands[] = { "status", "name", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "setinfo", "sendents", "fullupdate", "setpause", "unpause", "noclip", "god", "notarget", NULL };
|
||||
#else
|
||||
const char *clcommands[23] = { "status", "god", "notarget", "fly", "name", "noclip", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "nextdl", "setinfo", "showinfo", "sendents", "fullupdate", "setpause", "unpause", NULL };
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user