-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathm_cheat.c
268 lines (211 loc) · 5.27 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
#include "m_cheat.h"
#include "doomdef.h"
#include "d_englsh.h"
#include "p_inter.h"
#include "g_game.h"
#include "globdata.h"
static void cheat_god(void);
static void cheat_choppers(void);
static void cheat_idkfa(void);
static void cheat_ammo(void);
static void cheat_noclip(void);
static void cheat_invincibility(void);
static void cheat_berserk(void);
static void cheat_invisibility(void);
static void cheat_rad(void);
static void cheat_map(void);
static void cheat_goggles(void);
static void cheat_exit(void);
static void cheat_end(void);
static void cheat_rockets(void);
static void cheat_fps(void);
typedef struct
{
void (*cheat_function)(void);
char *sequence;
char *p;
} cheatseq_t;
static cheatseq_t cheat_def[] =
{
{cheat_choppers, "idchoppers", NULL},
{cheat_god, "iddqd", NULL},
{cheat_idkfa, "idkfa", NULL},
{cheat_ammo, "idfa", NULL},
{cheat_noclip, "idspispopd", NULL},
{cheat_invincibility, "idbeholdv", NULL},
{cheat_berserk, "idbeholds", NULL},
{cheat_invisibility, "idbeholdi", NULL},
{cheat_rad, "idbeholdr", NULL},
{cheat_map, "idbeholda", NULL},
{cheat_goggles, "idbeholdl", NULL},
{cheat_exit, "idclev", NULL},
{cheat_end, "idend", NULL},
{cheat_rockets, "idrocket", NULL}, // Because Goldeneye!
{cheat_fps, "idrate", NULL}
};
static const int16_t num_cheats = sizeof(cheat_def) / sizeof (cheatseq_t);
static boolean cht_CheckCheat(cheatseq_t *cht, char data1)
{
if (!cht->p)
cht->p = cht->sequence; // initialize if first time
if (*cht->p == data1)
cht->p++;
else
cht->p = cht->sequence;
if (*cht->p == '\0') // end of sequence character
{
cht->p = cht->sequence;
return true;
}
return false;
}
boolean C_Responder (event_t *ev)
{
if (ev->type == ev_keydown)
{
for (int16_t i = 0; i < num_cheats; i++)
{
if (cht_CheckCheat(&cheat_def[i], ev->data1))
{
cheat_def[i].cheat_function();
return true;
}
}
}
return false;
}
static void cheat_god()
{
_g_player.cheats ^= CF_GODMODE;
if(_g_player.cheats & CF_GODMODE)
{
_g_player.health = god_health;
_g_player.message = STSTR_DQDON;
}
else
{
_g_player.message = STSTR_DQDOFF;
}
}
static void cheat_choppers()
{
_g_player.weaponowned[wp_chainsaw] = true;
_g_player.pendingweapon = wp_chainsaw;
P_GivePower(&_g_player, pw_invulnerability);
_g_player.message = STSTR_CHOPPERS;
}
static void cheat_idkfa()
{
int16_t i;
player_t* plyr = &_g_player;
if (!plyr->backpack)
{
for (i=0 ; i<NUMAMMO ; i++)
plyr->maxammo[i] *= 2;
plyr->backpack = true;
}
plyr->armorpoints = idfa_armor; // Ty 03/09/98 - deh
plyr->armortype = idfa_armor_class; // Ty 03/09/98 - deh
// You can't own weapons that aren't in the game // phares 02/27/98
for (i=0;i<NUMWEAPONS;i++)
if (!(i == wp_plasma || i == wp_bfg || i == wp_supershotgun))
plyr->weaponowned[i] = true;
for (i=0;i<NUMAMMO;i++)
if (i!=am_cell)
plyr->ammo[i] = plyr->maxammo[i];
for (i=0;i<NUMCARDS;i++)
plyr->cards[i] = true;
plyr->message = STSTR_KFAADDED;
}
static void cheat_ammo()
{
int16_t i;
player_t* plyr = &_g_player;
if (!plyr->backpack)
{
for (i=0 ; i<NUMAMMO ; i++)
plyr->maxammo[i] *= 2;
plyr->backpack = true;
}
plyr->armorpoints = idfa_armor; // Ty 03/09/98 - deh
plyr->armortype = idfa_armor_class; // Ty 03/09/98 - deh
// You can't own weapons that aren't in the game // phares 02/27/98
for (i=0;i<NUMWEAPONS;i++)
if (!(i == wp_plasma || i == wp_bfg || i == wp_supershotgun))
plyr->weaponowned[i] = true;
for (i=0;i<NUMAMMO;i++)
if (i!=am_cell)
plyr->ammo[i] = plyr->maxammo[i];
plyr->message = STSTR_FAADDED;
}
static void cheat_noclip()
{
_g_player.cheats ^= CF_NOCLIP;
if(_g_player.cheats & CF_NOCLIP)
{
_g_player.message = STSTR_NCON;
}
else
{
_g_player.message = STSTR_NCOFF;
}
}
static void cheat_invincibility()
{
P_GivePower(&_g_player, pw_invulnerability);
}
static void cheat_berserk()
{
P_GivePower(&_g_player, pw_strength);
}
static void cheat_invisibility()
{
P_GivePower(&_g_player, pw_invisibility);
}
static void cheat_rad()
{
P_GivePower(&_g_player, pw_ironfeet);
}
static void cheat_map()
{
P_GivePower(&_g_player, pw_allmap);
}
static void cheat_goggles()
{
P_GivePower(&_g_player, pw_infrared);
}
static void cheat_exit()
{
G_ExitLevel();
}
static void cheat_end()
{
_g_gameaction = ga_victory;
}
static void cheat_rockets()
{
_g_player.cheats ^= CF_ENEMY_ROCKETS;
if(_g_player.cheats & CF_ENEMY_ROCKETS)
{
_g_player.health = god_health;
_g_player.weaponowned[wp_missile] = true;
_g_player.ammo[am_misl] = _g_player.maxammo[am_misl];
_g_player.pendingweapon = wp_missile;
_g_player.message = STSTR_ROCKETON;
}
else
{
_g_player.message = STSTR_ROCKETOFF;
}
}
static void cheat_fps()
{
_g_fps_show = !_g_fps_show;
if(_g_fps_show)
{
_g_player.message = STSTR_FPSON;
}else
{
_g_player.message = STSTR_FPSOFF;
}
}