Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Engine/source/T3D/AI/AIController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -307,6 +312,13 @@ void AIController::Movement::onStuck()
#endif
}

bool AIController::Movement::isInWater()
{
ShapeBase* sbo = dynamic_cast<ShapeBase*>(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"

Expand Down Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion Engine/source/T3D/AI/AIController.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,21 @@ class AIController : public SimObject {
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;
// move triggers
bool mMoveTriggers[MaxTriggerKeys];
void stopMove();
void onStuck();
bool isStopped() { return mMoveState == ModeStop; };
bool isInAir() { return mInAir; };
bool isInWater();
} mMovement;

struct TriggerState
Expand Down
Loading