mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-29 11:42:05 +00:00
Add FlagComponent and msg handlers
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "CavePrisonCage.h"
|
||||
|
||||
#include "EntityManager.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Character.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "RenderComponent.h"
|
||||
|
||||
@@ -161,10 +161,14 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the flag on the builder character
|
||||
const auto flagNum = 2020 + self->GetVarAs<int32_t>(u"myNumber");
|
||||
|
||||
// Set the flag on the builder character
|
||||
builder->GetCharacter()->SetPlayerFlag(flagNum, true);
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = builder->GetObjectID();
|
||||
setFlag.iFlagId = flagNum;
|
||||
setFlag.bFlag = true;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
|
||||
// Setup a timer named 'VillagerEscape' to be triggered in 5 seconds
|
||||
self->AddTimer("VillagerEscape", 5.0f);
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
#include "NjDragonEmblemChestServer.h"
|
||||
#include "Character.h"
|
||||
#include "EntityInfo.h"
|
||||
#include "Loot.h"
|
||||
#include "Entity.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "ePlayerFlag.h"
|
||||
|
||||
void NjDragonEmblemChestServer::OnUse(Entity* self, Entity* user) {
|
||||
auto* character = user->GetCharacter();
|
||||
if (character != nullptr) {
|
||||
character->SetPlayerFlag(ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST, false);
|
||||
}
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = user->GetObjectID();
|
||||
setFlag.iFlagId = ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST;
|
||||
setFlag.bFlag = false;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
|
||||
auto* destroyable = self->GetComponent<DestroyableComponent>();
|
||||
if (destroyable != nullptr) {
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
#include "NjGarmadonCelebration.h"
|
||||
#include "Character.h"
|
||||
|
||||
#include "GameMessages.h"
|
||||
#include "ePlayerFlag.h"
|
||||
|
||||
void NjGarmadonCelebration::OnCollisionPhantom(Entity* self, Entity* target) {
|
||||
auto* character = target->GetCharacter();
|
||||
GameMessages::GetFlag getFlag{};
|
||||
getFlag.target = target->GetObjectID();
|
||||
getFlag.iFlagId = ePlayerFlag::NJ_GARMADON_CINEMATIC_SEEN;
|
||||
|
||||
if (character == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!character->GetPlayerFlag(ePlayerFlag::NJ_GARMADON_CINEMATIC_SEEN)) {
|
||||
character->SetPlayerFlag(ePlayerFlag::NJ_GARMADON_CINEMATIC_SEEN, true);
|
||||
if (SEND_ENTITY_MSG(getFlag) && !getFlag.bFlag) {
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = target->GetObjectID();
|
||||
setFlag.iFlagId = ePlayerFlag::NJ_GARMADON_CINEMATIC_SEEN;
|
||||
setFlag.bFlag = true;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
|
||||
GameMessages::SendStartCelebrationEffect(target, target->GetSystemAddress(), GarmadonCelebrationID);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "NjNPCMissionSpinjitzuServer.h"
|
||||
#include "Character.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
#include "eMissionState.h"
|
||||
|
||||
void NjNPCMissionSpinjitzuServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
|
||||
@@ -12,13 +11,11 @@ void NjNPCMissionSpinjitzuServer::OnMissionDialogueOK(Entity* self, Entity* targ
|
||||
|
||||
// Wait for an animation to complete and flag that the player has learned spinjitzu
|
||||
self->AddCallbackTimer(5.0f, [targetID, element]() {
|
||||
auto* target = Game::entityManager->GetEntity(targetID);
|
||||
if (target != nullptr) {
|
||||
auto* character = target->GetCharacter();
|
||||
if (character != nullptr) {
|
||||
character->SetPlayerFlag(ElementFlags.at(element), true);
|
||||
}
|
||||
}
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = targetID;
|
||||
setFlag.iFlagId = ElementFlags.at(element);
|
||||
setFlag.bFlag = true;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "NjWuNPC.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "Character.h"
|
||||
#include "EntityManager.h"
|
||||
#include "GameMessages.h"
|
||||
#include "eMissionState.h"
|
||||
@@ -10,10 +9,8 @@ void NjWuNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, e
|
||||
|
||||
// The Dragon statue daily mission
|
||||
if (missionID == m_MainDragonMissionID) {
|
||||
auto* character = target->GetCharacter();
|
||||
auto* missionComponent = target->GetComponent<MissionComponent>();
|
||||
if (character == nullptr || missionComponent == nullptr)
|
||||
return;
|
||||
if (!missionComponent) return;
|
||||
|
||||
switch (missionState) {
|
||||
case eMissionState::AVAILABLE:
|
||||
@@ -24,8 +21,11 @@ void NjWuNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, e
|
||||
missionComponent->RemoveMission(subMissionID);
|
||||
missionComponent->AcceptMission(subMissionID);
|
||||
}
|
||||
|
||||
character->SetPlayerFlag(ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST, false);
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = target->GetObjectID();
|
||||
setFlag.iFlagId = ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST;
|
||||
setFlag.bFlag = false;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
|
||||
// Hide the chest
|
||||
for (auto* chest : Game::entityManager->GetEntitiesInGroup(m_DragonChestGroup)) {
|
||||
@@ -38,7 +38,11 @@ void NjWuNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, e
|
||||
case eMissionState::READY_TO_COMPLETE:
|
||||
case eMissionState::COMPLETE_READY_TO_COMPLETE:
|
||||
{
|
||||
character->SetPlayerFlag(ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST, true);
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = target->GetObjectID();
|
||||
setFlag.iFlagId = ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST;
|
||||
setFlag.bFlag = true;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
|
||||
// Show the chest
|
||||
for (auto* chest : Game::entityManager->GetEntitiesInGroup(m_DragonChestGroup)) {
|
||||
|
||||
Reference in New Issue
Block a user