mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-17 21:08:09 +00:00
Visual Debugger implementation
This commit is contained in:
@@ -54,7 +54,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
||||
auto* presetTarget = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
if (presetTarget != nullptr) {
|
||||
if (this->m_radius * this->m_radius >= Vector3::DistanceSquared(reference, presetTarget->GetPosition())) {
|
||||
if (this->m_radius * this->m_radius >= NiPoint3::DistanceSquared(reference, presetTarget->GetPosition())) {
|
||||
targets.push_back(presetTarget);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto distance = Vector3::DistanceSquared(reference, entity->GetPosition());
|
||||
const auto distance = NiPoint3::DistanceSquared(reference, entity->GetPosition());
|
||||
|
||||
if (this->m_radius * this->m_radius >= distance && (this->m_maxTargets == 0 || targets.size() < this->m_maxTargets)) {
|
||||
targets.push_back(entity);
|
||||
@@ -98,8 +98,8 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
||||
}
|
||||
|
||||
std::sort(targets.begin(), targets.end(), [reference](Entity* a, Entity* b) {
|
||||
const auto aDistance = Vector3::DistanceSquared(a->GetPosition(), reference);
|
||||
const auto bDistance = Vector3::DistanceSquared(b->GetPosition(), reference);
|
||||
const auto aDistance = NiPoint3::DistanceSquared(a->GetPosition(), reference);
|
||||
const auto bDistance = NiPoint3::DistanceSquared(b->GetPosition(), reference);
|
||||
|
||||
return aDistance > bDistance;
|
||||
});
|
||||
|
@@ -78,7 +78,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
||||
|
||||
const auto position = entity->GetPosition() + this->m_offset;
|
||||
|
||||
const auto distance = Vector3::Distance(position, other->GetPosition());
|
||||
const auto distance = NiPoint3::Distance(position, other->GetPosition());
|
||||
|
||||
const auto time = distance / this->m_projectileSpeed;
|
||||
|
||||
|
@@ -154,19 +154,19 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
// reference is the position of the caster.
|
||||
// If we cast a ray forward from the caster, does it come within m_farWidth of the target?
|
||||
|
||||
const auto distance = Vector3::Distance(reference, otherPosition);
|
||||
const auto distance = NiPoint3::Distance(reference, otherPosition);
|
||||
|
||||
if (m_method == 2) {
|
||||
NiPoint3 rayPoint = casterPosition + forward * distance;
|
||||
|
||||
if (m_farWidth > 0 && Vector3::DistanceSquared(rayPoint, otherPosition) > this->m_farWidth * this->m_farWidth) {
|
||||
if (m_farWidth > 0 && NiPoint3::DistanceSquared(rayPoint, otherPosition) > this->m_farWidth * this->m_farWidth) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
auto normalized = (reference - otherPosition) / distance;
|
||||
|
||||
const float degreeAngle = std::abs(Vector3::Angle(forward, normalized) * (180 / 3.14) - 180);
|
||||
const float degreeAngle = std::abs(NiPoint3::Angle(forward, normalized) * (180 / 3.14) - 180);
|
||||
|
||||
if (distance >= this->m_minDistance && this->m_maxDistance >= distance && degreeAngle <= 2 * this->m_angle) {
|
||||
targets.push_back(entity);
|
||||
@@ -174,8 +174,8 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
}
|
||||
|
||||
std::sort(targets.begin(), targets.end(), [reference](Entity* a, Entity* b) {
|
||||
const auto aDistance = Vector3::DistanceSquared(reference, a->GetPosition());
|
||||
const auto bDistance = Vector3::DistanceSquared(reference, b->GetPosition());
|
||||
const auto aDistance = NiPoint3::DistanceSquared(reference, a->GetPosition());
|
||||
const auto bDistance = NiPoint3::DistanceSquared(reference, b->GetPosition());
|
||||
|
||||
return aDistance > bDistance;
|
||||
});
|
||||
|
@@ -23,7 +23,7 @@ void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
return;
|
||||
}
|
||||
|
||||
const auto distance = Vector3::DistanceSquared(self->GetPosition(), entity->GetPosition());
|
||||
const auto distance = NiPoint3::DistanceSquared(self->GetPosition(), entity->GetPosition());
|
||||
|
||||
if (distance > this->m_range * this->m_range) {
|
||||
success = false;
|
||||
|
@@ -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;
|
||||
|
@@ -4919,7 +4919,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
|
||||
const auto& referencePoint = entity->GetPosition();
|
||||
|
||||
for (auto* scripted : scriptedEntities) {
|
||||
if (Vector3::DistanceSquared(scripted->GetPosition(), referencePoint) > 5.0f * 5.0f) continue;
|
||||
if (NiPoint3::DistanceSquared(scripted->GetPosition(), referencePoint) > 5.0f * 5.0f) continue;
|
||||
|
||||
scripted->OnEmoteReceived(emoteID, entity);
|
||||
}
|
||||
|
Reference in New Issue
Block a user