hook up Vehicle's getAIMove(Move*);

list aiControllerData's in the datablock. though the command is still required to set the controler and look up the relevant db for game specific logic
This commit is contained in:
AzaezelX 2025-04-18 12:28:49 -05:00
parent 2d0bcbcf8d
commit 712404c9b4
4 changed files with 34 additions and 3 deletions

View file

@ -147,6 +147,7 @@ VehicleData::VehicleData()
collDamageThresholdVel = 20;
collDamageMultiplier = 0.05f;
enablePhysicsRep = true;
mAIControllData = NULL;
}
@ -320,6 +321,13 @@ void VehicleData::initPersistFields()
"velocity).\n\nCurrently unused." );
endGroup("Collision");
addGroup("Movement");
addField("controlMap", TypeString, Offset(mControlMap, VehicleData),
"@brief movemap used by these types of objects.\n\n");
addField("aiControllerData", TYPEID< AIControllerData >(), Offset(mAIControllData, VehicleData),
"@brief ai controller used by these types of objects.\n\n");
endGroup("Collision");
addGroup("Steering");
addFieldV( "jetForce", TypeRangedF32, Offset(jetForce, VehicleData), &CommonValidators::PositiveFloat,
"@brief Additional force applied to the vehicle when it is jetting.\n\n"
@ -501,6 +509,12 @@ void Vehicle::processTick(const Move* move)
if ( isMounted() )
return;
// If we're not being controlled by a client, let the
// AI sub-module get a chance at producing a move.
Move aiMove;
if (!move && isServerObject() && getAIMove(&aiMove))
move = &aiMove;
// Warp to catch up to server
if (mDelta.warpCount < mDelta.warpTicks)
{
@ -1233,6 +1247,17 @@ bool Vehicle::setAIController(SimObjectId controller)
return false;
}
bool Vehicle::getAIMove(Move* move)
{
if (mAIController)
{
mAIController->getAIMove(move); //actual result
return true;
}
return false;
}
DefineEngineMethod(Vehicle, setAIController, bool, (S32 controller), , "")
{
return object->setAIController(controller);