diff --git a/Mod Sources/TSExtension/TSExtension.opensdf b/Mod Sources/TSExtension/TSExtension.opensdf index 4c4fcb5..34b05c3 100644 Binary files a/Mod Sources/TSExtension/TSExtension.opensdf and b/Mod Sources/TSExtension/TSExtension.opensdf differ diff --git a/Mod Sources/TSExtension/TSExtension.suo b/Mod Sources/TSExtension/TSExtension.suo index 20ab5cb..4f15ff2 100644 Binary files a/Mod Sources/TSExtension/TSExtension.suo and b/Mod Sources/TSExtension/TSExtension.suo differ diff --git a/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj b/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj index 15dfc68..4490b1d 100644 --- a/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj +++ b/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj @@ -20,7 +20,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj.filters b/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj.filters index 1a4e732..174d477 100644 --- a/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj.filters +++ b/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj.filters @@ -33,9 +33,6 @@ Source Files\DXAPI - - Source Files\DXAPI - Source Files\DXAPI @@ -87,6 +84,9 @@ Source Files\DXAPI + + Source Files\DXAPI + @@ -122,9 +122,6 @@ Header Files\DXAPI - - Header Files\DXAPI - Header Files\DXAPI @@ -146,5 +143,8 @@ Header Files\DXAPI + + Header Files\DXAPI + \ No newline at end of file diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/DXAPI.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/DXAPI.h index 93105e1..0f059a7 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/DXAPI.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/DXAPI.h @@ -16,7 +16,7 @@ #include "LinkerAPI.h" -#include +#include #include #include #include diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/GameConnection.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/GameConnection.h index a05bb7f..00599bc 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/GameConnection.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/GameConnection.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/GrenadeProjectile.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/GrenadeProjectile.h index ed0b3da..4da989e 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/GrenadeProjectile.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/GrenadeProjectile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace DX diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/MatMath.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/MatMath.h new file mode 100644 index 0000000..10ee5fb --- /dev/null +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/MatMath.h @@ -0,0 +1,181 @@ +#pragma once +#include +#include +#include +#include +#define M_PI 3.14159265359 +inline float mDegToRad(float d) +{ + return float((d * M_PI) / float(180)); +} + +inline float mRadToDeg(float r) +{ + return float((r * 180.0) / M_PI); +} + +inline double mDegToRad(double d) +{ + return (d * M_PI) / double(180); +} + +inline double mRadToDeg(double r) +{ + return (r * 180.0) / M_PI; +} + +namespace DX +{ + + struct Point { + float x; + float y; + float z; + }; + /** + * @brief A class representing a referenced 3D vector of floats in Tribes 2. + */ + #define idx(r,c) (r*4 + c) + class MatrixF; + class Point3F + { + public: + Point3F(); + Point3F(float &X, float &Y, float &Z); + float x; + float y; + float z; + }; + class Angle + { + public: + Angle(float *mat){ + float const *m = (float const *)mat; + + float trace = m[idx(0, 0)] + m[idx(1, 1)] + m[idx(2, 2)]; + if (trace > 0.0) { + float s = sqrt(trace + float(1)); + w = s * 0.5; + s = 0.5 / s; + x = (m[idx(1,2)] - m[idx(2,1)]) * s; + y = (m[idx(2,0)] - m[idx(0,2)]) * s; + z = (m[idx(0,1)] - m[idx(1,0)]) * s; + } else { + float* q = &x; + unsigned int i = 0; + if (m[idx(1, 1)] > m[idx(0, 0)]) i = 1; + if (m[idx(2, 2)] > m[idx(i, i)]) i = 2; + unsigned int j = (i + 1) % 3; + unsigned int k = (j + 1) % 3; + + float s = sqrt((m[idx(i, i)] - (m[idx(j, j)] + m[idx(k, k)])) + 1.0); + q[i] = s * 0.5; + s = 0.5 / s; + q[j] = (m[idx(i,j)] + m[idx(j,i)]) * s; + q[k] = (m[idx(i,k)] + m[idx(k, i)]) * s; + w = (m[idx(j,k)] - m[idx(k, j)]) * s; + + + + angle = acos( w ) * 2; + float sinHalfAngle = sqrt(1 - w * w); + if (sinHalfAngle != 0) + { + axis.x=(x / sinHalfAngle); + axis.y=(y / sinHalfAngle); + axis.z=(z / sinHalfAngle); + } + else + { + axis.x=1.0; + axis.y=0; + axis.z=0; + } + + } + } + void Angle::identity() + { + x = 0.0f; + y = 0.0f; + z = 0.0f; + w = 1.0f; + } + void Angle::normalize() { + float l = sqrt( x*x + y*y + z*z + w*w ); + if( l == float(0.0) ) + identity(); + else + { + x /= l; + y /= l; + z /= l; + w /= l; + } + } + float angle; + Point axis; + float x,y,z,w,s; + + }; + class MatrixF + { + public: + MatrixF(float *inm) { + m=inm; + } + float *m; + void MatrixF::m_quatF_set_matF_C( float x, float y, float z, float w) + { + #define qidx(r,c) (r*4 + c) + float xs = x * 2.0f; + float ys = y * 2.0f; + float zs = z * 2.0f; + float wx = w * xs; + float wy = w * ys; + float wz = w * zs; + float xx = x * xs; + float xy = x * ys; + float xz = x * zs; + float yy = y * ys; + float yz = y * zs; + float zz = z * zs; + m[qidx(0,0)] = 1.0f - (yy + zz); + m[qidx(1,0)] = xy - wz; + m[qidx(2,0)] = xz + wy; + m[qidx(3,0)] = 0.0f; + m[qidx(0,1)] = xy + wz; + m[qidx(1,1)] = 1.0f - (xx + zz); + m[qidx(2,1)] = yz - wx; + m[qidx(3,1)] = 0.0f; + m[qidx(0,2)] = xz - wy; + m[qidx(1,2)] = yz + wx; + m[qidx(2,2)] = 1.0f - (xx + yy); + m[qidx(3,2)] = 0.0f; + + m[qidx(0,3)] = 0.0f; + m[qidx(1,3)] = 0.0f; + m[qidx(2,3)] = 0.0f; + m[qidx(3,3)] = 1.0f; + #undef qidx + } + inline void getColumn(int col, Point3F *cptr) + { + cptr->x = m[col]; + cptr->y = m[col+4]; + cptr->z = m[col+8]; + } + + + inline void setColumn(int col, Point3F *cptr) + { + m[col] = cptr->x; + m[col+4] = cptr->y; + m[col+8] = cptr->z; + } + MatrixF(Angle *ang) { + m_quatF_set_matF_C(ang->x,ang->y,ang->z,ang->w); + } + }; + +} // End NameSpace DX diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetConnection.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetConnection.h index b9490a3..eeb28b0 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetConnection.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetConnection.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/Player.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/Player.h index ad49241..4c9ec47 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/Player.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/Player.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace DX diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/Projectile.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/Projectile.h index 222e62d..b7024b5 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/Projectile.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/Projectile.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/SceneObject.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/SceneObject.h index 6186d48..5a5f128 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/SceneObject.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/SceneObject.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace DX @@ -12,5 +12,28 @@ namespace DX Point3F position; Point3F scale; + float * worldtoobj; + float * objtoworld; + Point3F objboxmin; + Point3F objboxmax; + Point3F worldboxmin; + Point3F worldboxmax; + Point3F worldspherecenter; + float &worldsphereradius; + float *renderobjtoworld; + float *renderworldtoobj; + void setTransform(float *matrixinput) { + unsigned int bpv=this->base_pointer_value; + unsigned int minp = (unsigned int) matrixinput; + + __asm { + push minp + mov ecx,bpv + mov eax,bpv + mov eax,[eax] + add eax,0x74 + call [eax] + } + } }; } // End NameSpace DX \ No newline at end of file diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/StaticShape.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/StaticShape.h index 1426be7..3937237 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/StaticShape.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/StaticShape.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace DX diff --git a/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h b/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h index 33ce4c8..e3cdd05 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h @@ -13,7 +13,9 @@ #pragma once #include + void serverProcessReplacement(unsigned int timeDelta) ; +const char* conGetPosition(Linker::SimObject * obj, S32 argc, const char *argv[]); const char* congetServPAddr(Linker::SimObject *obj, S32 argc, const char *argv[]); // Returns the address of an object in memory const char* conGetAddress(Linker::SimObject *obj, S32 argc, const char *argv[]); diff --git a/Mod Sources/TSExtension/TSExtension/source/DXAPI/DXAPI.cpp b/Mod Sources/TSExtension/TSExtension/source/DXAPI/DXAPI.cpp index e68e788..dcc316b 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXAPI/DXAPI.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXAPI/DXAPI.cpp @@ -12,7 +12,7 @@ * @copyright (c) 2014 Robert MacGregor */ -#include +#include #include #include diff --git a/Mod Sources/TSExtension/TSExtension/source/DXAPI/MatMath.cpp b/Mod Sources/TSExtension/TSExtension/source/DXAPI/MatMath.cpp new file mode 100644 index 0000000..b8a827d --- /dev/null +++ b/Mod Sources/TSExtension/TSExtension/source/DXAPI/MatMath.cpp @@ -0,0 +1,14 @@ +#include + +namespace DX +{ + Point3F::Point3F(float &X, float &Y, float &Z) : x(X), y(Y), z(Z) + { + } + Point3F::Point3F() + { + x=0; + y=0; + z=0; + } +} diff --git a/Mod Sources/TSExtension/TSExtension/source/DXAPI/SceneObject.cpp b/Mod Sources/TSExtension/TSExtension/source/DXAPI/SceneObject.cpp index 938edd8..40d8da0 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXAPI/SceneObject.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXAPI/SceneObject.cpp @@ -4,6 +4,16 @@ namespace DX { SceneObject::SceneObject(unsigned int obj) : position(*(float*)(obj + 168), *(float*)(obj + 184), *(float*)(obj + 200)), scale(*(float*)(obj + 284), *(float*)(obj + 288), *(float*)(obj + 292)), + worldtoobj((float*)(obj + 0xDC)), + objtoworld((float*)(obj+0x9C)), + objboxmin(*(float*)(obj + 296), *(float*)(obj + 300), *(float*)(obj + 304)), + objboxmax(*(float*)(obj + 308), *(float*)(obj + 312), *(float*)(obj + 316)), + worldboxmin(*(float*)(obj + 320), *(float*)(obj + 324), *(float*)(obj + 328)), + worldboxmax(*(float*)(obj + 332), *(float*)(obj + 336), *(float*)(obj + 340)), + worldspherecenter(*(float*)(obj + 344), *(float*)(obj + 348), *(float*)(obj + 352)), + worldsphereradius(*(float*)(obj+356)), + renderobjtoworld((float*)(obj+360)), + renderworldtoobj((float*)(obj+424)), NetObject(obj) { } diff --git a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp index a28fe34..a21d20a 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp @@ -4,9 +4,25 @@ #define endian(hex) (((hex & 0x000000FF) << 24)+((hex & 0x0000FF00) << 8)+((hex & 0x00FF0000)>>8)+((hex & 0xFF000000) >> 24)) #include #include +#include +static float counter=0; void serverProcessReplacement(unsigned int timeDelta) { unsigned int servertickaddr=0x602350; unsigned int serverthisptr=0x9E5EC0; + float basex=348.08; + float basey=-178.761; + float basez=113.037; + if (Sim::findObjectc("Team1TurretBaseLarge1")) { + basex+=counter/180.0; + DX::SceneObject sobj = DX::SceneObject((unsigned int)Sim::findObjectc("Team1TurretBaseLarge1")); + DX::MatrixF mat1=DX::MatrixF(sobj.objtoworld); + mat1.setColumn(3,&DX::Point3F(basex,basey,basez)); + sobj.setTransform(mat1.m); + if (counter>=(30*180)){ + counter=0; + } + counter+=1.0; + } __asm { mov ecx,serverthisptr @@ -16,6 +32,20 @@ void serverProcessReplacement(unsigned int timeDelta) { return; } +const char* conGetPosition(Linker::SimObject * obj, S32 argc, const char *argv[]) { + char returnstr[256]=""; + DX::SceneObject sobj = DX::SceneObject((unsigned int)obj); + if (obj!=NULL) { + unsigned int bpv = (sobj.base_pointer_value); + unsigned int *matrixptr =(unsigned int *) (bpv+0x9C); + float *matrix1=(float*) matrixptr; + DX::MatrixF mat1=DX::MatrixF(sobj.objtoworld); + DX::Point3F test=DX::Point3F(); + mat1.getColumn(3,&test); + sprintf (returnstr,"%g %g %g",test.x,test.y,test.z); + } + return returnstr; +} const char* congetServPAddr(Linker::SimObject *obj, S32 argc, const char *argv[]) { char test[256] = ""; char test2[256]=""; diff --git a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp index 1348061..bb6139c 100644 --- a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp @@ -42,7 +42,7 @@ extern "C" Con::addMethodS("GrenadeProjectile", "getposition", &conGrenadeProjectileGetPosition,"Accurately gets the position of the GrenadeProjectile", 2, 2); Con::addMethodS("GrenadeProjectile", "getvelocity", &conGrenadeProjectileGetVelocity,"Gets the velocity of the GrenadeProjectile", 2, 2); Con::addMethodB("Projectile", "makeNerf", &conProjectileMakeNerf,"Makes the Projectile deal no damage", 2, 2); - + Con::addMethodS("SceneObject", "getPositionTest", &conGetPosition,"Gets the Rotation by alternate means as a test", 2, 2); // TCPObject #ifdef ENABLE_TCPOBJECT Con::addMethodS("TCPObject", "connect", &conTCPObjectConnect, "Connects to a remote server", 3, 3);