mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-15 16:27:14 +00:00
fix(njhub): a built counterweight goes down by itself, and the scripts hear it arrive
Live (the Frakjaw battle captures, LOT 16141): when its quick build completes the simple mover is serialized waiting at waypoint 0 (9) and about 0.1 s later travelling (2); it stops at its end without a serialization. That is the client's LWOPlatform, active once the quick build is complete (SendMessage 0x00bdc930), waiting the shortest wait and setting off (RunPlatform 0x00c86e10). L_CAVE_PRISON_CAGE and L_MONASTERY_BOSS_INSTANCE_SERVER never send it: they ask to be told of its PlatformAtLastWaypoint, and act then. So the simple mover sets off when it is built, the cave prison's button goes down when the counterweight arrives instead of when it is built, and Frakjaw is hit when it arrives (0.1 s and the row's 1 s after the build) instead of on a 0.5 s timer with a counterweight that never moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,19 +84,16 @@ void CavePrisonCage::SpawnCounterweight(Entity* self, Spawner* spawner) {
|
||||
});
|
||||
|
||||
quickBuildComponent->AddQuickBuildCompleteCallback([this, self](Entity* user) {
|
||||
auto* counterweight = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Counterweight"));
|
||||
|
||||
if (counterweight == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The counterweight is a simple mover (MovingPlatforms row 41): send it down to its end
|
||||
auto* const platform = counterweight->GetComponent<MovingPlatformComponent>();
|
||||
if (platform) platform->GotoWaypoint(1);
|
||||
|
||||
// Save the userID as Builder
|
||||
self->SetVar<LWOOBJID>(u"Builder", user->GetObjectID());
|
||||
});
|
||||
}
|
||||
|
||||
// L_CAVE_PRISON_CAGE (notifyPlatformAtLastWaypoint): the built counterweight, a simple mover (MovingPlatforms row
|
||||
// 41) that sets off by itself when its quick build completes, has gone down to the end of its path
|
||||
auto* const platform = counterweight->GetComponent<MovingPlatformComponent>();
|
||||
if (platform) {
|
||||
platform->AddPlatformAtLastWaypointCallback([this, self]() {
|
||||
// Get the button and make sure it still exists
|
||||
auto* button = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Button"));
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "NjMonastryBossInstance.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "MovingPlatformComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "dZoneManager.h"
|
||||
@@ -237,44 +238,49 @@ void NjMonastryBossInstance::HandleCounterWeightSpawned(Entity* self, Entity* co
|
||||
case eQuickBuildState::RESETTING:
|
||||
ActivityTimerStart(self, SpawnCounterWeightTimer, 0.0f, 0.0f);
|
||||
return;
|
||||
case eQuickBuildState::COMPLETED: {
|
||||
// TODO: Move the platform?
|
||||
|
||||
// The counterweight is actually a moving platform and we should listen to the last waypoint event here
|
||||
// 0.5f is a rough estimate of that path, though, and results in less needed logic
|
||||
self->AddCallbackTimer(0.5f, [this, self, counterWeight]() {
|
||||
if (counterWeight != nullptr) {
|
||||
counterWeight->Kill();
|
||||
}
|
||||
|
||||
auto* frakjaw = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(LedgeFrakjawVariable));
|
||||
if (frakjaw == nullptr) {
|
||||
GameMessages::NotifyClientObject(self->GetObjectID(), u"LedgeFrakjawDead", 0, 0, LWOOBJID_EMPTY, "").Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* skillComponent = frakjaw->GetComponent<SkillComponent>();
|
||||
if (skillComponent != nullptr) {
|
||||
skillComponent->CalculateBehavior(1635, 39097, frakjaw->GetObjectID(), true, false);
|
||||
}
|
||||
|
||||
RenderComponent::PlayAnimation(frakjaw, StunnedAnimation);
|
||||
GameMessages::PlayNDAudioEmitter(frakjaw->GetObjectID(), CounterSmashAudio).Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
// Before wave 4 we should lower frakjaw from the ledge
|
||||
if (self->GetVar<uint32_t>(WaveNumberVariable) == 3) {
|
||||
LowerFrakjaw(self, frakjaw);
|
||||
return;
|
||||
}
|
||||
|
||||
ActivityTimerStart(self, SpawnNextWaveTimer, 2.0f, 2.0f);
|
||||
});
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// L_MONASTERY_BOSS_INSTANCE_SERVER (notifyPlatformAtLastWaypoint): the built counterweight has gone down to the end
|
||||
// of its path. It is a simple mover that sets off by itself when its quick build completes: live sent it
|
||||
// travelling about 0.1 s after the build, and its trip takes the second of its MovingPlatforms row.
|
||||
auto* const platform = counterWeight->GetComponent<MovingPlatformComponent>();
|
||||
if (platform == nullptr) return;
|
||||
const auto counterWeightID = counterWeight->GetObjectID();
|
||||
platform->AddPlatformAtLastWaypointCallback([this, self, counterWeightID]() {
|
||||
// Not from inside the counterweight's own arrival
|
||||
self->AddCallbackTimer(0.0f, [this, self, counterWeightID]() {
|
||||
auto* const counterWeight = Game::entityManager->GetEntity(counterWeightID);
|
||||
if (counterWeight != nullptr) {
|
||||
counterWeight->Kill();
|
||||
}
|
||||
|
||||
auto* frakjaw = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(LedgeFrakjawVariable));
|
||||
if (frakjaw == nullptr) {
|
||||
GameMessages::NotifyClientObject(self->GetObjectID(), u"LedgeFrakjawDead", 0, 0, LWOOBJID_EMPTY, "").Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* skillComponent = frakjaw->GetComponent<SkillComponent>();
|
||||
if (skillComponent != nullptr) {
|
||||
skillComponent->CalculateBehavior(1635, 39097, frakjaw->GetObjectID(), true, false);
|
||||
}
|
||||
|
||||
RenderComponent::PlayAnimation(frakjaw, StunnedAnimation);
|
||||
GameMessages::PlayNDAudioEmitter(frakjaw->GetObjectID(), CounterSmashAudio).Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
// Before wave 4 we should lower frakjaw from the ledge
|
||||
if (self->GetVar<uint32_t>(WaveNumberVariable) == 3) {
|
||||
LowerFrakjaw(self, frakjaw);
|
||||
return;
|
||||
}
|
||||
|
||||
ActivityTimerStart(self, SpawnNextWaveTimer, 2.0f, 2.0f);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void NjMonastryBossInstance::HandleLowerFrakjawSpawned(Entity* self, Entity* lowerFrakjaw) {
|
||||
|
||||
Reference in New Issue
Block a user