Proper Visible Checks
Hi guys
well, since i dont play this game anymore, here is my visible check function.
Because as you could see by using only Trace or SingleLineCheck there were some circumstances where the target wasnt visible although you could shoot at him. It's not perfect but it worked really good. Have fun.
Credits:
LowHertz
well, since i dont play this game anymore, here is my visible check function.
Code:
BOOL IsVisible(APawn *Target, FVector *start, FVector *end, BOOL *bOutIsLeaning)
{
BOOL bFence = FALSE;
BOOL bNullObject = FALSE;
BOOL bLeaning = FALSE;
APawn *RetPawn;
if(g_pPC != NULL && Target != NULL && start != NULL && end != NULL)
{
RetPawn = (APawn *)g_pPC->Trace(*end, *start, 1, vExtent, 0, &HitLocation1, &HitNormal, &HitInfo1);
if(HitInfo1.Material != NULL)
{
if(strstr(HitInfo1.Material->GetFullName(), "Fence"))
{
RetPawn = (APawn *)Target->Trace(*start, *end, 1, vExtent, 0, &HitLocation2, &HitNormal, &HitInfo2);
if(HitInfo2.Material != NULL)
{
if(strstr(HitInfo2.Material->GetFullName(), "Fence"))
{
if(!strcmp(HitInfo2.Material->GetFullName(), HitInfo1.Material->GetFullName()))
bFence = TRUE;
}
}
}
}
if(HitInfo1.Material == NULL)
{
if(RetPawn != NULL && !RetPawn->IsA(AVehicle::StaticClass()))
{
RetPawn = (APawn *)Target->Trace(*start, *end, 1, vExtent, 0, &HitLocation2, &HitNormal, &HitInfo2);
if(HitInfo2.Material == NULL)
bNullObject = TRUE;
}
if(RetPawn != NULL)
{
if(Target->IsA(AcAPBPawn::StaticClass()))
{
AcAPBPawn *APBPawn = (AcAPBPawn *)Target;
if(APBPawn->m_VehicleUseData.m_bLeaningOut)
{
*bOutIsLeaning = TRUE;
bLeaning = TRUE;
}
}
}
}
return (Target == RetPawn || bNullObject || bFence || bLeaning);
}
return 0;
}
Because as you could see by using only Trace or SingleLineCheck there were some circumstances where the target wasnt visible although you could shoot at him. It's not perfect but it worked really good. Have fun.
Credits:
LowHertz