source: Daodan/src/Daodan_Cheater.c@ 822

Last change on this file since 822 was 692, checked in by alloc, 12 years ago

Daodan: Lots of cleanups (mostly unnecessary includes removed, empty files deleted, case of filenames corrected)

File size: 10.9 KB
RevLine 
[339]1#include <string.h>
[692]2#include "stdint.h"
[677]3#include <math.h>
[452]4#include "Oni.h"
[453]5#include "Oni_Character.h"
[452]6
[685]7#include "_Version.h"
8
[452]9#include "Daodan.h"
[339]10#include "Daodan_Cheater.h"
[677]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}};
[689]17#define DD_INFINITY (INFINITY_HACK.Value)
[339]18
19oniCheatCode DDr_CheatTable[] = {
[474]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 },
[685]51 { "tellmetheversion", "Daodan v."DAODAN_VERSION_STRING"", "", cheat_tellmetheversion },
[689]52 {0, 0, 0, 0}
[339]53};
[452]54
[476]55
56
[453]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
[677]87#define kangaroo_h (short)(60)
88#define kangaroo_jp (float)(0.06)
89#define marypoppins_jp (float)(0.14)
[455]90
[453]91uint16_t cheat_oldshield = 0;
[471]92int32_t cheat_oldhealth = 1;
93int32_t cheat_oldmaxhealth = 1;
[455]94float cheat_oldjet_accel = 0.03f;
95uint16_t cheat_oldjet_timer = 20;
96float cheat_oldheight1 = 45;
97float cheat_oldheight2 = 135;
98bool inc_fallingframes = true;
[677]99extern bool patch_bsl;
[452]100uint8_t ONICALL DDrCheater(uint32_t cheat)
101{
102 switch (cheat)
103 {
[453]104 case cheat_bigbadboss:
105 {
[677]106 Character* player = ONgGameState->PlayerCharacter;
107 //char* player = *((char**)(ONgGameState + GSA_player));
108 if (player->Flags & chr_bossshield)
[453]109 {
[677]110 player->Flags = player->Flags & ~chr_bossshield;
[453]111 return 0;
112 }
113 else
114 {
[677]115 player->Flags = player->Flags | chr_bossshield;
[453]116 return 1;
117 }
118 }
119 case cheat_bulletproof:
120 {
[677]121 Character* player = ONgGameState->PlayerCharacter;
122 if (player->Flags & chr_weaponimmune)
[453]123 {
[677]124 player->Flags = player->Flags & ~chr_weaponimmune;
125 player->Inventory.ShieldUsed = cheat_oldshield;
[453]126 return 0;
127 }
128 else
129 {
[677]130 player->Flags |= chr_weaponimmune;
131 cheat_oldshield = player->Inventory.ShieldUsed;
132 player->Inventory.ShieldUsed = 100;
[453]133 return 1;
134 }
135 }
[455]136 case cheat_kangaroo:
137 {
[677]138 Character* player = ONgGameState->PlayerCharacter;
139 //char* oncc = *(char**)(player + CHR_oncc);
[455]140 if (!inc_fallingframes)
141 inc_fallingframes = true;
[677]142 if (player->ONCC->JetpackTimer == kangaroo_h)
[455]143 {
[677]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;
[455]148 return 0;
149 }
[689]150 else if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
[455]151 {
[677]152 player->ONCC->JumpAcceleration = kangaroo_jp;
153 player->ONCC->JetpackTimer = kangaroo_h;
[689]154 player->ONCC->MaxFallingHeightWithoutDamage = DD_INFINITY;
155 player->ONCC->MaxFallingHeightWithDamage = DD_INFINITY;
[455]156 return 1;
157 }
158 else
159 {
[677]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;
[689]166 player->ONCC->MaxFallingHeightWithoutDamage = DD_INFINITY;
167 player->ONCC->MaxFallingHeightWithDamage = DD_INFINITY;
[455]168 return 1;
169 }
170 }
171 case cheat_marypoppins:
172 {
[677]173 Character* player = ONgGameState->PlayerCharacter;
[455]174 if (!inc_fallingframes)
175 {
176 inc_fallingframes = true;
[689]177 if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
[455]178 {
[677]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;
[455]183 }
184 return 0;
185 }
[677]186 else if (player->ONCC->JetpackTimer == kangaroo_h)
[455]187 {
[677]188 player->ONCC->JumpAcceleration = marypoppins_jp;
189 player->ONCC->JetpackTimer = 0xFFFF;
190 player->ONCC->MaxFallingHeightWithoutDamage = 0x7f800000;
191 player->ONCC->MaxFallingHeightWithDamage = 0x7f800000;
[455]192 inc_fallingframes = false;
193 return 1;
194 }
195 else
196 {
[677]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;
[455]205 inc_fallingframes = false;
206 return 1;
207 }
208 }
[453]209 case cheat_buddha:
210 {
[677]211 Character* player = ONgGameState->PlayerCharacter;
212 if (player->Flags& chr_unkillable)
[453]213 {
[677]214 player->Flags= player->Flags& ~chr_unkillable;
[453]215 return 0;
216 }
217 else
218 {
[677]219 player->Flags= player->Flags| chr_unkillable;
[453]220 return 1;
221 }
222 }
223 case cheat_shinobi:
224 {
[677]225 Character* player = ONgGameState->PlayerCharacter;
[453]226 if (player->MaxHealth == 1)
227 {
228 player->Health = cheat_oldhealth;
229 player->MaxHealth = cheat_oldmaxhealth;
[454]230 player->Flags = player->Flags & ~(chr_bossshield | chr_weaponimmune);
[473]231 ai2_deaf = 0;
[453]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;
[454]240 player->Flags = player->Flags | chr_bossshield | chr_weaponimmune;
[473]241 ai2_deaf = 1;
[453]242 return 1;
243 }
244
245 }
246 case cheat_testcheat:
247 {
[677]248 Character* player = ONgGameState->PlayerCharacter;
249 player->Flags = player->Flags | chr_noncombatant;
[453]250 return 1;
251 }
[677]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
[471]273 case cheat_tellmetheversion:
274 return 1;
[452]275 case cheat_x:
276 return ONrCheater(cheat_thedayismine);
277 default:
278 return ONrCheater(cheat);
279 }
280}
[455]281
282void ONICALL DDrCheater_LevelLoad()
283{
284 inc_fallingframes = true;
285}
286
[474]287// Biggest hack in the entire thing ^_^
[677]288void __stdcall FallingFrames(void* Ebp)
[455]289{
290 if (inc_fallingframes)
[677]291 ++*((unsigned int*)((char*)Ebp + 0xf6));
[455]292}
[685]293
Note: See TracBrowser for help on using the repository browser.