Experimental C++ API; added .deleteObject()

This commit is contained in:
Robert MacGregor 2014-08-18 15:22:13 -04:00
parent c088d86850
commit f958f435c1
41 changed files with 547 additions and 288 deletions

Binary file not shown.

View file

@ -0,0 +1,2 @@
#v4.0:v100
Debug|Win32|C:\Users\Robert MacGregor\Desktop\T2CPP\Mod Sources\TSExtension\|

Binary file not shown.

View file

@ -0,0 +1,2 @@
#v4.0:v100
Release|Win32|C:\Users\Robert MacGregor\Desktop\T2CPP\Mod Sources\TSExtension\|

View file

@ -11,14 +11,37 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\BaseMod.cpp" />
<ClCompile Include="source\dllmain.cpp" />
<ClCompile Include="source\DXAPI.cpp" />
<ClCompile Include="source\DXAPI\DXAPI.cpp" />
<ClCompile Include="source\DXAPI\FlyingVehicle.cpp" />
<ClCompile Include="source\DXAPI\GameBase.cpp" />
<ClCompile Include="source\DXAPI\GrenadeProjectile.cpp" />
<ClCompile Include="source\DXAPI\NetObject.cpp" />
<ClCompile Include="source\DXAPI\Player.cpp" />
<ClCompile Include="source\DXAPI\Point3F.cpp" />
<ClCompile Include="source\DXAPI\Projectile.cpp" />
<ClCompile Include="source\DXAPI\SceneObject.cpp" />
<ClCompile Include="source\DXAPI\ShapeBase.cpp" />
<ClCompile Include="source\DXAPI\SimObject.cpp" />
<ClCompile Include="source\DXAPI\StaticShape.cpp" />
<ClCompile Include="source\DXAPI\Vehicle.cpp" />
<ClCompile Include="source\DXConCmds.cpp" />
<ClCompile Include="source\LinkerAPI.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\DXAPI.h" />
<ClInclude Include="include\DXAPI\DXAPI.h" />
<ClInclude Include="include\DXAPI\FlyingVehicle.h" />
<ClInclude Include="include\DXAPI\GameBase.h" />
<ClInclude Include="include\DXAPI\GrenadeProjectile.h" />
<ClInclude Include="include\DXAPI\NetObject.h" />
<ClInclude Include="include\DXAPI\Player.h" />
<ClInclude Include="include\DXAPI\Point3F.h" />
<ClInclude Include="include\DXAPI\Projectile.h" />
<ClInclude Include="include\DXAPI\SceneObject.h" />
<ClInclude Include="include\DXAPI\ShapeBase.h" />
<ClInclude Include="include\DXAPI\SimObject.h" />
<ClInclude Include="include\DXAPI\StaticShape.h" />
<ClInclude Include="include\DXAPI\Vehicle.h" />
<ClInclude Include="include\DXConCmds.h" />
<ClInclude Include="include\LinkerAPI.h" />
</ItemGroup>

View file

