Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Basics-Sonic.cpp : Defines the exported functions for the DLL application.
- //
- #include "stdafx.h"
- #include "SADXModLoader.h"
- #include <cstdlib>
- #include <vector>
- #include <math.h>
- //#include "LandTableInfo.h"
- #include "Models_Header.h"
- #include "functions.h"
- PVMEntry SonicTextures[] = {
- { "SON_SONIC", (TexList *)0x91CB58 },
- { "SON_SON_EFF", (TexList *)0x927CB8 },
- { "KNU_EFF", (TexList *)0x91BD28 },
- { "SON_AMY_EFF", (TexList *)0x91C808 },
- { "SON_SUPERSONIC", (NJS_TEXLIST*)0x142272C },
- { 0 }
- };
- //DataPointer(char, Sonic_LightSpeedShoesObtained, 0x3B18895);
- //DataPointer(char, Sonic_CrystalRingObtained, 0x3B18896);
- //DataPointer(char, Sonic_AncientLightObtained, 0x3B188A7);
- //DataPointer(int, CurrentMusic, 0x0912698);
- //DataPointer(int, YGravity, 0x3B0F0FC);
- using std::vector;
- vector<NJS_MATERIAL *> materials;
- //To animate Super Sonic textures
- void processobject(NJS_OBJECT *obj)
- {
- do
- {
- if (obj->basicdxmodel)
- {
- NJS_MODEL_SADX *mdl = obj->basicdxmodel;
- for (int i = 0; i < mdl->nbMat; i++)
- if (mdl->mats[i].attr_texId == 29)
- materials.push_back(&mdl->mats[i]);
- }
- if (obj->child)
- processobject(obj->child);
- obj = obj->sibling;
- } while (obj);
- }
- using std::vector;
- vector<NJS_MATERIAL *> materials2;
- //To animate Hyper Sonic textures
- void processobject2(NJS_OBJECT *obj)
- {
- do
- {
- if (obj->basicdxmodel)
- {
- NJS_MODEL_SADX *mdl = obj->basicdxmodel;
- for (int i = 0; i < mdl->nbMat; i++)
- if (mdl->mats[i].attr_texId == 95)
- materials2.push_back(&mdl->mats[i]);
- }
- if (obj->child)
- processobject2(obj->child);
- obj = obj->sibling;
- } while (obj);
- }
- ////////////Timer bonus points
- //////////float __cdecl GetTimeBonus_r()
- //////////{
- ////////// double result; // st7@3
- //////////
- ////////// if (GetCurrentCharacterID() == Characters_Gamma)
- ////////// {
- ////////// if (TimeMinutes < 3)
- ////////// {
- ////////// return (double)(TimeSeconds + 60 * TimeMinutes) * 25.0;
- ////////// }
- ////////// return 5000.0;
- ////////// }
- ////////// if (!TimeMinutes)
- ////////// {
- ////////// return 10000.0;
- ////////// }
- ////////// result = 10000.0 - (double)(TimeSeconds + 60 * (TimeMinutes - 1)) * 20.0;
- ////////// if (result < 0.0)
- ////////// {
- ////////// result = 0.0;
- ////////// }
- ////////// return result;
- //////////}
- ////////////Stuff to hover on EC act1's water
- //////////static int __stdcall SuperWaterCheck_C(EntityData1* data1, CharObj2* data2)
- //////////{
- ////////// auto pad = ControllerPointers[data1->CharIndex];
- //////////
- ////////// if (data1->CharID == Characters_Sonic)
- ////////// {
- ////////// return pad && !(pad->HeldButtons & AttackButtons);
- ////////// }
- //////////
- ////////// return false;
- //////////}
- //////////static const void* surface_solid = (void*)0x004496E7;
- //////////static const void* surface_water = (void*)0x004497B6;
- //////////static void __declspec(naked) SuperWaterCheck()
- //////////{
- ////////// __asm
- ////////// {
- ////////// // If Gamma, treat surface as solid
- ////////// jnz not_gamma
- ////////// jmp surface_solid
- //////////
- ////////// not_gamma :
- ////////// // Save whatever's in EAX
- ////////// push eax
- //////////
- ////////// push[esp + 6A8h + 4h + 0Ch] // CharObj2
- ////////// push ebx // EntityData1
- ////////// call SuperWaterCheck_C
- //////////
- ////////// test eax, eax
- //////////
- ////////// jnz is_true
- //////////
- ////////// // Restore EAX
- ////////// pop eax
- //////////
- ////////// jmp surface_water
- //////////
- ////////// is_true :
- ////////// // Restore EAX
- ////////// pop eax
- ////////// jmp surface_solid
- ////////// }
- //////////}
- //WriteData((void*)0x4A1413, TrailData); Re-set the trail data (appear/disappear)
- //OnFrame variables
- bool air_boost_used = false;
- bool stomp_was_used = false;
- bool bouncing = false;
- bool stomp_was_used_twice = false;
- bool can_use_twice = false;
- bool B_or_X_pressed = false;
- bool bounce_attacking = false;
- bool lightdashflag = false;
- bool NoBoost_OnWater = false;
- bool is_super = false;
- bool is_hyper = false;
- bool transforming = false;
- bool just_transformed = false;
- bool is_boosting = false;
- bool is_flying = false;
- bool up_was_pressed = false;
- bool down_was_pressed = false;
- bool spincharging = false;
- bool no_LSA_sound = false;
- bool lightattacking = false;
- bool stop_flying = false;
- bool LSA_charged = false;
- bool no_boost_aura = false;
- char LightDashSpeedOUT_unNOP[] = { 0xC7, 0x47, 0x38, 0, 0, 0, 0 };
- char StompAnim[] = { 0x66, 0xC7, 0x87, 0x24, 0x01, 0, 0, 0x40, 0 };
- char HomingSpeed_Data[] = { 0xD9, 0x5F, 0x38 };
- char oldaction;
- char oldmusic;
- char invinsize[] = { 0xC7, 0x46, 0x2C, 0x9A, 0x99, 0x99, 0x3F, 0x90, 0x90 };
- char jumpdashspeed1_hyper[] = { 0xC7, 0x47, 0x38, 0, 0, 0xE4, 0x40 };
- char jumpdashspeed1_super[] = { 0xC7, 0x47, 0x38, 0, 0, 0xD0, 0x40 };
- char jumpdashspeed2_hyper[] = { 0xC7, 0x47, 0x38, 0, 0, 0xE4, 0x40 };
- char jumpdashspeed2_super[] = { 0xC7, 0x47, 0x38, 0, 0, 0xD0, 0x40 };
- char SonicLSAcharged_RunSpeed[] = { 0xC7, 0x86, 0xAC, 0, 0, 0, 0, 0, 0x40, 0x40 }; //original 0000003F
- char SuperLSAcharged_RunSpeed[] = { 0xC7, 0x86, 0xAC, 0, 0, 0, 0, 0, 0xC0, 0x40 };
- char alpha = 0;
- ObjectMaster *hypersparkles = nullptr;
- float SuperDash = 0.0f;
- float SuperTornado = 16.0f;
- float HyperLightAttackMoving = 16.0f;
- float ringdist = 100.0f;
- float ringmaxspeed = 16.0f;
- float LDringmaxspeed = 0.0f;
- float ringaccel = 0.052f;
- float ringspeedmultiplier = 1.0f;
- float average[2160000]{};//speedometer ************************ TO PUT IN SONIC+MISCELLANEOUS SINCE IT'S COMMON TO EVERYONE
- float dist = 0;
- float invinmult = 0.9;
- float SuperHomingSpeed = 6.0f;
- float HyperHomingSpeed = 7.0f;
- float mult = 5;
- float Testtt = 0.0f;
- float S_GA_NO_B_NO_SS = 0.05f;
- float S_GA_NO_B_SS = 0.1f;
- float S_GA_B1_NO_SS = 0.225f;
- float S_GA_B2_NO_SS = 0.15f;
- float S_GA_B1_SS = 0.45f;
- float S_GA_B2_SS = 0.225f;
- float SS_GA_NO_B_NO_SS = 0.085f;
- float SS_GA_NO_B_SS = 0.125f;
- float SS_GA_B1_NO_SS = 0.4f;
- float SS_GA_B2_NO_SS = 0.2f;
- float SS_GA_B1_SS = 0.6f;
- float SS_GA_B2_SS = 0.3f;
- float HS_GA_NO_B_NO_SS = 0.11f;
- float HS_GA_NO_B_SS = 0.15f;
- float HS_GA_B1_NO_SS = 0.5f;
- float HS_GA_B2_NO_SS = 0.25f;
- float HS_GA_B1_SS = 0.75f;
- float HS_GA_B2_SS = 0.375f;
- float S_MA_NO_B_NO_SS = 6.0f;
- float S_MA_NO_B_SS = 9.0f;
- float S_MA_B_NO_SS = 7.0f;
- float S_MA_B_SS = 10.5f;
- float SS_MA_NO_B_NO_SS = 8.5f;
- float SS_MA_NO_B_SS = 12.75f;
- float SS_MA_B_NO_SS = 10.25f;
- float SS_MA_B_SS = 15.375f;
- float HS_MA_NO_B_NO_SS = 10.5f;
- float HS_MA_NO_B_SS = 15.75f;
- float HS_MA_B_NO_SS = 13.5f;
- float HS_MA_B_SS = 20.25f;
- float sonic_accel = 0.0f;
- float GD_NO_B = -0.06f;
- float S_GD_B = 0.098f;
- float SS_GD_B = 0.143f;
- float HS_GD_B = 0.193f;
- int BoostSFX[]{ 780, 781 };
- int BoostVoices[]{ 770, 773, 776 };
- int FOV = 70;
- int SonicTrick3Timer1 = 0;
- int SonicTrick3Timer2 = 0;
- int BoostVarGrd = 0;
- int BoostVarAir = 0;
- int stompvar = 0;
- int stompvar2 = 0;
- int bouncevar = 0;
- int boostvoice = 0;
- int animation = 0;
- int average_index = 0;//speedometer
- int current_length = 0;
- int transforming_time = 0;
- int transform_anim = 0;
- int firstanim_speedup = 0;
- int untransforming = 0;
- int SUPERSpinballtextures[] = { 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92 };
- int HYPERSpinballtextures[] = { 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158 };
- int testvar = 0;
- int super_rings_depletion = 0;
- int hyper_rings_depletion = 0;
- int testvar3 = 0;
- int LSA_var = 0;
- int fly_then_ground = 0;
- int flying_to_NOTflying = 0;
- short oldanim;
- //short values[] = { 20, 20, 20, 20, 20, 20 };
- ObjectFunc(sub_485B00, 0x485B00);//Hammer impact object
- //Make SADX Super Sonic use Sonic's model
- HMODULE hmodule = GetModuleHandle(L"CHRMODELS_orig");
- NJS_ACTION **___SONIC_ACTIONS = (NJS_ACTION **)GetProcAddress(hmodule, "___SONIC_ACTIONS");
- //Original __SONIC_ACTIONS[]
- NJS_MOTION *sonicaction1motion;
- NJS_MOTION *sonicaction2motion;
- NJS_MOTION *sonicaction3motion;
- NJS_MOTION *sonicaction4motion;
- NJS_MOTION *sonicaction5motion;
- NJS_MOTION *sonicaction6motion;
- NJS_MOTION *sonicaction18motion;
- NJS_MOTION *sonicaction120motion;
- NJS_MOTION *sonicaction121motion;
- NJS_MOTION *sonicaction122motion;
- NJS_MOTION *sonicaction123motion;
- ///////////////////////////////////////////////////////////////////////// INIT FUNCTION ///////////////////////////////////////////////////////////////////////////////////////
- void Sonic_Init()
- {
- //Animated texture stuff
- HMODULE hmodule = GetModuleHandle(L"CHRMODELS_orig");
- NJS_OBJECT **___SONIC_OBJECTS = (NJS_OBJECT **)GetProcAddress(hmodule, "___SONIC_OBJECTS");
- processobject(&object_010056AF50);
- processobject(&object_01005729CC);
- processobject2(&object_020056AF50);
- processobject2(&object_02005729CC);
- //To get the right anim without the weird crashes...
- HMODULE handle = GetModuleHandle(L"CHRMODELS_orig");
- NJS_ACTION **___SONIC_ACTIONS = (NJS_ACTION **)GetProcAddress(handle, "___SONIC_ACTIONS");
- NJS_MODEL_SADX **___SONIC_MODELS = (NJS_MODEL_SADX **)GetProcAddress(handle, "___SONIC_MODELS");
- ___SONIC_OBJECTS[0] = &object_0056AF50;
- ___SONIC_ACTIONS[6]->motion = &___SONIC_ACTIONS_6;
- //Original __SONIC_ACTIONS[]
- sonicaction1motion = ___SONIC_ACTIONS[1]->motion;
- sonicaction2motion = ___SONIC_ACTIONS[2]->motion;
- sonicaction3motion = ___SONIC_ACTIONS[3]->motion;
- sonicaction4motion = ___SONIC_ACTIONS[4]->motion;
- sonicaction5motion = ___SONIC_ACTIONS[5]->motion;
- sonicaction6motion = ___SONIC_ACTIONS[6]->motion;
- sonicaction18motion = ___SONIC_ACTIONS[18]->motion;
- sonicaction120motion = ___SONIC_ACTIONS[120]->motion;
- sonicaction121motion = ___SONIC_ACTIONS[121]->motion;
- sonicaction122motion = ___SONIC_ACTIONS[122]->motion;
- sonicaction123motion = ___SONIC_ACTIONS[123]->motion;
- Gauge = 10000;
- };
- ///////////////////////////////////////////////////////////////////////// OnInput FUNCTION ///////////////////////////////////////////////////////////////////////////////////////
- void Sonic_OnInput()
- {
- if (GameState != 15 && GameState != 16)
- {
- memset(average, 0, sizeof(average));
- average_index = 0;
- current_length = 0;
- return;
- }
- CharObj2* data2 = GetCharObj2(0);
- if (data2 == 0)
- return;
- //const float x1 = data2->Speed.x;
- //const float z1 = data2->Speed.z;
- //const float speed = sqrt((x1 * x1) + (z1 * z1));
- //SetDebugFontSize(30);
- //DisplayDebugStringFormatted((40 << 16) | 28, "%4i km/h", (int)ceil(speed * 21.6f));
- //DisplayDebugStringFormatted((41 << 16) | 29, "%4i m/s", (int)ceil(speed * 6.0f));
- //DisplayDebugStringFormatted((42 << 16) | 31, "%4.1f km", speed * 0.0001);
- //SetDebugFontSize(12);
- //if (speed > 7.0f)
- // ControllersRaw[0].RightStickY = -127;
- //******************************************************************************************DisplayDebugStringFormatted((43 << 16) | 32, "%4i points", EnemyBonus);
- if (GameState == 15)
- {
- const float x = data2->Speed.x;
- const float z = data2->Speed.z;
- const float m = sqrt((x * x) + (z * z));
- average[average_index] = m;
- ++average_index;
- average_index %= 2160000;
- if (current_length < 2160000);
- current_length++;
- }
- float something = 0.0f;
- for (int i = 0; i < current_length; i++)
- {
- something += average[i];
- }
- something /= (float)current_length;
- //SetDebugFontSize(15);
- //DisplayDebugStringFormatted((83 << 16) | 65, "%6.0f km/h.avg", something * 21.6f);
- //SetDebugFontSize(12);
- }
- ///////////////////////////////////////////////////////////////////////// OnFrame FUNCTION ///////////////////////////////////////////////////////////////////////////////////////
- void Sonic_OnFrame()
- {
- HMODULE hmodule = GetModuleHandle(L"CHRMODELS_orig");
- NJS_OBJECT **___SONIC_OBJECTS = (NJS_OBJECT **)GetProcAddress(hmodule, "___SONIC_OBJECTS");
- WriteData((PVMEntry**)0x90ED54, SonicTextures);
- WriteCall((void*)0x4959AA, MetalSonic_AfterImage_Display_r);
- WriteData((ObjectFuncPtr*)0x495AED, MetalSonic_AfterImage_Display_r);
- WriteCall((void*)0x494BE7, PlayHomingSound);
- WriteCall((void*)0x4BA525, SetInvincible);
- WriteCall((void*)0x4BA537, UnsetInvincible);
- WriteData((void(**)(ObjectMaster*))0x441E10, &SetSpeedShoes);
- WriteData((void(**)(ObjectMaster*))0x441DEA, &UnsetSpeedShoes);
- WriteData<4>((void*)0x4A1413, 0x90u); //Trail stuff
- //WriteData((void*)0x55E95C, 0x90u, 6);//Sonic can animate the SuperAura
- //WriteData<3>((void*)0x610113, 0x90);
- //ResizeTextureList((NJS_TEXLIST *)0xB98BF8, 201); //For WaveOcean
- //To get the right model and anim for Sonic but causes weird crashes...
- //ChangeToSonicModel();
- ////To get the right anim without the weird crashes...
- //if (!is_hyper && !is_super)
- //{
- // ChangeToSonicModel();
- // //HMODULE handle = GetModuleHandle(L"CHRMODELS_orig");
- // //NJS_ACTION **___SONIC_ACTIONS = (NJS_ACTION **)GetProcAddress(handle, "___SONIC_ACTIONS");
- // //NJS_MODEL_SADX **___SONIC_MODELS = (NJS_MODEL_SADX **)GetProcAddress(handle, "___SONIC_MODELS");
- // //*___SONIC_OBJECTS[0] = object_0056AF50;
- // //*___SONIC_ACTIONS[6]->motion = ___SONIC_ACTIONS_6;
- //}
- //PVMEntry pvm = { "AMY_EFF", (NJS_TEXLIST*)0x91C808 };// helperFunctions.RegisterCharacterPVM(Characters_Sonic, pvm);
- //pvm = { "SUPERSONIC", (NJS_TEXLIST*)0x142272C }; helperFunctions.RegisterCharacterPVM(Characters_Sonic, pvm);
- //WaveOceanTEST
- // char pathbuf[MAX_PATH];
- // _snprintf(pathbuf, MAX_PATH, "%s\\LandTable.sa1lvl", path);
- // LandTableInfo *landtableinfo = new LandTableInfo(pathbuf);
- // LandTable *landtable = landtableinfo->getlandtable();
- // WriteData((LandTable**)0x97DA48, landtable);
- EntityData1* co1 = EntityData1Ptrs[0];
- CharObj2 *co2 = GetCharObj2(0);
- //if (CharacterSelection == 0)
- //{
- // ChangeToSonicModel();
- // njReleaseTexture((NJS_TEXLIST*)0x927CB8);
- // LoadPVM("SON_EFF", (NJS_TEXLIST*)0x927CB8);
- // njReleaseTexture((NJS_TEXLIST*)0x142272C);
- // LoadPVM("SUPERSONIC", (NJS_TEXLIST*)0x142272C);
- // njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
- // LoadPVM("EFF_REGULAR", (NJS_TEXLIST*)0x94A2A8);
- //}
- if (GameState == 15)
- {
- if (CurrentLevel == 26 || CurrentLevel == 29 || CurrentLevel == 33)
- {
- Sonic_LightSpeedShoesObtained = 1;
- Sonic_CrystalRingObtained = 1;
- Sonic_AncientLightObtained = 1;
- }
- else if (EntityData1Ptrs[0]->Action != 4 || (co1->Status & Status_LightDash) != Status_LightDash)
- {
- Sonic_LightSpeedShoesObtained = 1;
- Sonic_CrystalRingObtained = 0;
- Sonic_AncientLightObtained = 0;
- }
- else
- {
- Sonic_LightSpeedShoesObtained = 1;
- Sonic_CrystalRingObtained = 0;
- Sonic_AncientLightObtained = 1;
- }
- }
- if (CurrentMusic == 24 || CurrentMusic == 72 || CurrentMusic == 101 || CurrentMusic == 102 || CurrentMusic == 103)
- {
- ChangeToSonicModel();
- }
- ////FOR SHADOW'S CHAOS BOOST
- //if (Rings == 1)
- //{
- // Knuckles_MaximumHeat_Draw(&EntityData1Ptrs[0]->CollisionInfo->CollisionArray->origin, (njSin(++alpha << 10) + 1.0) * 0.2);
- //}
- //if (Lives == 1 && !hypersparkles)
- //{
- // hypersparkles = LoadObject(LoadObj_Data1, 2, Invincibility_Load);
- // if (hypersparkles) hypersparkles->Data1->CharIndex = 0;
- //}
- //if (Lives != 1)
- //{
- // DeleteObject_(hypersparkles);
- // hypersparkles = nullptr;
- //}
- //Extra transformations
- if (co2 == NULL) return;
- if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
- {
- if (CurrentMusic != 45 && CurrentMusic != 55 && CurrentMusic != 85 && CurrentMusic != 86 && CurrentMusic != 96) // FIX THIS SHIIIIIIIIIIIIIIIIIIIIIIIIIIIIT !!!!!!!!!!!!!!!!!!!!!!!
- {
- oldmusic = CurrentMusic;
- }
- //if (CurrentMusic == 85)
- if (CurrentLevel != 26 && CurrentLevel != 29 && CurrentLevel != 33)
- {
- if (GameState != 16)
- {
- if (!is_super)
- {
- if (!is_hyper)
- {
- if (!just_transformed && Rings >= 50)
- {
- if (EntityData1Ptrs[0]->Action == 8 && !(co1->Status & Status_LightDash))
- {
- if (ControllerPointers[0]->PressedButtons & Buttons_C && co2->AnimationThing.Index != 75)//Super transformation (toggle)
- {
- PlaySound(766, 0, 0, 0);
- if (CurrentMusic != 96)
- {
- //PlayMusic(MusicIDs_sprsonic);
- CurrentMusic = 86;
- }
- transforming = true;
- is_super = true;
- just_transformed = true;
- ChangeToSuperSonicModel();
- co2->Powerups |= Powerups_Invincibility;
- njReleaseTexture((NJS_TEXLIST*)0x927CB8);
- LoadPVM("SS_SON_EFF", (NJS_TEXLIST*)0x927CB8);
- njReleaseTexture((NJS_TEXLIST*)0x142272C);
- LoadPVM("SS_SUPERSONIC", (NJS_TEXLIST*)0x142272C);
- njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
- LoadPVM("SS_EFF_REGULAR", (NJS_TEXLIST*)0x94A2A8);
- }
- }
- }
- }
- else if (!transforming)
- {
- if (ControllerPointers[0]->PressedButtons & Buttons_C && co2->AnimationThing.Index != 75)//Super transformation (toggle)
- {
- is_super = true;
- is_hyper = false;
- PlaySound(815, 0, 0, 0);
- CurrentMusic = 86;
- //PlayMusic(MusicIDs_sprsonic);
- ChangeToSuperSonicModel();
- DeleteObject_(hypersparkles);
- hypersparkles = nullptr;
- co2->Powerups |= Powerups_Invincibility;
- njReleaseTexture((NJS_TEXLIST*)0x927CB8);
- LoadPVM("SS_SON_EFF", (NJS_TEXLIST*)0x927CB8);
- njReleaseTexture((NJS_TEXLIST*)0x142272C);
- LoadPVM("SS_SUPERSONIC", (NJS_TEXLIST*)0x142272C);
- njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
- LoadPVM("SS_EFF_REGULAR", (NJS_TEXLIST*)0x94A2A8);
- }
- }
- }
- else if (!transforming)
- {
- if ((ControllerPointers[0]->PressedButtons & Buttons_C && co2->AnimationThing.Index != 75) || Rings == 0)//Super transformation (toggle)
- {
- just_untransformed = true;
- is_super = false;
- is_hyper = false;
- PlaySound(816, 0, 0, 0);
- if (CurrentMusic != 96)
- {
- CurrentMusic = oldmusic;
- }
- ChangeToSonicModel();
- super_rings_depletion = 0;
- hyper_rings_depletion = 0;
- WriteData((short*)0x4BA46D, (short)1380);
- co2->Powerups &= ~Powerups_Invincibility;
- njReleaseTexture((NJS_TEXLIST*)0x927CB8);
- LoadPVM("SON_SON_EFF", (NJS_TEXLIST*)0x927CB8);
- njReleaseTexture((NJS_TEXLIST*)0x142272C);
- LoadPVM("SON_SUPERSONIC", (NJS_TEXLIST*)0x142272C);
- njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
- LoadPVM("EFF_REGULAR", (NJS_TEXLIST*)0x94A2A8);
- }
- else if (EntityData1Ptrs[0]->Action != 8 && ControllerPointers[0]->PressedButtons & Buttons_D)
- {
- just_untransformed = true;
- is_super = false;
- is_hyper = false;
- PlaySound(816, 0, 0, 0);
- if (CurrentMusic != 96)
- {
- CurrentMusic = oldmusic;
- }
- ChangeToSonicModel();
- super_rings_depletion = 0;
- hyper_rings_depletion = 0;
- WriteData((short*)0x4BA46D, (short)1380);
- co2->Powerups &= ~Powerups_Invincibility;
- njReleaseTexture((NJS_TEXLIST*)0x927CB8);
- LoadPVM("SON_SON_EFF", (NJS_TEXLIST*)0x927CB8);
- njReleaseTexture((NJS_TEXLIST*)0x142272C);
- LoadPVM("SON_SUPERSONIC", (NJS_TEXLIST*)0x142272C);
- njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
- LoadPVM("EFF_REGULAR", (NJS_TEXLIST*)0x94A2A8);
- }
- }
- if (!is_hyper)
- {
- if (!just_transformed && Rings >= 100)
- {
- if (EntityData1Ptrs[0]->Action == 8 && !(co1->Status & Status_LightDash))
- {
- if (ControllerPointers[0]->PressedButtons & Buttons_D && co2->AnimationThing.Index != 75)//Hyper transformation (toggle)
- {
- PlaySound(814, 0, 0, 0);
- co2->UnderwaterTime = 1;
- CurrentMusic = 45;
- //PlayMusic(MusicIDs_fishing);
- transforming = true;
- is_super = false;
- is_hyper = true;
- just_transformed = true;
- ChangeToHyperSonicModel();
- WriteData((short*)0x4BA46D, (short)65534);
- co2->Powerups &= ~Powerups_Invincibility;
- njReleaseTexture((NJS_TEXLIST*)0x927CB8);
- LoadPVM("HS_SON_EFF", (NJS_TEXLIST*)0x927CB8);
- njReleaseTexture((NJS_TEXLIST*)0x142272C);
- LoadPVM("HS_SUPERSONIC", (NJS_TEXLIST*)0x142272C);
- njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
- LoadPVM("HS_EFF_REGULAR", (NJS_TEXLIST*)0x94A2A8);
- }
- }
- }
- }
- else if (!transforming)
- {
- if ((ControllerPointers[0]->PressedButtons & Buttons_D && co2->AnimationThing.Index != 75) || Rings == 0)//Hyper transformation (toggle)
- {
- just_untransformed = true;
- is_super = false;
- is_hyper = false;
- PlaySound(816, 0, 0, 0);
- if (CurrentMusic != 96)
- {
- CurrentMusic = oldmusic;
- }
- ChangeToSonicModel();
- super_rings_depletion = 0;
- hyper_rings_depletion = 0;
- co2->Powerups &= ~Powerups_Invincibility;
- DeleteObject_(hypersparkles);
- hypersparkles = nullptr;
- WriteData((short*)0x4BA46D, (short)1380);
- njReleaseTexture((NJS_TEXLIST*)0x927CB8);
- LoadPVM("SON_SON_EFF", (NJS_TEXLIST*)0x927CB8);
- njReleaseTexture((NJS_TEXLIST*)0x142272C);
- LoadPVM("SON_SUPERSONIC", (NJS_TEXLIST*)0x142272C);
- njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
- LoadPVM("EFF_REGULAR", (NJS_TEXLIST*)0x94A2A8);
- }
- }
- }
- if (transforming)
- {
- ++transforming_time;
- //++transform_anim;
- //++firstanim_speedup;
- //if (firstanim_speedup > 0 && firstanim_speedup < 2)
- //{
- // ((AnimData_t*)0x3C56210)[85].AnimationSpeed = 20;
- //}
- //else ((AnimData_t*)0x3C56210)[85].AnimationSpeed = 1;
- //if (transform_anim <= 30)
- //{
- // co2->AnimationThing.Index = 85;
- //}
- //else
- //{
- // co2->AnimationThing.Index = 84;
- //}
- co2->AnimationThing.Index = 84;
- co2->Speed.x = 0;
- co2->Speed.y = 0.125;
- co2->Speed.z = 0;
- }
- if (transforming_time == 40)
- {
- transforming_time = 0;
- transforming = false;
- //transform_anim = 0;
- //firstanim_speedup = 0;
- }
- if ((co1->Status & Status_Ground) == Status_Ground || co2->AnimationThing.Index == 0 || co2->AnimationThing.Index == 1 || co2->AnimationThing.Index == 2 || 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 == 31)
- {
- just_transformed = false;
- }
- if (GameState == 0 || GameState == 1 || GameState == 2 || GameState == 3 || GameState == 4 || GameState == 6 || GameState == 7 || GameState == 9 || GameState == 20 || GameState == 21 || GameState == 23)
- {
- if (++testvar == 1)
- {
- transforming_time = 0;
- transforming = false;
- just_transformed = false;
- super_rings_depletion = 0;
- hyper_rings_depletion = 0;
- //transform_anim = 0;
- //if (CurrentLevel != 26 && CurrentLevel != 29 && CurrentLevel != 33)
- //{
- // if (++testvar2 == 1)
- // {
- is_super = false;
- is_hyper = false;
- ChangeToSonicModel();
- DeleteObject_(hypersparkles);
- hypersparkles = nullptr;
- njReleaseTexture((NJS_TEXLIST*)0x927CB8);
- LoadPVM("SON_SON_EFF", (NJS_TEXLIST*)0x927CB8);
- njReleaseTexture((NJS_TEXLIST*)0x142272C);
- LoadPVM("SON_SUPERSONIC", (NJS_TEXLIST*)0x142272C);
- njReleaseTexture((NJS_TEXLIST*)0x94A2A8);
- LoadPVM("EFF_REGULAR", (NJS_TEXLIST*)0x94A2A8);
- // }
- //}
- //else testvar2 = 0;
- }
- }
- else testvar = 0;
- if (just_untransformed)
- {
- if (co2->AnimationThing.Index == 9 || co2->AnimationThing.Index == 10 || co2->AnimationThing.Index == 11 || co2->AnimationThing.Index == 12 || co2->AnimationThing.Index == 13)
- {
- if (co2->Speed.x > 0.47)
- {
- //co2->PhysicsData.RollCancel = 100;
- //co2->PhysicsData.RollEnd = 100; // I NEED TO DO THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- //co2->PhysicsData.Run1 = 100;
- //co2->PhysicsData.Run2 = 100;
- }
- if (++untransforming > 1)
- {
- just_untransformed = false;
- }
- }
- }
- else
- {
- co2->PhysicsData.RollCancel = 0.46;
- co2->PhysicsData.RollEnd = 1.39;
- co2->PhysicsData.Run1 = 4.85;
- untransforming = 0;
- }
- }
- }
- //Hyper always sparkles
- if (is_hyper && (co2->Powerups & Powerups_Invincibility) != Powerups_Invincibility)
- {
- hypersparkles = LoadObject(LoadObj_Data1, 2, Invincibility_Load);
- if (hypersparkles) hypersparkles->Data1->CharIndex = 0;
- }
- //Super music
- if (is_super && co2->AnimationThing.Index != 75 && CurrentMusic != 96)
- {
- CurrentMusic = 86;
- //PlayMusic(MusicIDs_sprsonic);
- }
- //Hyper music and afterimages
- if (is_hyper && co2->AnimationThing.Index != 75)
- {
- CurrentMusic = 45;
- //PlayMusic(MusicIDs_fishing);
- double SpeedXYaftimages = sqrt(pow(co2->Speed.x, 2) + pow(co2->Speed.y, 2) + pow(co2->Speed.z, 2));
- if (GameState != 16)
- {
- if (!(co2->SurfaceFlags & 2))
- {
- if (!trailobj && !(EntityData1Ptrs[0]->Action == 6 && SpeedXYaftimages > 7.999 && SpeedXYaftimages < 8.001) && EntityData1Ptrs[0]->Action != 4 && EntityData1Ptrs[0]->Action != 5 && EntityData1Ptrs[0]->Action != 14 && EntityData1Ptrs[0]->Action != 44 && EntityData1Ptrs[0]->Action != 45)
- {
- if (++testvar3 == 2)
- {
- ObjectMaster *v1 = LoadObject(LoadObj_Data1, 3, MetalSonic_AfterImages_Main);
- if (v1) *(int*)&v1->Data1->Object = 1;
- testvar3 = 0;
- }
- }
- }
- else if (!is_boosting)
- {
- if (!(EntityData1Ptrs[0]->Action == 6 && SpeedXYaftimages > 7.999 && SpeedXYaftimages < 8.001) && EntityData1Ptrs[0]->Action != 4 && EntityData1Ptrs[0]->Action != 5 && EntityData1Ptrs[0]->Action != 14 && EntityData1Ptrs[0]->Action != 44 && EntityData1Ptrs[0]->Action != 45)
- {
- if (++testvar3 == 2)
- {
- if (GameState != 16)
- {
- ObjectMaster *v1 = LoadObject(LoadObj_Data1, 3, MetalSonic_AfterImages_Main);
- if (v1) *(int*)&v1->Data1->Object = 1;
- testvar3 = 0;
- }
- }
- }
- }
- }
- }
- //Anim data
- if (co2 == NULL) return;
- if (GetCharacterObject(0) && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0)
- {
- if (is_super || is_hyper)
- {
- ((AnimData_t*)0x3C56210)[18].TransitionSpeed = 0.1;
- ((AnimData_t*)0x3C56210)[64].TransitionSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[64].AnimationSpeed = 1.5;
- ((AnimData_t*)0x3C56210)[14].AnimationSpeed = 0.15;
- ((AnimData_t*)0x3C56210)[40].AnimationSpeed = 1.15;
- ((AnimData_t*)0x3C56210)[42].AnimationSpeed = 0.9;
- ((AnimData_t*)0x3C56210)[31].TransitionSpeed = 0.125;
- ((AnimData_t*)0x3C56210)[29].AnimationSpeed = 2.0;
- ((AnimData_t*)0x3C56210)[75].AnimationSpeed = 0.75;
- ((AnimData_t*)0x3C56210)[38].AnimationSpeed = 2.5;
- ((AnimData_t*)0x3C56210)[34].AnimationSpeed = 0.6;
- ((AnimData_t*)0x3C56210)[38].Property = 9;
- ((AnimData_t*)0x3C56210)[34].Property = 9;
- ((AnimData_t*)0x3C56210)[0].Property = 3;
- ((AnimData_t*)0x3C56210)[0].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[1].Property = 3;
- ((AnimData_t*)0x3C56210)[1].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[2].Property = 3;
- ((AnimData_t*)0x3C56210)[2].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[3].Property = 3;
- ((AnimData_t*)0x3C56210)[3].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[4].Property = 3;
- ((AnimData_t*)0x3C56210)[4].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[5].Property = 3;
- ((AnimData_t*)0x3C56210)[5].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[6].Property = 3;
- ((AnimData_t*)0x3C56210)[6].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[9].Property = 9;
- ((AnimData_t*)0x3C56210)[9].AnimationSpeed = 1.0;
- ((AnimData_t*)0x3C56210)[10].Property = 9;
- ((AnimData_t*)0x3C56210)[10].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[11].Property = 9;
- ((AnimData_t*)0x3C56210)[11].AnimationSpeed = 0.07;
- ((AnimData_t*)0x3C56210)[13].Property = 9;
- ((AnimData_t*)0x3C56210)[13].AnimationSpeed = 0.25;
- co2->PhysicsData.RollEnd = 3.0;
- co2->PhysicsData.Run1 = 12.0;
- ((AnimData_t*)0x3C56210)[27].AnimationSpeed = 100.0;
- ((AnimData_t*)0x3C56210)[28].AnimationSpeed = 100.0;
- if (EntityData1Ptrs[0]->Action == 18)
- {
- co2->Speed.x = 0.0;
- }
- }
- else
- {
- ((AnimData_t*)0x3C56210)[18].TransitionSpeed = 0.1;
- ((AnimData_t*)0x3C56210)[64].TransitionSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[64].AnimationSpeed = 1.5;
- ((AnimData_t*)0x3C56210)[12].AnimationSpeed = 0.415;
- ((AnimData_t*)0x3C56210)[13].AnimationSpeed = 0.415;
- ((AnimData_t*)0x3C56210)[14].AnimationSpeed = 0.15;
- ((AnimData_t*)0x3C56210)[40].AnimationSpeed = 1.15;
- ((AnimData_t*)0x3C56210)[42].AnimationSpeed = 0.9;
- ((AnimData_t*)0x3C56210)[31].TransitionSpeed = 0.125;
- ((AnimData_t*)0x3C56210)[29].AnimationSpeed = 2.0;
- ((AnimData_t*)0x3C56210)[75].AnimationSpeed = 0.75;
- ((AnimData_t*)0x3C56210)[38].AnimationSpeed = 2.5;
- ((AnimData_t*)0x3C56210)[34].AnimationSpeed = 0.6;
- ((AnimData_t*)0x3C56210)[38].Property = 9;
- ((AnimData_t*)0x3C56210)[34].Property = 9;
- ((AnimData_t*)0x3C56210)[0].Property = 3;
- ((AnimData_t*)0x3C56210)[0].AnimationSpeed = 0.5;
- ((AnimData_t*)0x3C56210)[1].Property = 4;
- ((AnimData_t*)0x3C56210)[1].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[2].Property = 3;
- ((AnimData_t*)0x3C56210)[2].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[3].Property = 4;
- ((AnimData_t*)0x3C56210)[3].AnimationSpeed = 1.0;
- ((AnimData_t*)0x3C56210)[4].Property = 4;
- ((AnimData_t*)0x3C56210)[4].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[5].Property = 4;
- ((AnimData_t*)0x3C56210)[5].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[6].Property = 6;
- ((AnimData_t*)0x3C56210)[6].AnimationSpeed = 0.25;
- ((AnimData_t*)0x3C56210)[9].Property = 9;
- ((AnimData_t*)0x3C56210)[9].AnimationSpeed = 3.4;
- ((AnimData_t*)0x3C56210)[10].Property = 9;
- ((AnimData_t*)0x3C56210)[10].AnimationSpeed = 1.4;
- ((AnimData_t*)0x3C56210)[11].Property = 9;
- ((AnimData_t*)0x3C56210)[12].Property = 9;
- ((AnimData_t*)0x3C56210)[13].Property = 9;
- co2->PhysicsData.RollEnd = 1.39;
- co2->PhysicsData.Run1 = 4.85;
- co2->PhysicsData.AirDecel = -0.028;
- ((AnimData_t*)0x3C56210)[27].AnimationSpeed = 1.0;
- ((AnimData_t*)0x3C56210)[28].AnimationSpeed = 1.0;
- //SONIC Run anim speed
- if (co2->Speed.x <= 2.3 && co2->Speed.x >= 1.3 && GetCharacterID(0) == Characters_Sonic && MetalSonicFlag == 0) ((AnimData_t*)0x3C56210)[11].AnimationSpeed = 0.9;
- else ((AnimData_t*)0x3C56210)[11].AnimationSpeed = 0.6225;
- }
- }
- //SA2 jumpball
- SA2_jumpball(co1, co2);
- //Super/Hyper Y Offset
- if (is_super || is_hyper)
- {
- double SpeedXYoffset = sqrt(pow(co2->Speed.x, 2) + pow(co2->Speed.y, 2) + pow(co2->Speed.z, 2));
- if ((GameState == 15 || GameState == 16 || GameState == 4) && !(co2->SurfaceFlags & 2) && !(EntityData1Ptrs[0]->Action == 6 && SpeedXYoffset > 7.999 && SpeedXYoffset < 8.001) && (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 == 9 || co2->AnimationThing.Index == 10 || co2->AnimationThing.Index == 11 || co2->AnimationThing.Index == 12 || co2->AnimationThing.Index == 13 || co2->AnimationThing.Index == 64))
- {
- co2->PhysicsData.YOff = 8.5;
- WriteData((float**)0x4B9D1E, &invinmult);
- WriteData((void*)0x4BA276, invinsize);
- WriteData<3>((void*)0x4BA280, 0x90);
- }
- else
- {
- co2->PhysicsData.YOff = 5.4;
- WriteData((float**)0x4B9D1E, &invinmult_orig);
- WriteData((void*)0x4BA276, invinsize_orig);
- WriteData((void*)0x4BA280, invin_stuff_unNOP);
- }
- }
- else
- {
- co2->PhysicsData.YOff = 5.4;
- WriteData((float**)0x4B9D1E, &invinmult_orig);
- WriteData((void*)0x4BA276, invinsize_orig);
- WriteData((void*)0x4BA280, invin_stuff_unNOP);
- }
- //Super/Hyper Sonic animated textures and ring depletion
- if (GameState != 16)
- {
- if (is_super)
- {
- for (auto iter = materials.cbegin(); iter != materials.cend(); ++iter) (*iter)->attr_texId = 29 + ((FrameCounter / 3) % 32);
- HMODULE handle = GetModuleHandle(L"CHRMODELS_orig");
- NJS_OBJECT **___SONIC_OBJECTS = (NJS_OBJECT **)GetProcAddress(handle, "___SONIC_OBJECTS");
- ___SONIC_OBJECTS[44]->basicdxmodel->mats[0].attr_texId = SUPERSpinballtextures[(FrameCounter / 3) % 32];
- ++super_rings_depletion;
- if (super_rings_depletion == 48 && Rings != 0 && co2->AnimationThing.Index != 75)
- {
- Rings -= 1;
- super_rings_depletion = 0;
- }
- }
- if (is_hyper)
- {
- for (auto iter = materials2.cbegin(); iter != materials2.cend(); ++iter) (*iter)->attr_texId = 95 + ((FrameCounter / 3) % 32);
- HMODULE handle = GetModuleHandle(L"CHRMODELS_orig");
- NJS_OBJECT **___SONIC_OBJECTS = (NJS_OBJECT **)GetProcAddress(handle, "___SONIC_OBJECTS");
- ___SONIC_OBJECTS[44]->basicdxmodel->mats[0].attr_texId = HYPERSpinballtextures[(FrameCounter / 3) % 32];
- ++hyper_rings_depletion;
- if (hyper_rings_depletion == 24 && Rings != 0 && co2->AnimationThing.Index != 75)
- {
- Rings -= 1;
- hyper_rings_depletion = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement