I had started off with a simple
if (rInfo.object == target)
return true;
But that didn't block the raycast with other players.
Full code for the function below:
bool AIPlayer::checkClearLos(GameBase* target, bool _checkEnabled)
{
if (!isServerObject()) return false;
if (!target)
{
target = mAimObject.getPointer();
if (!target)
return false;
}
if (_checkEnabled)
{
if (target->getTypeMask() & ShapeBaseObjectType)
{
ShapeBase *shapeBaseCheck = static_cast<ShapeBase *>(target);
if (shapeBaseCheck)
if (shapeBaseCheck->getDamageState() != Enabled) return false;
}
else
return false;
}
RayInfo rInfo;
disableCollision();
S32 mountCount = target->getMountedObjectCount();
for (S32 i = 0; i < mountCount; i++)
{
target->getMountedObject(i)->disableCollision();
}
Point3F checkPoint = getBoxCenter();
//getMuzzlePointAI(0, &checkPoint);
//getBoxCenter();
bool hit = !gServerContainer.castRay(checkPoint, target->getBoxCenter(), TerrainObjectType | StaticShapeObjectType | StaticObjectType | PlayerObjectType | DynamicShapeObjectType, &rInfo);
enableCollision();
for (S32 i = 0; i < mountCount; i++)
{
target->getMountedObject(i)->enableCollision();
}
if (!hit)
{
//only return true if it's our intended target!
S32 id = rInfo.object->getId();
if (id == target->getId())
return true;//<<<<<<<0----------------ALWAYS TRUE WHEN HIDING BEHIND OTHER PLAYERS
}
return false;
}
Any pointers on what I am doing wrong? I usually script this kinda thing but thought I'd try C++ instead.
//=============================================
//=============================================
edited ... moments after posting ...

DERP
My console function engineDefine was calling another LOS function and not my custom one here.

PROBLEM WAS WITH MUPPET AT KEYBOARD
