Skip to content

Commit

Permalink
Key-finder cheat
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlaux committed Mar 15, 2024
1 parent 05688df commit fa8b854
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- **_Night-Vision Visor Effect_** setting
- **_Alternative Intermission Background_** setting
- **Rewinding** [thanks @rfomin]
- **_'IDDF'_ cheat**, to find a key on the Automap
- **Support for optional health-based player pain sounds**
- **_SUMMON_ cheat spawning mobjs at position of Automap pointer**
- **_Higher god-mode face priority_** setting
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ All of these are CFG-Only, so their CVAR names are included.
- **_'GIBBERS'_** to force gibbing on dying enemies, independently of damage dealt
- **_'IDFLY'_** to fly (uses jumping/crouching keys) [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
- **_'RESURRECT' / 'IDRES'_** to resurrect the player without toggling IDDQD [i.b. ZDoom]
- **_'LINETARGET'_** to give some info on the player's linetarget [i.b. ZDoom]
- **_'MDK'_** to perform a hitscan attack of 1-million damage [i.b. ZDoom]
Expand Down
4 changes: 4 additions & 0 deletions docs/cheats.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ Actors are always spawned facing the same direction as the player.
If the Automap is enabled and the Follow Mode is off, the actors will be spawned where the pointer is located.
Otherwise, they will be spawned in front of the player.

`IDDF[C][T]`
Find a key on the Automap.
This cheat functions similarly to the `KEY` cheat, with `C` and `T` specifying the key color and type respectively.

`RESURRECT` / `IDRES`
Resurrect the player without toggling IDDQD.

Expand Down
81 changes: 80 additions & 1 deletion src/m_cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ static void cheat_summonr();
static int spawneetype = -1;
static boolean spawneefriend;

static void cheat_reveal_key();
static void cheat_reveal_keyx();
static void cheat_reveal_keyxx(int key);

static void cheat_linetarget(); // Give info on the current linetarget
static void cheat_mdk(); // Inspired by ZDoom's console command
static void cheat_saitama(); // MDK Fist
Expand Down Expand Up @@ -388,12 +392,25 @@ struct cheat_s cheat[] = {
{"nextmap", NULL, not_net | not_demo, {cheat_normalexit} },
{"nextsecret", NULL, not_net | not_demo, {cheat_secretexit} },
{"turbo", NULL, not_net | not_demo, {cheat_turbo}, -3 },

{"summon", NULL, not_net | not_demo, {cheat_summon} }, // Summon "Menu"
{"summone", NULL, not_net | not_demo, {cheat_summone0} }, // Summon Enemy "Menu"
{"summone", NULL, not_net | not_demo, {cheat_summone}, -3 }, // Summon a hostile mobj
{"summonf", NULL, not_net | not_demo, {cheat_summonf0} }, // Summon Friend "Menu"
{"summonf", NULL, not_net | not_demo, {cheat_summonf}, -3 }, // Summon a friendly mobj
{"summonr", NULL, not_net | not_demo, {cheat_summonr} }, // Repeat last summon

{"iddf", NULL, not_net | not_demo, {cheat_reveal_key} },
{"iddfb", NULL, not_net | not_demo, {cheat_reveal_keyx} },
{"iddfy", NULL, not_net | not_demo, {cheat_reveal_keyx} },
{"iddfr", NULL, not_net | not_demo, {cheat_reveal_keyx} },
{"iddfbc", NULL, not_net | not_demo, {cheat_reveal_keyxx}, 0 },
{"iddfyc", NULL, not_net | not_demo, {cheat_reveal_keyxx}, 2 },
{"iddfrc", NULL, not_net | not_demo, {cheat_reveal_keyxx}, 1 },
{"iddfbs", NULL, not_net | not_demo, {cheat_reveal_keyxx}, 5 },
{"iddfys", NULL, not_net | not_demo, {cheat_reveal_keyxx}, 3 },
{"iddfrs", NULL, not_net | not_demo, {cheat_reveal_keyxx}, 4 },

{"linetarget", NULL, not_net | not_demo, {cheat_linetarget} }, // Give info on the current linetarget
{"mdk", NULL, not_net | not_demo, {cheat_mdk} },
{"saitama", NULL, not_net | not_demo, {cheat_saitama} }, // MDK Fist
Expand All @@ -412,6 +429,8 @@ struct cheat_s cheat[] = {

//-----------------------------------------------------------------------------

extern int init_thinkers_count; // [Nugget]

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

#ifdef NUGMAGIC
Expand Down Expand Up @@ -671,6 +690,66 @@ static void cheat_summonr()
SummonMobj(spawneefriend);
}

static void cheat_reveal_key()
{
if (automapactive != AM_FULL) { return; }

displaymsg("Key Finder: Red, Yellow or Blue?");
}

static void cheat_reveal_keyx()
{
if (automapactive != AM_FULL) { return; }

displaymsg("Key Finder: Card or Skull?");
}

static void cheat_reveal_keyxx(int key)
{
if (automapactive != AM_FULL) { return; }

static int last_count;
static mobj_t *last_mobj;

// If the thinkers have been wiped, addresses are invalid
if (last_count != init_thinkers_count)
{
last_count = init_thinkers_count;
last_mobj = NULL;
}

thinker_t *th, *start_th;

if (last_mobj)
{ th = &(last_mobj->thinker); }
else
{ th = &thinkercap; }

start_th = th;

boolean found = false;

do {
th = th->next;

if (th->function.p1 == (actionf_p1) P_MobjThinker)
{
mobj_t *mobj = (mobj_t *) th;

if (mobj->type == MT_MISC4 + key)
{
found = true;
followplayer = false;
AM_SetMapCenter(mobj->x, mobj->y);
P_SetTarget(&last_mobj, mobj);
break;
}
}
} while (th != start_th);

if (!found) { displaymsg("Key Finder: key not found"); }
}

// Give info on the current `linetarget`
static void cheat_linetarget()
{
Expand Down Expand Up @@ -1440,7 +1519,7 @@ static void cheat_reveal_secret()
static void cheat_cycle_mobj(mobj_t **last_mobj, int *last_count,
int flags, int alive)
{
extern int init_thinkers_count;
// [Nugget] Moved `extern init_thinkers_count` to global scope
thinker_t *th, *start_th;

// If the thinkers have been wiped, addresses are invalid
Expand Down

0 comments on commit fa8b854

Please sign in to comment.