summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorIronClawTrem <louie.nutman@gmail.com>2020-02-24 00:10:26 +0000
committerIronClawTrem <louie.nutman@gmail.com>2020-02-25 19:11:28 +0000
commitdaa9252f4738a1784d1a3168297d20c87a2bd743 (patch)
tree2473be22e2586b8af13a9f91552b7075f4a142bd /src/game
parent419f5d0075c90bb5111dd0af366b941f148066a5 (diff)
add !god command
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_admin.c60
-rw-r--r--src/game/g_admin.h1
-rw-r--r--src/game/g_client.c2
-rw-r--r--src/game/g_local.h1
4 files changed, 64 insertions, 0 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 1a73536..9fcfdef 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -441,6 +441,11 @@ g_admin_cmd_t g_admin_cmds[ ] =
{"drug", G_admin_drug, "drug",
"induce a gas like effect on a player",
"[^3name|slot#^7]"
+ },
+
+ {"god", G_admin_god, "god",
+ "makes a player invincible",
+ "[^3name|slot#^7]"
}
};
@@ -8549,3 +8554,58 @@ qboolean G_admin_drug( gentity_t *ent, int skiparg )
return qtrue;
}
+
+qboolean G_admin_god( gentity_t *ent, int skiparg )
+{
+ int pids[ MAX_CLIENTS ];
+ char name[ MAX_NAME_LENGTH ], err[ MAX_STRING_CHARS ];
+ int minargc;
+ gentity_t *vic;
+
+ minargc = 2 + skiparg;
+
+ if( G_SayArgc() < minargc )
+ {
+ ADMP( "^3!god: ^7usage: !god [name|slot#]\n" );
+ return qfalse;
+ }
+
+ G_SayArgv( 1 + skiparg, name, sizeof( name ) );
+
+ if( G_ClientNumbersFromString( name, pids ) != 1 )
+ {
+ G_MatchOnePlayer( pids, err, sizeof( err ) );
+ ADMP( va( "^3!god: ^7%s\n", err ) );
+ return qfalse;
+ }
+
+ vic = &g_entities[ pids[ 0 ] ];
+
+ if( !ent )
+ {
+ ADMP( "^3!god: ^7sorry, but console cannot do this" );
+ return qfalse;
+ }
+
+ if( !admin_higher( ent, &g_entities[ pids[ 0 ] ] ) )
+ {
+ ADMP( "^3!god: ^7sorry, but that player has a higher admin"
+ " level than you\n" );
+ return qfalse;
+ }
+
+ vic->flags ^= FL_GODMODE;
+
+ if( vic->client->pers.godMode )
+ vic->client->pers.godMode = 0;
+ else
+ vic->client->pers.godMode = 1;
+
+ AP( va( "print \"^3!god: ^7godmode for %s ^7for %s ^7by %s^7\n\"",
+ ( vic->client->pers.godMode ) ? "enabled" : "disabled",
+ vic->client->pers.netname,
+ ( ent ) ? G_admin_adminPrintName( ent ) : "console" ) );
+
+ return qtrue;
+
+}
diff --git a/src/game/g_admin.h b/src/game/g_admin.h
index 877f286..81ff5ff 100644
--- a/src/game/g_admin.h
+++ b/src/game/g_admin.h
@@ -309,6 +309,7 @@ qboolean G_admin_is_restricted(gentity_t *ent, qboolean sendMessage);
qboolean G_admin_print2( gentity_t *ent, int skiparg );
qboolean G_admin_switch( gentity_t *ent, int skiparg );
qboolean G_admin_drug( gentity_t *ent, int skiparg );
+qboolean G_admin_god( gentity_t *ent, int skiparg );
void G_admin_print( gentity_t *ent, char *m );
void G_admin_buffer_print( gentity_t *ent, char *m );
diff --git a/src/game/g_client.c b/src/game/g_client.c
index db86f70..313927c 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -1857,6 +1857,8 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
ent->waterlevel = 0;
ent->watertype = 0;
ent->flags = 0;
+ if( ent->client->pers.godMode )
+ ent->flags = FL_GODMODE;
//TA: calculate each client's acceleration
ent->evaluateAcceleration = qtrue;
diff --git a/src/game/g_local.h b/src/game/g_local.h
index b09f822..f15e5c6 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -453,6 +453,7 @@ typedef struct
qboolean useUnlagged;
statsCounters_t statscounters;
int bubbleTime;
+ int godMode;
} clientPersistant_t;
#define MAX_UNLAGGED_MARKERS 10