Skip to content

Commit

Permalink
Riot Mode cheat
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlaux committed Jan 10, 2025
1 parent 5c0a57f commit dc2639f
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## New Features

- **_'RIOTMODE'_** cheat, to make enemies attack all sentient entities
- **_Message Fadeout_** setting
- **_Weapon Bob Speed_** setting
- **_Bob [Weapon] While Switching_** setting
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ All of these are CFG-only, so their CVAR names are included.
- **_'VALIANT'_** for fast weapons [i.b. ZDoom]
- **_'BOBBERS'_** serves as a shortcut to toggle the two cheats mentioned above, plus IDFA
- **_'GIBBERS'_** to force gibbing on dying enemies, independently of damage dealt
- **_'RIOTMODE'_** cheat, to make enemies attack all sentient entities
- **_'IDFLY'_** to fly (uses jumping/crouching buttons) [i.b. PrBoom+, ZDoom]
- **_'SUMMON'_** to spawn an actor based on its type index [i.b. ZDoom, PrBoomX]
- **_'IDDF'_** to find a key on the Automap
Expand Down
4 changes: 4 additions & 0 deletions docs/cheats.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ Shortcut to toggle the two cheats mentioned above, and IDFA.
`GIBBERS`
Force gibbing on dying enemies, independently of damage dealt.

`RIOTMODE`
Make enemies attack all sentient entities (including other enemies),
and allow entities to damage their same species.

`IDFLY`
Toggle Fly Mode (uses jumping/crouching keys).

Expand Down
7 changes: 7 additions & 0 deletions src/m_cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ static void cheat_bobbers(); // Shortcut to the two cheats above
boolean gibbers; // Used for 'GIBBERS'
static void cheat_gibbers(); // Everything gibs

static void cheat_riotmode(void);
static void cheat_resurrect();
static void cheat_fly();
static void cheat_normalexit(); // Emulate normal level exit
Expand Down Expand Up @@ -413,6 +414,7 @@ struct cheat_s cheat[] = {
{"valiant", NULL, not_net | not_demo, {cheat_fastweaps} }, // Fast weapons cheat
{"bobbers", NULL, not_net | not_demo, {cheat_bobbers} }, // Shortcut for the two above cheats
{"gibbers", NULL, not_net | not_demo, {cheat_gibbers} }, // Everything gibs
{"riotmode", NULL, not_net | not_demo, {cheat_riotmode} },
{"resurrect", NULL, not_net | not_demo, {cheat_resurrect} },
{"idres", NULL, not_net | not_demo, {cheat_resurrect} }, // 'RESURRECT' alternative
{"idfly", NULL, not_net | not_demo, {cheat_fly} },
Expand Down Expand Up @@ -852,6 +854,11 @@ static void cheat_boomcan()
displaymsg("Explosive Hitscan %s", (plyr->cheats & CF_BOOMCAN) ? "ON" : "OFF");
}

static void cheat_riotmode(void)
{
displaymsg("Riot Mode %s", (riotmode = !riotmode) ? "ON" : "OFF");
}

static void cheat_cheese()
{
cheese = !cheese;
Expand Down
55 changes: 55 additions & 0 deletions src/p_enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,52 @@ static boolean P_LookForMonsters(mobj_t *actor, boolean allaround)
return false; // No monster found
}

// [Nugget]
static boolean P_LookForAnyTargets(mobj_t *actor)
{
thinker_t *currentthinker = &thinkercap;

mobj_t *closest = NULL;
fixed_t closest_dist = 0;
boolean closest_visible = false;

while ((currentthinker = currentthinker->next) != &thinkercap)
{
if (currentthinker->function.p1 == (actionf_p1) P_MobjThinker)
{
mobj_t *const mo = (mobj_t *) currentthinker;

if (
mo->health > 0
&& ( mo->flags & MF_COUNTKILL
|| mo->type == MT_SKULL
|| (mo->player && mo->player->mo == mo && !(mo->player->cheats & CF_NOTARGET)))
&& mo != actor
) {
const fixed_t dist = P_AproxDistance(mo->x - actor->x, mo->y - actor->y);
boolean visible = false;

// If we found a visible mobj, don't bother checking whether this one
// is visible unless it's closer than the visible one
if (dist < closest_dist || !closest_visible)
{ visible = P_CheckSight(actor, mo); }

// Prefer visible targets regardless of distance
if (dist < closest_dist || (visible && !closest_visible) || !closest)
{
closest = mo;
closest_dist = dist;
closest_visible = visible;
}
}
}
}

P_SetTarget(&actor->target, closest);

return actor->target != NULL;
}

//
// P_LookForTargets
//
Expand All @@ -1054,6 +1100,10 @@ static boolean P_LookForMonsters(mobj_t *actor, boolean allaround)

static boolean P_LookForTargets(mobj_t *actor, int allaround)
{
// [Nugget]
if (riotmode && !(actor->flags & MF_FRIEND))
{ return P_LookForAnyTargets(actor); }

return actor->flags & MF_FRIEND ?
P_LookForMonsters(actor, allaround) || P_LookForPlayers (actor, allaround):
P_LookForPlayers (actor, allaround) || P_LookForMonsters(actor, allaround);
Expand Down Expand Up @@ -1114,6 +1164,8 @@ void A_Look(mobj_t *actor)

targ = actor->subsector->sector->soundtarget;

if (riotmode) { targ = NULL; } // [Nugget]

// [crispy] monsters don't look for players with NOTARGET cheat
if (targ && targ->player && (targ->player->cheats & CF_NOTARGET))
return;
Expand Down Expand Up @@ -1770,6 +1822,9 @@ static void WatchResurrection(mobj_t* target, mobj_t* raiser)

static boolean P_HealCorpse(mobj_t* actor, int radius, statenum_t healstate, sfxenum_t healsound)
{
// [Nugget]
if (riotmode && !(actor->flags & MF_FRIEND)) { return false; }

int xl, xh;
int yl, yh;
int bx, by;
Expand Down
11 changes: 8 additions & 3 deletions src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ int numspechit;
// Temporary holder for thing_sectorlist threads
msecnode_t *sector_list = NULL; // phares 3/16/98

// [Nugget] Hitscan trails /--------------------------------------------------
// [Nugget] /=================================================================

boolean riotmode;

// Hitscan trails ------------------------------------------------------------

int hitscan_trail_interval;

Expand Down Expand Up @@ -157,7 +161,7 @@ void P_SpawnHitscanTrail(fixed_t x, fixed_t y, fixed_t z,
}
}

// [Nugget] -----------------------------------------------------------------/
// [Nugget] =================================================================/

//
// TELEPORT MOVE
Expand Down Expand Up @@ -775,7 +779,8 @@ static boolean PIT_CheckThing(mobj_t *thing) // killough 3/26/98: make static
return true; // Don't hit same species as originator.
else
// Dehacked support - monsters infight
if (thing->type != MT_PLAYER && !deh_species_infighting) // Explode, but do no damage.
if (thing->type != MT_PLAYER && !deh_species_infighting // Explode, but do no damage.
&& !riotmode) // [Nugget]
return false; // Let players missile other players.
}

Expand Down
2 changes: 2 additions & 0 deletions src/p_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ void P_SetIsBFGTracer(const boolean value);

void P_SetIsBoomShot(const boolean value); // Explosive hitscan cheat

extern boolean riotmode;

// Hitscan trails ------------------------------------------------------------

int P_GetShowHitscanTrails(void);
Expand Down

0 comments on commit dc2639f

Please sign in to comment.