Files
DarkflameServer/dGame/dBehaviors/VerifyBehavior.cpp
Aaron Kimbrell 76b5b45d71 fix(behaviors): the verify behavior's blocking check as the game names it
The verify behaviors' parameter is check_blocking (on 145 of them), and the
client checks blocking unless it is 0. The server read "check blocking", which
no behavior has. It now reads check_blocking with the client's default. The
blocking check itself is still to be written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 07:09:07 -06:00

63 lines
1.6 KiB
C++

#include "VerifyBehavior.h"
#include "BehaviorBranchContext.h"
#include "EntityManager.h"
#include "NiPoint3.h"
#include "BehaviorContext.h"
#include "Game.h"
#include "Logger.h"
void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
auto* entity = Game::entityManager->GetEntity(branch.target);
auto success = true;
if (entity == nullptr) {
success = false;
} else if (this->m_rangeCheck) {
auto* self = Game::entityManager->GetEntity(context->originator);
if (self == nullptr) {
LOG("Invalid self for (%llu)", context->originator);
return;
}
const auto distance = Vector3::DistanceSquared(self->GetPosition(), entity->GetPosition());
if (distance > this->m_range) {
success = false;
}
} else if (this->m_blockCheck) {
// TODO
}
if (branch.target != LWOOBJID_EMPTY && branch.target != context->originator) {
bitStream.Write(success);
if (success) {
bitStream.Write<uint32_t>(1);
bitStream.Write0();
bitStream.Write0();
}
}
if (!success) {
branch.target = LWOOBJID_EMPTY;
}
m_action->Calculate(context, bitStream, branch);
}
void VerifyBehavior::Load() {
this->m_rangeCheck = GetBoolean("check_range");
// The client checks blocking unless the behavior turns it off
this->m_blockCheck = GetBoolean("check_blocking", true);
this->m_action = GetAction("action");
this->m_range = GetFloat("range");
this->m_range = this->m_range * this->m_range * 0.9f; // Range checks are slightly smaller than the actual range to account for client/server discrepancies
}