@ -13,6 +13,12 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Header Files\DXAPI">
<UniqueIdentifier>{6d8e53d2-8590-4c42-b4e2-ff67cedefcce}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\DXAPI">
<UniqueIdentifier>{5269716c-2798-40ef-aa8a-2c8e784cf99b}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\DXConCmds.cpp">
@ -21,25 +27,94 @@
<ClCompile Include="source\LinkerAPI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\BaseMod.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI.cpp">
<Filter>Source Files</Filter>
<ClCompile Include="source\DXAPI\DXAPI.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\Point3F.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\FlyingVehicle.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\GameBase.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\Projectile.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\ShapeBase.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\GrenadeProjectile.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\SceneObject.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\NetObject.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\StaticShape.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\Player.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\SimObject.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\Vehicle.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\LinkerAPI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\DXConCmds.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\Player.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\Projectile.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\SceneObject.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\ShapeBase.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\SimObject.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\StaticShape.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\DXAPI.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\GameBase.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\NetObject.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\Point3F.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\FlyingVehicle.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\Vehicle.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\GrenadeProjectile.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -1,136 +0,0 @@
/**
* @file DXAPI.h
* @brief The DXAPI is an API that allows you to manipulate various game objects
* in Tribes 2 from raw C++ code. It dynamically resolves the addresses of member
* variables as you can't really trust the compiler to produce binary compatible classes,
* especially with all the inheritance involved in the original Tribes 2 codebase.
*
* This code wouldn't be possible without Linker's original gift on the-construct.net forums,
* whose files are appropriately labelled in this codebase. These files have been edited where
* appropriate in order to make that code play better with the DXAPI.
*
* @copyright (c) 2014 Robert MacGregor
*/
#pragma once
#include "LinkerAPI.h"
namespace DX
{
//! A typedef referring to some type of unresolved object in the game.
typedef void* UnresolvedObject;
class Projectile {};
//! Structure representing a player object in the game.
typedef struct
{
//! Object Name
const char *name;
//! Object ID
const unsigned int &id;
//! X Coordinate of the position.
float &position_x;
//! Y Coordinate of the position.
float &position_y;
//! Z Coordinate of the position.
float &position_z;
//! Player Object Jetting State (readonly, writing it doesn't do anything)
const bool &is_jetting;
//! Player Object Jumping State (readonly, writing it doesn't do anything)
const bool &is_jumping;
//! Player Object Using Toggable Pack
bool &is_using_toggledpack;
} Player;
/**
* @brief Returns a usable Player structure from a void
* pointer.
* @param obj A void pointer to attempt to resolve from.
* @return A usable Player structure to manipulate.
*/
Player GetPlayerPointer(UnresolvedObject obj);
//! Structure representing a static shape in the game.
typedef struct
{
//! Object Name
const char *name;
//! X Coordinate of the position.
float &position_x;
//! Y Coordinate of the position.
float &position_y;
//! Z Coordinate of the position.
float &position_z;
} StaticShape;
//! Structure representing a grenade projectile.
typedef struct
{
//! X Coordinate of the position.
float &position_x;
//! Y Coordinate of the position.
float &position_y;
//! Z Coordinate of the position.
float &position_z;
// Note: Thile these values can be set, they're not networked properly
//! The X Coordinate of the velocity.
const float &velocity_x;
//! The Y Coordinate of the velocity.
const float &velocity_y;
//! The Z Coordinate of the velocity.
const float &velocity_z;
} GrenadeProjectile;
/**
* @brief Returns a usable StaticShape structure from a void
* pointer.
* @param obj A void pointer to attempt to resolve from.
* @return A usable StaticShape structure to manipulate.
*/
StaticShape GetStaticShapePointer(UnresolvedObject obj);
//! Structure representing a SimGroup in the game.
typedef struct
{
} SimGroup;
/**
* @brief Returns a usable SimGroup structure from a void
* pointer.
* @param obj A void pointer to attempt to resolve from.
* @return A usable SimGroup structure to manipulate.
*/
SimGroup GetSimGroupPointer(UnresolvedObject obj);
//! Structure representing a FlyingVehicle in the game.
typedef struct
{
//! Strafing State. 0=Not Strafing. -1=Strafing Left. 1=Strafing Right (readonly, writing it doesn't do anything)
const float &strafing_state;
} FlyingVehicle;
/**
* @brief Returns a usable FlyingVehicle structure from a void
* pointer.
* @param obj A void pointer to attempt to resolve from.
* @return A usable FlyingVehicle structure to manipulate.
*/
FlyingVehicle GetFlyingVehiclePointer(UnresolvedObject obj);
/**
* @brief Returns a usable GrenadeProjectile structure from a void
* pointer.
* @param obj A void pointer to attempt to resolve from.
* @return A usable GrenadeProjectile structure to manipulate.
*/
GrenadeProjectile GetGrenadeProjectilePointer(UnresolvedObject obj);
void Projectile_explode(Projectile *obj, const Point3F &position, const Point3F &normal, const unsigned int collideType);
}

View file

