Skip to content

Commit 84b2405

Browse files
authored
Merge pull request #1656 from Azaezel/alpha41/aiAugs
expanded movement state data for aicontrollers
2 parents d2b63f7 + 8411ae3 commit 84b2405

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

Engine/source/T3D/AI/AIController.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ bool AIController::getAIMove(Move* movePtr)
180180
if (obj->getContainer()->castRay(start, end, StaticShapeObjectType, &info))
181181
{
182182
getNav()->repath();
183+
mMovement.mInAir = false;
184+
}
185+
else
186+
{
187+
mMovement.mInAir = true;
183188
}
184189
obj->enableCollision();
185190
getGoal()->mInRange = false;
@@ -307,6 +312,13 @@ void AIController::Movement::onStuck()
307312
#endif
308313
}
309314

315+
bool AIController::Movement::isInWater()
316+
{
317+
ShapeBase* sbo = dynamic_cast<ShapeBase*>(getCtrl()->getAIInfo()->mObj.getPointer());
318+
if (!sbo) return false;
319+
return sbo->getWaterCoverage() > 0.0f;
320+
}
321+
310322
DefineEngineMethod(AIController, setMoveSpeed, void, (F32 speed), ,
311323
"@brief Sets the move speed for an AI object.\n\n"
312324

@@ -335,6 +347,23 @@ DefineEngineMethod(AIController, stop, void, (), ,
335347
object->mMovement.stopMove();
336348
}
337349

350+
DefineEngineMethod(AIController, isStopped, bool, (), ,
351+
"@brief is the player moving?.\n\n")
352+
{
353+
return object->mMovement.isStopped();
354+
}
355+
356+
DefineEngineMethod(AIController, isInAir, bool, (), ,
357+
"@brief is the player moving?.\n\n")
358+
{
359+
return object->mMovement.isInAir();
360+
}
361+
362+
DefineEngineMethod(AIController, isInWater, bool, (), ,
363+
"@brief is the player in water?.\n\n")
364+
{
365+
return object->mMovement.isInWater();
366+
}
338367

339368
/**
340369
* Set the state of a movement trigger.

Engine/source/T3D/AI/AIController.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,21 @@ class AIController : public SimObject {
8585
AIController* mControllerRef;
8686
AIController* getCtrl() { return mControllerRef; };
8787
MoveState mMoveState;
88+
bool mInAir = false;
8889
F32 mMoveSpeed = 1.0;
8990
void setMoveSpeed(F32 speed) { mMoveSpeed = speed; };
9091
F32 getMoveSpeed() { return mMoveSpeed; };
91-
bool mMoveSlowdown; // Slowdown as we near the destination
92+
bool mMoveSlowdown = false; // Slowdown as we near the destination
9293
Point3F mLastLocation; // For stuck check
9394
S32 mMoveStuckTestCountdown; // The current countdown until at AI starts to check if it is stuck
9495
Point3F mAimLocation;
9596
// move triggers
9697
bool mMoveTriggers[MaxTriggerKeys];
9798
void stopMove();
9899
void onStuck();
100+
bool isStopped() { return mMoveState == ModeStop; };
101+
bool isInAir() { return mInAir; };
102+
bool isInWater();
99103
} mMovement;
100104

101105
struct TriggerState

0 commit comments

Comments
 (0)