Skip to content

Commit

Permalink
Added sv_norecoil, sv_noreload, and sv_nooverheat cheats
Browse files Browse the repository at this point in the history
- sv_norecoil really just prevents the waittime between firing bullets
- sv_noreload gives you infinite ammo (so you don't have to keep spamming 'give all' in the console)
- sv_nooverheat prevents your weapon from being overheated.

These all see a bit buggy but they work. Firing rockets with sv_norecoil enabled will make for some interesing
game behavior. There's too many entities for the engine to handle and I haven't figured out how to increase the
entity limit. Same will happen with any automatic weapon (the gattling cannon especially). I have changed
the entity spawning code to thwart the crashing but it doesn't work well (things like doors disappear or don't work
right once you fire 3000 rockets).
  • Loading branch information
Justin Crawford authored and Justin Crawford committed Apr 2, 2014
1 parent 8b8145f commit c1b3488
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/game/q_shared.h
Expand Up @@ -1025,7 +1025,7 @@ typedef enum
// also be in this range
#define ENTITYNUM_NONE ( MAX_GENTITIES - 1 )
#define ENTITYNUM_WORLD ( MAX_GENTITIES - 2 )
#define ENTITYNUM_MAX_NORMAL ( MAX_GENTITIES - 2 )
#define ENTITYNUM_MAX_NORMAL ( (MAX_GENTITIES) - 2 )


#define MAX_MODELS 256 // these are sent over the net as 8 bits
Expand Down
12 changes: 10 additions & 2 deletions src/game/bg_pmove.c
Expand Up @@ -2868,7 +2868,7 @@ void PM_CheckForReload(int weapon)
ammoWeap = BG_FindAmmoForWeapon(weapon);

// Added infinite clips cheat - Justasic
cvar_t *ammoCheat = Cvar_Get("sv_infiniteclips", "0", CVAR_CHEAT);
cvar_t *ammoCheat = Cvar_Get("sv_noreload", "0", CVAR_CHEAT);
// Set to max clip size - Justasic
if (ammoCheat->integer)
pm->ps->ammoclip[clipWeap] = ammoTable[weapon].maxclip;
Expand Down Expand Up @@ -4149,6 +4149,10 @@ static void PM_Weapon(void)


aimSpreadScaleAdd = 0;

// Cheats.
cvar_t *recoilCheat = Cvar_Get("sv_norecoil", "0", CVAR_CHEAT);
cvar_t *overheatCheat = Cvar_Get("sv_nooverheat", "0", CVAR_CHEAT);

switch(pm->ps->weapon)
{
Expand Down Expand Up @@ -4315,6 +4319,7 @@ static void PM_Weapon(void)

// the weapon can overheat, and it's hot
if((pm->ps->aiChar != AICHAR_PROTOSOLDIER) &&
(overheatCheat->integer == 0) &&
(pm->ps->aiChar != AICHAR_SUPERSOLDIER) &&
(ammoTable[pm->ps->weapon].maxHeat && pm->ps->weapHeat[pm->ps->weapon]))
{
Expand Down Expand Up @@ -4345,7 +4350,10 @@ static void PM_Weapon(void)

pm->ps->aimSpreadScale = (int)(pm->ps->aimSpreadScaleFloat);

pm->ps->weaponTime += addTime;
if (!recoilCheat->integer)
pm->ps->weaponTime += addTime;
else
pm->ps->weaponTime = 0;

PM_SwitchIfEmpty();
}
Expand Down
19 changes: 17 additions & 2 deletions src/game/g_utils.c
Expand Up @@ -485,6 +485,7 @@ instead of being removed and recreated, which can cause interpolated
angles and bad trails.
=================
*/
void G_FreeEntity(gentity_t *ed);
gentity_t *G_Spawn(void)
{
int i, force;
Expand All @@ -499,7 +500,7 @@ gentity_t *G_Spawn(void)
// override the normal minimum times before use
e = &g_entities[MAX_CLIENTS];

for(i = MAX_CLIENTS ; i < level.num_entities ; i++, e++)
for(i = MAX_CLIENTS; i < level.num_entities; i++, e++)
{
if(e->inuse)
{
Expand All @@ -526,12 +527,26 @@ gentity_t *G_Spawn(void)

if(i == ENTITYNUM_MAX_NORMAL)
{
int currentEntities = level.num_entities;
for(i = 0; i < MAX_GENTITIES; i++)
{
G_Printf("%4i: %s\n", i, g_entities[i].classname);

// Since our sv_norecoil causes a lot of entities to spawn,
// we need to free some of them while they're being made.
// the entity limit is too low but it's too hard to raise it.
// The game allows 1024 entities max.
// this especially happens with the rocket launcher
if (!Q_stricmp(g_entities[i].classname, "tempEntity") ||
!Q_stricmp(g_entities[i].classname, "rocket"))
{
G_FreeEntity(&g_entities[i]);
level.num_entities--;
}
}

G_Error("G_Spawn: no free entities");
if (level.num_entities == currentEntities)
G_Error("G_Spawn: no free entities");
}

// open up a new slot
Expand Down

0 comments on commit c1b3488

Please sign in to comment.