mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-21 14:14:22 +00:00
Compare commits
3 Commits
dragon-scr
...
issue-1339
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59d8f3fa44 | ||
|
|
dd24e20165 | ||
|
|
54dc3a0b80 |
@@ -613,14 +613,13 @@ void Entity::Initialize() {
|
||||
|
||||
if (rebuildResetTime != 0.0f) {
|
||||
quickBuildComponent->SetResetTime(rebuildResetTime);
|
||||
}
|
||||
|
||||
const auto objectID = GetObjectID();
|
||||
// FV tree handler for when built so it sets the state to moving at the correct time
|
||||
if (GetLOT() == 9483) quickBuildComponent->AddQuickBuildCompleteCallback([objectID](Entity* user) {
|
||||
auto* const entity = Game::entityManager->GetEntity(objectID);
|
||||
if (entity) GameMessages::SendPlatformResync(entity, UNASSIGNED_SYSTEM_ADDRESS, false, 0, 1, 1, eMovementPlatformState::Moving, true);
|
||||
});
|
||||
// Known bug with moving platform in FV that casues it to build at the end instead of the start.
|
||||
// This extends the smash time so players can ride up the lift.
|
||||
if (m_TemplateID == 9483) {
|
||||
quickBuildComponent->SetResetTime(quickBuildComponent->GetResetTime() + 25);
|
||||
}
|
||||
}
|
||||
|
||||
const auto activityID = GetVar<int32_t>(u"activityID");
|
||||
|
||||
@@ -1617,7 +1616,7 @@ void Entity::Kill(Entity* murderer, const eKillType killType) {
|
||||
|
||||
const auto& grpNameQBShowBricks = GetVarAsString(u"grpNameQBShowBricks");
|
||||
if (!grpNameQBShowBricks.empty()) {
|
||||
for (auto* const spawner : Game::zoneManager->GetSpawnersByName(grpNameQBShowBricks)) if (spawner) spawner->Spawn();
|
||||
for (auto* const spawner : Game::zoneManager->GetSpawnersByName(grpNameQBShowBricks)) if (spawner) spawner->Spawn();
|
||||
for (auto* const spawner : Game::zoneManager->GetSpawnersInGroup(grpNameQBShowBricks)) if (spawner) spawner->Spawn();
|
||||
}
|
||||
|
||||
|
||||
@@ -723,10 +723,6 @@ void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool b
|
||||
for (const auto& pair : m_Equipped) {
|
||||
const auto item = pair.second;
|
||||
|
||||
if (bIsInitialUpdate) {
|
||||
AddItemSkills(item.lot);
|
||||
}
|
||||
|
||||
outBitStream.Write(item.id);
|
||||
outBitStream.Write(item.lot);
|
||||
|
||||
@@ -1175,14 +1171,12 @@ LOT InventoryComponent::GetConsumable() const {
|
||||
void InventoryComponent::AddItemSkills(const LOT lot) {
|
||||
const auto info = Inventory::FindItemComponent(lot);
|
||||
|
||||
const auto slot = FindBehaviorSlot(static_cast<eItemType>(info.itemType));
|
||||
const auto slot = FindBehaviorSlot(info.equipLocation);
|
||||
|
||||
if (slot == BehaviorSlot::Invalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto index = m_Skills.find(slot);
|
||||
|
||||
const auto skill = FindSkill(lot);
|
||||
|
||||
SetSkill(slot, skill);
|
||||
@@ -1210,7 +1204,7 @@ void InventoryComponent::FixInvisibleItems() {
|
||||
void InventoryComponent::RemoveItemSkills(const LOT lot) {
|
||||
const auto info = Inventory::FindItemComponent(lot);
|
||||
|
||||
const auto slot = FindBehaviorSlot(static_cast<eItemType>(info.itemType));
|
||||
const auto slot = FindBehaviorSlot(info.equipLocation);
|
||||
|
||||
if (slot == BehaviorSlot::Invalid) {
|
||||
return;
|
||||
@@ -1222,15 +1216,31 @@ void InventoryComponent::RemoveItemSkills(const LOT lot) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto old = index->second;
|
||||
const auto skillId = FindSkill(lot);
|
||||
|
||||
GameMessages::SendRemoveSkill(m_Parent, old);
|
||||
// Only act on this slot if it still holds the skill from this item.
|
||||
// Another item may have overwritten the slot since this one was equipped.
|
||||
if (index->second != skillId) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_Skills.erase(slot);
|
||||
|
||||
// Find another slot that still holds this skillID (if any).
|
||||
const auto surviving = std::ranges::find_if(m_Skills, [skillId](const auto& pair) {
|
||||
return pair.second == skillId;
|
||||
});
|
||||
|
||||
// The client stores one acquiredSkillsInfo entry per skillID, tagged with the slotID
|
||||
// it was originally added with. Always send RemoveSkill to clear that entry, then
|
||||
// re-add with the surviving slot so the client shows it in the correct place.
|
||||
GameMessages::SendRemoveSkill(m_Parent, skillId);
|
||||
if (surviving != m_Skills.end()) {
|
||||
GameMessages::SendAddSkill(m_Parent, skillId, surviving->first);
|
||||
}
|
||||
|
||||
if (slot == BehaviorSlot::Primary) {
|
||||
m_Skills.insert_or_assign(BehaviorSlot::Primary, 1);
|
||||
|
||||
GameMessages::SendAddSkill(m_Parent, 1, BehaviorSlot::Primary);
|
||||
}
|
||||
}
|
||||
@@ -1322,23 +1332,17 @@ void InventoryComponent::RemoveDatabasePet(LWOOBJID id) {
|
||||
m_Pets.erase(id);
|
||||
}
|
||||
|
||||
BehaviorSlot InventoryComponent::FindBehaviorSlot(const eItemType type) {
|
||||
switch (type) {
|
||||
case eItemType::HAT:
|
||||
return BehaviorSlot::Head;
|
||||
case eItemType::NECK:
|
||||
return BehaviorSlot::Neck;
|
||||
case eItemType::LEFT_HAND:
|
||||
return BehaviorSlot::Offhand;
|
||||
case eItemType::RIGHT_HAND:
|
||||
return BehaviorSlot::Primary;
|
||||
case eItemType::CONSUMABLE:
|
||||
return BehaviorSlot::Consumable;
|
||||
default:
|
||||
return BehaviorSlot::Invalid;
|
||||
}
|
||||
BehaviorSlot InventoryComponent::FindBehaviorSlot(const std::string& equipLocation) {
|
||||
// Skill slot is determined by equipLocation, not itemType.
|
||||
// Mapping confirmed against live captures and client data (issue #1339).
|
||||
if (equipLocation == "special_r") return BehaviorSlot::Primary;
|
||||
if (equipLocation == "hair") return BehaviorSlot::Head;
|
||||
if (equipLocation == "special_l") return BehaviorSlot::Offhand;
|
||||
if (equipLocation == "clavicle") return BehaviorSlot::Neck;
|
||||
return BehaviorSlot::Invalid;
|
||||
}
|
||||
|
||||
|
||||
bool InventoryComponent::IsTransferInventory(eInventoryType type, bool includeVault) {
|
||||
return type == VENDOR_BUYBACK || (includeVault && (type == VAULT_ITEMS || type == VAULT_MODELS)) || type == TEMP_ITEMS || type == TEMP_MODELS || type == MODELS_IN_BBB;
|
||||
}
|
||||
@@ -1679,10 +1683,28 @@ bool InventoryComponent::SetSkill(BehaviorSlot slot, uint32_t skillId) {
|
||||
const auto index = m_Skills.find(slot);
|
||||
if (index != m_Skills.end()) {
|
||||
const auto old = index->second;
|
||||
GameMessages::SendRemoveSkill(m_Parent, old);
|
||||
// Only remove the old skill from the client if no other slot still holds it.
|
||||
// The client's acquiredSkillsInfo is keyed by skillID (one entry per skill),
|
||||
// so RemoveSkill clears it globally — sending it while another slot still uses
|
||||
// the same skillID would break that slot on the client.
|
||||
const auto usedElsewhere = std::ranges::any_of(m_Skills, [&](const auto& pair) {
|
||||
return pair.first != slot && pair.second == old;
|
||||
});
|
||||
if (!usedElsewhere) {
|
||||
GameMessages::SendRemoveSkill(m_Parent, old);
|
||||
}
|
||||
}
|
||||
|
||||
// Only send AddSkill if the client doesn't already know about this skillID.
|
||||
// The client early-exits on duplicate AddSkill (same skillID already in
|
||||
// acquiredSkillsInfo) without updating the slot — so only send when it's new.
|
||||
const auto alreadyKnown = std::ranges::any_of(m_Skills, [&](const auto& pair) {
|
||||
return pair.first != slot && pair.second == skillId;
|
||||
});
|
||||
if (!alreadyKnown) {
|
||||
GameMessages::SendAddSkill(m_Parent, skillId, slot);
|
||||
}
|
||||
|
||||
GameMessages::SendAddSkill(m_Parent, skillId, slot);
|
||||
m_Skills.insert_or_assign(slot, skillId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -367,11 +367,10 @@ public:
|
||||
void RemoveDatabasePet(LWOOBJID id);
|
||||
|
||||
/**
|
||||
* Returns the current behavior slot active for the passed item type
|
||||
* @param type the item type to find the behavior slot for
|
||||
* @return the current behavior slot active for the passed item type
|
||||
* Returns the behavior slot for the given equipLocation string.
|
||||
* This is the authoritative mapping used for skill slot assignment.
|
||||
*/
|
||||
static BehaviorSlot FindBehaviorSlot(eItemType type);
|
||||
static BehaviorSlot FindBehaviorSlot(const std::string& equipLocation);
|
||||
|
||||
/**
|
||||
* Checks if the inventory type is a temp inventory
|
||||
@@ -403,6 +402,8 @@ public:
|
||||
|
||||
std::map<BehaviorSlot, uint32_t> GetSkills() { return m_Skills; };
|
||||
|
||||
void ClearSkills() { m_Skills.clear(); };
|
||||
|
||||
bool SetSkill(int slot, uint32_t skillId);
|
||||
bool SetSkill(BehaviorSlot slot, uint32_t skillId);
|
||||
|
||||
|
||||
@@ -159,6 +159,10 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System
|
||||
|
||||
InventoryComponent* inv = entity->GetComponent<InventoryComponent>();
|
||||
if (inv) {
|
||||
// Clear server-side skill state so AddItemSkills sends fresh AddSkill
|
||||
// packets to the now-ready client. Skills sent during entity construction
|
||||
// (Serialize) arrive before LWOSkillComponent is initialized and are dropped.
|
||||
inv->ClearSkills();
|
||||
auto items = inv->GetEquippedItems();
|
||||
for (auto pair : items) {
|
||||
const auto item = pair.second;
|
||||
|
||||
@@ -366,19 +366,18 @@ void GameMessages::SendResetMissions(Entity* entity, const SystemAddress& sysAdd
|
||||
|
||||
void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAddr, bool bStopAtDesiredWaypoint,
|
||||
int iIndex, int iDesiredWaypointIndex, int nextIndex,
|
||||
eMovementPlatformState movementState, bool special) {
|
||||
eMovementPlatformState movementState) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
const auto objID = entity->GetObjectID();
|
||||
const auto lot = entity->GetLOT();
|
||||
|
||||
if (lot == 12341 || lot == 5027 || lot == 5028 || lot == 14335 || lot == 14447 || lot == 14449 || lot == 11306 || lot == 11308 || lot == 9483) {
|
||||
if (lot == 12341 || lot == 5027 || lot == 5028 || lot == 14335 || lot == 14447 || lot == 14449 || lot == 11306 || lot == 11308) {
|
||||
iDesiredWaypointIndex = (lot == 11306 || lot == 11308) ? 1 : 0;
|
||||
iIndex = lot == 9483 ? 1 : 0;
|
||||
nextIndex = lot == 9483 && !special ? 1 : 0;
|
||||
iIndex = 0;
|
||||
nextIndex = 0;
|
||||
bStopAtDesiredWaypoint = true;
|
||||
movementState = lot == 9483 && !special ? eMovementPlatformState::Stopped : eMovementPlatformState::Stationary;
|
||||
movementState = eMovementPlatformState::Stationary;
|
||||
}
|
||||
|
||||
bitStream.Write(entity->GetObjectID());
|
||||
@@ -6485,8 +6484,8 @@ namespace GameMessages {
|
||||
}
|
||||
|
||||
void TeamPickupItem::Serialize(RakNet::BitStream& stream) const {
|
||||
stream.Write(lootID);
|
||||
stream.Write(lootOwnerID);
|
||||
stream.Write(lootID);
|
||||
stream.Write(lootOwnerID);
|
||||
}
|
||||
|
||||
void ToggleGMInvis::Serialize(RakNet::BitStream& stream) const {
|
||||
|
||||
@@ -103,11 +103,9 @@ namespace GameMessages {
|
||||
void SendPlayNDAudioEmitter(Entity* entity, const SystemAddress& sysAddr, std::string audioGUID);
|
||||
|
||||
void SendStartPathing(Entity* entity);
|
||||
|
||||
// special is for the FV tree platform, feature is complete if we just do that so meh
|
||||
void SendPlatformResync(Entity* entity, const SystemAddress& sysAddr, bool bStopAtDesiredWaypoint = false,
|
||||
int iIndex = 0, int iDesiredWaypointIndex = 1, int nextIndex = 1,
|
||||
eMovementPlatformState movementState = eMovementPlatformState::Moving, bool special = false);
|
||||
eMovementPlatformState movementState = eMovementPlatformState::Moving);
|
||||
|
||||
void SendResetMissions(Entity* entity, const SystemAddress& sysAddr, const int32_t missionid = -1);
|
||||
void SendRestoreToPostLoadStats(Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
@@ -135,7 +135,6 @@
|
||||
#include "FvMaelstromCavalry.h"
|
||||
#include "FvHorsemenTrigger.h"
|
||||
#include "FvFlyingCreviceDragon.h"
|
||||
#include "FvDragonInstanceServer.h"
|
||||
#include "FvMaelstromDragon.h"
|
||||
#include "FvDragonSmashingGolemQb.h"
|
||||
#include "TreasureChestDragonServer.h"
|
||||
@@ -491,7 +490,6 @@ namespace {
|
||||
{"scripts\\ai\\FV\\L_ACT_NINJA_TURRET_1.lua", []() {return new ActNinjaTurret();}},
|
||||
{"scripts\\02_server\\Map\\FV\\L_FV_HORSEMEN_TRIGGER.lua", []() {return new FvHorsemenTrigger();}},
|
||||
{"scripts\\ai\\FV\\L_FV_FLYING_CREVICE_DRAGON.lua", []() {return new FvFlyingCreviceDragon();}},
|
||||
{"scripts\\ai\\FV\\Dragon_Instance\\L_FV_DRAGON_INSTANCE_SERVER.lua", []() {return new FvDragonInstanceServer();}},
|
||||
{"scripts\\02_server\\Enemy\\FV\\L_FV_MAELSTROM_DRAGON.lua", []() {return new FvMaelstromDragon();}},
|
||||
{"scripts\\ai\\FV\\L_FV_DRAGON_SMASHING_GOLEM_QB.lua", []() {return new FvDragonSmashingGolemQb();}},
|
||||
{"scripts\\02_server\\Enemy\\General\\L_TREASURE_CHEST_DRAGON_SERVER.lua", []() {return new TreasureChestDragonServer();}},
|
||||
|
||||
@@ -18,13 +18,7 @@ set(DSCRIPTS_SOURCES_AI_FV
|
||||
"FvMaelstromGeyser.cpp"
|
||||
"TriggerGas.cpp")
|
||||
|
||||
add_subdirectory(Dragon_Instance)
|
||||
|
||||
foreach(file ${DSCRIPTS_SOURCES_AI_FV_DRAGON_INSTANCE})
|
||||
set(DSCRIPTS_SOURCES_AI_FV ${DSCRIPTS_SOURCES_AI_FV} "Dragon_Instance/${file}")
|
||||
endforeach()
|
||||
|
||||
add_library(dScriptsAiFV OBJECT ${DSCRIPTS_SOURCES_AI_FV})
|
||||
target_include_directories(dScriptsAiFV PUBLIC "." "Dragon_Instance")
|
||||
target_include_directories(dScriptsAiFV PUBLIC ".")
|
||||
target_precompile_headers(dScriptsAiFV REUSE_FROM dScriptsBase)
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
set(DSCRIPTS_SOURCES_AI_FV_DRAGON_INSTANCE
|
||||
"FvDragonInstanceServer.cpp"
|
||||
PARENT_SCOPE)
|
||||
@@ -1,13 +0,0 @@
|
||||
#include "FvDragonInstanceServer.h"
|
||||
|
||||
#include "Entity.h"
|
||||
#include "DestroyableComponent.h"
|
||||
|
||||
void FvDragonInstanceServer::OnPlayerLoaded(Entity* self, Entity* player) {
|
||||
auto* const destComp = player->GetComponent<DestroyableComponent>();
|
||||
if (destComp) {
|
||||
destComp->SetHealth(destComp->GetMaxHealth());
|
||||
destComp->SetArmor(destComp->GetMaxArmor());
|
||||
destComp->SetImagination(destComp->GetMaxImagination());
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class FvDragonInstanceServer : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnPlayerLoaded(Entity* self, Entity* player) override;
|
||||
};
|
||||
Reference in New Issue
Block a user