@ -0,0 +1,43 @@
/**
* @file DXAPI.h
* @brief The DXAPI is an API that allows you to manipulate various game objects
* in Tribes 2 from raw C++ code. It dynamically resolves the addresses of member
* variables as you can't really trust the compiler to produce binary compatible classes,
* especially with all the inheritance involved in the original Tribes 2 codebase.
*
* This code wouldn't be possible without Linker's original gift on the-construct.net forums,
* whose files are appropriately labelled in this codebase. These files have been edited where
* appropriate in order to make that code play better with the DXAPI.
*
* @copyright (c) 2014 Robert MacGregor
*/
//#pragma once
#include "LinkerAPI.h"
#include <DXAPI/Point3F.h>
#include <DXAPI/GameBase.h>
#include <DXAPI/NetObject.h>
#include <DXAPI/Player.h>
#include <DXAPI/Projectile.h>
#include <DXAPI/SceneObject.h>
#include <DXAPI/ShapeBase.h>
#include <DXAPI/SimObject.h>
#include <DXAPI/StaticShape.h>
#include <DXAPI/GrenadeProjectile.h>
#include <DXAPI/FlyingVehicle.h>
namespace DX
{
//! A typedef referring to some type of unresolved object in the game.
typedef void* UnresolvedObject;
//! Structure representing a static shape in the game.
//typedef struct
//{
// } StaticShape;
void Projectile_explode(Projectile *obj, const Point3F &position, const Point3F &normal, const unsigned int collideType);
} // End NameSpace DX

View file

@ -0,0 +1,13 @@
#pragma once
#include <DXAPI/Vehicle.h>
namespace DX
{
//! Class representing a FlyingVehicle in the game.
class FlyingVehicle : public Vehicle
{
public:
FlyingVehicle(unsigned int obj);
};
} // End NameSpace DX

View file

@ -0,0 +1,12 @@
#pragma once
#include <DXAPI/SceneObject.h>
namespace DX
{
class GameBase : public SceneObject
{
public:
GameBase(unsigned int obj);
};
} // End NameSpace DX

View file

@ -0,0 +1,13 @@
#pragma once
#include <DXAPI/Point3F.h>
#include <DXAPI/Projectile.h>
namespace DX
{
class GrenadeProjectile : public Projectile
{
public:
GrenadeProjectile(unsigned int obj);
};
} // End NameSpace DX

View file

@ -0,0 +1,12 @@
#pragma once
#include <DXAPI/SimObject.h>
namespace DX
{
class NetObject : public SimObject
{
public:
NetObject(unsigned int obj);
};
} // End NameSpace DX

View file

@ -0,0 +1,26 @@
#pragma once
#include <DXAPI/Point3F.h>
#include <DXAPI/ShapeBase.h>
namespace DX
{
//! Class representing a player object in the game.
class Player : public ShapeBase
{
public:
Player(unsigned int obj);
//! Object Name
const char *name;
//! Object ID
const unsigned int &id;
//! Player Object Jetting State (readonly, writing it doesn't do anything)
const bool &is_jetting;
//! Player Object Jumping State (readonly, writing it doesn't do anything)
const bool &is_jumping;
//! Player Object Using Toggable Pack
bool &is_using_toggledpack;
};
} // End NameSpace DX

View file

@ -0,0 +1,17 @@
#pragma once
namespace DX
{
/**
* @brief A class representing a referenced 3D vector of floats in Tribes 2.
*/
class Point3F
{
public:
Point3F(float &X, float &Y, float &Z);
float &x;
float &y;
float &z;
};
} // End NameSpace DX

View file

@ -0,0 +1,17 @@
#pragma once
#include <DXAPI/GameBase.h>
namespace DX
{
class Projectile : public GameBase
{
public:
Projectile(unsigned int obj);
//! Velocity. It is constant because modifying it directly breaks the sim.
const Point3F velocity;
bool &hidden;
};
} // End NameSpace DX

View file

@ -0,0 +1,16 @@
#pragma once
#include <DXAPI/Point3F.h>
#include <DXAPI/NetObject.h>
namespace DX
{
class SceneObject : public NetObject
{
public:
SceneObject(unsigned int obj);
Point3F position;
Point3F scale;
};
} // End NameSpace DX

View file

@ -0,0 +1,12 @@
#pragma once
#include <DXAPI/GameBase.h>
namespace DX
{
class ShapeBase : public GameBase
{
public:
ShapeBase(unsigned int obj);
};
} // End NameSpace DX

View file

@ -0,0 +1,15 @@
#pragma once
namespace DX
{
class SimObject
{
public:
SimObject(unsigned int obj);
void deleteObject(void);
protected:
const unsigned int base_pointer_value;
};
} // End NameSpace DX

View file

@ -0,0 +1,19 @@
#pragma once
#include <DXAPI/Point3F.h>
#include <DXAPI/ShapeBase.h>
namespace DX
{
//! Class representing a StaticShape in the game.
class StaticShape : public ShapeBase
{
public:
StaticShape(unsigned int obj);
//! Object Name
//const char *name;
//! Position
//const Point3F position;
};
} // End NameSpace DX

