mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-11 01:48:07 +00:00
Merge remote-tracking branch 'origin/main' into scripting-lua
This commit is contained in:
@@ -231,7 +231,8 @@ void Entity::Initialize()
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_RACING_STATS, nullptr));
|
||||
}
|
||||
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ITEM) > 0) {
|
||||
PetComponent* petComponent;
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ITEM) > 0 && !TryGetComponent(COMPONENT_TYPE_PET, petComponent)) {
|
||||
m_Components.insert(std::make_pair(COMPONENT_TYPE_ITEM, nullptr));
|
||||
}
|
||||
|
||||
|
@@ -60,7 +60,7 @@ void Trade::SetCoins(LWOOBJID participant, uint64_t coins)
|
||||
{
|
||||
m_CoinsA = coins;
|
||||
}
|
||||
else if (participant = m_ParticipantB)
|
||||
else if (participant == m_ParticipantB)
|
||||
{
|
||||
m_CoinsB = coins;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void Trade::SetItems(LWOOBJID participant, std::vector<TradeItem> items)
|
||||
{
|
||||
m_ItemsA = items;
|
||||
}
|
||||
else if (participant = m_ParticipantB)
|
||||
else if (participant == m_ParticipantB)
|
||||
{
|
||||
m_ItemsB = items;
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
void LoadFromXML(tinyxml2::XMLDocument* doc);
|
||||
|
||||
void UpdateXml(tinyxml2::XMLDocument* doc);
|
||||
void UpdateXml(tinyxml2::XMLDocument* doc) override;
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
|
||||
|
@@ -23,7 +23,7 @@ public:
|
||||
ControllablePhysicsComponent(Entity* entity);
|
||||
~ControllablePhysicsComponent() override;
|
||||
|
||||
void Update(float deltaTime);
|
||||
void Update(float deltaTime) override;
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
void LoadFromXML(tinyxml2::XMLDocument* doc);
|
||||
void ResetFlags();
|
||||
|
@@ -1229,19 +1229,19 @@ void InventoryComponent::AddItemSkills(const LOT lot)
|
||||
|
||||
const auto index = m_Skills.find(slot);
|
||||
|
||||
if (index != m_Skills.end())
|
||||
{
|
||||
const auto old = index->second;
|
||||
|
||||
GameMessages::SendRemoveSkill(m_Parent, old);
|
||||
}
|
||||
|
||||
const auto skill = FindSkill(lot);
|
||||
|
||||
if (skill == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (index != m_Skills.end())
|
||||
{
|
||||
const auto old = index->second;
|
||||
|
||||
GameMessages::SendRemoveSkill(m_Parent, old);
|
||||
}
|
||||
|
||||
GameMessages::SendAddSkill(m_Parent, skill, static_cast<int>(slot));
|
||||
|
||||
|
@@ -29,8 +29,8 @@ public:
|
||||
explicit MissionComponent(Entity* parent);
|
||||
~MissionComponent() override;
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
void LoadFromXml(tinyxml2::XMLDocument* doc);
|
||||
void UpdateXml(tinyxml2::XMLDocument* doc);
|
||||
void LoadFromXml(tinyxml2::XMLDocument* doc) override;
|
||||
void UpdateXml(tinyxml2::XMLDocument* doc) override;
|
||||
|
||||
/**
|
||||
* Returns all the missions for this entity, mapped by mission ID
|
||||
|
@@ -17,7 +17,7 @@ public:
|
||||
~ModuleAssemblyComponent() override;
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
void Update(float deltaTime);
|
||||
void Update(float deltaTime) override;
|
||||
|
||||
/**
|
||||
* Sets the subkey of this entity
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
MovementAIComponent(Entity* parentEntity, MovementAIInfo info);
|
||||
~MovementAIComponent() override;
|
||||
|
||||
void Update(float deltaTime);
|
||||
void Update(float deltaTime) override;
|
||||
|
||||
/**
|
||||
* Returns the basic settings that this entity uses to move around
|
||||
|
@@ -81,7 +81,7 @@ void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpd
|
||||
{
|
||||
const bool tamed = m_Owner != LWOOBJID_EMPTY;
|
||||
|
||||
outBitStream->Write1(); // Dirty?
|
||||
outBitStream->Write1(); // Always serialize as dirty for now
|
||||
|
||||
outBitStream->Write<uint32_t>(static_cast<unsigned int>(m_Status));
|
||||
outBitStream->Write<uint32_t>(static_cast<uint32_t>(tamed ? m_Ability : PetAbilityType::Invalid)); // Something with the overhead icon?
|
||||
@@ -263,29 +263,12 @@ void PetComponent::OnUse(Entity* originator)
|
||||
|
||||
auto position = originatorPosition;
|
||||
|
||||
NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector(); //m_Parent->GetRotation().GetForwardVector();
|
||||
NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector();
|
||||
forward.y = 0;
|
||||
|
||||
if (dpWorld::Instance().IsLoaded())
|
||||
{
|
||||
/*
|
||||
if (interactionDistance > 2)
|
||||
{
|
||||
interactionDistance -= 1;
|
||||
}
|
||||
*/
|
||||
|
||||
NiPoint3 attempt = petPosition + forward * interactionDistance;
|
||||
|
||||
/*
|
||||
float deg = std::atan2(petPosition.z - originatorPosition.z, petPosition.x - originatorPosition.x); //* 180 / M_PI;
|
||||
|
||||
auto position = NiPoint3(
|
||||
petPosition.x + interactionDistance * std::cos(-deg),
|
||||
petPosition.y,
|
||||
petPosition.z + interactionDistance * std::sin(-deg)
|
||||
);
|
||||
*/
|
||||
|
||||
float y = dpWorld::Instance().GetHeightAtPoint(attempt);
|
||||
|
||||
@@ -309,8 +292,6 @@ void PetComponent::OnUse(Entity* originator)
|
||||
|
||||
|
||||
auto rotation = NiQuaternion::LookAt(position, petPosition);
|
||||
|
||||
//GameMessages::SendTeleport(originator->GetObjectID(), position, rotation, originator->GetSystemAddress(), true);
|
||||
|
||||
GameMessages::SendNotifyPetTamingMinigame(
|
||||
originator->GetObjectID(),
|
||||
@@ -532,14 +513,12 @@ void PetComponent::Update(float deltaTime)
|
||||
m_Timer = 1;
|
||||
}
|
||||
|
||||
void PetComponent::TryBuild(std::vector<Brick>& bricks, bool clientFailed)
|
||||
{
|
||||
void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
||||
if (m_Tamer == LWOOBJID_EMPTY) return;
|
||||
|
||||
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
|
||||
|
||||
if (tamer == nullptr)
|
||||
{
|
||||
if (tamer == nullptr) {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
|
||||
return;
|
||||
@@ -547,19 +526,11 @@ void PetComponent::TryBuild(std::vector<Brick>& bricks, bool clientFailed)
|
||||
|
||||
const auto& cached = buildCache.find(m_Parent->GetLOT());
|
||||
|
||||
if (cached == buildCache.end())
|
||||
{
|
||||
GameMessages::SendPetTamingTryBuildResult(m_Tamer, false, 0, tamer->GetSystemAddress());
|
||||
|
||||
return;
|
||||
}
|
||||
if (cached == buildCache.end()) return;
|
||||
|
||||
auto* destroyableComponent = tamer->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (destroyableComponent == nullptr) return;
|
||||
|
||||
auto imagination = destroyableComponent->GetImagination();
|
||||
|
||||
@@ -569,59 +540,17 @@ void PetComponent::TryBuild(std::vector<Brick>& bricks, bool clientFailed)
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(tamer);
|
||||
|
||||
const auto& trueBricks = BrickDatabase::Instance()->GetBricks(cached->second.buildFile);
|
||||
|
||||
if (trueBricks.empty() || bricks.empty())
|
||||
{
|
||||
GameMessages::SendPetTamingTryBuildResult(m_Tamer, false, 0, tamer->GetSystemAddress());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto* brickIDTable = CDClientManager::Instance()->GetTable<CDBrickIDTableTable>("BrickIDTable");
|
||||
|
||||
int32_t correct = 0;
|
||||
|
||||
for (const auto& brick : bricks)
|
||||
{
|
||||
const auto brickEntries = brickIDTable->Query([brick](const CDBrickIDTable& entry)
|
||||
{
|
||||
return entry.NDObjectID == brick.designerID;
|
||||
});
|
||||
|
||||
if (brickEntries.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto designerID = brickEntries[0].LEGOBrickID;
|
||||
|
||||
for (const auto& trueBrick : trueBricks)
|
||||
{
|
||||
if (designerID == trueBrick.designerID && brick.materialID == trueBrick.materialID)
|
||||
{
|
||||
correct++;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto success = correct >= cached->second.numValidPieces;
|
||||
|
||||
GameMessages::SendPetTamingTryBuildResult(m_Tamer, success, correct, tamer->GetSystemAddress());
|
||||
|
||||
if (!success)
|
||||
{
|
||||
if (imagination < cached->second.imaginationCost)
|
||||
{
|
||||
if (clientFailed) {
|
||||
if (imagination < cached->second.imaginationCost) {
|
||||
ClientFailTamingMinigame();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
m_Timer = 0;
|
||||
}
|
||||
|
||||
if (numBricks == 0) return;
|
||||
|
||||
GameMessages::SendPetTamingTryBuildResult(m_Tamer, !clientFailed, numBricks, tamer->GetSystemAddress());
|
||||
}
|
||||
|
||||
void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
|
||||
@@ -727,7 +656,6 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
|
||||
|
||||
if (missionComponent != nullptr)
|
||||
{
|
||||
//missionComponent->ForceProgress(506, 768, 1, false);
|
||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_PET_TAMING, m_Parent->GetLOT());
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,7 @@ public:
|
||||
* @param bricks the bricks to try to complete the minigame with
|
||||
* @param clientFailed unused
|
||||
*/
|
||||
void TryBuild(std::vector<Brick>& bricks, bool clientFailed);
|
||||
void TryBuild(uint32_t numBricks, bool clientFailed);
|
||||
|
||||
/**
|
||||
* Handles a notification from the client regarding the completion of the pet minigame, adding the pet to their
|
||||
|
@@ -161,6 +161,8 @@ public:
|
||||
*/
|
||||
const std::map<LWOOBJID, LWOOBJID>& GetModels() const;
|
||||
|
||||
LWOCLONEID GetCloneId() { return clone_Id; };
|
||||
|
||||
private:
|
||||
/**
|
||||
* This
|
||||
|
@@ -380,7 +380,7 @@ void RebuildComponent::StartRebuild(Entity* user) {
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(user);
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_COMPLETED, user->GetObjectID());
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_BUILDING, user->GetObjectID());
|
||||
GameMessages::SendEnableRebuild(m_Parent, true, false, false, eFailReason::REASON_NOT_GIVEN, 0.0f, user->GetObjectID());
|
||||
|
||||
m_State = eRebuildState::REBUILD_BUILDING;
|
||||
@@ -421,7 +421,10 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
EntityManager::Instance()->SerializeEntity(user);
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_COMPLETED, user->GetObjectID());
|
||||
GameMessages::SendEnableRebuild(m_Parent, false, true, false, eFailReason::REASON_NOT_GIVEN, m_ResetTime, user->GetObjectID());
|
||||
GameMessages::SendPlayFXEffect(m_Parent, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
|
||||
GameMessages::SendEnableRebuild(m_Parent, false, false, true, eFailReason::REASON_NOT_GIVEN, m_ResetTime, user->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
|
||||
|
||||
|
||||
m_State = eRebuildState::REBUILD_COMPLETED;
|
||||
m_Timer = 0.0f;
|
||||
@@ -429,9 +432,6 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
|
||||
GameMessages::SendPlayFXEffect(m_Parent, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
|
||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
|
||||
|
||||
// Removes extra item requirements, isn't live accurate.
|
||||
// In live, all items were removed at the start of the quickbuild, then returned if it was cancelled.
|
||||
// TODO: fix?
|
||||
@@ -484,6 +484,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
character->SetPlayerFlag(flagNumber, true);
|
||||
}
|
||||
}
|
||||
GameMessages::SendPlayAnimation(user, u"rebuild-celebrate", 1.09f);
|
||||
}
|
||||
|
||||
void RebuildComponent::ResetRebuild(bool failed) {
|
||||
|
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
|
||||
void OnUse(Entity* originator);
|
||||
void OnUse(Entity* originator) override;
|
||||
|
||||
/**
|
||||
* Gets the buy scaler
|
||||
|
@@ -3238,12 +3238,12 @@ void GameMessages::HandleClientTradeRequest(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
void GameMessages::HandleClientTradeCancel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr)
|
||||
{
|
||||
Game::logger->Log("GameMessages", "Trade canceled from (%llu)\n", entity->GetObjectID());
|
||||
|
||||
auto* trade = TradingManager::Instance()->GetPlayerTrade(entity->GetObjectID());
|
||||
|
||||
if (trade == nullptr) return;
|
||||
|
||||
Game::logger->Log("GameMessages", "Trade canceled from (%llu)\n", entity->GetObjectID());
|
||||
|
||||
TradingManager::Instance()->CancelTrade(trade->GetTradeId());
|
||||
}
|
||||
|
||||
@@ -3676,7 +3676,7 @@ void GameMessages::HandlePetTamingTryBuild(RakNet::BitStream* inStream, Entity*
|
||||
return;
|
||||
}
|
||||
|
||||
petComponent->TryBuild(bricks, clientFailed);
|
||||
petComponent->TryBuild(bricks.size(), clientFailed);
|
||||
}
|
||||
|
||||
void GameMessages::HandleNotifyTamingBuildSuccess(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr)
|
||||
|
Reference in New Issue
Block a user