source: Daodan/MSVC/Daodan_Cheater.c@ 802

Last change on this file since 802 was 569, checked in by gumby, 14 years ago

Fixes, fixes, everywhere

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