View file

@ -0,0 +1,13 @@
#pragma once
#include <DXAPI/ShapeBase.h>
namespace DX
{
//! Class representing a FlyingVehicle in the game.
class Vehicle : public ShapeBase
{
public:
Vehicle(unsigned int obj);
};
} // End NameSpace DX

View file

@ -27,6 +27,7 @@ const char* conGrenadeProjectileGetVelocity(SimObject *obj, S32 argc, const char
// Projectile explode -------------------------------
bool conProjectileExplode(SimObject *obj, S32 argc, const char* argv[]);
bool conProjectileMakeNerf(SimObject *obj, S32 argc, const char* argv[]);
// General Commands ---------------------------------
const char* conSprintf(SimObject *obj, S32 argc, const char* argv[]);

View file

@ -1,24 +0,0 @@
// BaseMod.cpp : Defines the exported functions for the DLL application.
//
#include <DXAPI.h>
#include <LinkerAPI.h>
#include <DXConCmds.h>
extern "C"
{
__declspec(dllexport) void ModInitialize(void)
{
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("GrenadeProjectile", "explode", &conProjectileExplode,"Explodes the given projectile", 5, 5);
Con::addMethodB("Projectile", "explode", &conProjectileExplode,"Explodes the given projectile", 5, 5);
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::addMethodS(NULL, "sprintf", &conSprintf,"Formats a string. See the C sprintf.", 2, 20);
}
}

View file

@ -1,109 +0,0 @@
/**
* @file DXAPI.cpp
* @brief The DXAPI is an API that allows you to manipulate various game objects
* in Tribes 2 from raw C++ code. It dynamically resolves the addresses of member
* variables as you can't really trust the compiler to produce binary compatible classes,
* especially with all the inheritance involved in the original Tribes 2 codebase.
*
* This code wouldn't be possible without Linker's original gift on the-construct.net forums,
* whose files are appropriately labelled in this codebase. These files have been edited where
* appropriate in order to make that code play better with the DXAPI.
*
* @copyright (c) 2014 Robert MacGregor
*/
#include "DXAPI.h"
#include "LinkerAPI.h"
namespace DX
{
Player GetPlayerPointer(UnresolvedObject obj)
{
// Probably some way to do all this via assembly but screw me if I know
unsigned int base_tribes_pointer = (unsigned int)obj;
Player result =
{
0x00, // Object Name
*(unsigned int*)(base_tribes_pointer + 32), // Object ID
*(float*)(base_tribes_pointer + 168), // Position X
*(float*)(base_tribes_pointer + 184), // Position Y
*(float*)(base_tribes_pointer + 200), // Position Z
*(bool*)(base_tribes_pointer + 735), // Jetting State
*(bool*)(base_tribes_pointer + 734), // Jumping State
*(bool*)(base_tribes_pointer + 1172) // Using Toggled Pack
};
return result;
}
StaticShape GetStaticShapePointer(UnresolvedObject obj)
{
unsigned int base_tribes_pointer = (unsigned int)obj;
StaticShape result =
{
0x00, // Object Name
*(float*)(base_tribes_pointer + 200), // Position X
*(float*)(base_tribes_pointer + 200), // Position Y
*(float*)(base_tribes_pointer + 200) // Position Z
};
return result;
}
SimGroup GetSimGroupPointer(UnresolvedObject obj)
{
unsigned int base_tribes_pointer = (unsigned int)obj;
SimGroup result =
{
};
return result;
}
FlyingVehicle GetFlyingVehiclePointer(UnresolvedObject obj)
{
unsigned int base_tribes_pointer = (unsigned int)obj;
FlyingVehicle result =
{
*(float*)(base_tribes_pointer + 2200), // Strafing Status
};
return result;
}
GrenadeProjectile GetGrenadeProjectilePointer(UnresolvedObject obj)
{
unsigned int base_tribes_pointer = (unsigned int)obj;
GrenadeProjectile result =
{
*(float*)(base_tribes_pointer + 168), // Position X
*(float*)(base_tribes_pointer + 504), // Position Y
*(float*)(base_tribes_pointer + 520), // Position Z
*(float*)(base_tribes_pointer + 892), // Velocity X
*(float*)(base_tribes_pointer + 896), // Velocity Y
*(float*)(base_tribes_pointer + 900), // Velocity Z
};
return result;
}
void Projectile_explode(Projectile *obj, const Point3F &position, const Point3F &normal, const unsigned int collideType)
{
typedef void (__cdecl *explodeFunc)(const Point3F &position, const Point3F &normal, const unsigned int collideType);
static explodeFunc function_call = (explodeFunc)0x62DC30;
__asm {
push collideType;
push normal;
push position;
mov ecx,obj;
lea eax, function_call;
mov eax, [eax];
call eax;
}
}
}

View file

@ -0,0 +1,38 @@
/**
* @file DXAPI.cpp
* @brief The DXAPI is an API that allows you to manipulate various game objects
* in Tribes 2 from raw C++ code. It dynamically resolves the addresses of member
* variables as you can't really trust the compiler to produce binary compatible classes,
* especially with all the inheritance involved in the original Tribes 2 codebase.
*
* This code wouldn't be possible without Linker's original gift on the-construct.net forums,
* whose files are appropriately labelled in this codebase. These files have been edited where
* appropriate in order to make that code play better with the DXAPI.
*
* @copyright (c) 2014 Robert MacGregor
*/
#include <DXAPI/Point3F.h>
#include <DXAPI/DXAPI.h>
#include <LinkerAPI.h>
namespace DX
{
void Projectile_explode(Projectile *obj, const Point3F &position, const Point3F &normal, const unsigned int collideType)
{
typedef void (__cdecl *explodeFunc)(const Point3F &position, const Point3F &normal, const unsigned int collideType);
static explodeFunc function_call = (explodeFunc)0x62DC30;
__asm
{
push collideType;
push normal;
push position;
mov ecx,obj;
lea eax, function_call;
mov eax, [eax];
call eax;
}
}
}

View file

@ -0,0 +1,8 @@
#include <DXAPI/FlyingVehicle.h>
namespace DX
{
FlyingVehicle::FlyingVehicle(unsigned int obj) : Vehicle(obj)
{
}
}

View file

@ -0,0 +1,8 @@
#include <DXAPI/GameBase.h>
namespace DX
{
GameBase::GameBase(unsigned int obj) : SceneObject(obj)
{
}
} // End NameSpace DX

View file

@ -0,0 +1,8 @@
#include <DXAPI/GrenadeProjectile.h>
namespace DX
{
GrenadeProjectile::GrenadeProjectile(unsigned int obj) : Projectile(obj)
{
}
}

View file

@ -0,0 +1,8 @@
#include <DXAPI/NetObject.h>
namespace DX
{
NetObject::NetObject(unsigned int obj) : SimObject(obj)
{
}
}

View file

@ -0,0 +1,13 @@
#include <DXAPI/Player.h>
namespace DX
{
Player::Player(unsigned int obj) : ShapeBase(obj),
name(0x00), id(*(unsigned int*)(obj + 32)),
is_jetting(*(bool*)(obj + 735)),
is_jumping(*(bool*)(obj + 734)),
is_using_toggledpack(*(bool*)(obj + 1172))
{
}
}

View file

@ -0,0 +1,8 @@
#include <DXAPI/Point3F.h>
namespace DX
{
Point3F::Point3F(float &X, float &Y, float &Z) : x(X), y(Y), z(Z)
{
}
}

View file

@ -0,0 +1,10 @@
#include <DXAPI/Projectile.h>
namespace DX
{
Projectile::Projectile(unsigned int obj) : velocity(*(float*)(obj + 892), *(float*)(obj + 896), *(float*)(obj + 900)),
hidden(*(bool*)(obj + 796)),
GameBase(obj)
{
}
}

View file

@ -0,0 +1,10 @@
#include <DXAPI/SceneObject.h>
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)),
NetObject(obj)
{
}
}

