-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM_CHEAT.C
452 lines (365 loc) · 12.1 KB
/
M_CHEAT.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
// m_cheat.c : cheat sequence responder.
#include "doomdef.h"
#include "dstrings.h"
#include "am_map.h"
#include "m_cheat.h"
#include "g_game.h"
#include "r_local.h"
#include "p_local.h"
#include "p_inter.h"
#include "m_cheat.h"
#include "i_sound.h" // for I_PlayCD()
#include "s_sound.h"
// ==========================================================================
// CHEAT Structures
// ==========================================================================
unsigned char cheat_mus_seq[] =
{
0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff
};
//Fab:19-07-98: idcd xx : change cd track
unsigned char cheat_cd_seq[] =
{
0xb2, 0x26, 0xe2, 0x26, 1, 0, 0, 0xff
};
unsigned char cheat_choppers_seq[] =
{
0xb2, 0x26, 0xb2, 0x32, 0xb2, 0x2a, 0xb2, 0xa6, 0xb2, 0xea, 0xff // id...
};
unsigned char cheat_god_seq[] =
{
0xb2, 0xb2, 0x26, 0xb2, 0x26, 0xff // iddqd
};
unsigned char cheat_ammo_seq[] =
{
0xb2, 0xb2, 0xf2, 0x66, 0xb2, 0xff // idkfa
};
unsigned char cheat_ammonokey_seq[] =
{
0xb2, 0xb2, 0x66, 0xa2, 0xff // idfa
};
// Smashing Pumpkins Into Small Pieces Of Putrid Debris.
unsigned char cheat_noclip_seq[] =
{
0xb2, 0x26, 0xb2, 0x2a, 0xb2, // idspispopd
0xea, 0xb2, 0xf6, 0xb2, 0x26, 0xff
};
//
unsigned char cheat_commercial_noclip_seq[] =
{
0xb2, 0x26, 0xe2, 0xb2, 0xb2, 0xb2, 0xff // idclip
};
//added:28-02-98: new cheat to fly around levels using jump !!
unsigned char cheat_fly_around_seq[] =
{
0xb2, 0x26, SCRAMBLE('f'), SCRAMBLE('l'), SCRAMBLE('y'), 0xff // idfly
};
unsigned char cheat_powerup_seq[7][10] =
{
{ 0xb2, 0x26, 0xb2, 0xa6, 0x32, 0xf6, 0xb2, 0x26, 0xb2, 0xff }, // beholdv
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xea, 0xff }, // beholds
{ 0xb2, 0x26, 0x62, 0xb2, 0x32, 0xf6, 0x36, 0x26, 0xb2, 0xff }, // beholdi
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6a, 0xff }, // beholdr
{ 0xb2, 0x26, 0xb2, 0xa6, 0x32, 0xf6, 0xb2, 0x26, 0xa2, 0xff }, // beholda
{ 0xb2, 0x26, 0xb2, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x36, 0xff }, // beholdl
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0xb2, 0x26, 0xff } // behold
};
unsigned char cheat_clev_seq[] =
{
0xb2, 0x26, 0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff // idclev
};
// my position cheat
unsigned char cheat_mypos_seq[] =
{
0xb2, 0x26, 0xb2, 0xba, 0x2a, 0xf6, 0xea, 0xff // idmypos
};
unsigned char cheat_amap_seq[] = { 0xb2, 0x26, 0xb2, 0x2e, 0xff };
cheatseq_t cheat_amap = { cheat_amap_seq, 0 };
// Now what?
cheatseq_t cheat_mus = { cheat_mus_seq, 0 };
cheatseq_t cheat_cd = { cheat_cd_seq, 0 };
cheatseq_t cheat_god = { cheat_god_seq, 0 };
cheatseq_t cheat_ammo = { cheat_ammo_seq, 0 };
cheatseq_t cheat_ammonokey = { cheat_ammonokey_seq, 0 };
cheatseq_t cheat_noclip = { cheat_noclip_seq, 0 };
cheatseq_t cheat_commercial_noclip = { cheat_commercial_noclip_seq, 0 };
//added:28-02-98:
cheatseq_t cheat_fly_around = { cheat_fly_around_seq, 0 };
cheatseq_t cheat_powerup[7] =
{
{ cheat_powerup_seq[0], 0 },
{ cheat_powerup_seq[1], 0 },
{ cheat_powerup_seq[2], 0 },
{ cheat_powerup_seq[3], 0 },
{ cheat_powerup_seq[4], 0 },
{ cheat_powerup_seq[5], 0 },
{ cheat_powerup_seq[6], 0 }
};
cheatseq_t cheat_choppers = { cheat_choppers_seq, 0 };
cheatseq_t cheat_clev = { cheat_clev_seq, 0 };
cheatseq_t cheat_mypos = { cheat_mypos_seq, 0 };
// ==========================================================================
// CHEAT SEQUENCE PACKAGE
// ==========================================================================
static int firsttime = 1;
static unsigned char cheat_xlate_table[256];
//
// Called in st_stuff module, which handles the input.
// Returns a 1 if the cheat was successful, 0 if failed.
//
int cht_CheckCheat ( cheatseq_t* cht, char key )
{
int i;
int rc = 0;
if (firsttime)
{
firsttime = 0;
for (i=0;i<256;i++) cheat_xlate_table[i] = SCRAMBLE(i);
}
if (!cht->p)
cht->p = cht->sequence; // initialize if first time
if (*cht->p == 0)
*(cht->p++) = key;
else if
(cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++;
else
cht->p = cht->sequence;
if (*cht->p == 1)
cht->p++;
else if (*cht->p == 0xff) // end of sequence character
{
cht->p = cht->sequence;
rc = 1;
}
return rc;
}
void cht_GetParam ( cheatseq_t* cht,
char* buffer )
{
unsigned char *p, c;
p = cht->sequence;
while (*(p++) != 1);
do
{
c = *p;
*(buffer++) = c;
*(p++) = 0;
}
while (c && *p!=0xff );
if (*p==0xff)
*buffer = 0;
}
extern char* mapnames[];
extern int am_cheating;
// added 2-2-98 for compatibility with dehacked
int idfa_armor=200;
int idfa_armor_class=2;
int idkfa_armor=200;
int idkfa_armor_class=2;
int god_health=100;
player_t *plyr;
boolean cht_Responder (event_t* ev)
{
int i;
char* msg;
if (ev->type == ev_keydown)
{
msg = NULL;
// added 17-5-98
plyr = &players[consoleplayer];
// b. - enabled for more debug fun.
// if (gameskill != sk_nightmare) {
if (cht_CheckCheat(&cheat_amap, ev->data1))
am_cheating = (am_cheating+1) % 3;
else
// 'dqd' cheat for toggleable god mode
if (cht_CheckCheat(&cheat_god, ev->data1))
{
plyr->cheats ^= CF_GODMODE;
if (plyr->cheats & CF_GODMODE)
{
if (plyr->mo)
plyr->mo->health = god_health;
plyr->health = god_health;
//plyr->message = STSTR_DQDON;
msg = STSTR_DQDON;
}
else
//plyr->message = STSTR_DQDOFF;
msg = STSTR_DQDOFF;
}
// 'fa' cheat for killer fucking arsenal
else if (cht_CheckCheat(&cheat_ammonokey, ev->data1))
{
plyr->armorpoints = idfa_armor;
plyr->armortype = idfa_armor_class;
for (i=0;i<NUMWEAPONS;i++)
plyr->weaponowned[i] = true;
for (i=0;i<NUMAMMO;i++)
plyr->ammo[i] = plyr->maxammo[i];
//plyr->message = STSTR_FAADDED;
msg = STSTR_FAADDED;
}
// 'kfa' cheat for key full ammo
else if (cht_CheckCheat(&cheat_ammo, ev->data1))
{
plyr->armorpoints = idkfa_armor;
plyr->armortype = idkfa_armor_class;
for (i=0;i<NUMWEAPONS;i++)
plyr->weaponowned[i] = true;
for (i=0;i<NUMAMMO;i++)
plyr->ammo[i] = plyr->maxammo[i];
for (i=0;i<NUMCARDS;i++)
plyr->cards[i] = true;
//plyr->message = STSTR_KFAADDED;
msg = STSTR_KFAADDED;
}
// 'mus' cheat for changing music
else if (cht_CheckCheat(&cheat_mus, ev->data1))
{
char buf[3];
int musnum;
plyr->message = STSTR_MUS;
cht_GetParam(&cheat_mus, buf);
if (gamemode == commercial)
{
musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1;
if (((buf[0]-'0')*10 + buf[1]-'0') > 35)
//plyr->message = STSTR_NOMUS;
msg = STSTR_NOMUS;
else
S_ChangeMusic(musnum, 1);
}
else
{
musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1');
if (((buf[0]-'1')*9 + buf[1]-'1') > 31)
//plyr->message = STSTR_NOMUS;
msg = STSTR_NOMUS;
else
S_ChangeMusic(musnum, 1);
}
}
// 'cd' for changing cd track quickly
//NOTE: the cheat uses the REAL track numbers, not remapped ones
else if (cht_CheckCheat(&cheat_cd, ev->data1))
{
char buf[3];
cht_GetParam(&cheat_cd, buf);
plyr->message = "Changing cd track...\n";
I_PlayCD ((buf[0]-'0')*10 + (buf[1]-'0'), true);
}
// Simplified, accepting both "noclip" and "idspispopd".
// no clipping mode cheat
else
if ( cht_CheckCheat(&cheat_noclip, ev->data1) ||
cht_CheckCheat(&cheat_commercial_noclip,ev->data1) )
{
plyr->cheats ^= CF_NOCLIP;
if (plyr->cheats & CF_NOCLIP)
//plyr->message = STSTR_NCON;
msg = STSTR_NCON;
else
//plyr->message = STSTR_NCOFF;
msg = STSTR_NCOFF;
}
// 'behold?' power-up cheats
for (i=0;i<6;i++)
{
if (cht_CheckCheat(&cheat_powerup[i], ev->data1))
{
if (!plyr->powers[i])
P_GivePower( plyr, i);
else if (i!=pw_strength)
plyr->powers[i] = 1;
else
plyr->powers[i] = 0;
//plyr->message = STSTR_BEHOLDX;
msg = STSTR_BEHOLDX;
}
}
// 'behold' power-up menu
if (cht_CheckCheat(&cheat_powerup[6], ev->data1))
{
//plyr->message = STSTR_BEHOLD;
msg = STSTR_BEHOLD;
}
// 'choppers' invulnerability & chainsaw
else
if (cht_CheckCheat(&cheat_choppers, ev->data1))
{
plyr->weaponowned[wp_chainsaw] = true;
plyr->powers[pw_invulnerability] = true;
//plyr->message = STSTR_CHOPPERS;
msg = STSTR_CHOPPERS;
}
// 'mypos' for player position
else
if (cht_CheckCheat(&cheat_mypos, ev->data1))
{
//plyr->message = buf;
CONS_Printf (va("ang=0x%x;x,y=(0x%x,0x%x)",
players[statusbarplayer].mo->angle,
players[statusbarplayer].mo->x,
players[statusbarplayer].mo->y));
}
else
//added:28-02-98: new fly cheat using jump key
if (cht_CheckCheat(&cheat_fly_around, ev->data1))
{
plyr->cheats ^= CF_FLYAROUND;
if (plyr->cheats & CF_FLYAROUND)
//plyr->message = "FLY MODE ON : USE JUMP KEY";
msg = "FLY MODE ON : USE JUMP KEY\n";
else
//plyr->message = "FLY MODE OFF";
msg = "FLY MODE OFF\n";
}
// 'clev' change-level cheat
if (cht_CheckCheat(&cheat_clev, ev->data1))
{
char buf[3];
int epsd;
int map;
cht_GetParam(&cheat_clev, buf);
if (gamemode == commercial)
{
epsd = 0;
map = (buf[0] - '0')*10 + buf[1] - '0';
}
else
{
epsd = buf[0] - '0';
map = buf[1] - '0';
// added 3-1-98
if (epsd < 1)
return false;
}
// Catch invalid maps.
//added:08-01-98:moved if (epsd<1)... up
if (map < 1)
return false;
// Ohmygod - this is not going to work.
if ( (gamemode == retail) &&
((epsd > 4) || (map > 9)) )
return false;
if ( (gamemode == registered) &&
((epsd > 3) || (map > 9)) )
return false;
if ((gamemode == shareware) &&
((epsd > 1) || (map > 9)) )
return false;
if ((gamemode == commercial) &&
(( epsd > 1) || (map > 34)) )
return false;
// So be it.
//plyr->message = STSTR_CLEV;
msg = STSTR_CLEV;
G_DeferedInitNew(gameskill, G_BuildMapName(epsd, map));
}
// append a newline to the original doom messages
if (msg)
CONS_Printf("%s\n",msg);
}
return false;
}