1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-20 17:17:13 +02:00

Implement simple distance tracking for player and vehicle entities.

Doesn't differentiate from in-air and on-ground.
Just sums up the distance from last position on each position update.
This commit is contained in:
Sandu Liviu Catalin
2020-05-04 11:58:30 +03:00
parent f2be86a65e
commit 4c1030c76e
8 changed files with 150 additions and 5 deletions

@ -1481,7 +1481,12 @@ void Core::EmitPlayerUpdate(Int32 player_id, vcmpPlayerUpdate update_type)
// Now emit the event
EmitPlayerPosition(player_id);
}
// Should we check for area collision
// Should we check for distance traveled?
if (inst.mFlags & ENF_DIST_TRACK)
{
inst.mDistance += inst.mLastPosition.GetDistanceTo(pos);
}
// Should we check for area collision?
if (inst.mFlags & ENF_AREA_TRACK)
{
// Eliminate existing areas first, if the player is not in them anymore
@ -1716,7 +1721,12 @@ void Core::EmitVehicleUpdate(Int32 vehicle_id, vcmpVehicleUpdate update_type)
Vector3 pos;
// Retrieve the current vehicle position
_Func->GetVehiclePosition(vehicle_id, &pos.x, &pos.y, &pos.z);
// Should we check for area collision
// Should we check for distance traveled?
if (inst.mFlags & ENF_DIST_TRACK)
{
inst.mDistance += inst.mLastPosition.GetDistanceTo(pos);
}
// Should we check for area collision?
if (inst.mFlags & ENF_AREA_TRACK)
{
// Eliminate existing areas first, if the vehicle is not in them anymore

@ -344,6 +344,7 @@ void Core::PlayerInst::ResetInstance()
mID = -1;
mFlags = ENF_DEFAULT;
mAreas.clear();
mDistance = 0;
mTrackPosition = 0;
mTrackHeading = 0;
mTrackPositionHeader = 0;
@ -364,6 +365,7 @@ void Core::VehicleInst::ResetInstance()
mID = -1;
mFlags = ENF_DEFAULT;
mAreas.clear();
mDistance = 0;
mTrackPosition = 0;
mTrackRotation = 0;
mLastPrimaryColor = -1;