Added GrenadeProjectile.getVelocity() and updated the DXAPI

This commit is contained in:
Robert MacGregor 2014-08-15 15:44:13 -04:00
parent 79b8cc89d6
commit 5cd277771b
5 changed files with 74 additions and 1 deletions

View file

@ -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);
}

View file

@ -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[]);

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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;
}