source: Daodan/src/Daodan_Cheater.c@ 951

Last change on this file since 951 was 837, checked in by alloc, 12 years ago

Daodan:

  • Fixes #21
  • Fixes #31
  • Prepends "Daodan: " to every daodan related output on startup.txt
File size: 10.8 KB
Line 
1#include <string.h>
2#include "stdint.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 DD_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", "Kangaroo Jump Enabled", "Kangaroo Jump Disabled", cheat_kangaroo },
45 { "marypoppins", "Jet Pack Mode Enabled", "Jet Pack Mode Disabled", cheat_marypoppins },
46 { "buddha", "Unkillable Enabled", "Unkillable Disabled", cheat_buddha },
47 { "shinobi", "Ninja Mode Enabled (good luck!)", "Ninja Mode Disabled", cheat_shinobi },
48 { "x", "Developer Access Enabled", "Developer Access Disabled", cheat_x },
49 { "testcheat", "Testing...", "", cheat_testcheat },
50 { "tellmetheversion", "Daodan v."DAODAN_VERSION_STRING"", "", cheat_tellmetheversion },
51 {0, 0, 0, 0}
52};
53
54
55
56// Just copied all these defines from the old daodan, they were originaly from SFeLi's code.
57
58#define GSA_camera (0x00000080)
59#define GSA_player (0x000000AC)
60#define GSA_carousel (0x00000104) /* char */
61#define GSA_slowmotimer (0x00000108)
62#define GSA_splashscreen (0x00000118) /* char */
63
64#define CHR_flags (0x00000004)
65#define CHR_flags2 (0x00000008)
66#define CHR_oncc (0x0000000C)
67#define CHR_team (0x00000012) /* short */
68#define CHR_name (0x00000014) /* char[32] */
69#define CHR_scalemodel (0x00000034)
70#define CHR_weapon1 (0x00000194)
71#define CHR_weapon2 (0x00000198)
72#define CHR_weapon3 (0x0000019C)
73#define CHR_shield_curr (0x000001B6) /* short */
74#define CHR_shield (0x000001B8) /* short */
75#define CHR_phasecloak (0x000001BA) /* short */
76#define CHR_stats_kills (0x00001670)
77#define CHR_stats_damage (0x00001674)
78
79#define ONCC_jet_accel (0x00000010) /* float */
80#define ONCC_jet_timer (0x00000016) /* short */
81#define ONCC_height1 (0x00000018) /* float */
82#define ONCC_height2 (0x0000001C) /* float */
83#define ONCC_bodysize_min (0x00000C58) /* float */
84#define ONCC_bodysize_max (0x00000C8C) /* float */
85
86#define kangaroo_h (short)(60)
87#define kangaroo_jp (float)(0.06)
88#define marypoppins_jp (float)(0.14)
89
90uint16_t cheat_oldshield = 0;
91int32_t cheat_oldhealth = 1;
92int32_t cheat_oldmaxhealth = 1;
93float cheat_oldjet_accel = 0.03f;
94uint16_t cheat_oldjet_timer = 20;
95float cheat_oldheight1 = 45;
96float cheat_oldheight2 = 135;
97bool inc_fallingframes = true;
98extern bool patch_bsl;
99uint8_t ONICALL DDrCheater(uint32_t cheat)
100{
101 switch (cheat)
102 {
103 case cheat_bigbadboss:
104 {
105 Character* player = ONgGameState->PlayerCharacter;
106 //char* player = *((char**)(ONgGameState + GSA_player));
107 if (player->Flags & chr_bossshield)
108 {
109 player->Flags = player->Flags & ~chr_bossshield;
110 return 0;
111 }
112 else
113 {
114 player->Flags = player->Flags | chr_bossshield;
115 return 1;
116 }
117 }
118 case cheat_bulletproof:
119 {
120 Character* player = ONgGameState->PlayerCharacter;
121 if (player->Flags & chr_weaponimmune)
122 {
123 player->Flags = player->Flags & ~chr_weaponimmune;
124 player->Inventory.ShieldUsed = cheat_oldshield;
125 return 0;
126 }
127 else
128 {
129 player->Flags |= chr_weaponimmune;
130 cheat_oldshield = player->Inventory.ShieldUsed;
131 player->Inventory.ShieldUsed = 100;
132 return 1;
133 }
134 }
135 case cheat_kangaroo:
136 {
137 Character* player = ONgGameState->PlayerCharacter;
138 //char* oncc = *(char**)(player + CHR_oncc);
139 if (!inc_fallingframes)
140 inc_fallingframes = true;
141 if (player->ONCC->JetpackTimer == kangaroo_h)
142 {
143 player->ONCC->JumpAcceleration = cheat_oldjet_accel;
144 player->ONCC->JetpackTimer = cheat_oldjet_timer;
145 player->ONCC->MaxFallingHeightWithoutDamage = cheat_oldheight1;
146 player->ONCC->MaxFallingHeightWithDamage = cheat_oldheight2;
147 return 0;
148 }
149 else if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
150 {
151 player->ONCC->JumpAcceleration = kangaroo_jp;
152 player->ONCC->JetpackTimer = kangaroo_h;
153 player->ONCC->MaxFallingHeightWithoutDamage = DD_INFINITY;
154 player->ONCC->MaxFallingHeightWithDamage = DD_INFINITY;
155 return 1;
156 }
157 else
158 {
159 cheat_oldjet_accel = player->ONCC->JumpAcceleration;
160 cheat_oldjet_timer = player->ONCC->JetpackTimer;
161 cheat_oldheight1 = player->ONCC->MaxFallingHeightWithoutDamage ;
162 cheat_oldheight2 = player->ONCC->MaxFallingHeightWithDamage;
163 player->ONCC->JumpAcceleration = kangaroo_jp;
164 player->ONCC->JetpackTimer = kangaroo_h;
165 player->ONCC->MaxFallingHeightWithoutDamage = DD_INFINITY;
166 player->ONCC->MaxFallingHeightWithDamage = DD_INFINITY;
167 return 1;
168 }
169 }
170 case cheat_marypoppins:
171 {
172 Character* player = ONgGameState->PlayerCharacter;
173 if (!inc_fallingframes)
174 {
175 inc_fallingframes = true;
176 if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
177 {
178 player->ONCC->JumpAcceleration = cheat_oldjet_accel;
179 player->ONCC->JetpackTimer = cheat_oldjet_timer;
180 player->ONCC->MaxFallingHeightWithoutDamage = cheat_oldheight1;
181 player->ONCC->MaxFallingHeightWithDamage = cheat_oldheight2;
182 }
183 return 0;
184 }
185 else if (player->ONCC->JetpackTimer == kangaroo_h)
186 {
187 player->ONCC->JumpAcceleration = marypoppins_jp;
188 player->ONCC->JetpackTimer = 0xFFFF;
189 player->ONCC->MaxFallingHeightWithoutDamage = 0x7f800000;
190 player->ONCC->MaxFallingHeightWithDamage = 0x7f800000;
191 inc_fallingframes = false;
192 return 1;
193 }
194 else
195 {
196 cheat_oldjet_accel = player->ONCC->JumpAcceleration;
197 cheat_oldjet_timer = player->ONCC->JetpackTimer;
198 cheat_oldheight1 = player->ONCC->MaxFallingHeightWithoutDamage;
199 cheat_oldheight2 = player->ONCC->MaxFallingHeightWithDamage ;
200 player->ONCC->JumpAcceleration = marypoppins_jp;
201 player->ONCC->JetpackTimer = 0xFFFF;
202 player->ONCC->MaxFallingHeightWithoutDamage = 0x7f800000;
203 player->ONCC->MaxFallingHeightWithDamage = 0x7f800000;
204 inc_fallingframes = false;
205 return 1;
206 }
207 }
208 case cheat_buddha:
209 {
210 Character* player = ONgGameState->PlayerCharacter;
211 if (player->Flags& chr_unkillable)
212 {
213 player->Flags= player->Flags& ~chr_unkillable;
214 return 0;
215 }
216 else
217 {
218 player->Flags= player->Flags| chr_unkillable;
219 return 1;
220 }
221 }
222 case cheat_shinobi:
223 {
224 Character* player = ONgGameState->PlayerCharacter;
225 if (player->MaxHealth == 1)
226 {
227 player->Health = cheat_oldhealth;
228 player->MaxHealth = cheat_oldmaxhealth;
229 player->Flags = player->Flags & ~(chr_bossshield | chr_weaponimmune);
230 ai2_deaf = 0;
231 return 0;
232 }
233 else
234 {
235 cheat_oldhealth = player->Health;
236 cheat_oldmaxhealth = player->MaxHealth;
237 player->Health = 1;
238 player->MaxHealth = 1;
239 player->Flags = player->Flags | chr_bossshield | chr_weaponimmune;
240 ai2_deaf = 1;
241 return 1;
242 }
243
244 }
245 case cheat_testcheat:
246 {
247 Character* player = ONgGameState->PlayerCharacter;
248 player->Flags = player->Flags | chr_noncombatant;
249 return 1;
250 }
251 case cheat_elderrune:
252 {
253 if(patch_bsl) {
254 int* Regeneration = &ONgGameState->PlayerCharacter->RegenHax;
255 if(*Regeneration)
256 {
257 *Regeneration = 0;
258 return 0;
259 }
260 else
261 {
262 *Regeneration = 1;
263 return 1;
264 }
265 }
266 else
267 {
268 return ONrCheater(cheat_elderrune);
269 }
270 }
271
272 case cheat_tellmetheversion:
273 return 1;
274 case cheat_x:
275 return ONrCheater(cheat_thedayismine);
276 default:
277 return ONrCheater(cheat);
278 }
279}
280
281void ONICALL DDrCheater_LevelLoad()
282{
283 inc_fallingframes = true;
284}
285
286// Biggest hack in the entire thing ^_^
287void __stdcall FallingFrames(void* Ebp)
288{
289 if (inc_fallingframes)
290 ++*((unsigned int*)((char*)Ebp + 0xf6));
291}
292
Note: See TracBrowser for help on using the repository browser.