fix pack/unpack data for AIControllerData's (though we still send nothing, we do need to mark it clientside as false)

more pitchwork for flying vehicle drivers
when flocking is irrelevant just path to next node
This commit is contained in:
AzaezelX 2025-04-25 18:50:16 -05:00
parent 6efb3843f6
commit 675bdfe6b3
4 changed files with 20 additions and 17 deletions

View file

@ -777,17 +777,18 @@ void AIFlyingVehicleControllerData::resolvePitch(AIController* obj, Point3F loca
Point3F toTarg = location - aimLoc;
toTarg.normalize();
F32 lastPitch = fvo->getSteering().y;
movePtr->pitch = 0.0f;
F32 dotPitch = -mDot(up, toTarg);
F32 dotPitch = mDot(up, toTarg);
FlyingVehicleData* db = static_cast<FlyingVehicleData*>(fvo->getDataBlock());
F32 rollAmt = mFabs(fvo->getThrottle()* movePtr->yaw * db->steeringRollForce);
F32 rollAmt = mFabs(fvo->getThrottle()* movePtr->yaw / (db->steeringRollForce+1.0));
dotPitch *= 1.0-(mClampF(rollAmt, 0.0,1.0)); // reduce pitch by how much we're rolling
dotPitch *= M_PI_F;
dotPitch *= M_2PI_F;
if (mFabs(dotPitch) > 0.05f)
movePtr->pitch = dotPitch - lastPitch;
movePtr->pitch = dotPitch;
}
@ -803,9 +804,7 @@ void AIFlyingVehicleControllerData::resolveSpeed(AIController* obj, Point3F loca
}
if (!fvo) return;//not a FlyingVehicle
Parent::resolveSpeed(obj, location, movePtr);
movePtr->x = 0;
movePtr->y = mMax(movePtr->y, 0.0f);
movePtr->y = obj->mMovement.mMoveSpeed;
}
#endif //_AICONTROLLER_H_

View file

@ -147,8 +147,8 @@ public:
AIControllerData();
~AIControllerData() {};
void packData(BitStream* stream) override {};
void unpackData(BitStream* stream) override {};
void packData(BitStream* stream) override { Parent::packData(stream); };
void unpackData(BitStream* stream) override { Parent::unpackData(stream); };
static void initPersistFields();
DECLARE_CONOBJECT(AIControllerData);

View file

@ -126,9 +126,8 @@ void AINavigation::repath()
if (mPathData.path.isNull() || !mPathData.owned)
return;
if (mRandI(0, 100) < getCtrl()->mControllerData->mFlocking.mChance)
if (mRandI(0, 100) < getCtrl()->mControllerData->mFlocking.mChance && flock())
{
flock();
mPathData.path->mTo = mMoveDestination;
}
else
@ -296,7 +295,7 @@ void AINavigation::clearPath()
mPathData = PathData();
}
void AINavigation::flock()
bool AINavigation::flock()
{
AIControllerData::Flocking flockingData = getCtrl()->mControllerData->mFlocking;
SimObjectPtr<SceneObject> obj = getCtrl()->getAIInfo()->mObj;
@ -306,7 +305,7 @@ void AINavigation::flock()
Point3F searchArea = Point3F(flockingData.mMin / 2, flockingData.mMax / 2, getCtrl()->getAIInfo()->mObj->getObjBox().maxExtents.z / 2);
F32 maxFlocksq = flockingData.mMax * flockingData.mMax;
bool flocking = false;
if (getCtrl()->getGoal())
{
Point3F dest = mMoveDestination;
@ -403,17 +402,22 @@ void AINavigation::flock()
//if we're not jumping...
if (mJump == None)
{
dest.z -= obj->getObjBox().len_z()*0.5;
dest.z = obj->getPosition().z;
//make sure we don't run off a cliff
Point3F zlen(0, 0, getCtrl()->getAIInfo()->mRadius);
Point3F zlen(0, 0, getCtrl()->mControllerData->mHeightTolerance);
if (obj->getContainer()->castRay(dest + zlen, dest - zlen, TerrainObjectType | StaticShapeObjectType | StaticObjectType, &info))
{
mMoveDestination = dest;
if ((mMoveDestination - dest).len() > getCtrl()->mControllerData->mMoveTolerance)
{
mMoveDestination = dest;
flocking = true;
}
}
}
}
}
obj->enableCollision();
return flocking;
}
DefineEngineMethod(AIController, setMoveDestination, void, (Point3F goal, bool slowDown), (true),

View file

@ -97,7 +97,7 @@ struct AINavigation
/// Move to the specified node in the current path.
void moveToNode(S32 node);
void flock();
bool flock();
};
#endif