1 | #include <string.h>
|
---|
2 | #include "stdint.h"
|
---|
3 | #include <math.h>
|
---|
4 |
|
---|
5 | #include "../Oni/Oni.h"
|
---|
6 |
|
---|
7 | #include "../_Version.h"
|
---|
8 |
|
---|
9 | #include "../Daodan.h"
|
---|
10 | #include "../Daodan_Config.h"
|
---|
11 | #include "Cheater.h"
|
---|
12 |
|
---|
13 | union MSVC_EVIL_FLOAT_HACK
|
---|
14 | {
|
---|
15 | unsigned __int8 Bytes[4];
|
---|
16 | float Value;
|
---|
17 | };
|
---|
18 | static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
|
---|
19 | #define DD_INFINITY (INFINITY_HACK.Value)
|
---|
20 |
|
---|
21 | oniCheatCode DDr_CheatTable[] = {
|
---|
22 | { "shapeshifter", "Change Characters Enabled", "Change Characters Disabled", cheat_shapeshifter },
|
---|
23 | { "liveforever", "Invincibility Enabled", "Invincibility Disabled", cheat_liveforever },
|
---|
24 | { "touchofdeath", "Omnipotence Enabled", "Omnipotence Disabled", cheat_touchofdeath },
|
---|
25 | { "canttouchthis", "Unstoppable Enabled", "Unstoppable Disabled", cheat_canttouchthis },
|
---|
26 | { "fatloot", "Fat Loot Received", NULL, cheat_fatloot },
|
---|
27 | { "glassworld", "Glass Furniture Enabled", "Glass Furniture Disabled", cheat_glassworld },
|
---|
28 | { "winlevel", "Instantly Win Level", NULL, cheat_winlevel },
|
---|
29 | { "loselevel", "Instantly Lose Level", NULL, cheat_loselevel },
|
---|
30 | { "bighead", "Big Head Enabled", "Big Head Disabled", cheat_bighead },
|
---|
31 | { "minime", "Mini Mode Enabled", "Mini Mode Disabled", cheat_minime },
|
---|
32 | { "superammo", "Super Ammo Mode Enabled", "Super Ammo Mode Disabled", cheat_superammo },
|
---|
33 | { "thedayismine", "Developer Access Enabled", "Developer Access Disabled", cheat_thedayismine },
|
---|
34 | { "reservoirdogs", "Last Man Standing Enabled", "Last Man Standing Disabled", cheat_reservoirdogs },
|
---|
35 | { "roughjustice", "Gatling Guns Enabled", "Gatling Guns Disabled", cheat_roughjustice },
|
---|
36 | { "chenille", "Daodan Power Enabled", "Daodan Power Disabled", cheat_chenille },
|
---|
37 | { "behemoth", "Godzilla Mode Enabled", "Godzilla Mode Disabled", cheat_behemoth },
|
---|
38 | { "elderrune", "Regeneration Enabled", "Regeneration Disabled", cheat_elderrune },
|
---|
39 | { "moonshadow", "Phase Cloak Enabled", "Phase Cloak Disabled", cheat_moonshadow },
|
---|
40 | { "munitionfrenzy", "Weapons Locker Created", NULL, cheat_munitionfrenzy },
|
---|
41 | { "fistsoflegend", "Fists Of Legend Enabled", "Fists Of Legend Disabled", cheat_fistsoflegend },
|
---|
42 | { "killmequick", "Ultra Mode Enabled", "Ultra Mode Disabled", cheat_killmequick },
|
---|
43 | { "carousel", "Slow Motion Enabled", "Slow Motion Disabled", cheat_carousel },
|
---|
44 | { "bigbadboss", "Boss Shield Enabled", "Boss Shield Disabled", cheat_bigbadboss },
|
---|
45 | { "bulletproof", "Force Field Enabled", "Force Field Disabled", cheat_bulletproof },
|
---|
46 | { "kangaroo", "Kangaroo Jump Enabled", "Kangaroo Jump Disabled", cheat_kangaroo },
|
---|
47 | { "marypoppins", "Jet Pack Mode Enabled", "Jet Pack Mode Disabled", cheat_marypoppins },
|
---|
48 | { "buddha", "Unkillable Enabled", "Unkillable Disabled", cheat_buddha },
|
---|
49 | { "shinobi", "Ninja Mode Enabled (good luck!)", "Ninja Mode Disabled", cheat_shinobi },
|
---|
50 | { "x", "Developer Access Enabled", "Developer Access Disabled", cheat_x },
|
---|
51 | { "testcheat", "Testing...", "", cheat_testcheat },
|
---|
52 | { "tellmetheversion", "Daodan v."DAODAN_VERSION_STRING"", "", cheat_tellmetheversion },
|
---|
53 | {0, 0, 0, 0}
|
---|
54 | };
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 | // Just copied all these defines from the old daodan, they were originaly from SFeLi's code.
|
---|
59 |
|
---|
60 | #define GSA_camera (0x00000080)
|
---|
61 | #define GSA_player (0x000000AC)
|
---|
62 | #define GSA_carousel (0x00000104) /* char */
|
---|
63 | #define GSA_slowmotimer (0x00000108)
|
---|
64 | #define GSA_splashscreen (0x00000118) /* char */
|
---|
65 |
|
---|
66 | #define CHR_flags (0x00000004)
|
---|
67 | #define CHR_flags2 (0x00000008)
|
---|
68 | #define CHR_oncc (0x0000000C)
|
---|
69 | #define CHR_team (0x00000012) /* short */
|
---|
70 | #define CHR_name (0x00000014) /* char[32] */
|
---|
71 | #define CHR_scalemodel (0x00000034)
|
---|
72 | #define CHR_weapon1 (0x00000194)
|
---|
73 | #define CHR_weapon2 (0x00000198)
|
---|
74 | #define CHR_weapon3 (0x0000019C)
|
---|
75 | #define CHR_shield_curr (0x000001B6) /* short */
|
---|
76 | #define CHR_shield (0x000001B8) /* short */
|
---|
77 | #define CHR_phasecloak (0x000001BA) /* short */
|
---|
78 | #define CHR_stats_kills (0x00001670)
|
---|
79 | #define CHR_stats_damage (0x00001674)
|
---|
80 |
|
---|
81 | #define ONCC_jet_accel (0x00000010) /* float */
|
---|
82 | #define ONCC_jet_timer (0x00000016) /* short */
|
---|
83 | #define ONCC_height1 (0x00000018) /* float */
|
---|
84 | #define ONCC_height2 (0x0000001C) /* float */
|
---|
85 | #define ONCC_bodysize_min (0x00000C58) /* float */
|
---|
86 | #define ONCC_bodysize_max (0x00000C8C) /* float */
|
---|
87 |
|
---|
88 | #define kangaroo_h (short)(60)
|
---|
89 | #define kangaroo_jp (float)(0.06)
|
---|
90 | #define marypoppins_jp (float)(0.14)
|
---|
91 |
|
---|
92 | uint16_t cheat_oldshield = 0;
|
---|
93 | int32_t cheat_oldhealth = 1;
|
---|
94 | int32_t cheat_oldmaxhealth = 1;
|
---|
95 | float cheat_oldjet_accel = 0.03f;
|
---|
96 | uint16_t cheat_oldjet_timer = 20;
|
---|
97 | float cheat_oldheight1 = 45;
|
---|
98 | float cheat_oldheight2 = 135;
|
---|
99 | bool inc_fallingframes = true;
|
---|
100 |
|
---|
101 | uint8_t ONICALL DDrCheater(uint32_t cheat)
|
---|
102 | {
|
---|
103 | switch (cheat)
|
---|
104 | {
|
---|
105 | case cheat_bigbadboss:
|
---|
106 | {
|
---|
107 | Character* player = ONgGameState->PlayerCharacter;
|
---|
108 | //char* player = *((char**)(ONgGameState + GSA_player));
|
---|
109 | if (player->Flags & chr_bossshield)
|
---|
110 | {
|
---|
111 | player->Flags = player->Flags & ~chr_bossshield;
|
---|
112 | return 0;
|
---|
113 | }
|
---|
114 | else
|
---|
115 | {
|
---|
116 | player->Flags = player->Flags | chr_bossshield;
|
---|
117 | return 1;
|
---|
118 | }
|
---|
119 | }
|
---|
120 | case cheat_bulletproof:
|
---|
121 | {
|
---|
122 | Character* player = ONgGameState->PlayerCharacter;
|
---|
123 | if (player->Flags & chr_weaponimmune)
|
---|
124 | {
|
---|
125 | player->Flags = player->Flags & ~chr_weaponimmune;
|
---|
126 | player->Inventory.ShieldUsed = cheat_oldshield;
|
---|
127 | return 0;
|
---|
128 | }
|
---|
129 | else
|
---|
130 | {
|
---|
131 | player->Flags |= chr_weaponimmune;
|
---|
132 | cheat_oldshield = player->Inventory.ShieldUsed;
|
---|
133 | player->Inventory.ShieldUsed = 100;
|
---|
134 | return 1;
|
---|
135 | }
|
---|
136 | }
|
---|
137 | case cheat_kangaroo:
|
---|
138 | {
|
---|
139 | Character* player = ONgGameState->PlayerCharacter;
|
---|
140 | //char* oncc = *(char**)(player + CHR_oncc);
|
---|
141 | if (!inc_fallingframes)
|
---|
142 | inc_fallingframes = true;
|
---|
143 | if (player->ONCC->JetpackTimer == kangaroo_h)
|
---|
144 | {
|
---|
145 | player->ONCC->JumpAcceleration = cheat_oldjet_accel;
|
---|
146 | player->ONCC->JetpackTimer = cheat_oldjet_timer;
|
---|
147 | player->ONCC->MaxFallingHeightWithoutDamage = cheat_oldheight1;
|
---|
148 | player->ONCC->MaxFallingHeightWithDamage = cheat_oldheight2;
|
---|
149 | return 0;
|
---|
150 | }
|
---|
151 | else if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
|
---|
152 | {
|
---|
153 | player->ONCC->JumpAcceleration = kangaroo_jp;
|
---|
154 | player->ONCC->JetpackTimer = kangaroo_h;
|
---|
155 | player->ONCC->MaxFallingHeightWithoutDamage = DD_INFINITY;
|
---|
156 | player->ONCC->MaxFallingHeightWithDamage = DD_INFINITY;
|
---|
157 | return 1;
|
---|
158 | }
|
---|
159 | else
|
---|
160 | {
|
---|
161 | cheat_oldjet_accel = player->ONCC->JumpAcceleration;
|
---|
162 | cheat_oldjet_timer = player->ONCC->JetpackTimer;
|
---|
163 | cheat_oldheight1 = player->ONCC->MaxFallingHeightWithoutDamage ;
|
---|
164 | cheat_oldheight2 = player->ONCC->MaxFallingHeightWithDamage;
|
---|
165 | player->ONCC->JumpAcceleration = kangaroo_jp;
|
---|
166 | player->ONCC->JetpackTimer = kangaroo_h;
|
---|
167 | player->ONCC->MaxFallingHeightWithoutDamage = DD_INFINITY;
|
---|
168 | player->ONCC->MaxFallingHeightWithDamage = DD_INFINITY;
|
---|
169 | return 1;
|
---|
170 | }
|
---|
171 | }
|
---|
172 | case cheat_marypoppins:
|
---|
173 | {
|
---|
174 | Character* player = ONgGameState->PlayerCharacter;
|
---|
175 | if (!inc_fallingframes)
|
---|
176 | {
|
---|
177 | inc_fallingframes = true;
|
---|
178 | if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
|
---|
179 | {
|
---|
180 | player->ONCC->JumpAcceleration = cheat_oldjet_accel;
|
---|
181 | player->ONCC->JetpackTimer = cheat_oldjet_timer;
|
---|
182 | player->ONCC->MaxFallingHeightWithoutDamage = cheat_oldheight1;
|
---|
183 | player->ONCC->MaxFallingHeightWithDamage = cheat_oldheight2;
|
---|
184 | }
|
---|
185 | return 0;
|
---|
186 | }
|
---|
187 | else if (player->ONCC->JetpackTimer == kangaroo_h)
|
---|
188 | {
|
---|
189 | player->ONCC->JumpAcceleration = marypoppins_jp;
|
---|
190 | player->ONCC->JetpackTimer = 0xFFFF;
|
---|
191 | player->ONCC->MaxFallingHeightWithoutDamage = 0x7f800000;
|
---|
192 | player->ONCC->MaxFallingHeightWithDamage = 0x7f800000;
|
---|
193 | inc_fallingframes = false;
|
---|
194 | return 1;
|
---|
195 | }
|
---|
196 | else
|
---|
197 | {
|
---|
198 | cheat_oldjet_accel = player->ONCC->JumpAcceleration;
|
---|
199 | cheat_oldjet_timer = player->ONCC->JetpackTimer;
|
---|
200 | cheat_oldheight1 = player->ONCC->MaxFallingHeightWithoutDamage;
|
---|
201 | cheat_oldheight2 = player->ONCC->MaxFallingHeightWithDamage ;
|
---|
202 | player->ONCC->JumpAcceleration = marypoppins_jp;
|
---|
203 | player->ONCC->JetpackTimer = 0xFFFF;
|
---|
204 | player->ONCC->MaxFallingHeightWithoutDamage = 0x7f800000;
|
---|
205 | player->ONCC->MaxFallingHeightWithDamage = 0x7f800000;
|
---|
206 | inc_fallingframes = false;
|
---|
207 | return 1;
|
---|
208 | }
|
---|
209 | }
|
---|
210 | case cheat_buddha:
|
---|
211 | {
|
---|
212 | Character* player = ONgGameState->PlayerCharacter;
|
---|
213 | if (player->Flags& chr_unkillable)
|
---|
214 | {
|
---|
215 | player->Flags= player->Flags& ~chr_unkillable;
|
---|
216 | return 0;
|
---|
217 | }
|
---|
218 | else
|
---|
219 | {
|
---|
220 | player->Flags= player->Flags| chr_unkillable;
|
---|
221 | return 1;
|
---|
222 | }
|
---|
223 | }
|
---|
224 | case cheat_shinobi:
|
---|
225 | {
|
---|
226 | Character* player = ONgGameState->PlayerCharacter;
|
---|
227 | if (player->MaxHealth == 1)
|
---|
228 | {
|
---|
229 | player->Health = cheat_oldhealth;
|
---|
230 | player->MaxHealth = cheat_oldmaxhealth;
|
---|
231 | player->Flags = player->Flags & ~(chr_bossshield | chr_weaponimmune);
|
---|
232 | ai2_deaf = 0;
|
---|
233 | return 0;
|
---|
234 | }
|
---|
235 | else
|
---|
236 | {
|
---|
237 | cheat_oldhealth = player->Health;
|
---|
238 | cheat_oldmaxhealth = player->MaxHealth;
|
---|
239 | player->Health = 1;
|
---|
240 | player->MaxHealth = 1;
|
---|
241 | player->Flags = player->Flags | chr_bossshield | chr_weaponimmune;
|
---|
242 | ai2_deaf = 1;
|
---|
243 | return 1;
|
---|
244 | }
|
---|
245 |
|
---|
246 | }
|
---|
247 | case cheat_testcheat:
|
---|
248 | {
|
---|
249 | Character* player = ONgGameState->PlayerCharacter;
|
---|
250 | player->Flags = player->Flags | chr_noncombatant;
|
---|
251 | return 1;
|
---|
252 | }
|
---|
253 | case cheat_elderrune:
|
---|
254 | {
|
---|
255 | ConfigOption_t* co = DDrConfig_GetOptOfType("patch.bsl", C_BOOL);
|
---|
256 | if (co->value.intBoolVal)
|
---|
257 | {
|
---|
258 | int* Regeneration = &ONgGameState->PlayerCharacter->RegenHax;
|
---|
259 | if(*Regeneration)
|
---|
260 | {
|
---|
261 | *Regeneration = 0;
|
---|
262 | return 0;
|
---|
263 | }
|
---|
264 | else
|
---|
265 | {
|
---|
266 | *Regeneration = 1;
|
---|
267 | return 1;
|
---|
268 | }
|
---|
269 | }
|
---|
270 | else
|
---|
271 | {
|
---|
272 | return ONrCheater(cheat_elderrune);
|
---|
273 | }
|
---|
274 | }
|
---|
275 |
|
---|
276 | case cheat_tellmetheversion:
|
---|
277 | return 1;
|
---|
278 | case cheat_x:
|
---|
279 | return ONrCheater(cheat_thedayismine);
|
---|
280 | default:
|
---|
281 | return ONrCheater(cheat);
|
---|
282 | }
|
---|
283 | }
|
---|
284 |
|
---|
285 | void ONICALL DDrCheater_LevelLoad()
|
---|
286 | {
|
---|
287 | inc_fallingframes = true;
|
---|
288 | }
|
---|
289 |
|
---|
290 | // Biggest hack in the entire thing ^_^
|
---|
291 | void __stdcall FallingFrames(void* Ebp)
|
---|
292 | {
|
---|
293 | if (inc_fallingframes)
|
---|
294 | ++*((unsigned int*)((char*)Ebp + 0xf6));
|
---|
295 | }
|
---|
296 |
|
---|