ped attractors done

This commit is contained in:
Nikolay Korolev
2020-05-16 01:49:30 +03:00
parent 09a0207e55
commit 08b2138c7e
7 changed files with 90 additions and 33 deletions

View File

@ -1033,12 +1033,12 @@ CFileLoader::Load2dEffect(const char *line)
sscanf(line, "%d %f %f %f %d %d %d %d %d %d %f %f %f %f %f %f",
&id, &x, &y, &z, &r, &g, &b, &a, &type,
&ptype,
&effect->pedattr.useDir.x,
&effect->pedattr.useDir.y,
&effect->pedattr.useDir.z,
&effect->pedattr.queueDir.x,
&effect->pedattr.queueDir.y,
&effect->pedattr.queueDir.z);
&effect->pedattr.queueDir.z,
&effect->pedattr.useDir.x,
&effect->pedattr.useDir.y,
&effect->pedattr.useDir.z);
effect->pedattr.type = ptype;
break;
}

View File

@ -2236,3 +2236,58 @@ CWorld::UseDetonator(CEntity *pEntity)
}
}
}
bool
CWorld::IsWanderPathClear(CVector const& point1, CVector const& point2, float distance, int maxSteps)
{
if (Abs(point1.z - point2.z) > distance)
return false;
if (!GetIsLineOfSightClear(point1, point2, true, false, false, false, false, false, false))
return false;
CVector vecBetween = point2 - point1;
uint32 nSteps = Max(vecBetween.Magnitude(), maxSteps);
if (nSteps == 0)
return true;
vecBetween.Normalise();
uint32 step = 1;
for (step = 1; step < nSteps; step++) {
CVector posThisStep = point1 + vecBetween * step;
float level;
if (!CWaterLevel::GetWaterLevel(posThisStep, &level, false))
continue;
posThisStep.z = level;
AdvanceCurrentScanCode();
CVector vecCheckedPos(posThisStep.x, posThisStep.y, Max(point1.z, point2.z));
CColPoint colpoint;
CEntity* entity;
if (!ProcessVerticalLineSector(*GetSector(GetSectorIndexX(posThisStep.x), GetSectorIndexY(posThisStep.y)),
CColLine(posThisStep, vecCheckedPos), colpoint, entity, true, false, false, false, false, false, nil))
return false;
}
CVector posThisStep = point1;
AdvanceCurrentScanCode();
CVector vecCheckedPos(posThisStep.x, posThisStep.y, point1.z - 5.0f);
CColPoint colpoint;
CEntity* entity;
if (!ProcessVerticalLineSector(*GetSector(GetSectorIndexX(posThisStep.x), GetSectorIndexY(posThisStep.y)),
CColLine(posThisStep, vecCheckedPos), colpoint, entity, true, false, false, false, false, false, nil))
return false;
float heightNextStep = colpoint.point.z + 0.5f;
for (step = 1; step < nSteps; step++) {
CVector posThisStep = point1 + vecBetween * step;
posThisStep.z = heightNextStep;
AdvanceCurrentScanCode();
CVector vecCheckedPos(posThisStep.x, posThisStep.y, heightNextStep - 2.0f);
if (!ProcessVerticalLineSector(*GetSector(GetSectorIndexX(posThisStep.x), GetSectorIndexY(posThisStep.y)),
CColLine(posThisStep, vecCheckedPos), colpoint, entity, true, false, false, false, false, false, nil))
return false;
if (Abs(colpoint.point.z - heightNextStep) > 1.0f)
return false;
heightNextStep = colpoint.point.z + 0.5f;
}
return true;
}

View File

@ -125,6 +125,8 @@ public:
static void CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1, float x2, float y2, float fStartX, float fStartY, float fEndX, float fEndY);
static void CallOffChaseForAreaSectorListPeds(CPtrList& list, float x1, float y1, float x2, float y2);
static bool IsWanderPathClear(CVector const&, CVector const&, float, int);
static float GetSectorX(float f) { return ((f - WORLD_MIN_X)/SECTOR_SIZE_X); }
static float GetSectorY(float f) { return ((f - WORLD_MIN_Y)/SECTOR_SIZE_Y); }
static int GetSectorIndexX(float f) { return (int)GetSectorX(f); }