From 9dadd28ab85e12d66da145ddeeb3e56f542778b8 Mon Sep 17 00:00:00 2001 From: John3 Date: Sun, 19 Jun 2016 10:03:15 -0500 Subject: [PATCH] Correct Bot aim. http://forums.torque3d.org/viewtopic.php?f=11&t=673&p=5718#p5718 --- Engine/source/T3D/aiPlayer.cpp | 24 ++++++++++++++++++++++++ Engine/source/T3D/aiPlayer.h | 1 + 2 files changed, 25 insertions(+) diff --git a/Engine/source/T3D/aiPlayer.cpp b/Engine/source/T3D/aiPlayer.cpp index 4c62075a7..838a4ae0f 100644 --- a/Engine/source/T3D/aiPlayer.cpp +++ b/Engine/source/T3D/aiPlayer.cpp @@ -293,6 +293,30 @@ void AIPlayer::clearAim() mAimOffset = Point3F(0.0f, 0.0f, 0.0f); } +/** + * Sets the correct aim for the bot to the target + */ +void AIPlayer::getMuzzleVector(U32 imageSlot,VectorF* vec) +{ + MatrixF mat; + getMuzzleTransform(imageSlot,&mat); + + MountedImage& image = mMountedImageList[imageSlot]; + + if (image.dataBlock->correctMuzzleVector) + { + disableHeadZCalc(); + if (getCorrectedAim(mat, vec)) + { + enableHeadZCalc(); + return; + } + enableHeadZCalc(); + + } + mat.getColumn(1,vec); +} + /** * Set the state of a movement trigger. * diff --git a/Engine/source/T3D/aiPlayer.h b/Engine/source/T3D/aiPlayer.h index e4f47eb9a..d37cb896b 100644 --- a/Engine/source/T3D/aiPlayer.h +++ b/Engine/source/T3D/aiPlayer.h @@ -170,6 +170,7 @@ public: void setAimLocation( const Point3F &location ); Point3F getAimLocation() const { return mAimLocation; } void clearAim(); + void AIPlayer::getMuzzleVector(U32 imageSlot,VectorF* vec); bool checkInLos(GameBase* target = NULL, bool _useMuzzle = false, bool _checkEnabled = false); bool checkInFoV(GameBase* target = NULL, F32 camFov = 45.0f, bool _checkEnabled = false); F32 getTargetDistance(GameBase* target, bool _checkEnabled);