mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-16 04:18:08 +00:00
Visual Debugger implementation
This commit is contained in:
@@ -402,7 +402,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
||||
if (target != nullptr && !m_DirtyThreat) {
|
||||
const auto targetPosition = target->GetPosition();
|
||||
|
||||
if (Vector3::DistanceSquared(targetPosition, m_StartPosition) < m_HardTetherRadius * m_HardTetherRadius) {
|
||||
if (NiPoint3::DistanceSquared(targetPosition, m_StartPosition) < m_HardTetherRadius * m_HardTetherRadius) {
|
||||
return m_Target;
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
||||
|
||||
const auto maxDistanceSquared = m_HardTetherRadius * m_HardTetherRadius;
|
||||
|
||||
if (Vector3::DistanceSquared(targetPosition, m_StartPosition) > maxDistanceSquared) {
|
||||
if (NiPoint3::DistanceSquared(targetPosition, m_StartPosition) > maxDistanceSquared) {
|
||||
if (threat > 0) {
|
||||
SetThreat(entry, 0);
|
||||
}
|
||||
@@ -448,7 +448,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto proximityThreat = -(Vector3::DistanceSquared(targetPosition, reference) - maxDistanceSquared) / 100; // Proximity threat takes last priority
|
||||
const auto proximityThreat = -(NiPoint3::DistanceSquared(targetPosition, reference) - maxDistanceSquared) / 100; // Proximity threat takes last priority
|
||||
|
||||
if (proximityThreat > biggestThreat) {
|
||||
biggestThreat = proximityThreat;
|
||||
@@ -477,7 +477,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
||||
|
||||
const auto targetPosition = entity->GetPosition();
|
||||
|
||||
if (Vector3::DistanceSquared(targetPosition, m_StartPosition) > m_HardTetherRadius * m_HardTetherRadius) {
|
||||
if (NiPoint3::DistanceSquared(targetPosition, m_StartPosition) > m_HardTetherRadius * m_HardTetherRadius) {
|
||||
deadThreats.push_back(threatTarget.first);
|
||||
|
||||
continue;
|
||||
@@ -508,7 +508,7 @@ std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
|
||||
for (auto id : m_Parent->GetTargetsInPhantom()) {
|
||||
auto* other = EntityManager::Instance()->GetEntity(id);
|
||||
|
||||
const auto distance = Vector3::DistanceSquared(m_Parent->GetPosition(), other->GetPosition());
|
||||
const auto distance = NiPoint3::DistanceSquared(m_Parent->GetPosition(), other->GetPosition());
|
||||
|
||||
if (distance > m_AggroRadius * m_AggroRadius) continue;
|
||||
|
||||
@@ -657,7 +657,7 @@ void BaseCombatAIComponent::Wander() {
|
||||
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
|
||||
}
|
||||
|
||||
if (Vector3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {
|
||||
if (NiPoint3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {
|
||||
m_MovementAI->Stop();
|
||||
|
||||
return;
|
||||
@@ -685,16 +685,16 @@ void BaseCombatAIComponent::OnAggro() {
|
||||
NiPoint3 currentPos = m_MovementAI->GetCurrentPosition();
|
||||
|
||||
// If the player's position is within range, attack
|
||||
if (Vector3::DistanceSquared(currentPos, targetPos) <= m_AttackRadius * m_AttackRadius) {
|
||||
if (NiPoint3::DistanceSquared(currentPos, targetPos) <= m_AttackRadius * m_AttackRadius) {
|
||||
m_MovementAI->Stop();
|
||||
} else if (Vector3::DistanceSquared(m_StartPosition, targetPos) > m_HardTetherRadius * m_HardTetherRadius) //Return to spawn if we're too far
|
||||
} else if (NiPoint3::DistanceSquared(m_StartPosition, targetPos) > m_HardTetherRadius * m_HardTetherRadius) //Return to spawn if we're too far
|
||||
{
|
||||
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
||||
|
||||
m_MovementAI->SetDestination(m_StartPosition);
|
||||
} else //Chase the player's new position
|
||||
{
|
||||
if (IsMech() && Vector3::DistanceSquared(targetPos, currentPos) > m_AttackRadius * m_AttackRadius * 3 * 3) return;
|
||||
if (IsMech() && NiPoint3::DistanceSquared(targetPos, currentPos) > m_AttackRadius * m_AttackRadius * 3 * 3) return;
|
||||
|
||||
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
||||
|
||||
@@ -718,9 +718,9 @@ void BaseCombatAIComponent::OnTether() {
|
||||
NiPoint3 targetPos = target->GetPosition();
|
||||
NiPoint3 currentPos = m_MovementAI->ApproximateLocation();
|
||||
|
||||
if (Vector3::DistanceSquared(currentPos, targetPos) <= m_AttackRadius * m_AttackRadius) {
|
||||
if (NiPoint3::DistanceSquared(currentPos, targetPos) <= m_AttackRadius * m_AttackRadius) {
|
||||
m_MovementAI->Stop();
|
||||
} else if (Vector3::DistanceSquared(m_StartPosition, targetPos) > m_HardTetherRadius * m_HardTetherRadius) //Return to spawn if we're too far
|
||||
} else if (NiPoint3::DistanceSquared(m_StartPosition, targetPos) > m_HardTetherRadius * m_HardTetherRadius) //Return to spawn if we're too far
|
||||
{
|
||||
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
||||
|
||||
@@ -728,7 +728,7 @@ void BaseCombatAIComponent::OnTether() {
|
||||
|
||||
m_State = AiState::aggro;
|
||||
} else {
|
||||
if (IsMech() && Vector3::DistanceSquared(targetPos, currentPos) > m_AttackRadius * m_AttackRadius * 3 * 3) return;
|
||||
if (IsMech() && NiPoint3::DistanceSquared(targetPos, currentPos) > m_AttackRadius * m_AttackRadius * 3 * 3) return;
|
||||
|
||||
m_MovementAI->SetSpeed(m_PursuitSpeed);
|
||||
|
||||
|
@@ -815,7 +815,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
const auto position = m_Parent->GetPosition();
|
||||
|
||||
for (auto* lauchPad : rocketLauchPads) {
|
||||
if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
||||
if (NiPoint3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
||||
|
||||
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||
|
||||
|
@@ -55,7 +55,7 @@ void MovementAIComponent::Update(const float deltaTime) {
|
||||
|
||||
SetPosition(source + velocity);
|
||||
|
||||
if (Vector3::DistanceSquared(GetCurrentPosition(), m_PullPoint) < 2 * 2) {
|
||||
if (NiPoint3::DistanceSquared(GetCurrentPosition(), m_PullPoint) < 2 * 2) {
|
||||
m_Interrupted = false;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ void MovementAIComponent::Update(const float deltaTime) {
|
||||
}
|
||||
|
||||
if (m_HaltDistance > 0) {
|
||||
if (Vector3::DistanceSquared(ApproximateLocation(), GetDestination()) < m_HaltDistance * m_HaltDistance) // Prevent us from hugging the target
|
||||
if (NiPoint3::DistanceSquared(ApproximateLocation(), GetDestination()) < m_HaltDistance * m_HaltDistance) // Prevent us from hugging the target
|
||||
{
|
||||
Stop();
|
||||
|
||||
@@ -373,7 +373,7 @@ void MovementAIComponent::SetDestination(const NiPoint3& value) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (Vector3::DistanceSquared(value, GetDestination()) < 2 * 2)
|
||||
/*if (NiPoint3::DistanceSquared(value, GetDestination()) < 2 * 2)
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
|
@@ -177,7 +177,7 @@ void MovingPlatformComponent::StartPathing() {
|
||||
SetMovementState(MovementPlatformState::Moving);
|
||||
});
|
||||
|
||||
const auto travelTime = Vector3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5f;
|
||||
const auto travelTime = NiPoint3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5f;
|
||||
|
||||
const auto travelNext = subComponent->mWaitTime + travelTime;
|
||||
|
||||
@@ -285,7 +285,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
||||
SetMovementState(MovementPlatformState::Moving);
|
||||
});
|
||||
|
||||
auto travelTime = Vector3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5;
|
||||
auto travelTime = NiPoint3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5;
|
||||
|
||||
if (m_Parent->GetLOT() == 9483) {
|
||||
travelTime += 20;
|
||||
|
@@ -400,7 +400,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
auto destination = owner->GetPosition();
|
||||
NiPoint3 position = m_MovementAI->GetCurrentPosition();
|
||||
|
||||
float distanceToOwner = Vector3::DistanceSquared(position, destination);
|
||||
float distanceToOwner = NiPoint3::DistanceSquared(position, destination);
|
||||
|
||||
if (distanceToOwner > 50 * 50 || m_TimerAway > 5) {
|
||||
m_MovementAI->Warp(destination);
|
||||
@@ -430,7 +430,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
if (closestSwitch != nullptr) {
|
||||
if (!closestSwitch->GetActive()) {
|
||||
NiPoint3 switchPosition = closestSwitch->GetParentEntity()->GetPosition();
|
||||
float distance = Vector3::DistanceSquared(position, switchPosition);
|
||||
float distance = NiPoint3::DistanceSquared(position, switchPosition);
|
||||
if (distance < 3 * 3) {
|
||||
m_Interaction = closestSwitch->GetParentEntity()->GetObjectID();
|
||||
closestSwitch->EntityEnter(m_Parent);
|
||||
@@ -451,7 +451,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
}
|
||||
|
||||
NiPoint3 tresurePosition = closestTresure->GetPosition();
|
||||
float distance = Vector3::DistanceSquared(position, tresurePosition);
|
||||
float distance = NiPoint3::DistanceSquared(position, tresurePosition);
|
||||
if (distance < 3 * 3) {
|
||||
m_Interaction = closestTresure->GetObjectID();
|
||||
|
||||
@@ -825,7 +825,7 @@ void PetComponent::Wander() {
|
||||
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
|
||||
}
|
||||
|
||||
if (Vector3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {
|
||||
if (NiPoint3::DistanceSquared(destination, m_MovementAI->GetCurrentPosition()) < 2 * 2) {
|
||||
m_MovementAI->Stop();
|
||||
|
||||
return;
|
||||
|
@@ -794,7 +794,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Vector3::DistanceSquared(position, vehiclePosition) > 50 * 50) {
|
||||
if (NiPoint3::DistanceSquared(position, vehiclePosition) > 50 * 50) {
|
||||
++respawnIndex;
|
||||
|
||||
continue;
|
||||
|
@@ -12,12 +12,12 @@ struct DynamicShootingGalleryParams {
|
||||
/**
|
||||
* The distance from the camera to the barrel
|
||||
*/
|
||||
Vector3 cameraBarrelOffset;
|
||||
NiPoint3 cameraBarrelOffset;
|
||||
|
||||
/**
|
||||
* The area the barrel is looking at
|
||||
*/
|
||||
Vector3 facing;
|
||||
NiPoint3 facing;
|
||||
|
||||
/**
|
||||
* The velocity of the cannonballs
|
||||
@@ -58,12 +58,12 @@ struct StaticShootingGalleryParams {
|
||||
/**
|
||||
* The position of the camera
|
||||
*/
|
||||
Vector3 cameraPosition;
|
||||
NiPoint3 cameraPosition;
|
||||
|
||||
/**
|
||||
* The position that the camera is looking at
|
||||
*/
|
||||
Vector3 cameraLookatPosition;
|
||||
NiPoint3 cameraLookatPosition;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -314,9 +314,9 @@ void SkillComponent::CalculateUpdate(const float deltaTime) {
|
||||
|
||||
const auto targetPosition = target->GetPosition();
|
||||
|
||||
const auto closestPoint = Vector3::ClosestPointOnLine(entry.lastPosition, position, targetPosition);
|
||||
const auto closestPoint = NiPoint3::ClosestPointOnLine(entry.lastPosition, position, targetPosition);
|
||||
|
||||
const auto distance = Vector3::DistanceSquared(targetPosition, closestPoint);
|
||||
const auto distance = NiPoint3::DistanceSquared(targetPosition, closestPoint);
|
||||
|
||||
if (distance > 3 * 3) {
|
||||
/*
|
||||
@@ -328,7 +328,7 @@ void SkillComponent::CalculateUpdate(const float deltaTime) {
|
||||
|
||||
const auto homingTarget = rotation.GetForwardVector() * speed;
|
||||
|
||||
Vector3 homing;
|
||||
NiPoint3 homing;
|
||||
|
||||
// Move towards
|
||||
|
||||
|
@@ -108,7 +108,7 @@ SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) {
|
||||
SwitchComponent* closest = nullptr;
|
||||
|
||||
for (SwitchComponent* petSwitch : petSwitches) {
|
||||
float distance = Vector3::DistanceSquared(petSwitch->m_Parent->GetPosition(), position);
|
||||
float distance = NiPoint3::DistanceSquared(petSwitch->m_Parent->GetPosition(), position);
|
||||
|
||||
if (closest == nullptr || distance < closestDistance) {
|
||||
closestDistance = distance;
|
||||
|
Reference in New Issue
Block a user