summaryrefslogtreecommitdiffstats
path: root/src/peds/PedPlacement.cpp
diff options
context:
space:
mode:
author_AG <gennariarmando@outlook.com>2019-07-07 15:16:54 +0200
committer_AG <gennariarmando@outlook.com>2019-07-07 15:16:54 +0200
commitd1c6a6aaa6c17250e069d1267b27e13303d6e20f (patch)
tree76d55bfd8bcc8f72cdd4d261c0bb1eaa050e522a /src/peds/PedPlacement.cpp
parentMerge branch 'master' into master (diff)
parentthe great reorganization (diff)
downloadre3-d1c6a6aaa6c17250e069d1267b27e13303d6e20f.tar
re3-d1c6a6aaa6c17250e069d1267b27e13303d6e20f.tar.gz
re3-d1c6a6aaa6c17250e069d1267b27e13303d6e20f.tar.bz2
re3-d1c6a6aaa6c17250e069d1267b27e13303d6e20f.tar.lz
re3-d1c6a6aaa6c17250e069d1267b27e13303d6e20f.tar.xz
re3-d1c6a6aaa6c17250e069d1267b27e13303d6e20f.tar.zst
re3-d1c6a6aaa6c17250e069d1267b27e13303d6e20f.zip
Diffstat (limited to 'src/peds/PedPlacement.cpp')
-rw-r--r--src/peds/PedPlacement.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/peds/PedPlacement.cpp b/src/peds/PedPlacement.cpp
new file mode 100644
index 00000000..e9a3f7d9
--- /dev/null
+++ b/src/peds/PedPlacement.cpp
@@ -0,0 +1,40 @@
+#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
+ );
+
+ if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil))
+ foundColZ = foundCol.point.z;
+
+ // Adjust coords and do a second test
+ vec.x += 0.1f;
+ vec.y += 0.1f;
+
+ if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil))
+ foundColZ2 = foundCol.point.z;
+
+ zForPed = max(foundColZ, foundColZ2);
+
+ if (zForPed > -99.0f)
+ pos->z = 1.04f + zForPed;
+}
+
+STARTPATCHES
+ InjectHook(0x4EE340, &CPedPlacement::FindZCoorForPed, PATCH_JUMP);
+ENDPATCHES