--- Daodan/src/Patches/Patches.c 2014/05/04 18:17:11 1000 +++ Daodan/src/Patches/Patches.c 2015/03/23 23:29:19 1017 @@ -5,6 +5,7 @@ #include "Cheater.h" #include "../Daodan_Config.h" #include "GL.h" +#include "Input.h" #include "../Daodan_Patch.h" #include "Utility.h" #include "Win32.h" @@ -131,6 +132,8 @@ int16_t ONICALL DD_COrTextArea_Resize(vo return Oni_COrTextArea_Resize(inTextArea, inBounds, inNumTextEntries); } + + #define IMcShade_Red (0xFFFF0000) #define IMcShade_Green (0xFF00FF00) #define IMcShade_Blue (0xFF0000FF) @@ -277,7 +280,29 @@ void DD_Patch_ShowNames() } - +void DD_Patch_CharacterAwareness() +{ + const unsigned char patch[] = + { + 0x52, // 0: push edx + 0xBA, 0xA0, 0x16, 0x00, 0x00, // 1: mov edx,0x16a0 + 0x89, 0xF8, // 6: mov eax,edi + 0xF7, 0xE2, // 8: mul edx + 0x89, 0xC2, // a: mov edx,eax + 0xE8, 0x00, 0x00, 0x00, 0x00, // c: call ONrGameState_LivingCharacterList_Get (-> OniExe + 0x000fca90) + 0x8B, 0x00, // 11: mov eax,[eax] + 0x01, 0xD0, // 13: add eax,edx + 0x89, 0xC6, // 15: mov esi,eax + 0x5A, // 17: pop edx + 0x8B, 0x46, 0x04, // 18: (ORIG) mov eax, dword [ds:esi+0x4] + 0xF6, 0xC4, 0x80 // 1b: (ORIG) test ah, 0x80 + }; + void* newCode = DDrPatch_ExecutableASM((char*)(OniExe + 0x0009A609), (char*)(OniExe + 0x0009A60F), patch, sizeof(patch)); + if ((int)newCode > 0) { + DDrPatch_MakeCall((char*)(newCode+0xC), (char*)(OniExe + 0x000FCA90)); + DDrPatch_NOOP((char*)(OniExe + 0x0009A60E), 1); + } +} @@ -321,6 +346,9 @@ bool DD_Patch_Init() if (DDrConfig_GetOptOfType("modding.d_regen", C_BOOL)->value.intBoolVal) DD_Patch_Regeneration(); + if (DDrConfig_GetOptOfType("gameplay.characterawareness", C_BOOL)->value.intBoolVal) + DD_Patch_CharacterAwareness(); + // Cheats always enabled if (DDrConfig_GetOptOfType("gameplay.cheatsenabled", C_BOOL)->value.intBoolVal) { @@ -346,6 +374,11 @@ bool DD_Patch_Init() // At end of ONrUnlockLevel to init values on level loading DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad); + + if (DDrConfig_GetOptOfType("gameplay.bindablecheats", C_BOOL)->value.intBoolVal) + { + InitBindableCheats(); + } } if (DDrConfig_GetOptOfType("language.chinese", C_BOOL)->value.intBoolVal) @@ -413,6 +446,12 @@ bool DD_Patch_Init() Oni_COrTextArea_Resize = DDrPatch_MakeDetour((void*)COrTextArea_Resize, (void*)DD_COrTextArea_Resize); } + // Allow custom actions to be bound through Daodan + if (DDrConfig_GetOptOfType("gameplay.customactions", C_BOOL)->value.intBoolVal) + { + Input_PatchCode (); + } + // Hackish fix for Konoko not kicking guns // Don't use this, it breaks stairs. if (DDrConfig_GetOptOfType("gameplay.kickguns", C_BOOL)->value.intBoolVal)