View file

@ -0,0 +1,8 @@
#include <DXAPI/ShapeBase.h>
namespace DX
{
ShapeBase::ShapeBase(unsigned int obj) : GameBase(obj)
{
}
}

View file

@ -0,0 +1,24 @@
#include <DXAPI/SimObject.h>
namespace DX
{
SimObject::SimObject(unsigned int obj) : base_pointer_value(obj)
{
}
void SimObject::deleteObject(void)
{
void *pointer = (void*)this->base_pointer_value;
typedef void (__cdecl *deleteObjectFunc)(void);
static deleteObjectFunc function_call = (deleteObjectFunc)0x439DE0;
__asm
{
mov ecx, pointer;
lea eax, function_call;
mov eax, [eax];
call eax;
}
}
}

View file

@ -0,0 +1,10 @@
#include <DXAPI/StaticShape.h>
namespace DX
{
StaticShape::StaticShape(unsigned int obj) : ShapeBase(obj)
//name(0x00),
//position(*(float*)(obj + 200), *(float*)(obj + 200), *(float*)(obj + 200))
{
}
}

View file

@ -0,0 +1,8 @@
#include <DXAPI/Vehicle.h>
namespace DX
{
Vehicle::Vehicle(unsigned int obj) : ShapeBase(obj)
{
}
}

View file

@ -3,7 +3,7 @@
*/
#include <LinkerAPI.h>
#include <DXAPI.h>
#include <DXAPI/DXAPI.h>
const char *conGetAddress(SimObject *obj, S32 argc, const char *argv[])
{
@ -15,14 +15,14 @@ const char *conGetAddress(SimObject *obj, S32 argc, const char *argv[])
bool conPlayerGetJumpingState(SimObject *obj, S32 argc, const char* argv[])
{
DX::Player operand = DX::GetPlayerPointer(obj);
DX::Player operand = DX::Player((unsigned int)obj);
return operand.is_jumping;
}
bool conPlayerGetJettingState(SimObject *obj, S32 argc, const char* argv[])
{
DX::Player operand = DX::GetPlayerPointer(obj);
DX::Player operand = DX::Player((unsigned int)obj);
return operand.is_jetting;
}
@ -40,7 +40,15 @@ bool conProjectileExplode(SimObject *obj, S32 argc, const char* argv[])
normal.z = 0;
unsigned int collideType = atoi(argv[4]);
DX::Projectile_explode((DX::Projectile*)obj, position, normal, collideType);
//DX::Projectile_explode((DX::Projectile*)obj, position, normal, collideType);
return true;
}
bool conProjectileMakeNerf(SimObject *obj, S32 argc, const char* argv[])
{
DX::GrenadeProjectile grenade = DX::GrenadeProjectile((unsigned int)obj);
grenade.hidden = true;
return true;
}
@ -49,8 +57,8 @@ const char* conGrenadeProjectileGetPosition(SimObject *obj, S32 argc, const char
{
char result[256];
DX::GrenadeProjectile grenade = DX::GetGrenadeProjectilePointer(obj);
sprintf_s<256>(result, "%f %f %f", grenade.position_x, grenade.position_y, grenade.position_z);
DX::GrenadeProjectile grenade = DX::GrenadeProjectile((unsigned int)obj);
sprintf_s<256>(result, "%f %f %f", grenade.position.x, grenade.position.y, grenade.position.z);
return result;
}
@ -58,8 +66,9 @@ const char* conGrenadeProjectileGetVelocity(SimObject *obj, S32 argc, const char
{
char result[256];
DX::GrenadeProjectile grenade = DX::GetGrenadeProjectilePointer(obj);
sprintf_s<256>(result, "%f %f %f", grenade.velocity_x, grenade.velocity_y, grenade.velocity_z);
DX::GrenadeProjectile grenade((unsigned int)obj);
sprintf_s<256>(result, "%f %f %f", grenade.velocity.x, grenade.velocity.y, grenade.velocity.z);
return result;
}

View file

@ -18,3 +18,30 @@ BOOL APIENTRY DllMain( HMODULE hModule,
return TRUE;
}
#include <DXAPI/DXAPI.h>
#include <LinkerAPI.h>
#include <DXConCmds.h>
extern "C"
{
__declspec(dllexport) void ModInitialize(void)
{
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("GrenadeProjectile", "explode", &conProjectileExplode,"Explodes the given projectile", 5, 5);
Con::addMethodB("Projectile", "explode", &conProjectileExplode,"Explodes the given projectile", 5, 5);
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(NULL, "sprintf", &conSprintf,"Formats a string. See the C sprintf.", 2, 20);
// Add this Gvar to signify that TSExtension is active
static bool is_active = true;
Con::addVariable("$TSExtension::isActive", TypeBool, &is_active);
}
}