mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-09-05 23:08:31 +00:00
Add FlagComponent and msg handlers
This commit is contained in:
@@ -1,15 +1,26 @@
|
||||
#include "Binoculars.h"
|
||||
#include "Character.h"
|
||||
|
||||
#include "GameMessages.h"
|
||||
#include "Game.h"
|
||||
#include "dServer.h"
|
||||
#include "dZoneManager.h"
|
||||
|
||||
void Binoculars::OnUse(Entity* self, Entity* user) {
|
||||
const auto number = self->GetVarAsString(u"number");
|
||||
|
||||
int32_t flag = std::stoi(std::to_string(Game::server->GetZoneID()).substr(0, 2) + number);
|
||||
if (user->GetCharacter()->GetPlayerFlag(flag) == false) {
|
||||
user->GetCharacter()->SetPlayerFlag(flag, true);
|
||||
int32_t flag = std::stoi(std::to_string(Game::zoneManager->GetZoneID().GetMapID()).substr(0, 2) + number);
|
||||
|
||||
GameMessages::GetFlag getFlag{};
|
||||
getFlag.target = user->GetObjectID();
|
||||
getFlag.iFlagId = flag;
|
||||
SEND_ENTITY_MSG(getFlag);
|
||||
|
||||
if (!getFlag.bFlag) {
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = user->GetObjectID();
|
||||
setFlag.iFlagId = flag;
|
||||
setFlag.bFlag = true;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
|
||||
GameMessages::SendFireEventClientSide(self->GetObjectID(), user->GetSystemAddress(), u"achieve", LWOOBJID_EMPTY, 0, -1, LWOOBJID_EMPTY);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#include "NjRailActivatorsServer.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "Character.h"
|
||||
|
||||
void NjRailActivatorsServer::OnUse(Entity* self, Entity* user) {
|
||||
const auto flag = self->GetVar<int32_t>(u"RailFlagNum");
|
||||
@@ -8,9 +7,10 @@ void NjRailActivatorsServer::OnUse(Entity* self, Entity* user) {
|
||||
|
||||
// Only allow use if this is not a quick build or the quick build is built
|
||||
if (quickBuildComponent == nullptr || quickBuildComponent->GetState() == eQuickBuildState::COMPLETED) {
|
||||
auto* character = user->GetCharacter();
|
||||
if (character != nullptr) {
|
||||
character->SetPlayerFlag(flag, true);
|
||||
}
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = user->GetObjectID();
|
||||
setFlag.iFlagId = flag;
|
||||
setFlag.bFlag = true;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,9 @@
|
||||
#include "dZoneManager.h"
|
||||
#include "PetDigServer.h"
|
||||
|
||||
#include "dZoneManager.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "Character.h"
|
||||
#include "PetComponent.h"
|
||||
#include "User.h"
|
||||
#include "eMissionState.h"
|
||||
|
||||
std::vector<LWOOBJID> PetDigServer::treasures{};
|
||||
@@ -110,7 +109,6 @@ void PetDigServer::HandleXBuildDig(const Entity* self, Entity* owner, Entity* pe
|
||||
if (!playerEntity || !playerEntity->GetCharacter())
|
||||
return;
|
||||
|
||||
auto* player = playerEntity->GetCharacter();
|
||||
const auto groupID = self->GetVar<std::u16string>(u"groupID");
|
||||
int32_t playerFlag = 0;
|
||||
|
||||
@@ -123,15 +121,22 @@ void PetDigServer::HandleXBuildDig(const Entity* self, Entity* owner, Entity* pe
|
||||
playerFlag = 63;
|
||||
}
|
||||
|
||||
GameMessages::GetFlag getFlag{};
|
||||
getFlag.target = playerEntity->GetObjectID();
|
||||
getFlag.iFlagId = playerFlag;
|
||||
SEND_ENTITY_MSG(getFlag);
|
||||
// If the player doesn't have the flag yet
|
||||
if (playerFlag != 0 && !player->GetPlayerFlag(playerFlag)) {
|
||||
if (playerFlag != 0 && SEND_ENTITY_MSG(getFlag) && !getFlag.bFlag) {
|
||||
auto* petComponent = pet->GetComponent<PetComponent>();
|
||||
if (petComponent != nullptr) {
|
||||
// TODO: Pet state = 9 ??
|
||||
}
|
||||
|
||||
// Shows the flag object to the player
|
||||
player->SetPlayerFlag(playerFlag, true);
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = playerEntity->GetObjectID();
|
||||
setFlag.iFlagId = playerFlag;
|
||||
setFlag.bFlag = true;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
}
|
||||
|
||||
auto* xObject = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"X"));
|
||||
@@ -173,12 +178,17 @@ void PetDigServer::ProgressPetDigMissions(const Entity* owner, const Entity* che
|
||||
if (excavatorMissionState == eMissionState::ACTIVE) {
|
||||
if (chest->HasVar(u"PetDig")) {
|
||||
int32_t playerFlag = 1260 + chest->GetVarAs<int32_t>(u"PetDig");
|
||||
Character* player = owner->GetCharacter();
|
||||
|
||||
GameMessages::GetFlag getFlag{};
|
||||
getFlag.target = owner->GetObjectID();
|
||||
getFlag.iFlagId = playerFlag;
|
||||
// check if player flag is set
|
||||
if (!player->GetPlayerFlag(playerFlag)) {
|
||||
if (SEND_ENTITY_MSG(getFlag) && !getFlag.bFlag) {
|
||||
missionComponent->ForceProgress(505, 767, 1);
|
||||
player->SetPlayerFlag(playerFlag, 1);
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = owner->GetObjectID();
|
||||
setFlag.iFlagId = playerFlag;
|
||||
setFlag.bFlag = true;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "StoryBoxInteractServer.h"
|
||||
#include "Character.h"
|
||||
#include "GameMessages.h"
|
||||
#include "dServer.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "Amf3.h"
|
||||
#include "Entity.h"
|
||||
|
||||
@@ -36,11 +36,19 @@ void StoryBoxInteractServer::OnUse(Entity* self, Entity* user) {
|
||||
if(!storyValue) return;
|
||||
int32_t boxFlag = self->GetVar<int32_t>(u"altFlagID");
|
||||
if (boxFlag <= 0) {
|
||||
boxFlag = (10000 + Game::server->GetZoneID() + storyValue.value());
|
||||
boxFlag = (10000 + Game::zoneManager->GetZoneID().GetMapID() + storyValue.value());
|
||||
}
|
||||
|
||||
if (user->GetCharacter()->GetPlayerFlag(boxFlag) == false) {
|
||||
user->GetCharacter()->SetPlayerFlag(boxFlag, true);
|
||||
GameMessages::GetFlag getFlag{};
|
||||
getFlag.target = user->GetObjectID();
|
||||
getFlag.iFlagId = boxFlag;
|
||||
if (SEND_ENTITY_MSG(getFlag) && !getFlag.bFlag) {
|
||||
GameMessages::SetFlag setFlag{};
|
||||
setFlag.target = user->GetObjectID();
|
||||
setFlag.iFlagId = boxFlag;
|
||||
setFlag.bFlag = true;
|
||||
SEND_ENTITY_MSG(setFlag);
|
||||
|
||||
GameMessages::SendFireEventClientSide(self->GetObjectID(), user->GetSystemAddress(), u"achieve", LWOOBJID_EMPTY, 0, -1, LWOOBJID_EMPTY);
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,14 @@
|
||||
#include "TokenConsoleServer.h"
|
||||
|
||||
#include "InventoryComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Character.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eTerminateType.h"
|
||||
#include "ePlayerFlag.h"
|
||||
|
||||
//2021-05-03 - max - added script, omitted some parts related to inheritance in lua which we don't need
|
||||
|
||||
void TokenConsoleServer::OnUse(Entity* self, Entity* user) {
|
||||
auto* inv = static_cast<InventoryComponent*>(user->GetComponent(eReplicaComponentType::INVENTORY));
|
||||
auto* inv = user->GetComponent<InventoryComponent>();
|
||||
|
||||
//make sure the user has the required amount of infected bricks
|
||||
if (inv && inv->GetLotCount(6194) >= bricksToTake) {
|
||||
@@ -22,17 +21,18 @@ void TokenConsoleServer::OnUse(Entity* self, Entity* user) {
|
||||
}
|
||||
|
||||
//figure out which faction the player belongs to:
|
||||
auto character = user->GetCharacter();
|
||||
if (!character) return;
|
||||
// At this point the player has to be in a faction.
|
||||
|
||||
GameMessages::GetFlag getFlag{};
|
||||
getFlag.target = user->GetObjectID();
|
||||
LOT tokenLOT = 0;
|
||||
if (character->GetPlayerFlag(ePlayerFlag::VENTURE_FACTION)) //venture
|
||||
if (getFlag.iFlagId = ePlayerFlag::VENTURE_FACTION, SEND_ENTITY_MSG(getFlag) && getFlag.bFlag) //venture
|
||||
tokenLOT = 8321;
|
||||
else if (character->GetPlayerFlag(ePlayerFlag::ASSEMBLY_FACTION)) //assembly
|
||||
else if (getFlag.iFlagId = ePlayerFlag::ASSEMBLY_FACTION, SEND_ENTITY_MSG(getFlag) && getFlag.bFlag) //assembly
|
||||
tokenLOT = 8318;
|
||||
else if (character->GetPlayerFlag(ePlayerFlag::PARADOX_FACTION)) //paradox
|
||||
else if (getFlag.iFlagId = ePlayerFlag::PARADOX_FACTION, SEND_ENTITY_MSG(getFlag) && getFlag.bFlag) //paradox
|
||||
tokenLOT = 8320;
|
||||
else if (character->GetPlayerFlag(ePlayerFlag::SENTINEL_FACTION)) //sentinel
|
||||
else if (getFlag.iFlagId = ePlayerFlag::SENTINEL_FACTION, SEND_ENTITY_MSG(getFlag) && getFlag.bFlag) //sentinel
|
||||
tokenLOT = 8319;
|
||||
inv->AddItem(tokenLOT, tokensToGive, eLootSourceType::NONE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user