2019-06-24 16:57:54 +02:00
|
|
|
#include "common.h"
|
|
|
|
#include "patcher.h"
|
|
|
|
#include "PedPlacement.h"
|
|
|
|
#include "World.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
CPedPlacement::FindZCoorForPed(CVector* pos)
|
|
|
|
{
|
|
|
|
float zForPed;
|
|
|
|
float startZ = pos->z - 100.0f;
|
|
|
|
float foundColZ = -100.0f;
|
|
|
|
float foundColZ2 = -100.0f;
|
|
|
|
CColPoint foundCol;
|
|
|
|
CEntity* foundEnt;
|
|
|
|
|
|
|
|
CVector vec(
|
|
|
|
pos->x,
|
|
|
|
pos->y,
|
|
|
|
pos->z + 1.0f
|
|
|
|
);
|
|
|
|
|
2019-06-30 12:53:39 +02:00
|
|
|
if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil))
|
2019-06-24 16:57:54 +02:00
|
|
|
foundColZ = foundCol.point.z;
|
|
|
|
|
|
|
|
// Adjust coords and do a second test
|
|
|
|
vec.x += 0.1f;
|
|
|
|
vec.y += 0.1f;
|
|
|
|
|
2019-06-30 12:53:39 +02:00
|
|
|
if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil))
|
2019-06-24 16:57:54 +02:00
|
|
|
foundColZ2 = foundCol.point.z;
|
|
|
|
|
2019-08-27 20:50:59 +02:00
|
|
|
zForPed = max(foundColZ, foundColZ2);
|
2019-06-24 16:57:54 +02:00
|
|
|
|
|
|
|
if (zForPed > -99.0f)
|
|
|
|
pos->z = 1.04f + zForPed;
|
|
|
|
}
|
|
|
|
|
2019-07-18 04:26:46 +02:00
|
|
|
CEntity*
|
|
|
|
CPedPlacement::IsPositionClearOfCars(CVector* pos)
|
|
|
|
{
|
2019-07-31 17:54:18 +02:00
|
|
|
return CWorld::TestSphereAgainstWorld(*pos, 0.25f, nil, true, true, false, false, false, false);
|
2019-07-18 04:26:46 +02:00
|
|
|
}
|
|
|
|
|
2019-06-24 16:57:54 +02:00
|
|
|
STARTPATCHES
|
|
|
|
InjectHook(0x4EE340, &CPedPlacement::FindZCoorForPed, PATCH_JUMP);
|
2019-07-18 04:26:46 +02:00
|
|
|
InjectHook(0x4EE310, &CPedPlacement::IsPositionClearOfCars, PATCH_JUMP);
|
2019-06-24 16:57:54 +02:00
|
|
|
ENDPATCHES
|