From 48e34718319562583bac80dd6de21a9d82be5291 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Mon, 23 Jun 2025 00:07:52 -0700 Subject: [PATCH] fix: imaginite not being taken when starting shooting gallery (#1823) --- dGame/Entity.cpp | 5 +++-- dGame/dComponents/ShootingGalleryComponent.cpp | 4 +--- dGame/dComponents/ShootingGalleryComponent.h | 6 +++--- .../Map/njhub/boss_instance/NjMonastryBossInstance.cpp | 2 ++ dScripts/ActivityManager.cpp | 10 ++++++---- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index c51c6152..6963637a 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -673,8 +673,9 @@ void Entity::Initialize() { } // Shooting gallery component - if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SHOOTING_GALLERY) > 0) { - AddComponent(); + const auto shootingGalleryComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SHOOTING_GALLERY); + if (shootingGalleryComponentID > 0) { + AddComponent(shootingGalleryComponentID); } if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY, -1) != -1) { diff --git a/dGame/dComponents/ShootingGalleryComponent.cpp b/dGame/dComponents/ShootingGalleryComponent.cpp index 20665a01..34f3693b 100644 --- a/dGame/dComponents/ShootingGalleryComponent.cpp +++ b/dGame/dComponents/ShootingGalleryComponent.cpp @@ -2,11 +2,9 @@ #include "EntityManager.h" #include "ScriptedActivityComponent.h" -ShootingGalleryComponent::ShootingGalleryComponent(Entity* parent) : Component(parent) { +ShootingGalleryComponent::ShootingGalleryComponent(Entity* parent, int32_t activityID) : ActivityComponent(parent, activityID) { } -ShootingGalleryComponent::~ShootingGalleryComponent() = default; - void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams& params) { m_StaticParams = params; } diff --git a/dGame/dComponents/ShootingGalleryComponent.h b/dGame/dComponents/ShootingGalleryComponent.h index 9382d87e..b6c5a9ba 100644 --- a/dGame/dComponents/ShootingGalleryComponent.h +++ b/dGame/dComponents/ShootingGalleryComponent.h @@ -4,6 +4,7 @@ #include "Entity.h" #include "Component.h" #include "eReplicaComponentType.h" +#include "ActivityComponent.h" /** * Parameters for the shooting gallery that change during playtime @@ -71,12 +72,11 @@ struct StaticShootingGalleryParams { * A very ancient component that was used to guide shooting galleries, it's still kind of used but a lot of logic is * also in the related scripts. */ -class ShootingGalleryComponent final : public Component { +class ShootingGalleryComponent final : public ActivityComponent { public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SHOOTING_GALLERY; - explicit ShootingGalleryComponent(Entity* parent); - ~ShootingGalleryComponent(); + explicit ShootingGalleryComponent(Entity* parent, int32_t activityID); void Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) override; /** diff --git a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp index a74e1eac..919a2b4f 100644 --- a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp +++ b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp @@ -50,6 +50,8 @@ void NjMonastryBossInstance::OnPlayerLoaded(Entity* self, Entity* player) { // Join the player in the activity UpdatePlayer(self, player->GetObjectID()); + TakeActivityCost(self, player->GetObjectID()); + // Buff the player auto* destroyableComponent = player->GetComponent(); if (destroyableComponent != nullptr) { diff --git a/dScripts/ActivityManager.cpp b/dScripts/ActivityManager.cpp index 68ee79e4..f173be58 100644 --- a/dScripts/ActivityManager.cpp +++ b/dScripts/ActivityManager.cpp @@ -6,6 +6,7 @@ #include #include "Logger.h" #include "Loot.h" +#include "ShootingGalleryComponent.h" bool ActivityManager::IsPlayerInActivity(Entity* self, LWOOBJID playerID) { const auto* sac = self->GetComponent(); @@ -93,15 +94,16 @@ void ActivityManager::SaveScore(Entity* self, const LWOOBJID playerID, const flo } bool ActivityManager::TakeActivityCost(const Entity* self, const LWOOBJID playerID) { - auto* sac = self->GetComponent(); - if (sac == nullptr) - return false; + ActivityComponent* activityComponent = self->GetComponent(); + if (activityComponent == nullptr) { + activityComponent = self->GetComponent(); + } auto* player = Game::entityManager->GetEntity(playerID); if (player == nullptr) return false; - return sac->TakeCost(player); + return activityComponent->TakeCost(player); } uint32_t ActivityManager::CalculateActivityRating(Entity* self, const LWOOBJID playerID) {