Начинающий
-
Автор темы
- #1
Всем привет, нашел в исходах варфейса такую функцию:
void CPlayerStateUtil::PhySetFly( CPlayer& player )
{
IPhysicalEntity* pPhysEnt = player.GetEntity()->GetPhysics();
if (pPhysEnt != NULL)
{
pe_player_dynamics pd;
pd.bSwimming = true;
pd.kAirControl = 1.0f;
pd.kAirResistance = 0.0f;
pd.gravity.zero();
pPhysEnt->SetParams(&pd);
}
}
и чёт решил восстановить ее - SetParams.
В итоге всё нашел но при попытке вызвать функцию SetParams, именно со структурой pe_player_dynamics крашит игру. Кто работал с этой функцией в чем проблема?
Код
void CPlayerStateUtil::PhySetFly( CPlayer& player )
{
IPhysicalEntity* pPhysEnt = player.GetEntity()->GetPhysics();
if (pPhysEnt != NULL)
{
pe_player_dynamics pd;
pd.bSwimming = true;
pd.kAirControl = 1.0f;
pd.kAirResistance = 0.0f;
pd.gravity.zero();
pPhysEnt->SetParams(&pd);
}
}
и чёт решил восстановить ее - SetParams.
В итоге всё нашел но при попытке вызвать функцию SetParams, именно со структурой pe_player_dynamics крашит игру. Кто работал с этой функцией в чем проблема?
Код
Код:
struct pe_params
{
int type;
};
enum EPE_Params
{
ePE_params_pos = 0,
ePE_player_dimensions = 1,
ePE_params_car = 2,
ePE_params_particle = 3,
ePE_player_dynamics = 4,
ePE_params_joint = 5,
ePE_params_part = 6,
ePE_params_sensors = 7,
ePE_params_articulated_body = 8,
ePE_params_outer_entity = 9,
ePE_simulation_params = 10,
ePE_params_foreign_data = 11,
ePE_params_buoyancy = 12,
ePE_params_rope = 13,
ePE_params_bbox = 14,
ePE_params_flags = 15,
ePE_params_wheel = 16,
ePE_params_softbody = 17,
ePE_params_area = 18,
ePE_tetrlattice_params = 19,
ePE_params_ground_plane = 20,
ePE_params_structural_joint = 21,
ePE_params_waterman = 22,
ePE_params_timeout = 23,
ePE_params_skeleton = 24,
ePE_params_structural_initial_velocity = 25,
ePE_params_collision_class = 26,
ePE_params_walking_rigid = 27,
ePE_Params_Count
};
struct pe_player_dynamics : pe_params
{
enum entype { type_id = ePE_player_dynamics };
pe_player_dynamics()
{
type = type_id;
/*MARK_UNUSED kInertia, kInertiaAccel, kAirControl, gravity, gravity.z, nodSpeed, mass, bSwimming, surface_idx, bActive, collTypes, pLivingEntToIgnore;
MARK_UNUSED minSlideAngle, maxClimbAngle, maxJumpAngle, minFallAngle, kAirResistance, bNetwork, maxVelGround, timeImpulseRecover, iRequestedTime, bReleaseGroundColliderWhenNotActive;*/
}
float kInertia; //!< inertia koefficient, the more it is, the less inertia is; 0 means no inertia
float kInertiaAccel; //!< inertia on acceleration
float kAirControl; //!< air control koefficient 0..1, 1 - special value (total control of movement)
float kAirResistance; //!< standard air resistance
Vec3 gravity; //!< gravity vector
float nodSpeed; //!< vertical camera shake speed after landings
int bSwimming; //!< whether entity is swimming (is not bound to ground plane)
float mass; //!< mass (in kg)
int surface_idx; //!< surface identifier for collisions
float minSlideAngle; //!< if surface slope is more than this angle, player starts sliding (angle is in radians)
float maxClimbAngle; //!< player cannot climb surface which slope is steeper than this angle
float maxJumpAngle; //!< player is not allowed to jump towards ground if this angle is exceeded
float minFallAngle; //!< player starts falling when slope is steeper than this
float maxVelGround; //!< player cannot stand of surfaces that are moving faster than this
float timeImpulseRecover; //!< forcefully turns on inertia for that duration after receiving an impulse
int collTypes; //!< entity types to check collisions against
IPhysicalEntity* pLivingEntToIgnore; //!< ignore collisions with this *living entity* (doesn't work with other entity types)
int bNetwork; //!< uses extended history information (obsolete)
int bActive; //!< 0 disables all simulation for the character, apart from moving along the requested velocity
int iRequestedTime; //!< requests that the player rolls back to that time and re-executes pending actions during the next step
int bReleaseGroundColliderWhenNotActive; //!< when not 0, if the living entity is not active, the ground collider, if any, will be explicitly released during the simulation step.
};
class IPhysicalEntity
{
public:
int SetParams(pe_params* params, int bThreadSafe = 0)
{
return CallFunction<int(__fastcall*)(PVOID, pe_params*, int)>(this, 0x38)(this, params, bThreadSafe);
}
int GetParams(pe_params* params)
{
return CallFunction<int(__fastcall*)(PVOID, pe_params*)>(this, 0x40)(this, params);
}
};
class CEntity
{
public:
IPhysicalEntity* GetPhysics()
{
return CallFunction<IPhysicalEntity* (__fastcall*)(PVOID)>(this, 0x1F8)(this);
}
}
IPhysicalEntity* pPhysEnt = pClientEntity->GetPhysics();
if (pPhysEnt)
{
pe_player_dynamics pd;
pd.bSwimming = true;
pd.kAirControl = 1.0f;
pd.kAirResistance = 0.0f;
pd.gravity = Vec3{ 0,0,0 };
if (GetAsyncKeyState('Z') & 1) pPhysEnt->SetParams(&pd);
}