diff --git a/CommonAPI/Common/Debug/Common.lastbuildstate b/CommonAPI/Common/Debug/Common.lastbuildstate new file mode 100644 index 0000000..598a8df --- /dev/null +++ b/CommonAPI/Common/Debug/Common.lastbuildstate @@ -0,0 +1,2 @@ +#v4.0:v100 +Debug|Win32|C:\t2cpp\T2-CPP-master\| diff --git a/CommonAPI/Common/Debug/Common.unsuccessfulbuild b/CommonAPI/Common/Debug/Common.unsuccessfulbuild new file mode 100644 index 0000000..e69de29 diff --git a/CommonAPI/Common/Debug/vc100.idb b/CommonAPI/Common/Debug/vc100.idb new file mode 100644 index 0000000..f43848e Binary files /dev/null and b/CommonAPI/Common/Debug/vc100.idb differ diff --git a/CommonAPI/Common/Release/Common.lastbuildstate b/CommonAPI/Common/Release/Common.lastbuildstate new file mode 100644 index 0000000..88c2954 --- /dev/null +++ b/CommonAPI/Common/Release/Common.lastbuildstate @@ -0,0 +1,2 @@ +#v4.0:v100 +Release|Win32|C:\t2cpp\T2-CPP-master\| diff --git a/CommonAPI/Common/include/DXAPI/DXAPI.h b/CommonAPI/Common/include/DXAPI/DXAPI.h index 9e57c59..813f48b 100644 --- a/CommonAPI/Common/include/DXAPI/DXAPI.h +++ b/CommonAPI/Common/include/DXAPI/DXAPI.h @@ -42,6 +42,9 @@ namespace DX bool GetRelativePath(const char *filename, char *ret, int buffer_length); bool GetRunningMod(char *ret, int buffer_length); - + bool memPatch(unsigned int addr, unsigned char * data, unsigned int size); + bool memToHex(unsigned int addr, char * dst, int size, bool spaces); + unsigned int memToUInt(unsigned int addr); + float memToFloat(unsigned int addr); bool SanitizeFileName(char *ret, int buffer_length); } // End NameSpace DX \ No newline at end of file diff --git a/CommonAPI/Common/include/DXAPI/Player.h b/CommonAPI/Common/include/DXAPI/Player.h index ad49241..dfd644d 100644 --- a/CommonAPI/Common/include/DXAPI/Player.h +++ b/CommonAPI/Common/include/DXAPI/Player.h @@ -20,6 +20,8 @@ namespace DX const bool &is_jetting; //! Player Object Jumping State (readonly, writing it doesn't do anything) const bool &is_jumping; + float &headRotationZ; + float &mRotZ; //! Player Object Using Toggable Pack bool &is_using_toggledpack; diff --git a/CommonAPI/Common/source/DXAPI/DXAPI.cpp b/CommonAPI/Common/source/DXAPI/DXAPI.cpp index e68e788..d8932b1 100644 --- a/CommonAPI/Common/source/DXAPI/DXAPI.cpp +++ b/CommonAPI/Common/source/DXAPI/DXAPI.cpp @@ -14,12 +14,58 @@ #include #include - +#include #include namespace DX { - + bool memPatch(unsigned int addr, unsigned char * data, unsigned int size){ + DWORD oldprotect=0; + DWORD oldnewprotect=0; + VirtualProtect((void *)addr,size,PAGE_EXECUTE_READWRITE,&oldprotect); + memcpy((void *)addr,(void*) data,size); + VirtualProtect((void *)addr,size,oldprotect,&oldnewprotect); + return true; + } + float memToFloat(unsigned int addr){ + DWORD oldprotect=0; + DWORD oldnewprotect=0; + VirtualProtect((void *)addr,4,PAGE_EXECUTE_READWRITE,&oldprotect); + float * floatout=(float *)addr; + float retfloat=0.0; + retfloat = *floatout; + VirtualProtect((void *)addr,4,oldprotect,&oldnewprotect); + return true; + } + unsigned int memToUInt(unsigned int addr){ + DWORD oldprotect=0; + DWORD oldnewprotect=0; + VirtualProtect((void *)addr,4,PAGE_EXECUTE_READWRITE,&oldprotect); + unsigned int * intout=(unsigned int *)addr; + int retint=0; + retint = *intout; + VirtualProtect((void *)addr,4,oldprotect,&oldnewprotect); + return true; + } + bool memToHex(unsigned int addr, char * dst, int size, bool spaces=false){ + DWORD oldprotect=0; + DWORD oldnewprotect=0; + char hexdigits[20]=""; + char outstr[256]; + VirtualProtect((void *)addr,size,PAGE_EXECUTE_READWRITE,&oldprotect); + for (int i=0; i #include +const char *conDumpHex(Linker::SimObject *obj, S32 argc, const char *argv[]) +{ + // Hmm... + char result[256]; + unsigned int addr=atoi(argv[1]); + DX::memToHex(addr,result,atoi(argv[2]),dAtob(argv[3])); + return result; + +} +const char *conDumpUInt(Linker::SimObject *obj, S32 argc, const char *argv[]) +{ + // Hmm... + char result[256]; + + unsigned int addr=atoi(argv[1]); + sprintf(result,"%d",DX::memToUInt(addr)); + return result; + +} +const char *conDumpFloat(Linker::SimObject *obj, S32 argc, const char *argv[]) +{ + // Hmm... + char result[256]; + + unsigned int addr=atoi(argv[1]); + sprintf(result,"%f",DX::memToFloat(addr)); + return result; + +} const char *conGetAddress(Linker::SimObject *obj, S32 argc, const char *argv[]) { // Hmm... @@ -11,7 +40,13 @@ const char *conGetAddress(Linker::SimObject *obj, S32 argc, const char *argv[]) sprintf(result, "%x", obj); return result; } - +const char *conGetAddressDec(Linker::SimObject *obj, S32 argc, const char *argv[]) +{ + // Hmm... + char result[256]; + sprintf(result, "%d", obj); + return result; +} bool conShapeBaseSetCloakValue(Linker::SimObject *obj, S32 argc, const char* argv[]) { DX::ShapeBase operand = DX::ShapeBase((unsigned int)obj); diff --git a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp index 70bc65e..4a046ce 100644 --- a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp @@ -1,7 +1,8 @@ // dllmain.cpp : Defines the entry point for the DLL application. #include #include - +#define _USE_MATH_DEFINES +#include BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -24,12 +25,74 @@ BOOL APIENTRY DllMain( HMODULE hModule, #include static DX::Move curmove; static unsigned int tmpobjptr=0; - - +unsigned char movemem[500]; +static DX::Move mechchangedmove; +static void * moveptrmech; +unsigned int updatemoveretptr=0x5d2d7c; +float maxrot=2.9; +float minrot=-2.9; +static unsigned int playerptr=0x0; +static float newTurn = 0.1; +static float turnStrength = 1.0; extern "C" { static DX::AIMove aimoves[1024]; +#define MECH_TURNING_SPEED 0.4 + // Maximum radians per 32ms tick +__declspec(naked) void updateMoveHook() +{ + // this gets run from 0x5D2D6E + + __asm { + mov playerptr,ebx + mov eax,[ebp+0x8] + mov moveptrmech,eax + }; + + unsigned playerptr2; + DX::Player *playervar; + playerptr2=playerptr; + playervar=&(DX::Player(playerptr2)); + memcpy((void *)&mechchangedmove,(void *)(moveptrmech),sizeof(DX::Move)); + + if (dAtob((playervar->CallMethod("isMechControlEnabled",0))) && mechchangedmove.freelook && (mechchangedmove.y>0.0)) + { + mechchangedmove.pitch = 0; + mechchangedmove.yaw = 0; + mechchangedmove.roll = 0; + mechchangedmove.freelook = true; + + // FIXME: The 3 here should reference the datablock's maximum turning angle -- we're essentially normalizing our rotation here. + float turnStrength = playervar->headRotationZ / 3; + // Use whatever is leftover in our forward movement + float forwardStrength = 1 - fabs(turnStrength); + // Calculate a new turn value that we use for both the main body and the head. + float newTurn = turnStrength * MECH_TURNING_SPEED; + float newHeadTurn = turnStrength * (MECH_TURNING_SPEED/20); + + mechchangedmove.y = forwardStrength; + mechchangedmove.x = turnStrength; + // FIXME: Is the yaw value definitely in radians? + playervar->mRotZ += newTurn; + + // Now, we must translate the turning strength into an appropriate subtraction for our + // head rotation. + playervar->headRotationZ += -newTurn; + + } + __asm { + mov eax,offset mechchangedmove + mov [ebp+8],eax + mov ebx,playerptr + mov eax,[ebp+8] + mov edx,[eax] + mov [ebx+0x894],edx + mov eax,[eax+4] + jmp [updatemoveretptr] + }; +} + static unsigned int updatemovehookptr = (unsigned int)updateMoveHook; DX::AIMove * getAIMovePtr(unsigned int id) { int moveindex=0; bool foundindex=false; @@ -157,7 +220,9 @@ extern "C" // Init WSA WSADATA wsadata; WSAStartup(0x0202, &wsadata); - + Con::addMethodS(NULL,"dumpHex",&conDumpHex,"dumpHex(addr,size,spaces)",4,5); + Con::addMethodS(NULL,"dumpDec",&conDumpUInt,"dumpDec(addr)",2,3); + Con::addMethodS(NULL,"dumpFloat",&conDumpFloat,"dumpFloat(addr)",2,3); Con::addMethodB("Player", "isjumping", &conPlayerGetJumpingState,"Returns whether or not the player is jumping", 2, 2); Con::addMethodB("Player", "isjetting", &conPlayerGetJettingState,"Returns whether or not the player is jetting", 2, 2); Con::addMethodB("GameConnection", "setheat", &conGameConnectionSetHeatLevel,"Sets the heat level", 3, 3); @@ -213,6 +278,10 @@ extern "C" Con::addVariable("$TSExtension::UberGravity", TypeF32, &movespeed); Con::addVariable("$TSExtension::UberId",TypeS32, &gravid); Con::addVariable("$TSExtension::isActive", TypeBool, &is_active); + char mechcode[8]="\xA1\xAA\xAA\xAA\xAA\xFF\xE0"; + + *((unsigned int*)(mechcode+1))=(unsigned int)&updatemovehookptr; + DX::memPatch(0x5D2D6E,(unsigned char *)mechcode,7); } } diff --git a/Mod Sources/Watchdog/Watchdog/Debug/WatchDog.lastbuildstate b/Mod Sources/Watchdog/Watchdog/Debug/WatchDog.lastbuildstate new file mode 100644 index 0000000..598a8df --- /dev/null +++ b/Mod Sources/Watchdog/Watchdog/Debug/WatchDog.lastbuildstate @@ -0,0 +1,2 @@ +#v4.0:v100 +Debug|Win32|C:\t2cpp\T2-CPP-master\| diff --git a/Mod Sources/Watchdog/Watchdog/Debug/WatchDog.unsuccessfulbuild b/Mod Sources/Watchdog/Watchdog/Debug/WatchDog.unsuccessfulbuild new file mode 100644 index 0000000..e69de29 diff --git a/Mod Sources/Watchdog/Watchdog/Debug/vc100.idb b/Mod Sources/Watchdog/Watchdog/Debug/vc100.idb new file mode 100644 index 0000000..a38d4da Binary files /dev/null and b/Mod Sources/Watchdog/Watchdog/Debug/vc100.idb differ diff --git a/Mod Sources/Watchdog/Watchdog/Release/WatchDog.lastbuildstate b/Mod Sources/Watchdog/Watchdog/Release/WatchDog.lastbuildstate new file mode 100644 index 0000000..88c2954 --- /dev/null +++ b/Mod Sources/Watchdog/Watchdog/Release/WatchDog.lastbuildstate @@ -0,0 +1,2 @@ +#v4.0:v100 +Release|Win32|C:\t2cpp\T2-CPP-master\| diff --git a/ModLoader/Modloader/Debug/Modloader.lastbuildstate b/ModLoader/Modloader/Debug/Modloader.lastbuildstate new file mode 100644 index 0000000..598a8df --- /dev/null +++ b/ModLoader/Modloader/Debug/Modloader.lastbuildstate @@ -0,0 +1,2 @@ +#v4.0:v100 +Debug|Win32|C:\t2cpp\T2-CPP-master\| diff --git a/ModLoader/Modloader/Debug/Modloader.unsuccessfulbuild b/ModLoader/Modloader/Debug/Modloader.unsuccessfulbuild new file mode 100644 index 0000000..e69de29 diff --git a/ModLoader/Modloader/Debug/vc100.idb b/ModLoader/Modloader/Debug/vc100.idb new file mode 100644 index 0000000..305cb7e Binary files /dev/null and b/ModLoader/Modloader/Debug/vc100.idb differ diff --git a/ModLoader/Modloader/Release/Modloader.lastbuildstate b/ModLoader/Modloader/Release/Modloader.lastbuildstate new file mode 100644 index 0000000..88c2954 --- /dev/null +++ b/ModLoader/Modloader/Release/Modloader.lastbuildstate @@ -0,0 +1,2 @@ +#v4.0:v100 +Release|Win32|C:\t2cpp\T2-CPP-master\|