Advertisement
Benji23245

Untitled

May 3rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 115.99 KB | None | 0 0
  1. // Basics-Shadow.cpp : Defines the exported functions for the DLL application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "SADXModLoader.h"
  6. #include <cstdlib>
  7. //#include "Sonic&KnuxToShadowModel.h"
  8. #include "Models_Header_Shadow.h"
  9.  
  10.  
  11.  
  12. //To make the Chaos Spear model
  13. //WriteJump((void*)4C39A0/*address_of_missile_display_function*/, DisplayChaosSpear);
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. PVMEntry SonicTextures[] = {
  24. { "SHA_SONIC", (TexList *)0x91CB58 },
  25. { "SHA_SON_EFF", (TexList *)0x927CB8 },
  26. { "SHA_KNUCKLES", (TexList *)0x91BD20 },
  27. { "SHA_KNU_EFF", (TexList *)0x91BD28 },
  28. { "E102BEAM", (TexList *)0x91C568 },
  29. { "E102EFFECT", (TexList *)0x91C570 },
  30. { "SHA_E102TIME", (TexList *)0x91D5E0 },
  31. { "E102HIT", (TexList *)0x91D15C },
  32. { "SUPERSONIC", (NJS_TEXLIST*)0x142272C },
  33. { 0 }
  34. };
  35.  
  36. PVMEntry KnucklesTextures[] = {
  37. { "SHA_SONIC", (TexList *)0x91CB58 },
  38. { "SHA_SON_EFF", (TexList *)0x927CB8 },
  39. { "SHA_KNUCKLES", (TexList *)0x91BD20 },
  40. { "SHA_KNU_EFF", (TexList *)0x91BD28 },
  41. { "E102BEAM", (TexList *)0x91C568 },
  42. { "E102EFFECT", (TexList *)0x91C570 },
  43. { "SHA_E102TIME", (TexList *)0x91D5E0 },
  44. { "E102HIT", (TexList *)0x91D15C },
  45. { "SUPERSONIC", (NJS_TEXLIST*)0x142272C },
  46. { 0 }
  47. };
  48.  
  49.  
  50. DataPointer(short, word_3C53606, 0x3C53606);
  51. DataPointer(short, word_3C53616, 0x3C53616);
  52. DataPointer(short, word_3C53626, 0x3C53626);
  53. DataPointer(short, Y_gravity, 0x3B0F0FC);
  54. DataPointer(char, Sonic_LightSpeedShoesObtained, 0x3B18895);
  55. DataPointer(char, Sonic_CrystalRingObtained, 0x3B18896);
  56. DataPointer(char, Sonic_AncientLightObtained, 0x3B188A7);
  57. DataPointer(char, Gamma_JetBoosterObtained, 0x3B18991);
  58. DataPointer(char, Gamma_LaserBlasterObtained, 0x3B18992);
  59. DataPointer(int, CurrentMusic, 0x0912698);
  60.  
  61.  
  62. FunctionPointer(void, sub_43EC90, (EntityData1 *a1, NJS_VECTOR *a2), 0x43EC90);
  63. FastcallFunctionPointer(float, sub_788D40, (NJS_VECTOR *a1, NJS_LINE *a2, NJS_VECTOR *a3), 0x788D40);
  64. FunctionPointer(signed int, sub_438410, (NJS_VECTOR *a1, NJS_VECTOR *a2, NJS_VECTOR *a3), 0x438410);
  65. FunctionPointer(void, sub_442360, (EntityData1 *a1), 0x442360);
  66.  
  67. //Chaos Spear stuff
  68. #pragma pack(push, 8)
  69. struct GammaShootingThing
  70. {
  71. char AimAction;
  72. char ShootAction;
  73. char gap2[14];
  74. __int16 AimTimer;
  75. __int16 field_12;
  76. char gap14[28];
  77. ObjectMaster *TargetedObject;
  78. NJS_VECTOR LaserPosition;
  79. NJS_VECTOR LaserDirection;
  80. float field_4C;
  81. float field_50;
  82. NJS_VECTOR GunPosition;
  83. NJS_VECTOR GunDirection;
  84. ObjectMaster *TargetThing;
  85. float field_70;
  86. char gap74[16];
  87. float SightAnimFrame;
  88. char gap88[12];
  89. NJS_VECTOR field_94;
  90. NJS_VECTOR field_A0;
  91. char gapAC[407];
  92. char placeholder;
  93. };
  94. #pragma pack(pop)
  95.  
  96.  
  97. //////////////For Chaos Spear Model
  98. ////////////void __cdecl DisplayChaosSpear(ObjectMaster *a1)
  99. ////////////{
  100. //////////// EntityData1 *v1 = a1->Data1;
  101. //////////// EntityData2 *v2 = a1->Data2;
  102. //////////// if (!MissedFrames)
  103. //////////// {
  104. //////////// //njSetTexture(&some_texlist);
  105. //////////// njPushMatrix(nullptr);
  106. //////////// njTranslateV(nullptr, &v1->Position);
  107. //////////// njRotateY(nullptr, 0x8000 - (int)(atan2(v2->VelocityDirection.z, v2->VelocityDirection.x) * 65536.0 * 0.1591549762031479));
  108. //////////// double v24 = v2->VelocityDirection.z;
  109. //////////// double v25 = v2->VelocityDirection.x;
  110. //////////// double v26 = v24 * v24 + v25 * v25;
  111. //////////// double v27 = squareroot(v26);
  112. //////////// njRotateZ(nullptr, (int)(atan2(v2->VelocityDirection.y, v27) * 65536.0 * -0.1591549762031479));
  113. //////////// //ProcessModelNode_B(&chaos_spear_model, 1);
  114. //////////// ClampGlobalColorThing_Thing();
  115. //////////// njPopMatrix(1u);
  116. //////////// }
  117. ////////////}
  118.  
  119. //To Fix Shadow's Arms crossed anim
  120. void Sonic_GroundAnim_ri(EntityData1 *a1, CharObj2 *a2)
  121. {
  122. __int16 v2; // ax
  123. int v3; // eax
  124. signed int v4; // eax
  125. float v5; // ecx
  126. float v6; // edx
  127. float v7; // [esp+0h] [ebp-40h]
  128. NJS_VECTOR a2a; // [esp+4h] [ebp-3Ch]
  129. NJS_VECTOR a3; // [esp+10h] [ebp-30h]
  130. NJS_VECTOR a1a; // [esp+1Ch] [ebp-24h]
  131. NJS_LINE v11; // [esp+28h] [ebp-18h]
  132.  
  133. if (a2->AnimationThing.Index != 29)
  134. {
  135. v7 = -njInnerProduct(&Gravity, &a2->SurfaceNormal);
  136. if (njCos(4551) >= (double)v7 || MetalSonicFlag)
  137. {
  138. v3 = a2->SurfaceFlags;
  139. if (!(v3 & 0x4000) && njCos(0x2000) < (double)v7)
  140. {
  141. v5 = a2->SurfaceNormal.y;
  142. v6 = a2->SurfaceNormal.z;
  143. v11.vx = a2->SurfaceNormal.x;
  144. v11.vy = v5;
  145. v11.vz = v6;
  146. v11.pz = 0.0;
  147. v11.py = 0.0;
  148. v11.px = 0.0;
  149. a2a.x = 1.0;
  150. a2a.z = 0.0;
  151. a2a.y = 0.0;
  152. sub_43EC90(a1, &a2a);
  153. sub_788D40(&a2a, &v11, &a1a);
  154. njUnitVector(&a1a);
  155. sub_788D40(&Gravity, &v11, &a3);
  156. njUnitVector(&a3);
  157. v4 = sub_438410(&a1a, &a3, &a2->SurfaceNormal);
  158. if (v4 <= 49152 && v4 >= 0x4000)
  159. {
  160. ++a2->IdleTime;
  161. a2->AnimationThing.Index = 7;
  162. return;
  163. }
  164. a2->AnimationThing.Index = 8;
  165. }
  166. }
  167. else
  168. {
  169. v2 = a2->AnimationThing.Index;
  170. if (v2 && v2 != 1 && v2 != 2 && v2 != 3 && v2 != 4 && v2 != 5 && v2 != 6 && v2 != 131 && v2 != 132)
  171. {
  172. ++a2->IdleTime;
  173. a2->AnimationThing.Index = 0;
  174. return;
  175. }
  176. if (a2->IdleTime > 1800)
  177. {
  178. a2->IdleTime = 0;
  179. a2->AnimationThing.Index = 4;
  180. sub_442360(a1);
  181. ++a2->IdleTime;
  182. return;
  183. }
  184. }
  185. ++a2->IdleTime;
  186. }
  187. }
  188. static void __declspec(naked) Sonic_GroundAnim_r()
  189. {
  190. __asm
  191. {
  192. push esi // a2
  193. push ebx // a1
  194.  
  195. // Call your __cdecl function here:
  196. call Sonic_GroundAnim_ri
  197.  
  198. pop ebx // a1
  199. pop esi // a2
  200. retn
  201. }
  202. }
  203.  
  204.  
  205. extern "C"
  206. {
  207. //__declspec(dllexport) PointerList Pointers = { arrayptrandlengthT(pointers, int) };
  208.  
  209. __declspec(dllexport) ModInfo SADXModInfo = { ModLoaderVer };
  210.  
  211.  
  212. /////////////////////////////////////////////////////////////////// OnFrame variables //////////////////////////////////////////////////////////////////////////////////////////
  213.  
  214.  
  215. bool r = false;
  216. bool fall_after_roll = false;
  217. bool homing = false;
  218. bool just_homing_attacked = false;
  219. bool in_air_after_homing = false;
  220. bool dashing = false;
  221. bool no_longer_dashing = false;
  222. bool was_on_trampoline = false;
  223. bool was_invincible_before = false;
  224. bool LightDash_SuperDash_ON = false;
  225. bool just_flipped = false;
  226. bool just_spindashed = false;
  227. bool no_light_attack = false;
  228. bool Z_was_pressed_on_ground = false;
  229. bool Z_was_pressed_in_air = false;
  230. bool air_boost_used = false;
  231. bool was_on_ground = false;
  232. bool stomp_was_used = false;
  233. bool just_rolled = false;
  234. bool LSA_launch = false;
  235. bool LSA_used = false;
  236. bool ok = false;
  237. bool LD_fix = false;
  238. bool GO_sound_played = false;
  239. bool cant_punch_now = false;
  240. bool can_go_back_to_shadow = false;
  241. bool X_is_held = false;
  242. bool didnt_target = false;
  243. bool ready = false;
  244. bool is_paused = false;
  245. bool cant_chaos_spear = false;
  246. bool cant_chaos_spear2 = false;
  247. bool is_CB = false;
  248. bool X_was_pressed = false;
  249. bool cant_chaos_spear_again = false;
  250. bool pressed_X_while_Gamma = false;
  251. bool DO_chaos_spear_again = false;
  252. bool cant_spindash = false;
  253. bool CS_launch_was_played = false;
  254. bool CS_charging_was_played = false;
  255. bool CS_empty_was_played = false;
  256. bool is_in_CS_state = false;
  257. bool X_was_released = false;
  258. bool has_homing_attacked = false;
  259. bool CB_lv1 = false;
  260. bool CB_lv2 = false;
  261. bool CB_lv3 = false;
  262. bool CB_active = false;
  263. bool using_chaos_blast = false;
  264. bool transforming_CB = false;
  265. bool CHAOSBLAST_was_played = false;
  266. bool go_back_to_gameplay = false;
  267. bool LV1_active = false;
  268. bool LV2_active = false;
  269. bool LV3_active = false;
  270. bool do_multi_punch = false;
  271. bool is_shadow = true; //MEANT FOR ALL TOGETHER MOD
  272.  
  273. char balldata[] = { 0xBD, 0x20, 0, 0, 0 };
  274. char HangTimeCheckData[] = { 0x3B, 0x90, 0x9C, 0, 0, 0 };
  275. char LightDash_unNOP[] = { 0xC6, 0x06, 0x06, 0x33, 0xD2 };
  276. //char LightDashSpeed_unNOP[] = { 0xC7, 0x47, 0x38, 0, 0, 0, 0 }; //this controls the "NoRing LightDash" speed
  277. //char LightDashAnim_unNOP[] = { 0x66, 0xC7, 0x87, 0x24, 0x1, 0, 0, 0x40, 0 };
  278. char StompAnim[] = { 0x66, 0xC7, 0x87, 0x24, 0x01, 0, 0, 0x40, 0 };
  279. char TrailData[] = { 0x66, 0x09, 0x5D, 0x04 };
  280. char WalkOnWaterData[] = { 0xF, 0x85, 0xCF, 0, 0, 0 };
  281. char spindashdata[] = { 0xC6, 0x7, 0x4, };
  282. char SuperSplashData[] = { 0x8B, 0x43, 0x74, 0x85, 0xC0 };
  283. char jumpdashspeed1[] = { 0xC7, 0x47, 0x38, 0, 0, 0xE0, 0x40 };
  284. char jumpdashspeed1_orig[] = { 0xC7, 0x47, 0x38, 0, 0, 0xA0, 0x40 };
  285. char jumpdashspeed2[] = { 0xC7, 0x47, 0x38, 0, 0, 0xE0, 0x40 };
  286. char jumpdashspeed2_orig[] = { 0xC7, 0x47, 0x38, 0, 0, 0xA0, 0x40 };
  287. char knuxattackdata[] = { 0x66, 0x89, 0xB2, 0x24, 0x01, 0, 0 };
  288. char knuxobjectcrash_NOP[] = { 0xB8, 0, 0, 0, 0 };
  289. char knuxobjectcrash_unNOP[] = { 0xE8, 0x7B, 0x0F, 0xF9, 0xFF };
  290. char jump_cancel_unNOP[] = { 0xC6, 0x06, 0x0C };
  291. char LSA_sound[] = { 0xE8, 0xDE, 0x0C, 0xF9, 0xFF };
  292. char LightDashTrail_unNOP[] = { 0xE8, 0x15, 0x91, 0xFF, 0xFF };
  293. char LD_forced_out_speed[] = { 0xC7, 0x43, 0x38, 0, 0, 0x80, 0x40 };
  294. char shadow3rdpunchspeed[] = { 0xC7, 0x47, 0x38, 0, 0, 0x00, 0x41 };
  295. char enable_aiming[] = { 0x0F, 0xBE, 0x06 };
  296. char enable_shooting[] = { 0xC6, 0x46, 0x01, 0x03 };
  297. char shooting05_unNOP[] = { 0xC6, 0x46, 0x01, 0x05 };
  298. char enable_GAMMAflashing[] = { 0x66, 0x89, 0x43, 0x06 };
  299. char enable_SONIC_KNUXflashing[] = { 0x66, 0x89, 0x45, 0x06 };
  300. char supersonic_homingspeed[] = { 0xC7, 0x47, 0x38, 0, 0, 0xE0, 0x40 };
  301. char CB_LV1_stuff1[] = { 0xC6, 0x45, 0, 0x0C };
  302. char CB_LV1_stuff2[] = { 0x80, 0x65, 0x05, 0xFA };
  303. char CB_LV1_stuff3[] = { 0xD9, 0x5F, 0x38 };
  304. char gravity_orig_hovering[] = { 0x89, 0x90, 0x14, 0x01, 0, 0 };
  305. char gravity_underwater_orig_hovering[] = { 0xD9, 0x98, 0x14, 0x01, 0, 0 };
  306.  
  307. ObjectMaster *auraobj = nullptr;
  308. ObjectMaster *trailobj = nullptr;
  309. CollisionInfo *oldcol = nullptr; //character change stuff
  310.  
  311. float ChaosBoostLv1 = 7.0f;
  312. float UN_ChaosBoostLv1 = 5.0f;
  313. float SuperDash = 8.0f;
  314. float SuperTornado = 16.0f;
  315. float LightDash_SuperDash = -100.0f;
  316. float Boost_SuperTornado = -100.0f;
  317. float LightAttackStatic = 0.0f;
  318. float LightAttackMoving = 10.0f;
  319. float SuperLightAttackMoving = 16.0f;
  320. float CBHomingAttackStatic = 0.0f;
  321. float CBHomingAttackMoving = 7.0f;
  322. float missilespeed = 10.0f;
  323. float missilespeed_orig = 5.0f;
  324. float LDringdist = 0.0f;
  325. float old_X_position;
  326. float old_Y_position;
  327. float old_Z_position;
  328.  
  329. int LightAttackTimer = 0;
  330. int CBHomingAttackTimer = 0;
  331. int HangTimeLikeHeroes = 0;
  332. int OldEnemyBonus;
  333. int SpeedShoesCount = 0;
  334. int HomingSounds[]{ 762, 777, 778, 779 };
  335. int BoostSFX[]{ 780, 781 };
  336. int BoostVoices[]{ 770, 773, 776 };
  337. int FOV = 70;
  338. int SonicTrick3Timer1 = 0;
  339. int SonicTrick3Timer2 = 0;
  340. int ShadowTrick1Timer1 = 0;
  341. int ShadowTrick1Timer2 = 0;
  342. int ShadowTrick2Timer1 = 0;
  343. int ShadowTrick2Timer2 = 0;
  344. int ShadowTrick3Timer1 = 0;
  345. int ShadowTrick3Timer2 = 0;
  346. int SpindashNOPingTimer = 0;
  347. int homing_reattack_timer = 0;
  348. int punchattack = 0;
  349. int justrolled = 0;
  350. int no_longer_punching = 0;
  351. int punching = 0;
  352. int backtoshadow1 = 0;
  353. int backtoshadow2 = 0;
  354. int NOP_forced_out_speed = 0;
  355. int LD_punch = 0;
  356. int no_z_speed = 0;
  357. int chaos_spear_stop = 0;
  358. //int X_was_released = 0;
  359. int paused = 0;
  360. int stop_supersonic = 0;
  361. int didnt_target_OK = 0;
  362. int can_chaos_spear_again = 0;
  363. int gonna_chaos_spear_again = 0;
  364. int X_gonna_be_unheld = 0;
  365. //int Gauge = 0;
  366. int transforming_CB_time = 0;
  367. int chaos_blast_active_timer = 0;
  368. int X_was_released_int = 0;
  369. int cant_release_X = 0;
  370. int anim_84_was_played = 0;
  371. int can_multi_punch = 0;
  372.  
  373. ObjectFunc(sub_441D50, 0x441D50);
  374. void SetSpeedShoes(ObjectMaster *obj)
  375. {
  376. SpeedShoesCount++;
  377. sub_441D50(obj);
  378. }
  379.  
  380. ObjectFunc(sub_441D10, 0x441D10);
  381. void UnsetSpeedShoes(ObjectMaster *obj)
  382. {
  383. if (SpeedShoesCount > 0)
  384. SpeedShoesCount--;
  385. sub_441D10(obj);
  386. }
  387.  
  388. void SetInvincible(ObjectMaster *obj)
  389. {
  390. was_invincible_before = true;
  391. RunObjectChildren(obj);
  392. }
  393.  
  394. void UnsetInvincible(ObjectMaster *obj)
  395. {
  396. was_invincible_before = false;
  397. CheckThingButThenDeleteObject(obj);
  398. }
  399.  
  400. void PlayHomingSound() { PlaySound(HomingSounds[rand() % 4], 0, 0, 0); }
  401.  
  402.  
  403. //Ingame Model Swap Stuff **** MEANT TO GO INTO THE BIG MOD (that's what "is_shadow = true" is for)
  404. void sub_494400_r(int a1, CharObj2 *a2)
  405. {
  406. if (is_shadow)
  407. {
  408. NJS_ACTION *v4 = a2->AnimationThing.AnimData[a1].Animation;
  409. NJS_OBJECT *v3 = v4->object;
  410. if (v3 == *SONIC_OBJECTS)
  411. njAction_QueueObject(&object_0056AF50, v4->motion, a2->AnimationThing.Frame);
  412. else if (v3 == SONIC_OBJECTS[66])
  413. njAction_QueueObject(&object_005729CC, v4->motion, a2->AnimationThing.Frame);
  414. else
  415. njAction(v4, a2->AnimationThing.Frame);
  416. }
  417. else if (MetalSonicFlag)
  418. {
  419. NJS_ACTION *v4 = a2->AnimationThing.AnimData[a1].Animation;
  420. NJS_OBJECT *v3 = v4->object;
  421. if (v3 == *SONIC_OBJECTS)
  422. {
  423. if (v4 == *SONIC_ACTIONS)
  424. {
  425. njSetTexture(&METALSONIC_TEXLIST);
  426. njAction_QueueObject(SONIC_OBJECTS[68], SONIC_MOTIONS[1], a2->AnimationThing.Frame);
  427. }
  428. else
  429. {
  430. njSetTexture(&METALSONIC_TEXLIST);
  431. njAction_QueueObject(SONIC_OBJECTS[68], v4->motion, a2->AnimationThing.Frame);
  432. }
  433. }
  434. else if (v3 == SONIC_OBJECTS[66])
  435. {
  436. njSetTexture(&METALSONIC_TEXLIST);
  437. njAction_QueueObject(SONIC_OBJECTS[69], v4->motion, a2->AnimationThing.Frame);
  438. }
  439. else if (v3 == SONIC_OBJECTS[67])
  440. {
  441. njSetTexture(&METALSONIC_TEXLIST);
  442. njAction_QueueObject(SONIC_OBJECTS[70], v4->motion, a2->AnimationThing.Frame);
  443. }
  444. else
  445. njAction(v4, a2->AnimationThing.Frame);
  446. }
  447. else if (*(int*)0x3ABD9CC)
  448. {
  449. DrawQueueDepthBias = -5952.0;
  450. njAction_Queue(a2->AnimationThing.AnimData[a1].Animation, a2->AnimationThing.Frame, QueuedModelFlagsB_EnableZWrite);
  451. DrawQueueDepthBias = 0.0;
  452. }
  453. else
  454. njAction(a2->AnimationThing.AnimData[a1].Animation, a2->AnimationThing.Frame);
  455. }
  456.  
  457. static void __declspec(naked) sub_494400()
  458. {
  459. __asm
  460. {
  461. push esi // a2
  462. push eax // a1
  463.  
  464. // Call your __cdecl function here:
  465. call sub_494400_r
  466.  
  467. pop eax // a1
  468. pop esi // a2
  469. retn
  470. }
  471. }
  472.  
  473.  
  474. ///////////////////////////////////////////////////////////////////////// INIT FUNCTION ///////////////////////////////////////////////////////////////////////////////////////
  475.  
  476.  
  477. __declspec(dllexport) void Init(const char *path, const HelperFunctions &helperFunctions)
  478. {
  479. WriteCall((void*)0x494BE7, PlayHomingSound);
  480. WriteCall((void*)0x4BA525, SetInvincible);
  481. WriteCall((void*)0x4BA537, UnsetInvincible);
  482. WriteData((void(**)(ObjectMaster*))0x441E10, &SetSpeedShoes);
  483. WriteData((void(**)(ObjectMaster*))0x441DEA, &UnsetSpeedShoes);
  484. WriteData((void*)0x4A1413, 0x90u, 4); //Trail stuff
  485. WriteData((void*)0x55E95C, 0x90u, 6);//Shadow can animate the SuperAura
  486. //WriteData((void*)0x610113, 0x90, 3);
  487. //ResizeTextureList((NJS_TEXLIST *)0x2592E8C, 201); //For R101
  488. ResizeTextureList((NJS_TEXLIST *)0x91BD20, 20);//KNUCKLES.PVM
  489.  
  490.  
  491.  
  492.  
  493.  
  494. //Disable Sonic Morphs
  495. WriteData((void*)0x493711, 0x90, 3);
  496. WriteData((void*)0x49356D, 0x90, 3);
  497. WriteData((void*)0x4935E3, 0x90, 3);
  498. WriteData((void*)0x493722, 0x90, 3);
  499. WriteData((void*)0x4936EA, 0x90, 3);
  500. WriteData((void*)0x493657, 0x90, 3);
  501. WriteData((void*)0x4936CD, 0x90, 3);
  502. WriteData((void*)0x493C5D, 0x90, 3);
  503. WriteData((void*)0x4937A1, 0x90, 3);
  504.  
  505. //Disable Knuckles Morphs
  506. WriteData((void*)0x473FB2, 0x90, 3);
  507. WriteData((void*)0x473CC1, 0x90, 3);
  508. WriteData((void*)0x473FC7, 0x90, 3);
  509. WriteData((void*)0x473CD5, 0x90, 3);
  510. WriteData((void*)0x4726D3, 0x90, 3);
  511. WriteData((void*)0x4726EA, 0x90, 3);
  512. WriteData((void*)0x472701, 0x90, 3);
  513. WriteData((void*)0x472719, 0x90, 3);
  514. WriteData((void*)0x472730, 0x90, 3);
  515. WriteData((void*)0x472747, 0x90, 3);
  516. WriteData((void*)0x47275F, 0x90, 3);
  517. WriteData((void*)0x472776, 0x90, 3);
  518. WriteData((void*)0x472B4A, 0x90, 3);
  519. WriteData((void*)0x472B61, 0x90, 3);
  520. WriteData((void*)0x472B78, 0x90, 3);
  521. WriteData((void*)0x472B90, 0x90, 3);
  522. WriteData((void*)0x472BA7, 0x90, 3);
  523. WriteData((void*)0x472BBE, 0x90, 3);
  524. WriteData((void*)0x472BD6, 0x90, 3);
  525. WriteData((void*)0x472BED, 0x90, 3);
  526.  
  527.  
  528. PhysicsArray[Characters_Sonic].MaxAccel = 4.25;
  529. PhysicsArray[Characters_Sonic].field_68 = -0.425;
  530.  
  531.  
  532. HMODULE hmodule = GetModuleHandle(L"CHRMODELS_orig");
  533. NJS_OBJECT **___SONIC_OBJECTS = (NJS_OBJECT **)GetProcAddress(hmodule, "___SONIC_OBJECTS");
  534.  
  535.  
  536. //To get the right anim without the weird crashes...
  537. //HMODULE handle = GetModuleHandle(L"CHRMODELS_orig");
  538. //NJS_ACTION **___SONIC_ACTIONS = (NJS_ACTION **)GetProcAddress(handle, "___SONIC_ACTIONS");
  539. //NJS_MODEL_SADX **___SONIC_MODELS = (NJS_MODEL_SADX **)GetProcAddress(handle, "___SONIC_MODELS");
  540. //___SONIC_OBJECTS[0] = &object_0056AF50;
  541. //___SONIC_ACTIONS[145]->motion = &___SONIC_ACTIONS_18;
  542. //___SONIC_ACTIONS[146]->motion = &___SONIC_ACTIONS_122;
  543. //___SONIC_ACTIONS[147]->motion = &___SONIC_ACTIONS_123;
  544. //___KNUCKLES_OBJECTS[0] = &object_002E23B0;
  545.  
  546. //For Character swap like SADX's Metal Sonic
  547. WriteJump((void*)0x494400, sub_494400);
  548.  
  549. //To fix Shadow's arms crossed anim
  550. WriteJump((void*)0x491660, Sonic_GroundAnim_r);
  551.  
  552.  
  553. };
  554.  
  555. ///////////////////////////////////////////////////////////////////////// OnInput FUNCTION ///////////////////////////////////////////////////////////////////////////////////////
  556.  
  557. void __declspec(dllexport) OnInput()
  558. {
  559.  
  560. //For multipunching
  561. if (GameState == 15)
  562. {
  563. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Knuckles)
  564. {
  565. if (can_multi_punch > 2 && ControllerPointers[0]->PressedButtons & Buttons_X )
  566. {
  567. do_multi_punch = true;//make it so you can double punch too
  568. }
  569. if (do_multi_punch)
  570. {
  571. ControllerPointers[0]->PressedButtons = Buttons_X;
  572. }
  573. }
  574. }
  575.  
  576.  
  577. //For Chaos Spear
  578. if (GameState == 15)
  579. {
  580. if (is_in_CS_state)
  581. {
  582. if (!X_was_released)
  583. {
  584. if (ControllerPointers[0]->HeldButtons & Buttons_X)
  585. {
  586. ControllerPointers[1]->PressedButtons = Buttons_B;
  587. ControllerPointers[1]->HeldButtons = Buttons_B;
  588. }
  589. }
  590. if (++cant_release_X <= 6)
  591. {
  592. ControllerPointers[0]->HeldButtons = Buttons_X;
  593. ControllerPointers[1]->PressedButtons = Buttons_B;
  594. ControllerPointers[1]->HeldButtons = Buttons_B;
  595. }
  596. }
  597. }
  598. }
  599.  
  600. ///////////////////////////////////////////////////////////////////////// OnFrame FUNCTION ///////////////////////////////////////////////////////////////////////////////////////
  601.  
  602. void __declspec(dllexport) OnFrame()
  603. {
  604.  
  605.  
  606. HMODULE hmodule = GetModuleHandle(L"CHRMODELS_orig");
  607. NJS_OBJECT **___SONIC_OBJECTS = (NJS_OBJECT **)GetProcAddress(hmodule, "___SONIC_OBJECTS");
  608.  
  609. ////For model swaps
  610.  
  611. //if (ControllerPointers[0]->PressedButtons & Buttons_Y)
  612. //{
  613. // HMODULE handle = GetModuleHandle(L"CHRMODELS_orig");
  614. // NJS_OBJECT **___SONIC_OBJECTS = (NJS_OBJECT **)GetProcAddress(handle, "___SONIC_OBJECTS");
  615. // NJS_ACTION **___SONIC_ACTIONS = (NJS_ACTION **)GetProcAddress(handle, "___SONIC_ACTIONS");
  616. // NJS_OBJECT **___KNUCKLES_OBJECTS = (NJS_OBJECT **)GetProcAddress(handle, "___KNUCKLES_OBJECTS");
  617. // NJS_ACTION **___KNUCKLES_ACTIONS = (NJS_ACTION **)GetProcAddress(handle, "___KNUCKLES_ACTIONS");
  618. // ___SONIC_OBJECTS[0] = &object_0056AF50;
  619. // ___SONIC_OBJECTS[1] = &object_00563B7C;
  620. // ___SONIC_OBJECTS[2] = &object_00563D0C;
  621. // ___SONIC_OBJECTS[3] = &object_005654EC;
  622. // ___SONIC_OBJECTS[4] = &object_00564CD0;
  623. // ___SONIC_OBJECTS[5] = &object_005647B8;
  624. // ___SONIC_OBJECTS[6] = &object_00564A78;
  625. // ___SONIC_OBJECTS[7] = &object_00561F14;
  626. // ___SONIC_OBJECTS[8] = &object_005620A4;
  627. // ___SONIC_OBJECTS[9] = &object_005638CC;
  628. // ___SONIC_OBJECTS[10] = &object_005630B0;
  629. // ___SONIC_OBJECTS[11] = &object_00562B80;
  630. // ___SONIC_OBJECTS[12] = &object_0056044C;
  631. // ___SONIC_OBJECTS[13] = &object_005605DC;
  632. // ___SONIC_OBJECTS[14] = &object_00561C68;
  633. // ___SONIC_OBJECTS[15] = &object_005613F8;
  634. // ___SONIC_OBJECTS[16] = &object_00560DD0;
  635. // ___SONIC_OBJECTS[17] = &object_0055E99C;
  636. // ___SONIC_OBJECTS[18] = &object_0055EB2C;
  637. // ___SONIC_OBJECTS[19] = &object_005601B8;
  638. // ___SONIC_OBJECTS[20] = &object_0055F948;
  639. // ___SONIC_OBJECTS[21] = &object_0055F330;
  640. // ___SONIC_OBJECTS[22] = &object_0062DE88;
  641. // ___SONIC_OBJECTS[23] = &object_00626AB4;
  642. // ___SONIC_OBJECTS[24] = &object_00626C44;
  643. // ___SONIC_OBJECTS[25] = &object_0062840C;
  644. // ___SONIC_OBJECTS[26] = &object_00627BF0;
  645. // ___SONIC_OBJECTS[27] = &object_006276D8;
  646. // ___SONIC_OBJECTS[28] = &object_00624E3C;
  647. // ___SONIC_OBJECTS[29] = &object_00624FCC;
  648. // ___SONIC_OBJECTS[30] = &object_006267F4;
  649. // ___SONIC_OBJECTS[31] = &object_00625FD8;
  650. // ___SONIC_OBJECTS[32] = &object_00625AA8;
  651. // ___SONIC_OBJECTS[33] = &object_00623474;
  652. // ___SONIC_OBJECTS[34] = &object_00623604;
  653. // ___SONIC_OBJECTS[35] = &object_00624B78;
  654. // ___SONIC_OBJECTS[36] = &object_00624308;
  655. // ___SONIC_OBJECTS[37] = &object_00623C14;
  656. // ___SONIC_OBJECTS[38] = &object_00621AC4;
  657. // ___SONIC_OBJECTS[39] = &object_00621C54;
  658. // ___SONIC_OBJECTS[40] = &object_006231E0;
  659. // ___SONIC_OBJECTS[41] = &object_00622970;
  660. // ___SONIC_OBJECTS[42] = &object_00622254;
  661. // ___SONIC_OBJECTS[44] = &object_0057BC44;
  662. // ___SONIC_OBJECTS[45] = &object_0056998C;
  663. // ___SONIC_OBJECTS[46] = &object_00569594;
  664. // ___SONIC_OBJECTS[47] = &object_005812AC;
  665. // ___SONIC_OBJECTS[48] = &object_00569DEC;
  666. // ___SONIC_OBJECTS[49] = &object_00569594;
  667. // ___SONIC_OBJECTS[50] = &object_00569E20;
  668. // ___SONIC_OBJECTS[51] = &object_00569CE8;
  669. // ___SONIC_OBJECTS[52] = &object_005698F0;
  670. // ___SONIC_OBJECTS[56] = &object_0061B4DC;
  671. // ___SONIC_OBJECTS[57] = &object_0061AA94;
  672. // ___SONIC_OBJECTS[58] = &object_0055F948;
  673. // ___SONIC_OBJECTS[60] = &object_005613F8;
  674. // ___SONIC_OBJECTS[62] = &object_00565520;
  675. // ___SONIC_OBJECTS[63] = &object_00583284;
  676. // ___SONIC_OBJECTS[64] = &object_00583904;
  677. // ___SONIC_OBJECTS[65] = &object_00585EB4;
  678. // ___SONIC_OBJECTS[66] = &object_005729CC;
  679. // ___SONIC_OBJECTS[67] = &object_0057BC44;
  680. // ___SONIC_OBJECTS[68] = &object_00591068;
  681. // ___SONIC_OBJECTS[69] = &object_0059C234;
  682. // ___SONIC_OBJECTS[74] = &object_00630794;
  683. // ___SONIC_OBJECTS[75] = &object_00631128;
  684. // ___SONIC_OBJECTS[76] = &object_00631AC0;
  685. // ___SONIC_ACTIONS[0]->object = &object_0056AF50;
  686. // ___SONIC_ACTIONS[1]->object = &object_0056AF50;
  687. // ___SONIC_ACTIONS[2]->object = &object_0056AF50;
  688. // ___SONIC_ACTIONS[3]->object = &object_0056AF50;
  689. // ___SONIC_ACTIONS[4]->object = &object_0056AF50;
  690. // ___SONIC_ACTIONS[5]->object = &object_0056AF50;
  691. // ___SONIC_ACTIONS[6]->object = &object_0056AF50;
  692. // ___SONIC_ACTIONS[7]->object = &object_0056AF50;
  693. // ___SONIC_ACTIONS[8]->object = &object_0056AF50;
  694. // ___SONIC_ACTIONS[9]->object = &object_0056AF50;
  695. // ___SONIC_ACTIONS[10]->object = &object_0056AF50;
  696. // ___SONIC_ACTIONS[11]->object = &object_0056AF50;
  697. // ___SONIC_ACTIONS[12]->object = &object_0056AF50;
  698. // ___SONIC_ACTIONS[13]->object = &object_0056AF50;
  699. // ___SONIC_ACTIONS[14]->object = &object_005729CC;
  700. // ___SONIC_ACTIONS[15]->object = &object_0056AF50;
  701. // ___SONIC_ACTIONS[16]->object = &object_0056AF50;
  702. // ___SONIC_ACTIONS[17]->object = &object_0056AF50;
  703. // ___SONIC_ACTIONS[18]->motion = &___SONIC_ACTIONS_18;
  704. // ___SONIC_ACTIONS[18]->object = &object_0056AF50;
  705. // ___SONIC_ACTIONS[19]->object = &object_0056AF50;
  706. // ___SONIC_ACTIONS[20]->object = &object_0056AF50;
  707. // ___SONIC_ACTIONS[21]->object = &object_0057BC44;
  708. // ___SONIC_ACTIONS[22]->object = &object_0056AF50;
  709. // ___SONIC_ACTIONS[23]->object = &object_0056AF50;
  710. // ___SONIC_ACTIONS[27]->object = &object_0056AF50;
  711. // ___SONIC_ACTIONS[28]->object = &object_0056AF50;
  712. // ___SONIC_ACTIONS[29]->object = &object_0056AF50;
  713. // ___SONIC_ACTIONS[30]->object = &object_0056AF50;
  714. // ___SONIC_ACTIONS[31]->object = &object_0056AF50;
  715. // ___SONIC_ACTIONS[32]->object = &object_0056AF50;
  716. // ___SONIC_ACTIONS[33]->object = &object_0056AF50;
  717. // ___SONIC_ACTIONS[34]->object = &object_0056AF50;
  718. // ___SONIC_ACTIONS[35]->object = &object_0056AF50;
  719. // ___SONIC_ACTIONS[36]->object = &object_0056AF50;
  720. // ___SONIC_ACTIONS[37]->object = &object_0056AF50;
  721. // ___SONIC_ACTIONS[38]->object = &object_0056AF50;
  722. // ___SONIC_ACTIONS[39]->object = &object_0056AF50;
  723. // ___SONIC_ACTIONS[40]->object = &object_0056AF50;
  724. // ___SONIC_ACTIONS[41]->object = &object_0056AF50;
  725. // ___SONIC_ACTIONS[42]->object = &object_0056AF50;
  726. // ___SONIC_ACTIONS[43]->object = &object_0056AF50;
  727. // ___SONIC_ACTIONS[44]->object = &object_0056AF50;
  728. // ___SONIC_ACTIONS[45]->object = &object_0056AF50;
  729. // ___SONIC_ACTIONS[46]->object = &object_0056AF50;
  730. // ___SONIC_ACTIONS[47]->object = &object_0056AF50;
  731. // ___SONIC_ACTIONS[48]->object = &object_0056AF50;
  732. // ___SONIC_ACTIONS[49]->object = &object_0056AF50;
  733. // ___SONIC_ACTIONS[50]->object = &object_0056AF50;
  734. // ___SONIC_ACTIONS[51]->object = &object_0056AF50;
  735. // ___SONIC_ACTIONS[52]->object = &object_0056AF50;
  736. // ___SONIC_ACTIONS[53]->object = &object_0056AF50;
  737. // ___SONIC_ACTIONS[54]->object = &object_0056AF50;
  738. // ___SONIC_ACTIONS[55]->object = &object_0056AF50;
  739. // ___SONIC_ACTIONS[56]->object = &object_0056AF50;
  740. // ___SONIC_ACTIONS[57]->object = &object_0056AF50;
  741. // ___SONIC_ACTIONS[58]->object = &object_0056AF50;
  742. // ___SONIC_ACTIONS[59]->object = &object_0056AF50;
  743. // ___SONIC_ACTIONS[60]->object = &object_0056AF50;
  744. // ___SONIC_ACTIONS[61]->object = &object_0056AF50;
  745. // ___SONIC_ACTIONS[62]->object = &object_0056AF50;
  746. // ___SONIC_ACTIONS[63]->object = &object_0056AF50;
  747. // ___SONIC_ACTIONS[64]->object = &object_0056AF50;
  748. // ___SONIC_ACTIONS[65]->object = &object_0056AF50;
  749. // ___SONIC_ACTIONS[66]->object = &object_0056AF50;
  750. // ___SONIC_ACTIONS[67]->object = &object_0056AF50;
  751. // ___SONIC_ACTIONS[68]->object = &object_0056AF50;
  752. // ___SONIC_ACTIONS[69]->object = &object_0056AF50;
  753. // ___SONIC_ACTIONS[70]->object = &object_0056AF50;
  754. // ___SONIC_ACTIONS[71]->object = &object_0056AF50;
  755. // ___SONIC_ACTIONS[72]->object = &object_0056AF50;
  756. // ___SONIC_ACTIONS[87]->object = &object_0056AF50;
  757. // ___SONIC_ACTIONS[88]->object = &object_0056AF50;
  758. // ___SONIC_ACTIONS[89]->object = &object_0056AF50;
  759. // ___SONIC_ACTIONS[90]->object = &object_0056AF50;
  760. // ___SONIC_ACTIONS[91]->object = &object_0056AF50;
  761. // ___SONIC_ACTIONS[92]->object = &object_0056AF50;
  762. // ___SONIC_ACTIONS[93]->object = &object_0056AF50;
  763. // ___SONIC_ACTIONS[94]->object = &object_0056AF50;
  764. // ___SONIC_ACTIONS[95]->object = &object_0056AF50;
  765. // ___SONIC_ACTIONS[96]->object = &object_0056AF50;
  766. // ___SONIC_ACTIONS[97]->object = &object_0056AF50;
  767. // ___SONIC_ACTIONS[98]->object = &object_0056AF50;
  768. // ___SONIC_ACTIONS[99]->object = &object_0056AF50;
  769. // ___SONIC_ACTIONS[100]->object = &object_0056AF50;
  770. // ___SONIC_ACTIONS[101]->object = &object_0056AF50;
  771. // ___SONIC_ACTIONS[102]->object = &object_0056AF50;
  772. // ___SONIC_ACTIONS[103]->object = &object_0056AF50;
  773. // ___SONIC_ACTIONS[104]->object = &object_0056AF50;
  774. // ___SONIC_ACTIONS[105]->object = &object_0056AF50;
  775. // ___SONIC_ACTIONS[106]->object = &object_0056AF50;
  776. // ___SONIC_ACTIONS[107]->object = &object_0056AF50;
  777. // ___SONIC_ACTIONS[108]->object = &object_0056AF50;
  778. // ___SONIC_ACTIONS[109]->object = &object_0056AF50;
  779. // ___SONIC_ACTIONS[113]->object = &object_0056AF50;
  780. // ___SONIC_ACTIONS[114]->object = &object_0056AF50;
  781. // ___SONIC_ACTIONS[115]->object = &object_0056AF50;
  782. // ___SONIC_ACTIONS[116]->object = &object_0056AF50;
  783. // ___SONIC_ACTIONS[117]->object = &object_0056AF50;
  784. // ___SONIC_ACTIONS[118]->object = &object_0056AF50;
  785. // ___SONIC_ACTIONS[119]->object = &object_0056AF50;
  786. // ___SONIC_ACTIONS[120]->object = &object_0056AF50;
  787. // ___SONIC_ACTIONS[121]->object = &object_0056AF50;
  788. // ___SONIC_ACTIONS[122]->motion = &___SONIC_ACTIONS_122;
  789. // ___SONIC_ACTIONS[122]->object = &object_0056AF50;
  790. // ___SONIC_ACTIONS[123]->motion = &___SONIC_ACTIONS_123;
  791. // ___SONIC_ACTIONS[123]->object = &object_0056AF50;
  792. // ___SONIC_ACTIONS[124]->object = &object_0056AF50;
  793. // ___SONIC_ACTIONS[125]->object = &object_0056AF50;
  794. // ___SONIC_ACTIONS[126]->object = &object_0056AF50;
  795. // ___SONIC_ACTIONS[127]->object = &object_0056AF50;
  796. // ___SONIC_ACTIONS[128]->object = &object_0056AF50;
  797. // ___SONIC_ACTIONS[129]->object = &object_0056AF50;
  798. // ___SONIC_ACTIONS[130]->object = &object_0062DE88;
  799. // ___SONIC_ACTIONS[131]->object = &object_0062DE88;
  800. // ___SONIC_ACTIONS[132]->object = &object_0062DE88;
  801. // ___SONIC_ACTIONS[133]->object = &object_0062DE88;
  802. // ___SONIC_ACTIONS[134]->object = &object_0056AF50;
  803. // ___SONIC_ACTIONS[135]->object = &object_0056AF50;
  804. // ___SONIC_ACTIONS[136]->object = &object_0056AF50;
  805. // ___SONIC_ACTIONS[137]->object = &object_0056AF50;
  806. // ___SONIC_ACTIONS[138]->object = &object_0062DE88;
  807. // ___SONIC_ACTIONS[139]->object = &object_0062DE88;
  808. // ___SONIC_ACTIONS[140]->object = &object_0062DE88;
  809. // ___SONIC_ACTIONS[141]->object = &object_0062DE88;
  810. // ___SONIC_ACTIONS[142]->object = &object_0062FE6C;
  811. // ___SONIC_ACTIONS[143]->object = &object_0062DE88;
  812. // ___SONIC_ACTIONS[144]->object = &object_0062DE88;
  813. // ___SONIC_ACTIONS[145]->object = &object_0056AF50;
  814. // ___SONIC_ACTIONS[146]->object = &object_0056AF50;
  815. // ___SONIC_ACTIONS[147]->object = &object_0056AF50;
  816. // ___SONIC_ACTIONS[148]->object = &object_0056AF50;
  817. // ___KNUCKLES_OBJECTS[0] = &object_002E23B0;
  818. // ___KNUCKLES_OBJECTS[2] = &object_002DB8A4;
  819. // ___KNUCKLES_OBJECTS[3] = &object_002DBA34;
  820. // ___KNUCKLES_OBJECTS[4] = &object_002DD0AC;
  821. // ___KNUCKLES_OBJECTS[5] = &object_002DC244;
  822. // ___KNUCKLES_OBJECTS[6] = &object_002D9E5C;
  823. // ___KNUCKLES_OBJECTS[7] = &object_002D9FEC;
  824. // ___KNUCKLES_OBJECTS[8] = &object_002DB5F4;
  825. // ___KNUCKLES_OBJECTS[9] = &object_002DAB34;
  826. // ___KNUCKLES_OBJECTS[10] = &object_002D876C;
  827. // ___KNUCKLES_OBJECTS[11] = &object_002D88FC;
  828. // ___KNUCKLES_OBJECTS[12] = &object_002D9BB0;
  829. // ___KNUCKLES_OBJECTS[13] = &object_002D6FE4;
  830. // ___KNUCKLES_OBJECTS[14] = &object_002D7174;
  831. // ___KNUCKLES_OBJECTS[15] = &object_002D8438;
  832. // ___KNUCKLES_OBJECTS[16] = &object_002D9754;
  833. // ___KNUCKLES_OBJECTS[17] = &object_002D9088;
  834. // ___KNUCKLES_OBJECTS[18] = &object_002D7FDC;
  835. // ___KNUCKLES_OBJECTS[19] = &object_002D7900;
  836. // ___KNUCKLES_OBJECTS[20] = &object_002DC94C;
  837. // ___KNUCKLES_OBJECTS[21] = &object_002DC244;
  838. // ___KNUCKLES_OBJECTS[22] = &object_002DAEE4;
  839. // ___KNUCKLES_OBJECTS[23] = &object_002DAB34;
  840. // ___KNUCKLES_OBJECTS[49] = &object_002E191C;
  841. // ___KNUCKLES_OBJECTS[51] = &object_002E21A8;
  842. // ___KNUCKLES_OBJECTS[52] = &object_002E2070;
  843. // ___KNUCKLES_OBJECTS[53] = &object_002E1C78;
  844. // ___KNUCKLES_OBJECTS[54] = &object_002E1D14;
  845. // ___KNUCKLES_OBJECTS[55] = &object_002E191C;
  846. // ___KNUCKLES_OBJECTS[58] = &object_002DB5F4;
  847. // ___KNUCKLES_OBJECTS[59] = &object_002DAEE4;
  848. // ___KNUCKLES_OBJECTS[60] = &object_002DAB34;
  849. // ___KNUCKLES_OBJECTS[61] = &object_002DA324;
  850. // ___KNUCKLES_OBJECTS[62] = &object_002DD0AC;
  851. // ___KNUCKLES_OBJECTS[63] = &object_002DC94C;
  852. // ___KNUCKLES_OBJECTS[64] = &object_002DC244;
  853. // ___KNUCKLES_OBJECTS[65] = &object_002DC59C;
  854. // ___KNUCKLES_ACTIONS[0]->object = &object_002E23B0;
  855. // ___KNUCKLES_ACTIONS[1]->object = &object_002E23B0;
  856. // ___KNUCKLES_ACTIONS[6]->object = &object_002E23B0;
  857. // ___KNUCKLES_ACTIONS[9]->object = &object_002E23B0;
  858. // ___KNUCKLES_ACTIONS[10]->object = &object_002E23B0;
  859. // ___KNUCKLES_ACTIONS[11]->object = &object_002E23B0;
  860. // ___KNUCKLES_ACTIONS[12]->object = &object_002E23B0;
  861. // ___KNUCKLES_ACTIONS[13]->object = &object_002E23B0;
  862. // ___KNUCKLES_ACTIONS[14]->object = &object_002E23B0;
  863. // ___KNUCKLES_ACTIONS[22]->object = &object_002E23B0;
  864. // ___KNUCKLES_ACTIONS[23]->object = &object_002E23B0;
  865. // ___KNUCKLES_ACTIONS[24]->object = &object_002E23B0;
  866. // ___KNUCKLES_ACTIONS[25]->object = &object_002E23B0;
  867. // ___KNUCKLES_ACTIONS[26]->object = &object_002E23B0;
  868. // ___KNUCKLES_ACTIONS[27]->object = &object_002E23B0;
  869. // ___KNUCKLES_ACTIONS[28]->object = &object_002E23B0;
  870. // ___KNUCKLES_ACTIONS[29]->object = &object_002E23B0;
  871. // ___KNUCKLES_ACTIONS[30]->object = &object_002E23B0;
  872. // ___KNUCKLES_ACTIONS[31]->object = &object_002E23B0;
  873. // ___KNUCKLES_ACTIONS[32]->object = &object_002E23B0;
  874. // ___KNUCKLES_ACTIONS[33]->object = &object_002E23B0;
  875. // ___KNUCKLES_ACTIONS[34]->object = &object_002E23B0;
  876. // ___KNUCKLES_ACTIONS[38]->object = &object_002E23B0;
  877. // ___KNUCKLES_ACTIONS[40]->object = &object_002E23B0;
  878. // ___KNUCKLES_ACTIONS[41]->object = &object_002E23B0;
  879. // ___KNUCKLES_ACTIONS[43]->object = &object_002E23B0;
  880. // ___KNUCKLES_ACTIONS[44]->object = &object_002E23B0;
  881. // ___KNUCKLES_ACTIONS[45]->object = &object_002E23B0;
  882. // ___KNUCKLES_ACTIONS[46]->object = &object_002E23B0;
  883. // ___KNUCKLES_ACTIONS[47]->object = &object_002E23B0;
  884. // ___KNUCKLES_ACTIONS[48]->object = &object_002E23B0;
  885. // ___KNUCKLES_ACTIONS[49]->object = &object_002E23B0;
  886. // ___KNUCKLES_ACTIONS[50]->object = &object_002E23B0;
  887. // ___KNUCKLES_ACTIONS[51]->object = &object_002E23B0;
  888. // ___KNUCKLES_ACTIONS[53]->object = &object_002E23B0;
  889. // ___KNUCKLES_ACTIONS[54]->object = &object_002E23B0;
  890. // ___KNUCKLES_ACTIONS[55]->object = &object_002E23B0;
  891. // ___KNUCKLES_ACTIONS[56]->object = &object_002E23B0;
  892. // ___KNUCKLES_ACTIONS[58]->object = &object_002E23B0;
  893. // ___KNUCKLES_ACTIONS[59]->object = &object_002E23B0;
  894. // ___KNUCKLES_ACTIONS[60]->object = &object_002E23B0;
  895. // ___KNUCKLES_ACTIONS[63]->object = &object_002E23B0;
  896. // ___KNUCKLES_ACTIONS[64]->object = &object_002E23B0;
  897. // ___KNUCKLES_ACTIONS[65]->object = &object_002E23B0;
  898. // ___KNUCKLES_ACTIONS[66]->object = &object_002E23B0;
  899. // ___KNUCKLES_ACTIONS[67]->object = &object_002E23B0;
  900. // ___KNUCKLES_ACTIONS[68]->object = &object_002E23B0;
  901. // ___KNUCKLES_ACTIONS[69]->object = &object_002E23B0;
  902. // ___KNUCKLES_ACTIONS[70]->object = &object_002E23B0;
  903. // ___KNUCKLES_ACTIONS[71]->object = &object_002E23B0;
  904. // ___KNUCKLES_ACTIONS[72]->object = &object_002E23B0;
  905. // ___KNUCKLES_ACTIONS[73]->object = &object_002E23B0;
  906. // ___KNUCKLES_ACTIONS[74]->object = &object_002E23B0;
  907. // ___KNUCKLES_ACTIONS[75]->object = &object_002E23B0;
  908. // ___KNUCKLES_ACTIONS[76]->object = &object_002E23B0;
  909. // ___KNUCKLES_ACTIONS[77]->object = &object_002E23B0;
  910. // ___KNUCKLES_ACTIONS[78]->object = &object_002E23B0;
  911. // ___KNUCKLES_ACTIONS[79]->object = &object_002E23B0;
  912. // ___KNUCKLES_ACTIONS[80]->object = &object_002E23B0;
  913. // ___KNUCKLES_ACTIONS[81]->object = &object_002E23B0;
  914. // ___KNUCKLES_ACTIONS[82]->object = &object_002E23B0;
  915. // ___KNUCKLES_ACTIONS[83]->object = &object_002E23B0;
  916. // ___KNUCKLES_ACTIONS[84]->object = &object_002E23B0;
  917. // ___KNUCKLES_ACTIONS[86]->object = &object_002E23B0;
  918. // ___KNUCKLES_ACTIONS[87]->object = &object_002E23B0;
  919. // ___KNUCKLES_ACTIONS[88]->object = &object_002E23B0;
  920. // ___KNUCKLES_ACTIONS[89]->object = &object_002E23B0;
  921. //}
  922.  
  923.  
  924.  
  925. WriteData((PVMEntry**)0x90ED54, SonicTextures);
  926. WriteData((PVMEntry**)0x90ED60, KnucklesTextures);
  927.  
  928.  
  929. //character change stuff*****************************
  930. if (!IsGamePaused() && oldcol)
  931. {
  932. if (HIBYTE(oldcol->Flags) & 0x80)
  933. {
  934. if (oldcol->CollisionArray)
  935. {
  936. FreeMemory(oldcol->CollisionArray);
  937. oldcol->CollisionArray = nullptr;
  938. }
  939. }
  940. FreeMemory(oldcol);
  941. oldcol = nullptr;
  942. }
  943. //***************************************************
  944.  
  945. EntityData1* co1 = EntityData1Ptrs[0];
  946. EntityData1* co1CPU = EntityData1Ptrs[1];
  947. CharObj2 *co2 = GetCharObj2(0);
  948. CharObj2 *co2CPU = GetCharObj2(1);
  949. GammaShootingThing *thing = nullptr;
  950. if (GetCharacterObject(1) && GetCharacterID(1) == Characters_Gamma) thing = *(GammaShootingThing**)&co2CPU->SonicSpinTimeProbably;
  951.  
  952.  
  953.  
  954. if (CurrentLevel == 26 || CurrentLevel == 29 || CurrentLevel == 33) //***************** WHY ....................???????????
  955. {
  956. //Sonic_LightSpeedShoesObtained = 1;
  957. Sonic_CrystalRingObtained = 1;
  958. //Sonic_AncientLightObtained = 1;
  959. }
  960. else
  961. {
  962. //Sonic_LightSpeedShoesObtained = 1;
  963. Sonic_CrystalRingObtained = 0;
  964. //Sonic_AncientLightObtained = 0;
  965. }
  966.  
  967.  
  968.  
  969.  
  970. if (CurrentMusic == 24 || CurrentMusic == 72 || CurrentMusic == 101 || CurrentMusic == 102 || CurrentMusic == 103)
  971. {
  972. //ChangeToShadowModel();
  973. //njReleaseTexture((NJS_TEXLIST*)0x91CB58);
  974. //LoadPVM("SHA_SONIC", (NJS_TEXLIST*)0x91CB58);
  975. //njReleaseTexture((NJS_TEXLIST*)0x927CB8);
  976. //LoadPVM("SHA_SON_EFF", (NJS_TEXLIST*)0x927CB8);
  977. //njReleaseTexture((NJS_TEXLIST*)0x142272C);
  978. //LoadPVM("SHA_SUPERSONIC", (NJS_TEXLIST*)0x142272C);
  979. //njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
  980. //LoadPVM("SHA_KNUCKLES", (NJS_TEXLIST*)0x94A2A8);
  981. //njReleaseTexture((NJS_TEXLIST*)0x142272C);
  982. //LoadPVM("SHA_KNU_EFF", (NJS_TEXLIST*)0x142272C);
  983. //njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
  984. //LoadPVM("SHA_E102BEAM", (NJS_TEXLIST*)0x94A2A8);
  985. }
  986.  
  987.  
  988.  
  989. //Anim data
  990. WriteData((short*)0x00495C27, (short)13);
  991.  
  992. if (co2 == NULL) return;
  993. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  994. {
  995. ((AnimData_t*)0x3C56210)[18].TransitionSpeed = 0.1;
  996. ((AnimData_t*)0x3C56210)[64].TransitionSpeed = 0.25;
  997. ((AnimData_t*)0x3C56210)[1].TransitionSpeed = 0.075;
  998. ((AnimData_t*)0x3C56210)[2].TransitionSpeed = 0.075;
  999. ((AnimData_t*)0x3C56210)[64].AnimationSpeed = 1.5;
  1000.  
  1001.  
  1002. ((AnimData_t*)0x3C56210)[54].AnimationSpeed = 1.5;
  1003.  
  1004.  
  1005. ((AnimData_t*)0x3C56210)[11].AnimationSpeed = 0.9;
  1006. ((AnimData_t*)0x3C56210)[12].AnimationSpeed = 0.6;
  1007. ((AnimData_t*)0x3C56210)[13].AnimationSpeed = 1.0;
  1008. ((AnimData_t*)0x3C56210)[13].Property = 3;
  1009. ((AnimData_t*)0x3C56210)[14].AnimationSpeed = 0.15;
  1010. ((AnimData_t*)0x3C56210)[40].AnimationSpeed = 1.15;
  1011. ((AnimData_t*)0x3C56210)[42].AnimationSpeed = 0.9;
  1012. ((AnimData_t*)0x3C56210)[31].TransitionSpeed = 0.125;
  1013. ((AnimData_t*)0x3C56210)[29].AnimationSpeed = 2.0;
  1014. ((AnimData_t*)0x3C56210)[75].AnimationSpeed = 0.75;
  1015. ((AnimData_t*)0x3C56210)[38].AnimationSpeed = 2.5;
  1016. ((AnimData_t*)0x3C56210)[34].AnimationSpeed = 0.6;
  1017. ((AnimData_t*)0x3C56210)[38].Property = 9;
  1018. ((AnimData_t*)0x3C56210)[34].Property = 9;
  1019. // PhysicsArray[Characters_Sonic].RollEnd = 1.6;
  1020. PhysicsArray[Characters_Sonic].Run1 = 2.0;
  1021. PhysicsArray[Characters_Sonic].Run2 = 5.25;
  1022. co2->PhysicsData.AirDecel = -0.028;
  1023. }
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029. //Remove the bounce ball when transforming/breathe bubbling
  1030. if (co2->AnimationThing.Index == 84)
  1031. {
  1032. co1->Status &= ~Status_Ball;
  1033. }
  1034.  
  1035.  
  1036. //To be in Jump mode after LSA
  1037. WriteData((char*)0x498763, (char)0x08);
  1038. WriteData((void*)0x49876D, 0x90, 4);
  1039. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  1040. {
  1041. if (LSA_used && (ControllerPointers[0]->PressedButtons & Buttons_B || ControllerPointers[0]->PressedButtons & Buttons_X))
  1042. {
  1043. EntityData1Ptrs[0]->Action = 12;
  1044. }
  1045. if (EntityData1Ptrs[0]->Action == 44)
  1046. {
  1047. LSA_used = true;
  1048. }
  1049. else
  1050. {
  1051. LSA_used = false;
  1052. }
  1053. }
  1054.  
  1055.  
  1056. //No magnetic while LightDashing
  1057. if (EntityData1Ptrs[0]->Action != 6)
  1058. {
  1059. WriteData((float**)0x44FAFF, (float*)0x7DD574);
  1060. WriteData((float*)0x44FBBA, 50.0f);
  1061. }
  1062. else
  1063. {
  1064. WriteData((float**)0x44FAFF, &LDringdist);
  1065. WriteData((float*)0x44FBBA, LDringdist);
  1066. }
  1067.  
  1068.  
  1069. //LSA launch a bit in the air after it's finished
  1070. if (EntityData1Ptrs[0]->Action == 44)
  1071. {
  1072. LSA_launch = true;
  1073. }
  1074. if (LSA_launch && EntityData1Ptrs[0]->Action != 44)
  1075. {
  1076. co2->Speed.y = 2;
  1077. LSA_launch = false;
  1078. }
  1079.  
  1080. //LSA don't work with Y
  1081. if (GameState == 15)
  1082. {
  1083. if (Sonic_AncientLightObtained == 1)
  1084. {
  1085. if (EntityData1Ptrs[0]->Action == 4 || co1->Status & Status_LightDash)
  1086. {
  1087. co2->Upgrades |= Upgrades_AncientLight;
  1088. }
  1089. else
  1090. {
  1091. co2->Upgrades &= ~Upgrades_AncientLight;
  1092. }
  1093. }
  1094. }
  1095.  
  1096.  
  1097.  
  1098. //Being able to cancel Chaos Boost's homing attack
  1099. if (GameState == 16)
  1100. {
  1101. paused = 0;
  1102. is_paused = true;
  1103. }
  1104. else if (paused < 4)
  1105. {
  1106. if (++paused == 2)
  1107. {
  1108. is_paused = false;
  1109. }
  1110. }
  1111. if (!is_paused)
  1112. {
  1113. if (EntityData1Ptrs[0]->Action == 14)
  1114. {
  1115. if (ControllerPointers[0]->PressedButtons & Buttons_X || ControllerPointers[0]->PressedButtons & Buttons_B)
  1116. {
  1117. cant_chaos_spear = true;
  1118. EntityData1Ptrs[0]->Action = 8;
  1119. X_was_pressed = true;
  1120. }
  1121. }
  1122. else if (!X_was_pressed)
  1123. {
  1124. cant_chaos_spear = false;
  1125. }
  1126. else
  1127. {
  1128. EntityData1Ptrs[0]->Action = 14;
  1129. X_was_pressed = false;
  1130. }
  1131. }
  1132.  
  1133.  
  1134.  
  1135. //Being able to cancel lightdash
  1136. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  1137. {
  1138. if (EntityData1Ptrs[0]->Action == 6)
  1139. {
  1140. if (ControllerPointers[0]->PressedButtons & Buttons_B || ControllerPointers[0]->PressedButtons & Buttons_X)
  1141. {
  1142. EntityData1Ptrs[0]->Action = 12;
  1143. }
  1144. }
  1145. }
  1146.  
  1147.  
  1148. //Top speed anim Shadow ADD ANIMATION SPEED CHECK => why did I write this ? I don't remember ... :/
  1149. if (co2 == NULL) return;
  1150. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  1151. {
  1152. if (co2->Speed.x >= 4.0) (WriteData((short*)0x00495B44, (short)130));
  1153. else (WriteData((short*)0x00495B44, (short)12));
  1154. WriteData((short*)0x00495C27, (short)130);
  1155. WriteData((short*)0x00497A88, (short)131);
  1156. WriteData((short*)0x0049691F, (short)131);
  1157. WriteData((short*)0x0049773F, (short)131);
  1158. }
  1159.  
  1160.  
  1161.  
  1162. //Anims better looks => OK
  1163. WriteData((short*)0x004984A3, (short)31);
  1164. WriteData((short*)0x0049629E, (short)31);
  1165. WriteData((short*)0x004962BF, (short)31);
  1166. WriteData((short*)0x00495E2C, (short)11);
  1167. //WriteData((short*)0x0049773F, (short)1);
  1168.  
  1169.  
  1170. //Remove Knux's rolling => OK
  1171. WriteData((char*)0x47824B, (char)0xEB);//74 is the original value
  1172.  
  1173. //Knux's 3rd punch's stop speed => 47419A - C7 47 38 0008040
  1174. WriteData((void*)0x47419A, shadow3rdpunchspeed);
  1175.  
  1176. //If I want to have the 3rd punch not stop the speed when finished => 474293 - D9 5F 38
  1177. //WriteData((void*)0x474293, 0x90, 3);shadow3rdpunchspeed
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184. //// ATTENTION : NOT ENOUGH FAST BEAMS MAKES EXPLOSIONS NOT APPEAR !!!!!!!m***************
  1185. //// FOUND WHAT CONTROLS THE FLASHING WHEN PSEUDO-INVINCIBLE !!!!
  1186. //// 48152E - 66 89 43 06 => NOP that and he wont flash anymore
  1187. ////
  1188. ////FIXED*************************************** : Exception thrown at 0x004CEB34.********************* (came from the target squares)
  1189.  
  1190. //////Chaos Spear Action (no chaos boost) NEW****************************
  1191.  
  1192. ////ERROR : Exception thrown at 0x3F800000 in sonic.exe: 0xC0000005: Access violation executing location 0x3F800000.
  1193. ////ERROR : Exception thrown at 0x0040B2AF in sonic.exe: 0xC0000005: Access violation writing location 0x004BFDA0.
  1194. ////ERROR as Gamma : Exception thrown at 0x004CEFF6 in sonic.exe: 0xC0000005: Access violation reading location 0x3F9999BA.
  1195. ////ERROR as Sonic : Exception thrown at 0x00493CB0 in sonic.exe: 0xC0000005: Access violation reading location 0xBE561298.
  1196. ////ERROR : Exception thrown at 0x00440243 in sonic.exe: 0xC0000005: Access violation writing location 0x00000000.
  1197. ////ERROR : Exception thrown at 0x0043861B in sonic.exe: 0xC0000005: Access violation reading location 0x3F0B2F45.
  1198. ////ERROR : Exception thrown at 0x0078CF24 in sonic.exe: 0xC0000005: Access violation reading location 0x00000013. => texture issue, maybe because there's no Sonic textures as Gamma ?
  1199. ////ERROR_OFTEN : Exception thrown at 0x0040B33E in sonic.exe: 0xC0000005: Access violation reading location 0xBE03126F.
  1200. ////ERROR_OFTEN : Exception thrown at 0x0040B3DA in sonic.exe: 0xC0000005: Access violation writing location 0x00000031. => FREEMEMORY ISSUE
  1201. ////ERROR : Exception thrown at 0x00456F22 in sonic.exe: 0xC0000005: Access violation reading location 0x00000035. => SPRITE ISSUE
  1202. ////ERROR : Unhandled exception at 0x0CC82BEE in sonic.exe: 0xC0000005: Access violation writing location 0x00181110.
  1203. ////ERROR : Exception thrown at 0x0044058E in sonic.exe: 0xC0000005: Access violation reading location 0xC16FF7F4.
  1204. //////NOP JumpCancel Action/Animation/HSpeed/VSpeed
  1205. //WriteData((void*)0x492F68, 0x90, 3);
  1206. ////WriteData((void*)0x43C560, 0x90, 3);
  1207. ////WriteData((void*)0x43C55D, 0x90, 3);
  1208. //WriteData((short*)0x4C4E34, (short)30000);//Gamma aiming laser timer
  1209. //WriteData((void*)0x4496E1, WalkOnWaterData);
  1210. //WriteData((void*)0x42667F, 0x90, 5); //stop the timer to go up when killing enemies as Gamma
  1211. //if (GameState == 4)
  1212. //{
  1213. // backtoshadow2 = 0;
  1214. // can_go_back_to_shadow = false;
  1215. // chaos_spear_stop = 0;
  1216. // WriteData((void*)0x4C4DA9, enable_aiming);
  1217. // WriteData((void*)0x4C475B, enable_shooting);
  1218. // WriteData((void*)0x48152E, enable_GAMMAflashing);
  1219. // didnt_target = false;
  1220. // ready = false;
  1221. // X_was_released = 0;
  1222. // cant_chaos_spear2 = false;
  1223. // DO_chaos_spear_again = false;
  1224. // pressed_X_while_Gamma = false;
  1225. // gonna_chaos_spear_again = 0;
  1226. //}
  1227. //if ((co1->Status & Status_Ground) == Status_Ground)
  1228. //{
  1229. // DO_chaos_spear_again = false;
  1230. //}
  1231. //if (GameState == 15)
  1232. //{
  1233. // if (co2 == NULL) return;
  1234. // if (is_CB)
  1235. // {
  1236. // Gamma_LaserBlasterObtained = 1;
  1237. // }
  1238. // else Gamma_LaserBlasterObtained = 0;
  1239. // if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  1240. // {
  1241. // if (cant_chaos_spear_again)
  1242. // {
  1243. // if (++can_chaos_spear_again >= 2)
  1244. // {
  1245. // cant_chaos_spear_again = false;
  1246. // can_chaos_spear_again = 0;
  1247. // }
  1248. // }
  1249. // if (pressed_X_while_Gamma)
  1250. // {
  1251. // if (++gonna_chaos_spear_again >= 2)
  1252. // {
  1253. // DO_chaos_spear_again = true;
  1254. // pressed_X_while_Gamma = false;
  1255. // gonna_chaos_spear_again = 0;
  1256. // }
  1257. // }
  1258. // if (ControllerPointers[0]->PressedButtons & Buttons_Z && !is_CB)
  1259. // {
  1260. // is_CB = true;
  1261. // }
  1262. // else if (ControllerPointers[0]->PressedButtons & Buttons_Z && is_CB)
  1263. // {
  1264. // is_CB = false;
  1265. // }
  1266. // WriteData((void*)0x48152E, enable_GAMMAflashing);
  1267. // co2->PhysicsData.AirDecel = -0.028;
  1268. // WriteData((void*)0x4C4DA9, enable_aiming);
  1269. // WriteData((void*)0x4C475B, enable_shooting);
  1270. // WriteData((void*)0x4C4643, 0x90, 4); //C6 46 01 05 - To make shooting action not go to 5, making instant shooting happen********************************************************
  1271. // WriteData((char*)0x4CEA60, (char)0xC3);//removes the red/yellow squares
  1272. // ready = false;
  1273. // if (backtoshadow2 >= 27)
  1274. // {
  1275. // if (++backtoshadow2 == 29)
  1276. // {
  1277. // EntityData1Ptrs[0]->Action = 8;
  1278. // co2->AnimationThing.Index = 119;
  1279. // co1->Status |= Status_Ball;
  1280. // backtoshadow2 = 0;
  1281. // cant_chaos_spear2 = false;
  1282. // }
  1283. // }
  1284. // if (didnt_target)
  1285. // {
  1286. // EntityData1Ptrs[0]->Action = 8;
  1287. // co2->AnimationThing.Index = 18;
  1288. // co1->Status |= Status_Ball;
  1289. // if (++backtoshadow2 == 2)
  1290. // {
  1291. // backtoshadow2 = 0;
  1292. // didnt_target = false;
  1293. // cant_chaos_spear2 = false;
  1294. // }
  1295. // }
  1296. // if ((co1->Status & Status_Ground) != Status_Ground && (co2->AnimationThing.Index == 14 || co2->AnimationThing.Index == 18 || co2->AnimationThing.Index == 116 || co2->AnimationThing.Index == 117 || co2->AnimationThing.Index == 119))
  1297. // {
  1298. // if (EntityData1Ptrs[0]->Action == 8 && !cant_chaos_spear && !cant_chaos_spear2 && !cant_chaos_spear_again) // && (co2->AnimationThing.Index == 14 || co2->AnimationThing.Index == 18)
  1299. // {
  1300. // if ((!X_is_held && ControllerPointers[0]->HeldButtons & Buttons_X) || (DO_chaos_spear_again)) // fix to have it false when onground !! and fix anyway that stuff
  1301. // {
  1302. // DO_chaos_spear_again = false;
  1303. // X_is_held = true;
  1304. // ObjectMaster *obj = GetCharacterObject(0);
  1305. // CharObj2 *obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1306. // short powerups = obj2->Powerups;
  1307. // short jumptime = obj2->JumpTime;
  1308. // short underwatertime = obj2->UnderwaterTime;
  1309. // float loopdist = obj2->LoopDist;
  1310. // NJS_VECTOR speed = obj2->Speed;
  1311. // ObjectMaster *heldobj = obj2->ObjectHeld;
  1312. // obj->DeleteSub(obj);
  1313. // obj->MainSub = Gamma_Main;
  1314. // obj->Data1->CharID = (char)Characters_Gamma;
  1315. // obj->Data1->Action = 0;
  1316. // obj->Data1->Status &= ~(Status_Attack | Status_Ball | Status_LightDash | Status_Unknown3);
  1317. // if (!oldcol)
  1318. // {
  1319. // oldcol = obj->Data1->CollisionInfo;
  1320. // obj->Data1->CollisionInfo = nullptr;
  1321. // }
  1322. // else
  1323. // Collision_Free(obj);
  1324. // obj->MainSub(obj);
  1325. // obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1326. // obj2->Powerups = powerups;
  1327. // obj2->JumpTime = jumptime;
  1328. // obj2->UnderwaterTime = underwatertime;
  1329. // obj2->LoopDist = loopdist;
  1330. // obj2->Speed = speed;
  1331. // obj2->ObjectHeld = heldobj;
  1332. // LoadSoundList(48);
  1333. // if (VoiceLanguage)
  1334. // LoadSoundList(68);
  1335. // else
  1336. // LoadSoundList(67);
  1337. // //WriteData((char*)0x4CEA60, (char)0x8B);//put the red/yellow squares
  1338. // WriteData((float**)0x4C41CD, &missilespeed);
  1339. // WriteData((float**)0x4C41DC, &missilespeed);
  1340. // WriteData((float**)0x4C41E8, &missilespeed);
  1341. // can_chaos_spear_again = 0;
  1342. // WriteData((void*)0x48152E, 0x90, 4); //make the character not flash when "invulnerable time"
  1343. // EntityData1Ptrs[0]->InvulnerableTime = 60000;
  1344. // *(*((char**)&obj2->SonicSpinTimeProbably)) = 2; //it starts at 0 (init), then it goes to 1 (normal), where it checks if you're holding B, then it goes to 2 (activating laser), which goes to 3 (using laser), where it either checks if you release B, where it goes to 5 (shooting), or the timer runs out and it goes to 4 (time out) which goes to 6 (shooting after time out), and then I guess it goes back to 1
  1345. // }
  1346. // }
  1347. // }
  1348. // if (X_is_held && !(ControllerPointers[0]->HeldButtons & Buttons_X))
  1349. // {
  1350. // X_is_held = false;
  1351. // }
  1352. // else if (ControllerPointers[0]->HeldButtons & Buttons_X)
  1353. // {
  1354. // X_is_held = true;
  1355. // }
  1356. // }
  1357. // if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Gamma)
  1358. // {
  1359. // can_chaos_spear_again = 0;
  1360. // co2->Upgrades &= ~Upgrades_JetBooster;
  1361. // co2->PhysicsData.YOff = 5.4;
  1362. // if (X_is_held && !(ControllerPointers[0]->HeldButtons & Buttons_X))
  1363. // {
  1364. // X_is_held = false;
  1365. // }
  1366. // else if (ControllerPointers[0]->HeldButtons & Buttons_X)
  1367. // {
  1368. // X_is_held = true;
  1369. // }
  1370. // EntityData1Ptrs[0]->Action = 7;
  1371. // co2->AnimationThing.Index = 49;
  1372. // co2->PhysicsData.AirDecel = -0.128;
  1373. // co2->Speed.x = 0.0;
  1374. // co2->Speed.y = 0.1;
  1375. // co2->Speed.z = 0.0;
  1376. // if (!X_is_held && X_was_released < 2)
  1377. // {
  1378. // ++X_was_released;
  1379. // if (X_was_released > 1)
  1380. // {
  1381. // if ((*(char**)&co2->SonicSpinTimeProbably)[1] == 1)
  1382. // {
  1383. // didnt_target = true;
  1384. // }
  1385. // else
  1386. // {
  1387. // ready = true;
  1388. // can_go_back_to_shadow = true;
  1389. // didnt_target = false;
  1390. // }
  1391. // }
  1392. // }
  1393. // if (is_CB)
  1394. // {
  1395. // co2->Upgrades |= Upgrades_LaserBlaster;
  1396. // if (ready && chaos_spear_stop < 4)
  1397. // {
  1398. // if (++chaos_spear_stop == 4)
  1399. // {
  1400. // WriteData((void*)0x4C4643, shooting05_unNOP);
  1401. // WriteData((void*)0x4C475B, 0x90, 4); //to stop the shooting response
  1402. // }
  1403. // }
  1404. // }
  1405. // else
  1406. // {
  1407. // co2->Upgrades &= ~Upgrades_LaserBlaster;
  1408. // if (ready && chaos_spear_stop < 2)
  1409. // {
  1410. // if (++chaos_spear_stop == 2)
  1411. // {
  1412. // WriteData((void*)0x4C4643, shooting05_unNOP);
  1413. // WriteData((void*)0x4C475B, 0x90, 4); //to stop the shooting response
  1414. // }
  1415. // }
  1416. // }
  1417. // if (can_go_back_to_shadow && !didnt_target)
  1418. // {
  1419. // if (backtoshadow2 > 12 && ControllerPointers[0]->PressedButtons & Buttons_X)
  1420. // {
  1421. // pressed_X_while_Gamma = true;
  1422. // }
  1423. // ++backtoshadow2;
  1424. // if (backtoshadow2 > 3 && backtoshadow2 < 24)
  1425. // {
  1426. // WriteData((void*)0x4C4DA9, 0x90, 3); //disables aiming action
  1427. // }
  1428. // if (backtoshadow2 == 24)
  1429. // {
  1430. // WriteData((float**)0x4C41CD, &missilespeed_orig);
  1431. // WriteData((float**)0x4C41DC, &missilespeed_orig);
  1432. // WriteData((float**)0x4C41E8, &missilespeed_orig);
  1433. // WriteData((void*)0x4C4DA9, enable_aiming);
  1434. // }
  1435. // if (backtoshadow2 == 25)
  1436. // {
  1437. // *(*((char**)&co2->SonicSpinTimeProbably)) = 4;
  1438. // }
  1439. // if (backtoshadow2 == 26)
  1440. // {
  1441. // WriteData((void*)0x4C4DA9, 0x90, 3); //disables aiming action
  1442. // }
  1443. // if (backtoshadow2 == 27)
  1444. // {
  1445. // WriteData((char*)0x4CEA60, (char)0xC3);//removes the red/yellow squares
  1446. // *(*((char**)&co2->SonicSpinTimeProbably)) = 4;
  1447. // ObjectMaster *obj = GetCharacterObject(0);
  1448. // CharObj2 *obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1449. // short powerups = obj2->Powerups;
  1450. // short jumptime = obj2->JumpTime;
  1451. // short underwatertime = obj2->UnderwaterTime;
  1452. // float loopdist = obj2->LoopDist;
  1453. // NJS_VECTOR speed = obj2->Speed;
  1454. // ObjectMaster *heldobj = obj2->ObjectHeld;
  1455. // obj->DeleteSub(obj);
  1456. // obj->MainSub = Sonic_Main;
  1457. // obj->Data1->CharID = (char)Characters_Sonic;
  1458. // obj->Data1->Action = 0;
  1459. // obj->Data1->Status &= ~(Status_Attack | Status_Ball | Status_LightDash | Status_Unknown3);
  1460. // if (!oldcol)
  1461. // {
  1462. // oldcol = obj->Data1->CollisionInfo;
  1463. // obj->Data1->CollisionInfo = nullptr;
  1464. // }
  1465. // else
  1466. // Collision_Free(obj);
  1467. // obj->MainSub(obj); // ERROR : Exception thrown at 0x00440243 in sonic.exe: 0xC0000005: Access violation writing location 0x00000000.
  1468. // obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1469. // obj2->Powerups = powerups;
  1470. // obj2->JumpTime = jumptime;
  1471. // obj2->UnderwaterTime = underwatertime;
  1472. // obj2->LoopDist = loopdist;
  1473. // obj2->Speed = speed;
  1474. // obj2->ObjectHeld = heldobj;
  1475. // LoadSoundList(1);
  1476. // if (VoiceLanguage)
  1477. // LoadSoundList(72);
  1478. // else
  1479. // LoadSoundList(71);
  1480. // obj2->AnimationThing.Index = 119;
  1481. // can_go_back_to_shadow = false;
  1482. // chaos_spear_stop = 0;
  1483. // X_was_released = 0;
  1484. // EntityData1Ptrs[0]->InvulnerableTime = 0;
  1485. // cant_chaos_spear2 = true;
  1486. // cant_chaos_spear_again = true;
  1487. // }
  1488. // }
  1489. // if (didnt_target)
  1490. // {
  1491. // ++didnt_target_OK;
  1492. // }
  1493. // if (didnt_target_OK >= 2)
  1494. // {
  1495. // WriteData((char*)0x4CEA60, (char)0xC3);//removes the red/yellow squares
  1496. // *(*((char**)&co2->SonicSpinTimeProbably)) = 4;
  1497. // ObjectMaster *obj = GetCharacterObject(0);
  1498. // CharObj2 *obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1499. // short powerups = obj2->Powerups;
  1500. // short jumptime = obj2->JumpTime;
  1501. // short underwatertime = obj2->UnderwaterTime;
  1502. // float loopdist = obj2->LoopDist;
  1503. // NJS_VECTOR speed = obj2->Speed;
  1504. // ObjectMaster *heldobj = obj2->ObjectHeld;
  1505. // obj->DeleteSub(obj);
  1506. // obj->MainSub = Sonic_Main;
  1507. // obj->Data1->CharID = (char)Characters_Sonic;
  1508. // obj->Data1->Action = 0;
  1509. // obj->Data1->Status &= ~(Status_Attack | Status_Ball | Status_LightDash | Status_Unknown3);
  1510. // if (!oldcol)
  1511. // {
  1512. // oldcol = obj->Data1->CollisionInfo;
  1513. // obj->Data1->CollisionInfo = nullptr;
  1514. // }
  1515. // else
  1516. // Collision_Free(obj);
  1517. // obj->MainSub(obj);
  1518. // obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1519. // obj2->Powerups = powerups;
  1520. // obj2->JumpTime = jumptime;
  1521. // obj2->UnderwaterTime = underwatertime;
  1522. // obj2->LoopDist = loopdist;
  1523. // obj2->Speed = speed;
  1524. // obj2->ObjectHeld = heldobj;
  1525. // LoadSoundList(1);
  1526. // if (VoiceLanguage)
  1527. // LoadSoundList(72);
  1528. // else
  1529. // LoadSoundList(71);
  1530. // obj2->AnimationThing.Index = 119;
  1531. // can_go_back_to_shadow = false;
  1532. // chaos_spear_stop = 0;
  1533. // X_was_released = 0;
  1534. // EntityData1Ptrs[0]->InvulnerableTime = 0;
  1535. // cant_chaos_spear2 = true;
  1536. // didnt_target_OK = 0;
  1537. // cant_chaos_spear_again = true;
  1538. // }
  1539. // }
  1540. //}
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560. // TO DISABLE THE AIMING SYSTEM => 4C4DA9 - 0FBE06
  1561. //WriteData((void*)0x4C4DA9, enable_aiming);
  1562. //WriteData((void*)0x4C4DA9, 0x90, 3);
  1563.  
  1564.  
  1565. //MULTIPLE CHAOS SPEARS :
  1566. //When 3 shots have been made, NOP this => 4C475B - C6 46 01 03 and, once 60 frames have passed, set this to 4 => *(*((char**)&co2->SonicSpinTimeProbably)) = 4;
  1567.  
  1568.  
  1569. //*(*((char**)&co2->SonicSpinTimeProbably)) = 2; for chaos boost (to auto kill => this is just a test) AND AN IDEA => MAYBE HAVE IT TO SHOOT 2 AND 2 AND 2 etc => I THINK I WON'T USE THAT AFTER ALL.
  1570. //WriteData((void*)0x4C4F20, 0x90, 2); for chaos boost (to auto kill => this is just a test) AND AN IDEA
  1571.  
  1572. //(*(char**)&co2->SonicSpinTimeProbably)[1] => setting this to always 4 allow to shoot all at the same time
  1573.  
  1574. //if (ControllerPointers[0]->HeldButtons & Buttons_Y)
  1575. //{
  1576. // *(*((char**)&co2->SonicSpinTimeProbably)) = 2;
  1577. //}
  1578. //if (ControllerPointers[0]->HeldButtons & Buttons_Left)
  1579. //{
  1580. // *(*((char**)&co2->SonicSpinTimeProbably)) = 3;
  1581. //}
  1582. //if (ControllerPointers[0]->HeldButtons & Buttons_Right)
  1583. //{
  1584. // *(*((char**)&co2->SonicSpinTimeProbably)) = 4;
  1585. //}
  1586. //if (ControllerPointers[0]->HeldButtons & Buttons_Down)
  1587. //{
  1588. // *(*((char**)&co2->SonicSpinTimeProbably)) = 5;
  1589. //}
  1590. //if (ControllerPointers[0]->HeldButtons & Buttons_Up)
  1591. //{
  1592. // *(*((char**)&co2->SonicSpinTimeProbably)) = 6;
  1593. //}
  1594.  
  1595.  
  1596.  
  1597.  
  1598. //Knuckles Punches data
  1599. //co2->field_84 = 0;
  1600. //((short *)&co2->field_84)[1] = 0;
  1601. word_3C53606 = 0; //1st to 2nd no longer automatic
  1602. //word_3C53616 = 0; //2nd to 3rd no longer automatic
  1603. word_3C53626 = 0; //3rd to 4th and 5th no longer automatic
  1604.  
  1605.  
  1606.  
  1607. //Fix Shadow punching when releasing lightattack on nothing
  1608. if ((co1->Status & Status_LightDash) == Status_LightDash)
  1609. {
  1610. cant_punch_now = true;
  1611. }
  1612. if (((co1->Status & Status_LightDash) != Status_LightDash) && cant_punch_now)
  1613. {
  1614. if (++LD_punch == 2)
  1615. {
  1616. cant_punch_now = false;
  1617. }
  1618. }
  1619. else if (LD_punch != 0 && !cant_punch_now)
  1620. {
  1621. LD_punch = 0;
  1622. }
  1623.  
  1624. //ERRORS Exception thrown at 0x00473D42 in sonic.exe: 0xC0000005: Access violation reading location 0x00000000.
  1625. //ERROR : Exception thrown at 0x0040B374 in sonic.exe: 0xC0000005: Access violation writing location 0x80000000.
  1626. //Punching Action******************************************************** DOESNT KEEP THE SPEED SHOES; SUMMONS WAY TOO MUCH BUBBLES UNDERWATER AND SUMMON A BIG BUBBLE WHEN SWAPPING;
  1627. //FIX THAT STAYING KNUX WHEN PUNCHING INTO TRAMPOLINE
  1628. if (GameState == 4)
  1629. {
  1630. can_multi_punch = 0;
  1631. do_multi_punch = false;
  1632. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Knuckles)
  1633. {
  1634. no_z_speed = 1;
  1635. ObjectMaster *obj = GetCharacterObject(0);
  1636. CharObj2 *obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1637. short powerups = obj2->Powerups;
  1638. short jumptime = obj2->JumpTime;
  1639. short underwatertime = obj2->UnderwaterTime;
  1640. float loopdist = obj2->LoopDist;
  1641. NJS_VECTOR speed = obj2->Speed;
  1642. ObjectMaster *heldobj = obj2->ObjectHeld;
  1643. obj->DeleteSub(obj);
  1644. obj->MainSub = Sonic_Main;
  1645. obj->Data1->CharID = (char)Characters_Sonic;
  1646. obj->Data1->Action = 0;
  1647. obj->Data1->Status &= ~(Status_Attack | Status_Ball | Status_LightDash | Status_Unknown3);
  1648. if (!oldcol)
  1649. {
  1650. oldcol = obj->Data1->CollisionInfo;
  1651. obj->Data1->CollisionInfo = nullptr;
  1652. }
  1653. else
  1654. Collision_Free(obj);
  1655. obj->MainSub(obj);
  1656. obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1657. obj2->Powerups = powerups;
  1658. obj2->JumpTime = jumptime;
  1659. obj2->UnderwaterTime = underwatertime;
  1660. obj2->LoopDist = loopdist;
  1661. obj2->Speed = speed;
  1662. obj2->ObjectHeld = heldobj;
  1663. LoadSoundList(1);
  1664. if (VoiceLanguage)
  1665. LoadSoundList(72);
  1666. else
  1667. LoadSoundList(71);
  1668. EntityData1Ptrs[0]->InvulnerableTime = 0;
  1669. }
  1670. }
  1671. if (GameState == 15 && !cant_punch_now)
  1672. {
  1673. if (co2 == NULL) return;
  1674. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  1675. {
  1676. WriteData((void*)0x4780EE, enable_SONIC_KNUXflashing);
  1677. if (no_z_speed > 0)
  1678. {
  1679. co2->Speed.z = 0; //Fix the side speed after punching
  1680. if (++no_z_speed == 30)
  1681. {
  1682. no_z_speed = 0;
  1683. }
  1684. }
  1685. if (backtoshadow1 > 0)
  1686. {
  1687. ++backtoshadow1;
  1688. }
  1689. if (backtoshadow1 > 2)
  1690. {
  1691. //co2->Powerups &= ~Powerups_Invincibility;
  1692. backtoshadow1 = 0;
  1693. }
  1694. if (EntityData1Ptrs[0]->Action == 5) just_rolled = true;
  1695. if (EntityData1Ptrs[0]->Action == 8 || co2->Speed.x <= 0.46) just_rolled = false;
  1696. if (just_rolled && ControllerPointers[0]->PressedButtons & Buttons_X) ++justrolled;
  1697. if (justrolled == 2)
  1698. {
  1699. just_rolled = false;
  1700. justrolled = 0;
  1701. }
  1702. if (EntityData1Ptrs[0]->Action != 4 && EntityData1Ptrs[0]->Action != 5 && (co2->AnimationThing.Index == 0 || co2->AnimationThing.Index == 1 || co2->AnimationThing.Index == 2 || co2->AnimationThing.Index == 3 || co2->AnimationThing.Index == 4 || co2->AnimationThing.Index == 5 || co2->AnimationThing.Index == 6 || co2->AnimationThing.Index == 7 || co2->AnimationThing.Index == 8 || co2->AnimationThing.Index == 9 || co2->AnimationThing.Index == 10 || co2->AnimationThing.Index == 11 || co2->AnimationThing.Index == 12 || co2->AnimationThing.Index == 13 || co2->AnimationThing.Index == 14 || co2->AnimationThing.Index == 20 || co2->AnimationThing.Index == 25 || co2->AnimationThing.Index == 31 || co2->AnimationThing.Index == 44 || co2->AnimationThing.Index == 45 || co2->AnimationThing.Index == 71 || co2->AnimationThing.Index == 130))
  1703. {
  1704. if (ControllerPointers[0]->HeldButtons & Buttons_X && (co1->Status & Status_LightDash) != Status_LightDash && !just_rolled)
  1705. {
  1706. no_longer_punching = 0;
  1707. ++punchattack;
  1708. }
  1709. if (!just_rolled && punchattack < 30 && ControllerPointers[0]->ReleasedButtons & Buttons_X)
  1710. {
  1711. WriteData((void*)0x47A8E0, knuxobjectcrash_NOP);
  1712. ObjectMaster *obj = GetCharacterObject(0);
  1713. CharObj2 *obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1714. short powerups = obj2->Powerups;
  1715. short jumptime = obj2->JumpTime;
  1716. short underwatertime = obj2->UnderwaterTime;
  1717. float loopdist = obj2->LoopDist;
  1718. NJS_VECTOR speed = obj2->Speed;
  1719. ObjectMaster *heldobj = obj2->ObjectHeld;
  1720. obj->DeleteSub(obj);
  1721. obj->MainSub = Knuckles_Main;
  1722. obj->Data1->CharID = (char)Characters_Knuckles;
  1723. obj->Data1->Action = 0;
  1724. obj->Data1->Status &= ~(Status_Attack | Status_Ball | Status_LightDash | Status_Unknown3);
  1725. if (!oldcol)
  1726. {
  1727. oldcol = obj->Data1->CollisionInfo;
  1728. obj->Data1->CollisionInfo = nullptr;
  1729. }
  1730. else
  1731. Collision_Free(obj);
  1732. obj->MainSub(obj);
  1733. obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1734. obj2->PhysicsData.YOff = 5.4;
  1735. obj2->PhysicsData.CameraY = 7.0;
  1736. obj2->Powerups = powerups;
  1737. obj2->JumpTime = jumptime;
  1738. obj2->UnderwaterTime = underwatertime;
  1739. obj2->LoopDist = loopdist;
  1740. obj2->Speed = speed;
  1741. obj2->ObjectHeld = heldobj;
  1742. LoadSoundList(49);
  1743. if (VoiceLanguage)
  1744. {
  1745. LoadSoundList(70);
  1746. LoadSoundList(58);
  1747. }
  1748. else
  1749. {
  1750. LoadSoundList(69);
  1751. LoadSoundList(57);
  1752. }
  1753. EntityData1Ptrs[0]->Action = 26;
  1754. co2->AnimationThing.Index = 54;
  1755. //co2->Powerups |= Powerups_Invincibility;
  1756. EntityData1Ptrs[0]->InvulnerableTime = 60000;
  1757. }
  1758. }
  1759. }
  1760. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Knuckles)
  1761. {
  1762. ++can_multi_punch;
  1763. WriteData((void*)0x4780EE, 0x90, 4); //make knuckles not flash when "invulnerable time"
  1764. if (co2->AnimationThing.Index == 54 || co2->AnimationThing.Index == 55 || co2->AnimationThing.Index == 56)
  1765. {
  1766. co2->Speed.z = 0;
  1767. }
  1768. punchattack = 0;
  1769. if (no_longer_punching >= 0 && no_longer_punching < 4)
  1770. {
  1771. //co2->Powerups |= Powerups_Invincibility;
  1772. EntityData1Ptrs[0]->Action = 26;
  1773. co2->AnimationThing.Index = 54;
  1774. }
  1775. ++no_longer_punching;
  1776. if (no_longer_punching > 15 && (co2->AnimationThing.Index == 0 || co2->AnimationThing.Index == 9 || co2->AnimationThing.Index == 10 || co2->AnimationThing.Index == 11 || co2->AnimationThing.Index == 12 || co2->AnimationThing.Index == 13))
  1777. {
  1778. if (++backtoshadow1 == 2)
  1779. {
  1780. no_z_speed = 1;
  1781. ObjectMaster *obj = GetCharacterObject(0);
  1782. CharObj2 *obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1783. short powerups = obj2->Powerups;
  1784. short jumptime = obj2->JumpTime;
  1785. short underwatertime = obj2->UnderwaterTime;
  1786. float loopdist = obj2->LoopDist;
  1787. NJS_VECTOR speed = obj2->Speed;
  1788. ObjectMaster *heldobj = obj2->ObjectHeld;
  1789. obj->DeleteSub(obj);
  1790. obj->MainSub = Sonic_Main;
  1791. obj->Data1->CharID = (char)Characters_Sonic;
  1792. obj->Data1->Action = 0;
  1793. obj->Data1->Status &= ~(Status_Attack | Status_Ball | Status_LightDash | Status_Unknown3);
  1794. if (!oldcol)
  1795. {
  1796. oldcol = obj->Data1->CollisionInfo;
  1797. obj->Data1->CollisionInfo = nullptr;
  1798. }
  1799. else
  1800. Collision_Free(obj);
  1801. obj->MainSub(obj);
  1802. obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1803. obj2->Powerups = powerups;
  1804. obj2->JumpTime = jumptime;
  1805. obj2->UnderwaterTime = underwatertime;
  1806. obj2->LoopDist = loopdist;
  1807. obj2->Speed = speed;
  1808. obj2->ObjectHeld = heldobj;
  1809. LoadSoundList(1);
  1810. if (VoiceLanguage)
  1811. LoadSoundList(72);
  1812. else
  1813. LoadSoundList(71);
  1814. EntityData1Ptrs[0]->InvulnerableTime = 0;
  1815. can_multi_punch = 0;
  1816. do_multi_punch = false;
  1817. //WriteData((void*)0x47A8E0, knuxobjectcrash_unNOP);
  1818. //co2->Powerups &= ~Powerups_Invincibility;
  1819. }
  1820. }
  1821. if (co2->AnimationThing.Index == 17 || co2->AnimationThing.Index == 18 || co2->AnimationThing.Index == 19 || co2->AnimationThing.Index == 34 || co2->AnimationThing.Index == 51)
  1822. {
  1823. no_z_speed = 1;
  1824. ObjectMaster *obj = GetCharacterObject(0);
  1825. CharObj2 *obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1826. short powerups = obj2->Powerups;
  1827. short jumptime = obj2->JumpTime;
  1828. short underwatertime = obj2->UnderwaterTime;
  1829. float loopdist = obj2->LoopDist;
  1830. NJS_VECTOR speed = obj2->Speed;
  1831. ObjectMaster *heldobj = obj2->ObjectHeld;
  1832. obj->DeleteSub(obj);
  1833. obj->MainSub = Sonic_Main;
  1834. obj->Data1->CharID = (char)Characters_Sonic;
  1835. obj->Data1->Action = 0;
  1836. obj->Data1->Status &= ~(Status_Attack | Status_Ball | Status_LightDash | Status_Unknown3);
  1837. if (!oldcol)
  1838. {
  1839. oldcol = obj->Data1->CollisionInfo;
  1840. obj->Data1->CollisionInfo = nullptr;
  1841. }
  1842. else
  1843. Collision_Free(obj);
  1844. obj->MainSub(obj);
  1845. obj2 = ((EntityData2 *)obj->Data2)->CharacterData;
  1846. obj2->Powerups = powerups;
  1847. obj2->JumpTime = jumptime;
  1848. obj2->UnderwaterTime = underwatertime;
  1849. obj2->LoopDist = loopdist;
  1850. obj2->Speed = speed;
  1851. obj2->ObjectHeld = heldobj;
  1852. LoadSoundList(1);
  1853. if (VoiceLanguage)
  1854. LoadSoundList(72);
  1855. else
  1856. LoadSoundList(71);
  1857. EntityData1Ptrs[0]->InvulnerableTime = 0;
  1858. can_multi_punch = 0;
  1859. do_multi_punch = false;
  1860. //WriteData((void*)0x47A8E0, knuxobjectcrash_unNOP);
  1861. //co2->Powerups &= ~Powerups_Invincibility;
  1862. }
  1863. }
  1864. }
  1865.  
  1866.  
  1867. //Shadow's Spindash => OK
  1868. if (EntityData1Ptrs[0]->Action == 4)
  1869. {
  1870. WriteData((float*)0x496F23, (float)1.7f);
  1871. WriteData((float*)0x7DCB34, (float)8.5f);
  1872. WriteData((float*)0x7DD550, (float)0.34f);
  1873. }
  1874. else
  1875. {
  1876. WriteData((float*)0x496F23, (float)2.0f);
  1877. WriteData((float*)0x7DCB34, (float)10.0f);
  1878. WriteData((float*)0x7DD550, (float)0.4f);
  1879. }
  1880.  
  1881.  
  1882.  
  1883. //Try fixing the punching using the same 2P CPU technique !
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889. //FOR THE MODEL ANIMATION => try loading them all at once, and just swap from one another to avoid lag
  1890. //Use MainMemory's PlayVoice lag fix
  1891.  
  1892.  
  1893.  
  1894. ////Chaos Spear Action (no chaos boost) NEW****************************
  1895. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Amy)
  1896. {
  1897. if (GameState == 4)
  1898. {
  1899. backtoshadow2 = 0;
  1900. can_go_back_to_shadow = false;
  1901. chaos_spear_stop = 0;
  1902. WriteData((void*)0x4C4DA9, enable_aiming);
  1903. WriteData((void*)0x4C475B, enable_shooting);
  1904. WriteData((void*)0x48152E, enable_GAMMAflashing);
  1905. didnt_target = false;
  1906. ready = false;
  1907. X_was_released = 0;
  1908. cant_chaos_spear2 = false;
  1909. DO_chaos_spear_again = false;
  1910. pressed_X_while_Gamma = false;
  1911. gonna_chaos_spear_again = 0;
  1912. }
  1913. if ((co1->Status & Status_Ground) == Status_Ground)
  1914. {
  1915. DO_chaos_spear_again = false;
  1916. }
  1917. if (GameState == 15)
  1918. {
  1919. if (co2 == NULL) return;
  1920. if (is_CB)
  1921. {
  1922. Gamma_LaserBlasterObtained = 1;
  1923. }
  1924. else Gamma_LaserBlasterObtained = 0;
  1925. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  1926. {
  1927. if (cant_chaos_spear_again)
  1928. {
  1929. if (++can_chaos_spear_again >= 2)
  1930. {
  1931. cant_chaos_spear_again = false;
  1932. can_chaos_spear_again = 0;
  1933. }
  1934. }
  1935. if (pressed_X_while_Gamma)
  1936. {
  1937. if (++gonna_chaos_spear_again >= 2)
  1938. {
  1939. DO_chaos_spear_again = true;
  1940. pressed_X_while_Gamma = false;
  1941. gonna_chaos_spear_again = 0;
  1942. }
  1943. }
  1944. if (ControllerPointers[0]->PressedButtons & Buttons_Z && !is_CB)
  1945. {
  1946. is_CB = true;
  1947. }
  1948. else if (ControllerPointers[0]->PressedButtons & Buttons_Z && is_CB)
  1949. {
  1950. is_CB = false;
  1951. }
  1952. WriteData((void*)0x48152E, enable_GAMMAflashing);
  1953. co2->PhysicsData.AirDecel = -0.028;
  1954. WriteData((void*)0x4C4DA9, enable_aiming);
  1955. WriteData((void*)0x4C475B, enable_shooting);
  1956. WriteData((void*)0x4C4643, 0x90, 4); //C6 46 01 05 - To make shooting action not go to 5, making instant shooting happen********************************************************
  1957. WriteData((char*)0x4CEA60, (char)0xC3);//removes the red/yellow squares
  1958. ready = false;
  1959. if (backtoshadow2 >= 27)
  1960. {
  1961. if (++backtoshadow2 == 29)
  1962. {
  1963. EntityData1Ptrs[0]->Action = 8;
  1964. co2->AnimationThing.Index = 119;
  1965. co1->Status |= Status_Ball;
  1966. backtoshadow2 = 0;
  1967. cant_chaos_spear2 = false;
  1968. }
  1969. }
  1970. if (didnt_target)
  1971. {
  1972. EntityData1Ptrs[0]->Action = 8;
  1973. co2->AnimationThing.Index = 18;
  1974. co1->Status |= Status_Ball;
  1975. if (++backtoshadow2 == 2)
  1976. {
  1977. backtoshadow2 = 0;
  1978. didnt_target = false;
  1979. cant_chaos_spear2 = false;
  1980. }
  1981. }
  1982. if ((co1->Status & Status_Ground) != Status_Ground && (co2->AnimationThing.Index == 14 || co2->AnimationThing.Index == 18 || co2->AnimationThing.Index == 116 || co2->AnimationThing.Index == 117 || co2->AnimationThing.Index == 119))
  1983. {
  1984. if (EntityData1Ptrs[0]->Action == 8 && !cant_chaos_spear && !cant_chaos_spear2 && !cant_chaos_spear_again) // && (co2->AnimationThing.Index == 14 || co2->AnimationThing.Index == 18)
  1985. {
  1986. if ((!X_is_held && ControllerPointers[0]->HeldButtons & Buttons_X) || (DO_chaos_spear_again)) // fix to have it false when onground !! and fix anyway that stuff
  1987. {
  1988. //turn to gamma
  1989. // *(*((char**)&obj2->SonicSpinTimeProbably)) = 2; //it starts at 0 (init), then it goes to 1 (normal), where it checks if you're holding B, then it goes to 2 (activating laser), which goes to 3 (using laser), where it either checks if you release B, where it goes to 5 (shooting), or the timer runs out and it goes to 4 (time out) which goes to 6 (shooting after time out), and then I guess it goes back to 1
  1990. }
  1991. }
  1992. }
  1993. if (X_is_held && !(ControllerPointers[0]->HeldButtons & Buttons_X))
  1994. {
  1995. X_is_held = false;
  1996. }
  1997. else if (ControllerPointers[0]->HeldButtons & Buttons_X)
  1998. {
  1999. X_is_held = true;
  2000. }
  2001. }
  2002. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Gamma)
  2003. {
  2004. can_chaos_spear_again = 0;
  2005. co2->Upgrades &= ~Upgrades_JetBooster;
  2006. co2->PhysicsData.YOff = 5.4;
  2007. if (X_is_held && !(ControllerPointers[0]->HeldButtons & Buttons_X))
  2008. {
  2009. X_is_held = false;
  2010. }
  2011. else if (ControllerPointers[0]->HeldButtons & Buttons_X)
  2012. {
  2013. X_is_held = true;
  2014. }
  2015. EntityData1Ptrs[0]->Action = 7;
  2016. co2->AnimationThing.Index = 49;
  2017. co2->PhysicsData.AirDecel = -0.128;
  2018. co2->Speed.x = 0.0;
  2019. co2->Speed.y = 0.1;
  2020. co2->Speed.z = 0.0;
  2021. if (!X_is_held && X_was_released < 2)
  2022. {
  2023. ++X_was_released;
  2024. if (X_was_released > 1)
  2025. {
  2026. if ((*(char**)&co2->SonicSpinTimeProbably)[1] == 1)
  2027. {
  2028. didnt_target = true;
  2029. }
  2030. else
  2031. {
  2032. ready = true;
  2033. can_go_back_to_shadow = true;
  2034. didnt_target = false;
  2035. }
  2036. }
  2037. }
  2038. if (is_CB)
  2039. {
  2040. co2->Upgrades |= Upgrades_LaserBlaster;
  2041. if (ready && chaos_spear_stop < 4)
  2042. {
  2043. if (++chaos_spear_stop == 4)
  2044. {
  2045. WriteData((void*)0x4C4643, shooting05_unNOP);
  2046. WriteData((void*)0x4C475B, 0x90, 4); //to stop the shooting response
  2047. }
  2048. }
  2049. }
  2050. else
  2051. {
  2052. co2->Upgrades &= ~Upgrades_LaserBlaster;
  2053. if (ready && chaos_spear_stop < 2)//****************************************
  2054. {
  2055. if (++chaos_spear_stop == 2)
  2056. {
  2057. WriteData((void*)0x4C4643, shooting05_unNOP);
  2058. WriteData((void*)0x4C475B, 0x90, 4); //to stop the shooting response
  2059. }
  2060. }
  2061. }
  2062. if (can_go_back_to_shadow && !didnt_target)
  2063. {
  2064. if (backtoshadow2 > 12 && ControllerPointers[0]->PressedButtons & Buttons_X)
  2065. {
  2066. pressed_X_while_Gamma = true;
  2067. }
  2068. ++backtoshadow2;
  2069. if (backtoshadow2 > 3 && backtoshadow2 < 24)
  2070. {
  2071. WriteData((void*)0x4C4DA9, 0x90, 3); //disables aiming action
  2072. }
  2073. if (backtoshadow2 == 24)
  2074. {
  2075. WriteData((float**)0x4C41CD, &missilespeed_orig);
  2076. WriteData((float**)0x4C41DC, &missilespeed_orig);
  2077. WriteData((float**)0x4C41E8, &missilespeed_orig);
  2078. WriteData((void*)0x4C4DA9, enable_aiming);
  2079. }
  2080. if (backtoshadow2 == 25)
  2081. {
  2082. *(*((char**)&co2->SonicSpinTimeProbably)) = 4;
  2083. }
  2084. if (backtoshadow2 == 26)
  2085. {
  2086. WriteData((void*)0x4C4DA9, 0x90, 3); //disables aiming action
  2087. }
  2088. if (backtoshadow2 == 27)
  2089. {
  2090. //back to sonic
  2091. }
  2092. }
  2093. if (didnt_target)
  2094. {
  2095. ++didnt_target_OK;
  2096. }
  2097. if (didnt_target_OK >= 2)
  2098. {
  2099. //back to sonic
  2100. }
  2101. }
  2102. }
  2103. }
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. //******************************DO THE IF PRESSED X WHILE IN END OF CHAOS SPEAR THEN REDO CHAOS SPEAR ...???? REALLY DO I NEED IT ?
  2117. //Chaos Spear Action
  2118. Gamma_JetBoosterObtained = 0;
  2119. WriteData((ObjectFuncPtr*)0x47EDC1, Gamma_Main);
  2120. //*****Have that same CPU always there, in any level or adventure field, whenever Sonic is played as, that CPU must be here too
  2121. WriteData((short*)0x4C4E34, (short)30000);//Gamma infinite aiming laser timer
  2122. //*****Disable all Gamma sounds;
  2123. //*****Disable Gamma "5,4,3,2,1 sec left" textures;
  2124. //*****Make Gamma laser invisible;
  2125. //WriteData((char*)0x4CEA60, (char)0xC3);//removes the red/yellow squares
  2126. WriteData((void*)0x42667F, 0x90, 5);//Stop the timer from going up when killing enemies as gamma
  2127. //*****Disable Gamma's timebonuses (sounds and textures);
  2128. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0 && GetCharacterObject(1) && GetCharacterID(1) == Characters_Gamma)
  2129. {
  2130. WriteData((void*)0x4C4643, 0x90, 4); //C6 46 01 05 - To make shooting action not go to 5, making instant shooting happen********************************************************
  2131. WriteData((float**)0x4C41CD, &missilespeed);
  2132. WriteData((float**)0x4C41DC, &missilespeed);
  2133. WriteData((float**)0x4C41E8, &missilespeed);
  2134. if (GameState == 4)
  2135. {
  2136. WriteData((void*)0x4C4DA9, enable_aiming);
  2137. WriteData((void*)0x4C475B, enable_shooting);
  2138. //*****load normal shadow model;
  2139. go_back_to_gameplay = false;
  2140. ((AnimData_t*)0x3C56210)[18].AnimationSpeed = 1;
  2141. CS_launch_was_played = false;
  2142. CS_charging_was_played = false;
  2143. CS_empty_was_played = false;
  2144. is_in_CS_state = false;
  2145. X_was_released = false;
  2146. can_go_back_to_shadow = false;
  2147. co1CPU->Position.x = 500 + co1->Position.x;
  2148. co1CPU->Position.y = 500 + co1->Position.y;
  2149. co1CPU->Position.z = 500 + co1->Position.z;
  2150. WriteData((char*)0x4977AB, (char)0x74);//Allows homing attack
  2151. WriteData((void*)0x497013, enable_SONIC_KNUXflashing);
  2152. EntityData1Ptrs[0]->InvulnerableTime = 0;
  2153. has_homing_attacked = false;
  2154. WriteData((void*)0x43CC72, gravity_orig_hovering);
  2155. co2->PhysicsData.Gravity = 0.08;
  2156. Gamma_JetBoosterObtained = 0;
  2157. X_was_released_int = 0;
  2158. ready = false;
  2159. chaos_spear_stop = 0;
  2160. cant_release_X = 0;
  2161. //Gauge = 0;
  2162. }
  2163. if (GameState == 15)
  2164. {
  2165. Gamma_JetBoosterObtained = 0;
  2166. int anims2[]{ 116, 117, 119 };
  2167. EntityData1Ptrs[1]->InvulnerableTime = 65530;
  2168. co2CPU->Speed.x = 0;
  2169. co2CPU->Speed.y = 0;
  2170. co2CPU->Speed.z = 0;
  2171. EntityData1Ptrs[1]->Action = 7;
  2172. co2CPU->AnimationThing.Index = 8;
  2173. if (EntityData1Ptrs[0]->Action == 14)
  2174. {
  2175. has_homing_attacked = true;
  2176. }
  2177. if ((co1->Status & Status_Ground) == Status_Ground || co2->AnimationThing.Index == 0 || co2->AnimationThing.Index == 1 || co2->AnimationThing.Index == 2 || co2->AnimationThing.Index == 3 || co2->AnimationThing.Index == 4 || co2->AnimationThing.Index == 5 || co2->AnimationThing.Index == 6 || co2->AnimationThing.Index == 7 || co2->AnimationThing.Index == 8 || co2->AnimationThing.Index == 9 || co2->AnimationThing.Index == 10 || co2->AnimationThing.Index == 11 || co2->AnimationThing.Index == 12 || co2->AnimationThing.Index == 13 || co2->AnimationThing.Index == 14 || co2->AnimationThing.Index == 20 || co2->AnimationThing.Index == 25 || co2->AnimationThing.Index == 31 || co2->AnimationThing.Index == 71 || co2->AnimationThing.Index == 130 || co2->AnimationThing.Index == 131 || EntityData1Ptrs[0]->Action == 8 || EntityData1Ptrs[0]->Action == 6)
  2178. {
  2179. has_homing_attacked = false;
  2180. }
  2181. if ((co2->AnimationThing.Index == 14 || co2->AnimationThing.Index == 18 || co2->AnimationThing.Index == 116 || co2->AnimationThing.Index == 117 || co2->AnimationThing.Index == 119) && (EntityData1Ptrs[0]->Action != 4 && EntityData1Ptrs[0]->Action != 5 && EntityData1Ptrs[0]->Action != 14 && EntityData1Ptrs[0]->Action != 44) && !is_in_CS_state && !has_homing_attacked && (co1->Status & Status_LightDash) != Status_LightDash)
  2182. {
  2183. if (/*Gauge > 0 && */ControllerPointers[0]->PressedButtons & Buttons_X)
  2184. {
  2185. co1->Status &= ~Status_Ball;
  2186. co1->Status &= ~Status_Attack;
  2187. ((AnimData_t*)0x3C56210)[18].AnimationSpeed = 0;
  2188. EntityData1Ptrs[0]->Action = 12;
  2189. co2->AnimationThing.Index = 18;
  2190. is_in_CS_state = true;
  2191. WriteData((void*)0x4C4DA9, enable_aiming);
  2192. }
  2193. }
  2194. if (is_in_CS_state)
  2195. {
  2196. EntityData1Ptrs[1]->Action = 7;
  2197. co2CPU->AnimationThing.Index = 8;
  2198. co1CPU->Position.x = old_X_position;
  2199. co1CPU->Position.y = old_Y_position;
  2200. co1CPU->Position.z = old_Z_position;
  2201. co1CPU->Rotation.x = co1->Rotation.x;
  2202. co1CPU->Rotation.y = co1->Rotation.y;
  2203. co1CPU->Rotation.z = co1->Rotation.z;
  2204. WriteData((char*)0x4977AB, (char)0xEB);//disables homing attack
  2205. co1->Position.x = old_X_position;
  2206. co1->Position.y = old_Y_position;
  2207. co1->Position.z = old_Z_position;
  2208. co2->Speed.x = 0.0;
  2209. co2->Speed.y = 0.0;
  2210. co2->Speed.z = 0.0;
  2211. WriteData((void*)0x43CC72, 0x90, 6); //Allow gravity change for P1
  2212. co2->PhysicsData.Gravity = 0.0;
  2213. if (EntityData1Ptrs[0]->InvulnerableTime == 0)
  2214. {
  2215. WriteData((void*)0x497013, 0x90, 4);//disable sonic flashing when "invulnerable time"
  2216. EntityData1Ptrs[0]->InvulnerableTime = 32760;
  2217. }
  2218. if (!CS_charging_was_played)
  2219. {
  2220. PlayVoice(1323);
  2221. CS_charging_was_played = true;
  2222. }
  2223. if (!(ControllerPointers[0]->HeldButtons & Buttons_X))
  2224. {
  2225. X_was_released = true;
  2226. }
  2227. if (X_was_released)
  2228. {
  2229. if (X_was_released_int < 2)
  2230. {
  2231. ++X_was_released_int;
  2232. if (X_was_released_int > 1)
  2233. {
  2234. if (thing->ShootAction == 1)
  2235. {
  2236. go_back_to_gameplay = true;
  2237. }
  2238. else
  2239. {
  2240. PlaySound(775, 0, 0, 0);
  2241. CS_launch_was_played = true;
  2242. ready = true;
  2243. can_go_back_to_shadow = true;
  2244. }
  2245. }
  2246. }
  2247. if (CB_lv2 || CB_lv3)
  2248. {
  2249. co2->Upgrades |= Upgrades_LaserBlaster;
  2250. if (LV2_active || LV3_active)
  2251. {
  2252. if (ready && chaos_spear_stop < 5)
  2253. {
  2254. if (++chaos_spear_stop == 5)
  2255. {
  2256. WriteData((void*)0x4C4643, shooting05_unNOP);
  2257. WriteData((void*)0x4C475B, 0x90, 4); //to stop the shooting response
  2258. CS_launch_was_played = false;
  2259. }
  2260. }
  2261. }
  2262. else
  2263. {
  2264. if (ready && chaos_spear_stop < 3)
  2265. {
  2266. if (++chaos_spear_stop == 3)
  2267. {
  2268. WriteData((void*)0x4C4643, shooting05_unNOP);
  2269. WriteData((void*)0x4C475B, 0x90, 4); //to stop the shooting response
  2270. CS_launch_was_played = false;
  2271. }
  2272. }
  2273. }
  2274. }
  2275. else
  2276. {
  2277. co2->Upgrades &= ~Upgrades_LaserBlaster;
  2278. if (LV2_active || LV3_active)
  2279. {
  2280. if (ready && chaos_spear_stop < 2)
  2281. {
  2282. if (++chaos_spear_stop == 2)
  2283. {
  2284. WriteData((void*)0x4C4643, shooting05_unNOP);
  2285. WriteData((void*)0x4C475B, 0x90, 4); //to stop the shooting response
  2286. CS_launch_was_played = false;
  2287. }
  2288. }
  2289. }
  2290. else
  2291. {
  2292. if (ready && chaos_spear_stop < 1)
  2293. {
  2294. if (++chaos_spear_stop == 1)
  2295. {
  2296. WriteData((void*)0x4C4643, shooting05_unNOP);
  2297. WriteData((void*)0x4C475B, 0x90, 4); //to stop the shooting response
  2298. CS_launch_was_played = false;
  2299. }
  2300. }
  2301. }
  2302. }
  2303. if (can_go_back_to_shadow)
  2304. {
  2305. ++backtoshadow2;
  2306. if (backtoshadow2 > 3 && backtoshadow2 < 16)
  2307. {
  2308. WriteData((void*)0x4C4DA9, 0x90, 3); //disables aiming action
  2309. }
  2310. if (backtoshadow2 == 16)
  2311. {
  2312. //WriteData((float**)0x4C41CD, &missilespeed_orig);
  2313. //WriteData((float**)0x4C41DC, &missilespeed_orig);
  2314. //WriteData((float**)0x4C41E8, &missilespeed_orig);
  2315. WriteData((void*)0x4C4DA9, enable_aiming);
  2316. }
  2317. if (backtoshadow2 == 17)
  2318. {
  2319. thing->AimAction = 4;
  2320. }
  2321. if (backtoshadow2 == 18)
  2322. {
  2323. WriteData((void*)0x4C4DA9, 0x90, 3); //disables aiming action
  2324. go_back_to_gameplay = true;
  2325. }
  2326. }
  2327. if (!CS_empty_was_played)
  2328. {
  2329. PlayVoice(1321);
  2330. CS_empty_was_played = true;
  2331. }
  2332. if (go_back_to_gameplay)
  2333. {
  2334. fall_after_roll = false;
  2335. X_was_released_int = 0;
  2336. chaos_spear_stop = 0;
  2337. ready = false;
  2338. can_go_back_to_shadow = false;
  2339. backtoshadow2 = 0;
  2340. //load normal shadow model;
  2341. go_back_to_gameplay = false;
  2342. ((AnimData_t*)0x3C56210)[18].AnimationSpeed = 1;
  2343. CS_charging_was_played = false;
  2344. CS_launch_was_played = false;
  2345. CS_empty_was_played = false;
  2346. is_in_CS_state = false;
  2347. X_was_released = false;
  2348. if (has_homing_attacked)
  2349. {
  2350. EntityData1Ptrs[0]->Action = 12;
  2351. co2->AnimationThing.Index = 18;
  2352. }
  2353. else
  2354. {
  2355. EntityData1Ptrs[0]->Action = 8;
  2356. co1->Status |= Status_Ball;
  2357. co1->Status |= Status_Attack;
  2358. }
  2359. }
  2360. }
  2361. }
  2362. else
  2363. {
  2364. cant_release_X = 0;
  2365. if (GetCharacterObject(1) && GetCharacterID(1) == Characters_Gamma)
  2366. {
  2367. co1CPU->Position.x = 500 + co1->Position.x;
  2368. co1CPU->Position.y = 500 + co1->Position.y;
  2369. co1CPU->Position.z = 500 + co1->Position.z;
  2370. }
  2371. WriteData((void*)0x43CC72, gravity_orig_hovering);
  2372. if (co2->_struct_a3.ColFlagsA & ColFlags_Water)
  2373. {
  2374. co2->PhysicsData.Gravity = 0.032;
  2375. }
  2376. else co2->PhysicsData.Gravity = 0.08;
  2377. if (EntityData1Ptrs[0]->InvulnerableTime > 200)
  2378. {
  2379. WriteData((void*)0x497013, enable_SONIC_KNUXflashing);
  2380. EntityData1Ptrs[0]->InvulnerableTime = 0;
  2381. }
  2382. WriteData((char*)0x4977AB, (char)0x74);//Allows Homing Attack
  2383. old_X_position = co1->Position.x;
  2384. old_Y_position = co1->Position.y;
  2385. old_Z_position = co1->Position.z;
  2386. }
  2387. }
  2388. }
  2389. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Knuckles)
  2390. {
  2391. co1CPU->Position.x = 500 + co1->Position.x;
  2392. co1CPU->Position.y = 500 + co1->Position.y;
  2393. co1CPU->Position.z = 500 + co1->Position.z;
  2394. }
  2395.  
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404. ////FIX SUPER/HYPER TRANSFORMATION => They can homing attack while transforming
  2405.  
  2406.  
  2407. //Chaos Blast Action
  2408. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  2409. {
  2410. if (GameState == 4)
  2411. {
  2412. using_chaos_blast = false;
  2413. chaos_blast_active_timer = 0;
  2414. CHAOSBLAST_was_played = false;
  2415. WriteData((void*)0x43CC72, gravity_orig_hovering);
  2416. co2->PhysicsData.Gravity = 0.08;
  2417. }
  2418. if (GameState == 15)
  2419. {
  2420. if (CB_lv3)
  2421. {
  2422. if (EntityData1Ptrs[0]->Action != 16 && EntityData1Ptrs[0]->Action != 86 && EntityData1Ptrs[0]->Action != 44 && co2->AnimationThing.Index != 33 && co2->AnimationThing.Index != 34 && co2->AnimationThing.Index != 35 && co2->AnimationThing.Index != 36 && co2->AnimationThing.Index != 37 && co2->AnimationThing.Index != 38 && co2->AnimationThing.Index != 47 && co2->AnimationThing.Index != 48 && co2->AnimationThing.Index != 49 && co2->AnimationThing.Index != 50 && co2->AnimationThing.Index != 51 && co2->AnimationThing.Index != 52 && co2->AnimationThing.Index != 53 && co2->AnimationThing.Index != 54 && co2->AnimationThing.Index != 55 && co2->AnimationThing.Index != 56 && co2->AnimationThing.Index != 57 && co2->AnimationThing.Index != 58 && co2->AnimationThing.Index != 59 && co2->AnimationThing.Index != 60 && co2->AnimationThing.Index != 61 && co2->AnimationThing.Index != 62 && co2->AnimationThing.Index != 63 && co2->AnimationThing.Index != 65 && co2->AnimationThing.Index != 66 && co2->AnimationThing.Index != 67 && co2->AnimationThing.Index != 68 && co2->AnimationThing.Index != 69 && co2->AnimationThing.Index != 70 && co2->AnimationThing.Index != 71 && co2->AnimationThing.Index != 72 && co2->AnimationThing.Index != 73 && co2->AnimationThing.Index != 74 && co2->AnimationThing.Index != 75 && co2->AnimationThing.Index != 76 && co2->AnimationThing.Index != 77 && co2->AnimationThing.Index != 78 && co2->AnimationThing.Index != 79 && co2->AnimationThing.Index != 80 && co2->AnimationThing.Index != 81 && co2->AnimationThing.Index != 82 && co2->AnimationThing.Index != 89 && co2->AnimationThing.Index != 90 && co2->AnimationThing.Index != 91 && co2->AnimationThing.Index != 92 && co2->AnimationThing.Index != 93 && co2->AnimationThing.Index != 94 && co2->AnimationThing.Index != 95 && co2->AnimationThing.Index != 96 && co2->AnimationThing.Index != 97 && co2->AnimationThing.Index != 98 && co2->AnimationThing.Index != 99 && co2->AnimationThing.Index != 100 && co2->AnimationThing.Index != 101)
  2423. {
  2424. if (ControllerPointers[0]->PressedButtons & Buttons_Z && !using_chaos_blast)
  2425. {
  2426. using_chaos_blast = true;
  2427. co2->field_A = 240;//to disable controls for 4 secs
  2428. co2->Speed.x = 0;
  2429. co2->Speed.y = 0;
  2430. co2->Speed.z = 0;
  2431. WriteData((void*)0x43CC72, 0x90, 6); //Allow gravity change for P1
  2432. co2->PhysicsData.Gravity = 0.0;
  2433. EntityData1Ptrs[0]->Action = 12;
  2434. co2->AnimationThing.Index = 18;
  2435. co1->Status &= ~Status_Ball;
  2436. co1->Status &= ~Status_Attack;
  2437. }
  2438. if (using_chaos_blast)
  2439. {
  2440. co2->Speed.y += 0.025;
  2441. ++chaos_blast_active_timer;
  2442. if (chaos_blast_active_timer < 90)
  2443. {
  2444. co2->AnimationThing.Index = 85; //tweak the anim speed to make it look good
  2445. if (!CHAOSBLAST_was_played)
  2446. {
  2447. PlayVoice(1326);
  2448. CHAOSBLAST_was_played = true;
  2449. }
  2450. }
  2451. else if (chaos_blast_active_timer < 210)
  2452. {
  2453. co2->AnimationThing.Index = 84; //tweak the anim speed to make it look good
  2454. //*****spawn e-101-mk2's explosion;
  2455. }
  2456. else
  2457. {
  2458. using_chaos_blast = false;
  2459. chaos_blast_active_timer = 0;
  2460. CHAOSBLAST_was_played = false;
  2461. WriteData((void*)0x43CC72, gravity_orig_hovering);
  2462. if (co2->_struct_a3.ColFlagsA & ColFlags_Water)
  2463. {
  2464. co2->PhysicsData.Gravity = 0.032;
  2465. }
  2466. else co2->PhysicsData.Gravity = 0.08;
  2467. EntityData1Ptrs[0]->Action = 12;
  2468. co2->AnimationThing.Index = 18;
  2469. }
  2470. }
  2471. }
  2472. }
  2473. }
  2474. }
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483. ////FIX THE FACT THAT RESTART A LEVEL WHILE AS KNUCKLES WILL LEAVE KNUCKLES UNTIL WE REACH GAMESTATE == 15 => MAKE IT DO THAT SWAP ALSO WHEN GAMESTATE == 4
  2484.  
  2485.  
  2486. //Chaos Boost Action ********************************************************************************************** USE DEACTIVATE CHARACTER LIGHTING INSTEAD OF MODEL EDIT
  2487. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  2488. {
  2489. if (GameState == 4)
  2490. {
  2491. CB_lv1 = false;
  2492. CB_lv2 = false;
  2493. CB_lv3 = false;
  2494. CB_active = false;
  2495. transforming_CB = false;
  2496. transforming_CB_time = 0;
  2497. anim_84_was_played = 0;
  2498. //load normal specular;
  2499. //load normal Shadow model;
  2500. //load normal Shadow textures;
  2501. }
  2502. if (GameState == 15)
  2503. {
  2504. if (CB_lv1 || CB_lv2 || CB_lv3) CB_active = true;
  2505. else CB_active = false;
  2506. if (CB_active)
  2507. {
  2508. //do the animated textures; //to have shadows shoes to light up
  2509. //do the animated specular;
  2510. }
  2511. else anim_84_was_played = 0;
  2512. //if (Gauge <= 0 && CB_active && !using_chaos_blast)
  2513. //{
  2514. // CB_lv1 = false;
  2515. // CB_lv2 = false;
  2516. // CB_lv3 = false;
  2517. // //load normal specular;
  2518. // //load normal Shadow model;
  2519. // //load normal Shadow textures;
  2520. //}
  2521. if (/*Gauge >= 10000 && */!CB_active)
  2522. {
  2523. if (EntityData1Ptrs[0]->Action != 16 && EntityData1Ptrs[0]->Action != 86 && EntityData1Ptrs[0]->Action != 44 && co2->AnimationThing.Index != 33 && co2->AnimationThing.Index != 34 && co2->AnimationThing.Index != 35 && co2->AnimationThing.Index != 36 && co2->AnimationThing.Index != 37 && co2->AnimationThing.Index != 38 && co2->AnimationThing.Index != 47 && co2->AnimationThing.Index != 48 && co2->AnimationThing.Index != 49 && co2->AnimationThing.Index != 50 && co2->AnimationThing.Index != 51 && co2->AnimationThing.Index != 52 && co2->AnimationThing.Index != 53 && co2->AnimationThing.Index != 54 && co2->AnimationThing.Index != 55 && co2->AnimationThing.Index != 56 && co2->AnimationThing.Index != 57 && co2->AnimationThing.Index != 58 && co2->AnimationThing.Index != 59 && co2->AnimationThing.Index != 60 && co2->AnimationThing.Index != 61 && co2->AnimationThing.Index != 62 && co2->AnimationThing.Index != 63 && co2->AnimationThing.Index != 65 && co2->AnimationThing.Index != 66 && co2->AnimationThing.Index != 67 && co2->AnimationThing.Index != 68 && co2->AnimationThing.Index != 69 && co2->AnimationThing.Index != 70 && co2->AnimationThing.Index != 71 && co2->AnimationThing.Index != 72 && co2->AnimationThing.Index != 73 && co2->AnimationThing.Index != 74 && co2->AnimationThing.Index != 75 && co2->AnimationThing.Index != 76 && co2->AnimationThing.Index != 77 && co2->AnimationThing.Index != 78 && co2->AnimationThing.Index != 79 && co2->AnimationThing.Index != 80 && co2->AnimationThing.Index != 81 && co2->AnimationThing.Index != 82 && co2->AnimationThing.Index != 84 && co2->AnimationThing.Index != 85 && co2->AnimationThing.Index != 89 && co2->AnimationThing.Index != 90 && co2->AnimationThing.Index != 91 && co2->AnimationThing.Index != 92 && co2->AnimationThing.Index != 93 && co2->AnimationThing.Index != 94 && co2->AnimationThing.Index != 95 && co2->AnimationThing.Index != 96 && co2->AnimationThing.Index != 97 && co2->AnimationThing.Index != 98 && co2->AnimationThing.Index != 99 && co2->AnimationThing.Index != 100 && co2->AnimationThing.Index != 101)
  2524. {
  2525. if (ControllerPointers[0]->PressedButtons & Buttons_Z)
  2526. {
  2527. co1->Position.y += 1;
  2528. CB_lv1 = true;
  2529. //load CB specular;
  2530. //load CB Shadow model;
  2531. //load CB Shadow textures;
  2532. transforming_CB = true;
  2533. PlayVoice(1324);
  2534. //Load the kiki's bomb model for transformation ? Use Sonic 06 CB sphere model ?;
  2535. //Maybe do more, like a sprite animation around Shadow like it originally does in Sonic 06
  2536. }
  2537. }
  2538. }
  2539. if (CB_lv1 && !transforming_CB)
  2540. {
  2541. //if (Gauge > 0) Gauge -= 5
  2542. if (ControllerPointers[0]->PressedButtons & Buttons_Z)
  2543. {
  2544. CB_lv1 = false;
  2545. CB_lv2 = true;
  2546. PlayVoice(1324);//supposed to be the chaos boost level up sound
  2547. //Load the kiki's bomb model for transformation ? Use Sonic 06 CB sphere model ?
  2548. }
  2549. }
  2550. else if (CB_lv2)
  2551. {
  2552. //if (Gauge > 0) Gauge -= 6
  2553. //load CB_lv2 sprites / model / whatever
  2554. if (ControllerPointers[0]->PressedButtons & Buttons_Z)
  2555. {
  2556. CB_lv2 = false;
  2557. CB_lv3 = true;
  2558. PlayVoice(1324);//supposed to be the chaos boost level up sound
  2559. //Load the kiki's bomb model for transformation ? Use Sonic 06 CB sphere model ?
  2560. }
  2561. }
  2562. else if (CB_lv3)
  2563. {
  2564. //if (Gauge > 0) Gauge -= 8
  2565. //load CB_lv3 sprites / model / whatever
  2566. //use after images ?
  2567. //invincible - flashing ? invincible - supersonic ? lv2 = > lv3 ?
  2568. }
  2569. if (transforming_CB)
  2570. {
  2571. ++transforming_CB_time;
  2572. EntityData1Ptrs[0]->Action = 8;
  2573. if (++anim_84_was_played < 50)
  2574. {
  2575. co2->AnimationThing.Index = 84;
  2576. }
  2577. //X speed
  2578. if (co2->Speed.x > 0.75)
  2579. {
  2580. co2->Speed.x -= 0.75;
  2581. }
  2582. else if (co2->Speed.x < 0.75)
  2583. {
  2584. co2->Speed.x += 0.75;
  2585. }
  2586. else co2->Speed.x = 0;
  2587.  
  2588. //Y speed
  2589. if (co2->Speed.y > 0.75)
  2590. {
  2591. co2->Speed.y -= 0.75;
  2592. }
  2593. else if (co2->Speed.y < 0.75)
  2594. {
  2595. co2->Speed.y += 0.75;
  2596. }
  2597. else co2->Speed.y += 0;
  2598.  
  2599. //Z speed
  2600. if (co2->Speed.z > 0.75)
  2601. {
  2602. co2->Speed.z -= 0.75;
  2603. }
  2604. else if (co2->Speed.z < 0.75)
  2605. {
  2606. co2->Speed.z += 0.75;
  2607. }
  2608. else co2->Speed.z = 0;
  2609. co2->Speed.x = 0.0;
  2610. co2->Speed.y = 0.1;
  2611. co2->Speed.z = 0.0;
  2612. if (EntityData1Ptrs[0]->InvulnerableTime == 0)
  2613. {
  2614. EntityData1Ptrs[0]->InvulnerableTime = 32760;
  2615. WriteData((void*)0x497013, 0x90, 4);//disable sonic flashing when "invulnerable time"
  2616. }
  2617. if (transforming_CB_time == 65)
  2618. {
  2619. if (EntityData1Ptrs[0]->InvulnerableTime >= 300)
  2620. {
  2621. EntityData1Ptrs[0]->InvulnerableTime = 0;
  2622. WriteData((void*)0x497013, enable_SONIC_KNUXflashing);
  2623. }
  2624. transforming_CB_time = 0;
  2625. transforming_CB = false;
  2626. }
  2627. }
  2628. }
  2629. }
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636. //Shadow LightAttack Charge Speed Upgraded => OK
  2637. WriteData((short*)0x495097, (short)60); //=> without upgrade => 100
  2638.  
  2639.  
  2640.  
  2641.  
  2642. //Shadow random homing trick => OK
  2643. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  2644. {
  2645. if (GameState != 16)
  2646. {
  2647. int anims[]{ 116, 117, 119 };
  2648. if (EntityData1Ptrs[0]->Action == 14)
  2649. {
  2650. homing = true;
  2651. co2->AnimationThing.Index = 83;
  2652. }
  2653. //TRICK 1
  2654. if (co2->AnimationThing.Index == 112) co2->AnimationThing.Index = 18;
  2655. if (co2->AnimationThing.Index == 116)
  2656. {
  2657. if (++ShadowTrick1Timer1 == 1)
  2658. {
  2659. ((AnimData_t*)0x3C56210)[116].AnimationSpeed = 1;
  2660. }
  2661. if (++ShadowTrick1Timer2 == 58)
  2662. {
  2663. ((AnimData_t*)0x3C56210)[116].AnimationSpeed = 9;
  2664. }
  2665. }
  2666. else
  2667. {
  2668. ShadowTrick1Timer1 = 0;
  2669. ShadowTrick1Timer2 = 0;
  2670. ((AnimData_t*)0x3C56210)[116].AnimationSpeed = 9;
  2671. }
  2672. //TRICK 2
  2673. if (co2->AnimationThing.Index == 117)
  2674. {
  2675. if (++ShadowTrick2Timer1 == 2)
  2676. {
  2677. ((AnimData_t*)0x3C56210)[117].AnimationSpeed = 1.1;
  2678. }
  2679. if (++ShadowTrick2Timer2 == 47)
  2680. {
  2681. ((AnimData_t*)0x3C56210)[117].AnimationSpeed = 9;
  2682. }
  2683. }
  2684. else
  2685. {
  2686. ShadowTrick2Timer1 = 0;
  2687. ShadowTrick2Timer2 = 0;
  2688. ((AnimData_t*)0x3C56210)[117].AnimationSpeed = 9;
  2689. }
  2690. //TRICK 3
  2691. if (co2->AnimationThing.Index == 119)
  2692. {
  2693. if (++ShadowTrick3Timer1 == 2)
  2694. {
  2695. ((AnimData_t*)0x3C56210)[119].AnimationSpeed = 1.21;
  2696. }
  2697. if (++ShadowTrick3Timer2 == 54)
  2698. {
  2699. ((AnimData_t*)0x3C56210)[119].AnimationSpeed = 11;
  2700. }
  2701. }
  2702. else
  2703. {
  2704. ShadowTrick3Timer1 = 0;
  2705. ShadowTrick3Timer2 = 0;
  2706. ((AnimData_t*)0x3C56210)[119].AnimationSpeed = 11;
  2707. }
  2708. if (homing && (co1->Status & Status_Ground) != Status_Ground) in_air_after_homing = true;
  2709. if (homing && ((co1->Status & Status_Ground) == Status_Ground || co2->AnimationThing.Index == 0 || co2->AnimationThing.Index == 1 || co2->AnimationThing.Index == 2 || co2->AnimationThing.Index == 9 || co2->AnimationThing.Index == 10 || co2->AnimationThing.Index == 11 || co2->AnimationThing.Index == 12 || co2->AnimationThing.Index == 13 || co2->AnimationThing.Index == 31)) in_air_after_homing = false;
  2710. if (!in_air_after_homing) homing = false;
  2711. if (in_air_after_homing && EntityData1Ptrs[0]->Action == 8)
  2712. {
  2713. WriteData((void*)0x494AF9, 0x90, 5);
  2714. co2->AnimationThing.Index = anims[rand() % 3];
  2715. homing = false;
  2716. in_air_after_homing = false;
  2717. }
  2718. if (!auraobj && ((co1->Status & Status_Ground) == Status_Ground || homing)) WriteData((void*)0x494AF9, balldata);
  2719. }
  2720. }
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727. //No jumpball when jumping => OK
  2728. if (r && (co1->Status & Status_Ground) != Status_Ground) fall_after_roll = true;
  2729. if (ControllerPointers[0]->PressedButtons & Buttons_A) fall_after_roll = false;
  2730. if ((co1->Status & Status_Ground) == Status_Ground && EntityData1Ptrs[0]->Action == 5) fall_after_roll = true;
  2731. if ((co1->Status & Status_Ground) == Status_Ground && EntityData1Ptrs[0]->Action == 2) fall_after_roll = false;
  2732. if (co2 == NULL) return;
  2733. if (GetCharacterObject(0) && (EntityData1Ptrs[0]->Action != 4 || EntityData1Ptrs[0]->Action != 5 || EntityData1Ptrs[0]->Action != 14 || EntityData1Ptrs[0]->Action != 44)) WriteData((void*)0x494AF9, 0x90, 5);
  2734. if (GetCharacterObject(0) && (EntityData1Ptrs[0]->Action == 4 || EntityData1Ptrs[0]->Action == 5 || fall_after_roll || EntityData1Ptrs[0]->Action == 14 || EntityData1Ptrs[0]->Action == 44)) WriteData((void*)0x494AF9, balldata);
  2735.  
  2736.  
  2737.  
  2738.  
  2739. // Dash anim in air => OK
  2740. if (co2 == NULL) return;
  2741. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  2742. {
  2743. if (EntityData1Ptrs[0]->Action == 12 && co2->Speed.x >= 5) dashing = true;
  2744. if (EntityData1Ptrs[0]->Action != 12 || co2->Speed.x <= 4) dashing = false;
  2745. if (dashing)
  2746. {
  2747. co2->AnimationThing.Index = 64;
  2748. WriteData((short*)0x00494FDC, (short)64);
  2749. WriteData((short*)0x00497CC0, (short)64);
  2750. }
  2751.  
  2752. if (co2->AnimationThing.Index == 17 || co2->AnimationThing.Index == 26 || co2->AnimationThing.Index == 40 || co2->AnimationThing.Index == 42) was_on_trampoline = true;
  2753. if (!was_on_trampoline && EntityData1Ptrs[0]->Action == 12 && co2->Speed.x <= 4) no_longer_dashing = true;
  2754. if (EntityData1Ptrs[0]->Action != 12 || co2->Speed.x >= 4 || was_on_trampoline) no_longer_dashing = false;
  2755. if (co2->AnimationThing.Index != 17 || co2->AnimationThing.Index != 26 || co2->AnimationThing.Index != 40 || co2->AnimationThing.Index != 42) was_on_trampoline = false;
  2756. if (no_longer_dashing)
  2757. {
  2758. co2->AnimationThing.Index = 18;
  2759. WriteData((short*)0x494FDC, (short)18);
  2760. WriteData((short*)0x497CC0, (short)18);
  2761. }
  2762. }
  2763.  
  2764.  
  2765. //Play GO! when doing Light Attack
  2766. if (co2 == NULL) return;
  2767. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  2768. {
  2769. if (EntityData1Ptrs[0]->Action == 44)
  2770. {
  2771. if (!GO_sound_played)
  2772. {
  2773. PlaySound(1228, 0, 0, 0);
  2774. GO_sound_played = true;
  2775. }
  2776. }
  2777. else GO_sound_played = false;
  2778. }
  2779.  
  2780.  
  2781.  
  2782. //No LightDash when charged up
  2783. if (EntityData1Ptrs[0]->Action == 4)
  2784. {
  2785. WriteData((void*)0x493047, 0x90, 3);
  2786. }
  2787. else if (!(co1->Status & Status_LightDash))
  2788. {
  2789. WriteData((void*)0x493047, LightDash_unNOP);
  2790. }
  2791.  
  2792. //if you want to stop the "Go" sound, at 49AEE7 change 75 to EB
  2793. WriteData((char*)0x49309C, (char)0xEB);
  2794.  
  2795.  
  2796. //Fix lightdash/lightattack sound
  2797. if ((co1->Status & Status_LightDash) == Status_LightDash || ControllerPointers[0]->PressedButtons & Buttons_Right)
  2798. {
  2799. WriteData((void*)0x49308D, 0x90, 5);
  2800. }
  2801. else WriteData((void*)0x49308D, LSA_sound);
  2802.  
  2803.  
  2804.  
  2805. //LightDash with Y final
  2806. if (GameState == 15 && co2->AnimationThing.Index != 32 && !is_in_CS_state)
  2807. {
  2808. double SpeedXY2 = sqrt(pow(co2->Speed.x, 2) + pow(co2->Speed.y, 2) + pow(co2->Speed.z, 2));
  2809. WriteData((short*)0x49305C, (short)0);
  2810. WriteData((void*)0x493067, 0x90, 7);
  2811. WriteData((void*)0x492CAE, 0x90, 6);
  2812. WriteData((void*)0x4975AC, 0x90, 9); //this line disables the code that sets the animation
  2813. WriteData((float**)0x0055E739, &LightDash_SuperDash);
  2814. if (!ok)
  2815. {
  2816. WriteData((void*)0x49AF36, 0x90, 5);
  2817. WriteData((void*)0x49304C, 0x90, 9);
  2818. }
  2819. if (co2 == NULL) return;
  2820. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  2821. {
  2822. if (ControllerPointers[0]->PressedButtons & Buttons_Y && (EntityData1Ptrs[0]->Action == 0 || EntityData1Ptrs[0]->Action == 1 || EntityData1Ptrs[0]->Action == 2 || EntityData1Ptrs[0]->Action == 8 || EntityData1Ptrs[0]->Action == 12))
  2823. {
  2824. WriteData((char*)0x4975A2, co1->Action);
  2825. //WriteData((short*)0x4975B3, co2->AnimationThing.Index);
  2826. co1->Status |= Status_LightDash;
  2827. }
  2828. if (EntityData1Ptrs[0]->Action == 6 && SpeedXY2 > 7.9999 && SpeedXY2 < 8.0001)
  2829. {
  2830. LightDash_SuperDash_ON = true;
  2831. WriteData((void*)0x49AF36, LightDashTrail_unNOP);
  2832. co2->AnimationThing.Index = 64;
  2833. ok = true;
  2834. WriteData((void*)0x4975BC, LD_forced_out_speed);
  2835. NOP_forced_out_speed = 0;
  2836. }
  2837. else
  2838. {
  2839. ok = false;
  2840. LightDash_SuperDash_ON = false;
  2841. if (++NOP_forced_out_speed == 10)
  2842. {
  2843. WriteData((void*)0x4975BC, 0x90, 7); //nop the forced out speed
  2844. }
  2845. }
  2846. }
  2847. if (ok)
  2848. {
  2849. WriteData((char*)0x4975A2, (char)12);
  2850. //WriteData((short*)0x4975B3, (short)20);
  2851. }
  2852. if (LightDash_SuperDash_ON)
  2853. {
  2854. if (!auraobj) auraobj = LoadObject(LoadObj_Data1, 2, Sonic_SuperAura_Load);
  2855. }
  2856. //if (auraobj && EntityData1Ptrs[0]->Action != 6 && EntityData1Ptrs[0]->Action != 14 && EntityData1Ptrs[0]->Action != 44 && (*(float**)0x55E6FA != &Boost_SuperTornado) && !(co2->gap5C[0] & 2))
  2857. //{
  2858. // DeleteObject_(auraobj);
  2859. // auraobj = nullptr;
  2860. //}
  2861. if (EntityData1Ptrs[0]->Action == 6 && SpeedXY2 > 7.9999 && SpeedXY2 < 8.0001)
  2862. {
  2863. LD_fix = true;
  2864. }
  2865. else if (LD_fix)
  2866. {
  2867. LD_fix = false;
  2868. DeleteObject_(auraobj);
  2869. auraobj = nullptr;
  2870. DeleteObject_(trailobj);
  2871. trailobj = nullptr;
  2872. }
  2873. }
  2874.  
  2875.  
  2876.  
  2877.  
  2878. //HangTime like Heroes
  2879. if (co2 == NULL) return;
  2880. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  2881. {
  2882. PhysicsArray[Characters_Sonic].HangTime = 60000;
  2883. if (EntityData1Ptrs[0]->Action == 8)
  2884. {
  2885. if (ControllerPointers[0]->HeldButtons & Buttons_A)
  2886. {
  2887. if (++HangTimeLikeHeroes == 60)
  2888. {
  2889. WriteData((void*)0x43BFCB, 0x90, 6);
  2890. }
  2891. else if (EnemyBonus - OldEnemyBonus > 0 || co2->AnimationThing.Index == 40 || co2->AnimationThing.Index == 42)
  2892. {
  2893. WriteData((void*)0x43BFCB, HangTimeCheckData);
  2894. OldEnemyBonus = EnemyBonus;
  2895. }
  2896. }
  2897. }
  2898. else if ((co1->Status & Status_Ground) == Status_Ground || co2->AnimationThing.Index == 0 || co2->AnimationThing.Index == 1 || co2->AnimationThing.Index == 2 || co2->AnimationThing.Index == 9 || co2->AnimationThing.Index == 10 || co2->AnimationThing.Index == 11 || co2->AnimationThing.Index == 12 || co2->AnimationThing.Index == 13 || co2->AnimationThing.Index == 18 || co2->AnimationThing.Index == 31 || EntityData1Ptrs[0]->Action != 8)
  2899. {
  2900. WriteData((void*)0x43BFCB, HangTimeCheckData);
  2901. HangTimeLikeHeroes = 0;
  2902. }
  2903. }
  2904.  
  2905.  
  2906.  
  2907. //LightAttack like SA2
  2908. if (co2 == NULL) return;
  2909. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  2910. {
  2911. if (EntityData1Ptrs[0]->Action == 44)
  2912. {
  2913. if ((*(float**)0x492A3B == &LightAttackStatic) && (*(float**)0x492A4F == &LightAttackStatic) && (*(float**)0x492A6A == &LightAttackStatic))
  2914. {
  2915. WriteData((float**)0x492A3B, &LightAttackMoving);
  2916. WriteData((float**)0x492A4F, &LightAttackMoving);
  2917. WriteData((float**)0x492A6A, &LightAttackMoving);
  2918. }
  2919. if (++LightAttackTimer == 10)
  2920. {
  2921. WriteData((float**)0x492A3B, &LightAttackStatic);
  2922. WriteData((float**)0x492A4F, &LightAttackStatic);
  2923. WriteData((float**)0x492A6A, &LightAttackStatic);
  2924. LightAttackTimer = 0;
  2925. }
  2926. }
  2927. else LightAttackTimer = 0;
  2928. }
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934. //Spindash like SA2
  2935. WriteData((char*)0x496EF6, (char)0xEB);
  2936. if (GameState == 15)
  2937. {
  2938. if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  2939. {
  2940. if (((co2->AnimationThing.Index == 0 || co2->AnimationThing.Index == 1 || co2->AnimationThing.Index == 2 || co2->AnimationThing.Index == 3 || co2->AnimationThing.Index == 4 || co2->AnimationThing.Index == 5 || co2->AnimationThing.Index == 6 || co2->AnimationThing.Index == 7 || co2->AnimationThing.Index == 8 || co2->AnimationThing.Index == 9 || co2->AnimationThing.Index == 10 || co2->AnimationThing.Index == 11 || co2->AnimationThing.Index == 12 || co2->AnimationThing.Index == 13 || co2->AnimationThing.Index == 14 || co2->AnimationThing.Index == 20 || co2->AnimationThing.Index == 25 || co2->AnimationThing.Index == 31 || co2->AnimationThing.Index == 44 || co2->AnimationThing.Index == 45 || co2->AnimationThing.Index == 71 || co2->AnimationThing.Index == 130 || co2->AnimationThing.Index == 131)))
  2941. {
  2942. if (ControllerPointers[0]->HeldButtons & Buttons_X && (co1->Status & Status_LightDash) != Status_LightDash && EntityData1Ptrs[0]->Action != 8 && !cant_spindash)
  2943. {
  2944. if (++SpindashNOPingTimer >= 22)
  2945. {
  2946. WriteData((char*)0x496EF6, (char)0x74);
  2947. EntityData1Ptrs[0]->Action = 4;
  2948. co2->AnimationThing.Index = 14;
  2949. co1->Status |= Status_Ball;
  2950. }
  2951. if (SpindashNOPingTimer == 22)
  2952. {
  2953. PlaySound(770, 0, 0, 0); //I have to fix the sound when no Light Speed Shoes
  2954. co2->SonicSpinTimer = 0;
  2955. }
  2956. }
  2957. }
  2958. if (EntityData1Ptrs[0]->Action == 8)
  2959. {
  2960. SpindashNOPingTimer = 0;
  2961. punchattack = 0;
  2962. cant_spindash = true;
  2963. }
  2964. if (!(ControllerPointers[0]->HeldButtons & Buttons_X))
  2965. {
  2966. SpindashNOPingTimer = 0;
  2967. punchattack = 0;
  2968. cant_spindash = false;
  2969. }
  2970. }
  2971. }
  2972.  
  2973.  
  2974.  
  2975. //Homing Attack like Sonic 2006
  2976. if (EntityData1Ptrs[0]->Action == 14)
  2977. {
  2978. just_homing_attacked = true;
  2979. }
  2980. if (just_homing_attacked)
  2981. {
  2982. ++homing_reattack_timer;
  2983. WriteData((char*)0x4977AB, (char)0xEB);
  2984. }
  2985. if (is_CB)
  2986. {
  2987. if (homing_reattack_timer == 12)
  2988. {
  2989. WriteData((char*)0x4977AB, (char)0x74);
  2990. homing_reattack_timer = 0;
  2991. just_homing_attacked = false;
  2992. }
  2993. }
  2994. else
  2995. {
  2996. if (homing_reattack_timer == 18)
  2997. {
  2998. WriteData((char*)0x4977AB, (char)0x74);
  2999. homing_reattack_timer = 0;
  3000. just_homing_attacked = false;
  3001. }
  3002. }
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011. //Super Sonic/Shadow anybody LightAttack*************************************************
  3012.  
  3013.  
  3014.  
  3015. //LightAttack edits for Super forms
  3016. //WriteData((float**)0x492A3B, &LightAttackMoving);
  3017. //WriteData((float**)0x492A4F, &LightAttackMoving);
  3018. //WriteData((float**)0x492A6A, &LightAttackMoving);
  3019.  
  3020.  
  3021.  
  3022. //if (co2 == NULL) return;
  3023. //if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  3024. //{
  3025. // WriteData((float*)0x492FEB, (float)0.0f);
  3026. // if (EntityData1Ptrs[0]->Action == 44)
  3027. // {
  3028. // if ((*(float**)0x492A3B == &LightAttackStatic) && (*(float**)0x492A4F == &LightAttackStatic) && (*(float**)0x492A6A == &LightAttackStatic))
  3029. // {
  3030. // WriteData((float**)0x492A3B, &SuperLightAttackMoving);
  3031. // WriteData((float**)0x492A4F, &SuperLightAttackMoving);
  3032. // WriteData((float**)0x492A6A, &SuperLightAttackMoving);
  3033. // }
  3034. // if ((++LightAttackTimer == 1) || EnemyBonus - OldEnemyBonus > 0)
  3035. // {
  3036. // WriteData((float**)0x492A3B, &LightAttackStatic);
  3037. // WriteData((float**)0x492A4F, &LightAttackStatic);
  3038. // WriteData((float**)0x492A6A, &LightAttackStatic);
  3039. // }
  3040. // }
  3041. // else LightAttackTimer = 0;
  3042. // OldEnemyBonus = EnemyBonus;
  3043. //}
  3044.  
  3045.  
  3046. //******* IMPORTANT *********
  3047. // https://github.com/sonicretro/sadx-mod-loader/blob/master/data/Codes.lst#L239-L240
  3048.  
  3049.  
  3050. //Shadow's NORMAL homing attack **** useless now
  3051. //WriteData((void*)0x49234D, 0x90, 3);
  3052.  
  3053.  
  3054. //497013 - 66 89 45 06
  3055.  
  3056.  
  3057. //////////////////////////Chaos Boost Homing attack V2 *** fix the homing attack speed caused by Supersonic flag*******also fix the fact that pressing X while doing it in Chaos Boost doesn't let you leave it to jumping
  3058. ////////////////////////if (co2 == NULL) return;
  3059. ////////////////////////if (GameState == 4)
  3060. ////////////////////////{
  3061. //////////////////////// stop_supersonic = 0;
  3062. //////////////////////// EntityData1Ptrs[0]->InvulnerableTime = 0;
  3063. //////////////////////// WriteData((void*)0x497013, enable_SONIC_KNUXflashing);
  3064. ////////////////////////}
  3065. ////////////////////////if (is_CB)
  3066. ////////////////////////{
  3067. //////////////////////// //if ((co1->Status & Status_Ground) == Status_Ground)
  3068. //////////////////////// //{
  3069. //////////////////////// //if (stop_supersonic < 30)
  3070. //////////////////////// //{
  3071. //////////////////////// // EntityData1Ptrs[0]->InvulnerableTime = 0;
  3072. //////////////////////// // stop_supersonic = 0;
  3073. //////////////////////// //}
  3074. //////////////////////// //if (stop_supersonic > 0)
  3075. //////////////////////// //{
  3076. //////////////////////// // if (++stop_supersonic == 15)
  3077. //////////////////////// // {
  3078. //////////////////////// // EntityData1Ptrs[0]->InvulnerableTime = 0;
  3079. //////////////////////// // WriteData((void*)0x497013, enable_SONIC_KNUXflashing);
  3080. //////////////////////// // co2->Upgrades &= ~Upgrades_SuperSonic;
  3081. //////////////////////// // stop_supersonic = 0;
  3082. //////////////////////// // }
  3083. //////////////////////// //}
  3084. //////////////////////// //WriteData((void*)0x497013, enable_SONIC_KNUXflashing);
  3085. //////////////////////// //co2->Upgrades &= ~Upgrades_SuperSonic;
  3086. //////////////////////// //}
  3087. //////////////////////// if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  3088. //////////////////////// {
  3089. //////////////////////// WriteData((void*)0x494C19, supersonic_homingspeed);
  3090. //////////////////////// WriteData((float**)0x0049265F, &ChaosBoostLv1);//5.0
  3091. //////////////////////// WriteData((void*)0x494C56, jumpdashspeed1);//5.0
  3092. //////////////////////// WriteData((void*)0x494C2C, jumpdashspeed2);//5.0
  3093. //////////////////////// WriteData((void*)0x497CB5, 0x90, 4);//C6 45 00 0C
  3094. //////////////////////// WriteData((short*)0x497CC0, (short)83);//18
  3095. //////////////////////// WriteData((void*)0x497CC2, 0x90, 4);//80 65 05 FA
  3096. //////////////////////// WriteData((void*)0x49234D, 0x90, 3);//D9 5F 38 (I think it removes the homing out speed)
  3097. //////////////////////// if (GameState == 15)
  3098. //////////////////////// {
  3099. //////////////////////// if (EntityData1Ptrs[0]->Action == 14)
  3100. //////////////////////// {
  3101. //////////////////////// stop_supersonic = 1;
  3102. //////////////////////// co2->Upgrades |= Upgrades_SuperSonic;
  3103. //////////////////////// EntityData1Ptrs[0]->InvulnerableTime = 60000;
  3104. //////////////////////// WriteData((void*)0x497013, 0x90, 4);//disable sonic flashing when "invulnerable time"
  3105. //////////////////////// if ((*(float**)0x492A3B == &CBHomingAttackStatic) && (*(float**)0x492A4F == &CBHomingAttackStatic) && (*(float**)0x492A6A == &CBHomingAttackStatic))
  3106. //////////////////////// {
  3107. //////////////////////// WriteData((float**)0x492A3B, &CBHomingAttackMoving);
  3108. //////////////////////// WriteData((float**)0x492A4F, &CBHomingAttackMoving);
  3109. //////////////////////// WriteData((float**)0x492A6A, &CBHomingAttackMoving);
  3110. //////////////////////// }
  3111. //////////////////////// if ((++CBHomingAttackTimer == 1) || EnemyBonus - OldEnemyBonus > 0)
  3112. //////////////////////// {
  3113. //////////////////////// WriteData((float**)0x492A3B, &CBHomingAttackStatic);
  3114. //////////////////////// WriteData((float**)0x492A4F, &CBHomingAttackStatic);
  3115. //////////////////////// WriteData((float**)0x492A6A, &CBHomingAttackStatic);
  3116. //////////////////////// }
  3117. //////////////////////// }
  3118. //////////////////////// else
  3119. //////////////////////// {
  3120. //////////////////////// if (stop_supersonic > 0)
  3121. //////////////////////// {
  3122. //////////////////////// if (++stop_supersonic == 20)
  3123. //////////////////////// {
  3124. //////////////////////// EntityData1Ptrs[0]->InvulnerableTime = 0;
  3125. //////////////////////// WriteData((void*)0x497013, enable_SONIC_KNUXflashing);
  3126. //////////////////////// co2->Upgrades &= ~Upgrades_SuperSonic;
  3127. //////////////////////// stop_supersonic = 0;
  3128. //////////////////////// }
  3129. //////////////////////// }
  3130. //////////////////////// CBHomingAttackTimer = 0;
  3131. //////////////////////// }
  3132. //////////////////////// OldEnemyBonus = EnemyBonus;
  3133. //////////////////////// }
  3134. //////////////////////// }
  3135. ////////////////////////}
  3136. ////////////////////////else
  3137. ////////////////////////{
  3138. //////////////////////// if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
  3139. //////////////////////// {
  3140. //////////////////////// WriteData((float**)0x0049265F, &UN_ChaosBoostLv1);//5.0
  3141. //////////////////////// WriteData((void*)0x494C56, jumpdashspeed1_orig);//5.0
  3142. //////////////////////// WriteData((void*)0x494C2C, jumpdashspeed2_orig);//5.0
  3143. //////////////////////// WriteData((void*)0x497CB5, CB_LV1_stuff1);//C6 45 00 0C
  3144. //////////////////////// //WriteData((short*)0x497CC0, (short)18);//18
  3145. //////////////////////// WriteData((void*)0x497CC2, CB_LV1_stuff2);//80 65 05 FA
  3146. //////////////////////// WriteData((void*)0x49234D, 0x90, 3);//D9 5F 38 (I think it removes the homing out speed)
  3147. //////////////////////// if (stop_supersonic != 0)
  3148. //////////////////////// {
  3149. //////////////////////// EntityData1Ptrs[0]->InvulnerableTime = 0;
  3150. //////////////////////// }
  3151. //////////////////////// WriteData((void*)0x497013, enable_SONIC_KNUXflashing);
  3152. //////////////////////// co2->Upgrades &= ~Upgrades_SuperSonic;
  3153. //////////////////////// stop_supersonic = 0;
  3154. //////////////////////// }
  3155. ////////////////////////}
  3156.  
  3157.  
  3158. // **********************************************************************************************change trail's color to red-ish when chaosboost active
  3159.  
  3160.  
  3161. //Chaos Boost Lvl 3 => Chaos Blast (use DROWNING as CHARGE ANIMATION and BUBBLE BREATHING as RELEASE ANIMATION (no certainly shadow actually, to not use the character switch again) <-- (or maybe Knuckles's jumping while carrying stuff animation ? 38->19->18(reversed)->17)
  3162. //Use bomb item box to kill everyone ?
  3163.  
  3164.  
  3165.  
  3166.  
  3167. //IDEA : USE THE AFTERIMAGES FOR CHAOS BOOST => SHOULD I USE IT FOR EVERY LEVELS ?
  3168.  
  3169. //MAX SPEED = 4.25
  3170. //MAX ACCEL = -0.425
  3171.  
  3172.  
  3173. }
  3174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement