From 5cd277771bc40aec136d400a1482d382c081e43b Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Fri, 15 Aug 2014 15:44:13 -0400 Subject: [PATCH] Added GrenadeProjectile.getVelocity() and updated the DXAPI --- .../TSExtension/TSExtension/include/DXAPI.h | 29 +++++++++++++++++++ .../TSExtension/include/DXConCmds.h | 4 +++ .../TSExtension/source/BaseMod.cpp | 3 ++ .../TSExtension/TSExtension/source/DXAPI.cpp | 21 +++++++++++++- .../TSExtension/source/DXConCmds.cpp | 18 ++++++++++++ 5 files changed, 74 insertions(+), 1 deletion(-) diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI.h index a2f1d8a..060dd0e 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI.h @@ -42,6 +42,8 @@ namespace DX 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; /** @@ -64,6 +66,25 @@ namespace DX //! 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 @@ -103,5 +124,13 @@ namespace DX */ 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); } \ No newline at end of file diff --git a/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h b/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h index ebe53c7..5e89f5a 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h @@ -21,6 +21,10 @@ const char* conGetAddress(SimObject *obj, S32 argc, const char *argv[]); bool conPlayerGetJumpingState(SimObject *obj, S32 argc, const char* argv[]); bool conPlayerGetJettingState(SimObject *obj, S32 argc, const char* argv[]); +// GrenadeProjectile Commands ------------------------ +const char* conGrenadeProjectileGetPosition(SimObject *obj, S32 argc, const char* argv[]); +const char* conGrenadeProjectileGetVelocity(SimObject *obj, S32 argc, const char* argv[]); + // Projectile explode bool conProjectileExplode(SimObject *obj, S32 argc, const char* argv[]); diff --git a/Mod Sources/TSExtension/TSExtension/source/BaseMod.cpp b/Mod Sources/TSExtension/TSExtension/source/BaseMod.cpp index 28b42ce..83bd0b7 100644 --- a/Mod Sources/TSExtension/TSExtension/source/BaseMod.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/BaseMod.cpp @@ -15,5 +15,8 @@ extern "C" 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); } } \ No newline at end of file diff --git a/Mod Sources/TSExtension/TSExtension/source/DXAPI.cpp b/Mod Sources/TSExtension/TSExtension/source/DXAPI.cpp index fb176ed..c3cf100 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXAPI.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXAPI.cpp @@ -30,7 +30,8 @@ namespace DX *(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 + 734), // Jumping State + *(bool*)(base_tribes_pointer + 1172) // Using Toggled Pack }; return result; } @@ -68,6 +69,24 @@ namespace DX { *(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; } diff --git a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp index 70de4aa..bdc8901 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp @@ -55,4 +55,22 @@ bool conProjectileExplode(SimObject *obj, S32 argc, const char* argv[]) DX::Projectile_explode((DX::Projectile*)obj, position, normal, collideType); return true; +} + +const char* conGrenadeProjectileGetPosition(SimObject *obj, S32 argc, const char* argv[]) +{ + 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); + return result; +} + +const char* conGrenadeProjectileGetVelocity(SimObject *obj, S32 argc, const char* argv[]) +{ + 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); + return result; } \ No newline at end of file