source: Daodan/src/Daodan_Cheater.c@ 687

Last change on this file since 687 was 685, checked in by alloc, 12 years ago

Daodan: Version information

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