mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
Mounts v2 (#726)
* Mounts -v2 * fix stun state and make comments a bit nicer * remove extra serilization * update the char position a bit more correctly * make vehicles face thr player's direction * address feedback * fix compiling for real this time * removed uneeded check
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
#include "dLogger.h"
|
||||
#include "EntityManager.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "PossessableComponent.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "eItemType.h"
|
||||
|
||||
class Inventory;
|
||||
|
||||
@@ -71,6 +74,12 @@ Item::Item(
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_CHARACTER);
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_PERSISTENT);
|
||||
|
||||
const auto type = static_cast<eItemType>(info->itemType);
|
||||
|
||||
if (type == eItemType::ITEM_TYPE_MOUNT) {
|
||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT);
|
||||
}
|
||||
|
||||
this->id = id;
|
||||
|
||||
inventory->AddManagedItem(this);
|
||||
@@ -254,49 +263,34 @@ bool Item::Consume() {
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Item::UseNonEquip() {
|
||||
auto* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||
|
||||
const auto packageComponentId = compRegistryTable->GetByIDAndType(lot, COMPONENT_TYPE_PACKAGE);
|
||||
|
||||
auto* packCompTable = CDClientManager::Instance()->GetTable<CDPackageComponentTable>("PackageComponent");
|
||||
|
||||
auto packages = packCompTable->Query([=](const CDPackageComponent entry) {return entry.id == static_cast<uint32_t>(packageComponentId); });
|
||||
|
||||
const auto success = !packages.empty();
|
||||
|
||||
auto inventoryComponent = inventory->GetComponent();
|
||||
|
||||
auto playerEntity = inventoryComponent->GetParent();
|
||||
|
||||
if (subKey != LWOOBJID_EMPTY) {
|
||||
void Item::UseNonEquip() {
|
||||
const auto type = static_cast<eItemType>(info->itemType);
|
||||
if (type == eItemType::ITEM_TYPE_MOUNT) {
|
||||
GetInventory()->GetComponent()->HandlePossession(this);
|
||||
} else if (type == eItemType::ITEM_TYPE_PET_INVENTORY_ITEM && subKey != LWOOBJID_EMPTY) {
|
||||
const auto& databasePet = GetInventory()->GetComponent()->GetDatabasePet(subKey);
|
||||
|
||||
if (databasePet.lot != LOT_NULL) {
|
||||
GetInventory()->GetComponent()->SpawnPet(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (success && (playerEntity->GetGMLevel() >= eGameMasterLevel::GAME_MASTER_LEVEL_JUNIOR_DEVELOPER || this->GetPreconditionExpression()->Check(playerEntity))) {
|
||||
auto* entityParent = inventory->GetComponent()->GetParent();
|
||||
} else if (type == eItemType::ITEM_TYPE_PACKAGE) {
|
||||
auto* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||
const auto packageComponentId = compRegistryTable->GetByIDAndType(lot, COMPONENT_TYPE_PACKAGE);
|
||||
auto* packCompTable = CDClientManager::Instance()->GetTable<CDPackageComponentTable>("PackageComponent");
|
||||
auto packages = packCompTable->Query([=](const CDPackageComponent entry) {return entry.id == static_cast<uint32_t>(packageComponentId); });
|
||||
|
||||
for (auto& pack : packages) {
|
||||
std::unordered_map<LOT, int32_t> result{};
|
||||
|
||||
result = LootGenerator::Instance().RollLootMatrix(entityParent, pack.LootMatrixIndex);
|
||||
|
||||
if (!inventory->GetComponent()->HasSpaceForLoot(result)) {
|
||||
return false;
|
||||
const auto success = !packages.empty();
|
||||
if (success) {
|
||||
auto* entityParent = inventory->GetComponent()->GetParent();
|
||||
for (auto& pack : packages) {
|
||||
std::unordered_map<LOT, int32_t> result{};
|
||||
result = LootGenerator::Instance().RollLootMatrix(entityParent, pack.LootMatrixIndex);
|
||||
if (!inventory->GetComponent()->HasSpaceForLoot(result)) {
|
||||
}
|
||||
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
||||
}
|
||||
|
||||
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
||||
inventory->GetComponent()->RemoveItem(lot, 1);
|
||||
}
|
||||
Game::logger->Log("Item", "Used (%i)", lot);
|
||||
inventory->GetComponent()->RemoveItem(lot, 1);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void Item::Disassemble(const eInventoryType inventoryType) {
|
||||
|
@@ -193,9 +193,8 @@ public:
|
||||
|
||||
/**
|
||||
* Uses this item if its non equip, essentially an interface for the linked GM
|
||||
* @return whether the use was successful, e.g. the skill was cast
|
||||
*/
|
||||
bool UseNonEquip();
|
||||
void UseNonEquip();
|
||||
|
||||
/**
|
||||
* Disassembles the part LOTs of this item back into the inventory, if it has any
|
||||
|
Reference in New Issue
Block a user