mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-12 02:18:07 +00:00
WIP refactor into movment AI
So that combat behavior isn't fighting pathing
This commit is contained in:
@@ -124,8 +124,6 @@ void ActivityManager::ActivityTimerStart(Entity* self, const std::string& timerN
|
||||
auto* timer = new ActivityTimer{ timerName, updateInterval, stopTime };
|
||||
activeTimers.push_back(timer);
|
||||
|
||||
Game::logger->Log("ActivityManager", "Starting timer '%s', %f, %f", timerName.c_str(), updateInterval, stopTime);
|
||||
|
||||
self->AddTimer(GetPrefixedName(timer->name), timer->updateInterval);
|
||||
}
|
||||
|
||||
@@ -205,10 +203,8 @@ void ActivityManager::OnTimerDone(Entity* self, std::string timerName) {
|
||||
activeTimers.erase(std::remove(activeTimers.begin(), activeTimers.end(), timer),
|
||||
activeTimers.end());
|
||||
delete timer;
|
||||
Game::logger->Log("ActivityManager", "Executing timer '%s'", activityTimerName.c_str());
|
||||
OnActivityTimerDone(self, activityTimerName);
|
||||
} else {
|
||||
Game::logger->Log("ActivityManager", "Updating timer '%s'", activityTimerName.c_str());
|
||||
OnActivityTimerUpdate(self, timer->name, timer->stopTime - timer->runTime, timer->runTime);
|
||||
self->AddTimer(GetPrefixedName(timer->name), timer->updateInterval);
|
||||
}
|
||||
|
@@ -60,8 +60,6 @@ void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) {
|
||||
missionComponent->CompleteMission(instanceMissionID);
|
||||
}
|
||||
|
||||
Game::logger->Log("BossSpiderQueenEnemyServer", "Starting timer...");
|
||||
|
||||
// There is suppose to be a 0.1 second delay here but that may be admitted?
|
||||
auto* controller = EntityManager::Instance()->GetZoneControlEntity();
|
||||
|
||||
|
@@ -287,38 +287,27 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
|
||||
Game::logger->Log("SGCannon", "Spawning enemy %i on path %s", toSpawn.lot, path->pathName.c_str());
|
||||
|
||||
auto* enemy = EntityManager::Instance()->CreateEntity(info, nullptr, self);
|
||||
EntityManager::Instance()->ConstructEntity(enemy);
|
||||
if (enemy) {
|
||||
EntityManager::Instance()->ConstructEntity(enemy);
|
||||
auto* movementAI = enemy->GetComponent<MovementAIComponent>();
|
||||
|
||||
if (true) {
|
||||
auto* movementAI = new MovementAIComponent(enemy, {});
|
||||
|
||||
enemy->AddComponent(COMPONENT_TYPE_MOVEMENT_AI, movementAI);
|
||||
if (!movementAI) return;
|
||||
|
||||
movementAI->SetSpeed(toSpawn.initialSpeed);
|
||||
movementAI->SetCurrentSpeed(toSpawn.initialSpeed);
|
||||
movementAI->SetHaltDistance(0.0f);
|
||||
|
||||
std::vector<NiPoint3> pathWaypoints;
|
||||
|
||||
for (const auto& waypoint : path->pathWaypoints) {
|
||||
pathWaypoints.push_back(waypoint.position);
|
||||
}
|
||||
|
||||
if (GeneralUtils::GenerateRandomNumber<float_t>(0, 1) < 0.5f) {
|
||||
std::reverse(pathWaypoints.begin(), pathWaypoints.end());
|
||||
}
|
||||
|
||||
movementAI->SetPath(pathWaypoints);
|
||||
|
||||
enemy->AddDieCallback([this, self, enemy, name]() {
|
||||
RegisterHit(self, enemy, name);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Save the enemy and tell it to start pathing
|
||||
if (enemy != nullptr) {
|
||||
// Save the enemy
|
||||
const_cast<std::vector<LWOOBJID>&>(self->GetVar<std::vector<LWOOBJID>>(SpawnedObjects)).push_back(enemy->GetObjectID());
|
||||
GameMessages::SendPlatformResync(enemy, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
// if we are a moving platform, tell it to move
|
||||
auto* movingPlatformComponent = enemy->GetComponent<MovingPlatformComponent>();
|
||||
if (movingPlatformComponent) GameMessages::SendPlatformResync(enemy, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
}
|
||||
} else if (name == EndGameBufferTimer) {
|
||||
|
Reference in New Issue
Block a user