source: Daodan/src/Patches/Cheater.c@ 1012

Last change on this file since 1012 was 1000, checked in by alloc, 11 years ago

Daodan 3.7

File size: 10.8 KB
Line 
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
13union MSVC_EVIL_FLOAT_HACK
14{
15 unsigned __int8 Bytes[4];
16 float Value;
17};
18static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
19#define DD_INFINITY (INFINITY_HACK.Value)
20
21oniCheatCode 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
92uint16_t cheat_oldshield = 0;
93int32_t cheat_oldhealth = 1;
94int32_t cheat_oldmaxhealth = 1;
95float cheat_oldjet_accel = 0.03f;
96uint16_t cheat_oldjet_timer = 20;
97float cheat_oldheight1 = 45;
98float cheat_oldheight2 = 135;
99bool inc_fallingframes = true;
100
101uint8_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 if (DDrConfig_GetOptOfType("modding.d_regen", C_BOOL)->value.intBoolVal)
256 {
257 int* Regeneration = &ONgGameState->PlayerCharacter->RegenHax;
258 if(*Regeneration)
259 {
260 *Regeneration = 0;
261 return 0;
262 }
263 else
264 {
265 *Regeneration = 1;
266 return 1;
267 }
268 }
269 else
270 {
271 return ONrCheater(cheat_elderrune);
272 }
273 }
274
275 case cheat_tellmetheversion:
276 return 1;
277 case cheat_x:
278 return ONrCheater(cheat_thedayismine);
279 default:
280 return ONrCheater(cheat);
281 }
282}
283
284void ONICALL DDrCheater_LevelLoad()
285{
286 inc_fallingframes = true;
287}
288
289// Biggest hack in the entire thing ^_^
290void __stdcall FallingFrames(void* Ebp)
291{
292 if (inc_fallingframes)
293 ++*((unsigned int*)((char*)Ebp + 0xf6));
294}
295
Note: See TracBrowser for help on using the repository browser.