mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-19 02:05:28 +00:00
fix(shooting gallery): a target at the end of its path respawns and despawns, without a score
SG_TARGET.lua, the targets' server script: at the last waypoint of its path (onArrived with isLastPoint, which the client's PushToLua 0x00b1a910 sets for a moving platform's Arrived as for a waypoint follower's) a target notifies the cannon, FinishedPath, and sg_cannon.lua spawns the next one as after a hit (checkSpawn). A target set to despawn there then dies silently after 1 s, a moving platform after 2 s. Here ships and subs sat at the end of their path until the game ended, and nothing came after them. The script cannot load (the targets have a script row of their own), so the cannon does it: - the respawn is split out of RegisterHit (CheckSpawn), and the die callback only registers a hit when the death is not the silent one; - a moving platform target tells through PlatformAtLastWaypoint, a waypoint follower through a new MovementAIComponent waypoint callback. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -541,6 +541,9 @@ void MovementAIComponent::SetMaxSpeed(const float value) {
|
||||
|
||||
void MovementAIComponent::RunWaypointCommands(uint32_t waypointNum) {
|
||||
m_Parent->GetScript()->OnWaypointReached(m_Parent, waypointNum);
|
||||
// A callback may add another
|
||||
const auto callbacks = m_WaypointReachedCallbacks;
|
||||
for (const auto& callback : callbacks) callback(waypointNum);
|
||||
|
||||
if (!m_Path || waypointNum >= m_Path->pathWaypoints.size()) return;
|
||||
const auto& commands = m_Path->pathWaypoints[waypointNum].commands;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "Zone.h"
|
||||
#include "dpKnockback.h"
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
@@ -188,6 +189,12 @@ public:
|
||||
*/
|
||||
bool AtFinalWaypoint() const { return m_AtFinalWaypoint; }
|
||||
|
||||
/**
|
||||
* Calls back at each waypoint of the path the entity follows, with the waypoint's number (what the Arrived game
|
||||
* message tells an object's script)
|
||||
*/
|
||||
void AddWaypointReachedCallback(const std::function<void(uint32_t)>& callback) { m_WaypointReachedCallbacks.push_back(callback); }
|
||||
|
||||
/**
|
||||
* Renders the entity stationary
|
||||
*/
|
||||
@@ -380,6 +387,8 @@ private:
|
||||
// The number of waypoints that were on the path in the call to SetPath
|
||||
uint32_t m_CurrentPathWaypointCount{ 0 };
|
||||
|
||||
std::vector<std::function<void(uint32_t)>> m_WaypointReachedCallbacks;
|
||||
|
||||
LWOOBJID m_FollowedTarget{ LWOOBJID_EMPTY };
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user