mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
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:
parent
2d0bcbcf8d
commit
712404c9b4
4 changed files with 34 additions and 3 deletions
|
|
@ -31,6 +31,7 @@ IMPLEMENT_CONOBJECT(AIController);
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void AIController::throwCallback(const char* name)
|
void AIController::throwCallback(const char* name)
|
||||||
{
|
{
|
||||||
|
Con::warnf("throwCallback: %s", name);
|
||||||
Con::executef(mControllerData, name, getIdString()); //controller data callbacks
|
Con::executef(mControllerData, name, getIdString()); //controller data callbacks
|
||||||
|
|
||||||
GameBase* gbo = dynamic_cast<GameBase*>(getAIInfo()->mObj.getPointer());
|
GameBase* gbo = dynamic_cast<GameBase*>(getAIInfo()->mObj.getPointer());
|
||||||
|
|
@ -676,7 +677,6 @@ F32 AIWheeledVehicleControllerData::getSteeringAngle(AIController* obj, Point3F
|
||||||
maxSteeringAngle = vd->maxSteeringAngle;
|
maxSteeringAngle = vd->maxSteeringAngle;
|
||||||
|
|
||||||
Point2F steering = wvo->getSteering();
|
Point2F steering = wvo->getSteering();
|
||||||
|
|
||||||
if (finalYaw < 5 && steering.x != 0.0f)
|
if (finalYaw < 5 && steering.x != 0.0f)
|
||||||
steerState = Straight;
|
steerState = Straight;
|
||||||
else if (finalYaw < 5)
|
else if (finalYaw < 5)
|
||||||
|
|
|
||||||
|
|
@ -461,7 +461,7 @@ PlayerData::PlayerData()
|
||||||
|
|
||||||
physicsPlayerType = StringTable->EmptyString();
|
physicsPlayerType = StringTable->EmptyString();
|
||||||
mControlMap = StringTable->EmptyString();
|
mControlMap = StringTable->EmptyString();
|
||||||
|
mAIControllData = NULL;
|
||||||
dMemset( actionList, 0, sizeof(actionList) );
|
dMemset( actionList, 0, sizeof(actionList) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -740,8 +740,10 @@ void PlayerData::initPersistFields()
|
||||||
endGroup( "Camera" );
|
endGroup( "Camera" );
|
||||||
|
|
||||||
addGroup( "Movement" );
|
addGroup( "Movement" );
|
||||||
addField("controlMap", TypeString, Offset(mControlMap, PlayerData),
|
addField("controlMap", TypeString, Offset(mControlMap, PlayerData),
|
||||||
"@brief movemap used by these types of objects.\n\n");
|
"@brief movemap used by these types of objects.\n\n");
|
||||||
|
addField("aiControllerData", TYPEID< AIControllerData >(), Offset(mAIControllData, PlayerData),
|
||||||
|
"@brief ai controller used by these types of objects.\n\n");
|
||||||
|
|
||||||
addFieldV( "maxStepHeight", TypeRangedF32, Offset(maxStepHeight, PlayerData), &CommonValidators::PositiveFloat,
|
addFieldV( "maxStepHeight", TypeRangedF32, Offset(maxStepHeight, PlayerData), &CommonValidators::PositiveFloat,
|
||||||
"@brief Maximum height the player can step up.\n\n"
|
"@brief Maximum height the player can step up.\n\n"
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,7 @@ VehicleData::VehicleData()
|
||||||
collDamageThresholdVel = 20;
|
collDamageThresholdVel = 20;
|
||||||
collDamageMultiplier = 0.05f;
|
collDamageMultiplier = 0.05f;
|
||||||
enablePhysicsRep = true;
|
enablePhysicsRep = true;
|
||||||
|
mAIControllData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -320,6 +321,13 @@ void VehicleData::initPersistFields()
|
||||||
"velocity).\n\nCurrently unused." );
|
"velocity).\n\nCurrently unused." );
|
||||||
endGroup("Collision");
|
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");
|
addGroup("Steering");
|
||||||
addFieldV( "jetForce", TypeRangedF32, Offset(jetForce, VehicleData), &CommonValidators::PositiveFloat,
|
addFieldV( "jetForce", TypeRangedF32, Offset(jetForce, VehicleData), &CommonValidators::PositiveFloat,
|
||||||
"@brief Additional force applied to the vehicle when it is jetting.\n\n"
|
"@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() )
|
if ( isMounted() )
|
||||||
return;
|
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
|
// Warp to catch up to server
|
||||||
if (mDelta.warpCount < mDelta.warpTicks)
|
if (mDelta.warpCount < mDelta.warpTicks)
|
||||||
{
|
{
|
||||||
|
|
@ -1233,6 +1247,17 @@ bool Vehicle::setAIController(SimObjectId controller)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Vehicle::getAIMove(Move* move)
|
||||||
|
{
|
||||||
|
if (mAIController)
|
||||||
|
{
|
||||||
|
mAIController->getAIMove(move); //actual result
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineMethod(Vehicle, setAIController, bool, (S32 controller), , "")
|
DefineEngineMethod(Vehicle, setAIController, bool, (S32 controller), , "")
|
||||||
{
|
{
|
||||||
return object->setAIController(controller);
|
return object->setAIController(controller);
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ struct VehicleData : public RigidShapeData
|
||||||
F32 numDmgEmitterAreas;
|
F32 numDmgEmitterAreas;
|
||||||
|
|
||||||
bool enablePhysicsRep;
|
bool enablePhysicsRep;
|
||||||
|
StringTableEntry mControlMap;
|
||||||
|
AIControllerData* mAIControllData;
|
||||||
|
|
||||||
//
|
//
|
||||||
VehicleData();
|
VehicleData();
|
||||||
|
|
@ -152,6 +154,8 @@ public:
|
||||||
F32 getThrottle() { return mThrottle;};
|
F32 getThrottle() { return mThrottle;};
|
||||||
bool setAIController(SimObjectId controller);
|
bool setAIController(SimObjectId controller);
|
||||||
AIController* getAIController() { return mAIController; };
|
AIController* getAIController() { return mAIController; };
|
||||||
|
virtual bool getAIMove(Move*);
|
||||||
|
|
||||||
/// Interpolates between move ticks @see processTick
|
/// Interpolates between move ticks @see processTick
|
||||||
/// @param dt Change in time between the last call and this call to the function
|
/// @param dt Change in time between the last call and this call to the function
|
||||||
void advanceTime(F32 dt) override;
|
void advanceTime(F32 dt) override;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue