diff --git a/Engine/source/T3D/AI/AIController.cpp b/Engine/source/T3D/AI/AIController.cpp index d798585c4..8ace880f1 100644 --- a/Engine/source/T3D/AI/AIController.cpp +++ b/Engine/source/T3D/AI/AIController.cpp @@ -180,6 +180,11 @@ bool AIController::getAIMove(Move* movePtr) if (obj->getContainer()->castRay(start, end, StaticShapeObjectType, &info)) { getNav()->repath(); + mMovement.mInAir = false; + } + else + { + mMovement.mInAir = true; } obj->enableCollision(); getGoal()->mInRange = false; @@ -307,6 +312,13 @@ void AIController::Movement::onStuck() #endif } +bool AIController::Movement::isInWater() +{ + ShapeBase* sbo = dynamic_cast(getCtrl()->getAIInfo()->mObj.getPointer()); + if (!sbo) return false; + return sbo->getWaterCoverage() > 0.0f; +} + DefineEngineMethod(AIController, setMoveSpeed, void, (F32 speed), , "@brief Sets the move speed for an AI object.\n\n" @@ -335,6 +347,23 @@ DefineEngineMethod(AIController, stop, void, (), , object->mMovement.stopMove(); } +DefineEngineMethod(AIController, isStopped, bool, (), , + "@brief is the player moving?.\n\n") +{ + return object->mMovement.isStopped(); +} + +DefineEngineMethod(AIController, isInAir, bool, (), , + "@brief is the player moving?.\n\n") +{ + return object->mMovement.isInAir(); +} + +DefineEngineMethod(AIController, isInWater, bool, (), , + "@brief is the player in water?.\n\n") +{ + return object->mMovement.isInWater(); +} /** * Set the state of a movement trigger. diff --git a/Engine/source/T3D/AI/AIController.h b/Engine/source/T3D/AI/AIController.h index 340ee5d04..dcc46f661 100644 --- a/Engine/source/T3D/AI/AIController.h +++ b/Engine/source/T3D/AI/AIController.h @@ -85,10 +85,11 @@ public: AIController* mControllerRef; AIController* getCtrl() { return mControllerRef; }; MoveState mMoveState; + bool mInAir = false; F32 mMoveSpeed = 1.0; void setMoveSpeed(F32 speed) { mMoveSpeed = speed; }; F32 getMoveSpeed() { return mMoveSpeed; }; - bool mMoveSlowdown; // Slowdown as we near the destination + bool mMoveSlowdown = false; // Slowdown as we near the destination Point3F mLastLocation; // For stuck check S32 mMoveStuckTestCountdown; // The current countdown until at AI starts to check if it is stuck Point3F mAimLocation; @@ -96,6 +97,9 @@ public: bool mMoveTriggers[MaxTriggerKeys]; void stopMove(); void onStuck(); + bool isStopped() { return mMoveState == ModeStop; }; + bool isInAir() { return mInAir; }; + bool isInWater(); } mMovement; struct TriggerState