From 63a0e9a18d774812cd82e921e83136fe49b6d9e2 Mon Sep 17 00:00:00 2001 From: ricardocampos23 Date: Fri, 18 Apr 2014 01:02:11 +0100 Subject: [PATCH] Other clients can now see your ornaments as soon as they zone in --- common/Item.cpp | 2 -- zone/bot.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++--- zone/bot.h | 1 + zone/client.cpp | 4 +-- zone/command.cpp | 10 +++++- zone/inventory.cpp | 3 +- 6 files changed, 90 insertions(+), 11 deletions(-) diff --git a/common/Item.cpp b/common/Item.cpp index 5b21c4d86..aa7936a96 100644 --- a/common/Item.cpp +++ b/common/Item.cpp @@ -421,8 +421,6 @@ ItemInst* ItemInst::GetOrnamentation() const ItemInst *item; for (int i = 0; i < MAX_AUGMENT_SLOTS; ++i) { - - uint32 id = 0; if ((item = GetItem(i)) != nullptr && item->GetItem()->AugType == 524288) return item; } } diff --git a/zone/bot.cpp b/zone/bot.cpp index 1526beddc..1a4d8213d 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -4565,6 +4565,50 @@ void Bot::SetLevel(uint8 in_level, bool command) { } } +int32 Bot::GetEquipmentMaterial(uint8 material_slot) const +{ + // Moofta: Only supporting primary and secondary. next stage is heros forge. which could be any! + if // for primary and secondary we need the model, not the material + ( + material_slot == MaterialPrimary || + material_slot == MaterialSecondary + ) + { + uint8 inventorySlot = Inventory::CalcSlotFromMaterial(material_slot); + const ItemInst* inst = m_inv.GetItem(inventorySlot); + if (inst != nullptr) + { + if (inst->HasOrnamentation()) + { + const ItemInst* ornament = inst->GetOrnamentation(); + if (strlen(ornament->GetItem()->IDFile) > 2) + { + return atoi(&ornament->GetItem()->IDFile[2]); + } + } + else + { + if (strlen(inst->GetItem()->IDFile) > 2) + { + return atoi(&inst->GetItem()->IDFile[2]); + } + else //may as well try this, since were going to 0 anyways + { + return inst->GetItem()->Material; + } + } + } + } + else + { + const Item_Struct *item = database.GetItem(GetEquipment(material_slot)); + if (item!=nullptr) return item->Material; + } + + + return 0; +} + void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { if(ns) { Mob::FillSpawnStruct(ns, ForWho); @@ -4665,24 +4709,51 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { ns->spawn.colors[MaterialFeet].color = GetEquipmentColor(MaterialFeet); } } - inst = GetBotItem(SLOT_PRIMARY); if(inst) { item = inst->GetItem(); - if(item) { - if(strlen(item->IDFile) > 2) + if(item) + { + if (inst->HasOrnamentation()) + { + const ItemInst* ornament = inst->GetOrnamentation(); + if (strlen(ornament->GetItem()->IDFile) > 2) + { + ns->spawn.equipment[MaterialPrimary]= atoi(&ornament->GetItem()->IDFile[2]); + ns->spawn.colors[MaterialPrimary].color = GetEquipmentColor(MaterialPrimary); + } + } + else + { + item = inst->GetItem(); + if (strlen(item->IDFile) > 2) ns->spawn.equipment[MaterialPrimary] = atoi(&item->IDFile[2]); ns->spawn.colors[MaterialPrimary].color = GetEquipmentColor(MaterialPrimary); + } } } inst = GetBotItem(SLOT_SECONDARY); if(inst) { item = inst->GetItem(); - if(item) { - if(strlen(item->IDFile) > 2) + if(item) + { + if (inst->HasOrnamentation()) + { + const ItemInst* ornament = inst->GetOrnamentation(); + if (strlen(ornament->GetItem()->IDFile) > 2) + { + ns->spawn.equipment[MaterialSecondary]= atoi(&ornament->GetItem()->IDFile[2]); + ns->spawn.colors[MaterialSecondary].color = GetEquipmentColor(MaterialSecondary); + } + } + else + { + item = inst->GetItem(); + if (strlen(item->IDFile) > 2) ns->spawn.equipment[MaterialSecondary] = atoi(&item->IDFile[2]); ns->spawn.colors[MaterialSecondary].color = GetEquipmentColor(MaterialSecondary); + } } } } diff --git a/zone/bot.h b/zone/bot.h index 485d37377..41b591b11 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -332,6 +332,7 @@ public: void EquipBot(std::string* errorMessage); bool CheckLoreConflict(const Item_Struct* item); uint32 GetEquipmentColor(uint8 material_slot) const; + int32 GetEquipmentMaterial(uint8 material_slot) const; // Static Class Methods static void SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* errorMessage); diff --git a/zone/client.cpp b/zone/client.cpp index cb98a6b01..58b1455e2 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1909,7 +1909,7 @@ void Client::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) if ((inst = m_inv[SLOT_PRIMARY]) && inst->IsType(ItemClassCommon)) { if (inst->HasOrnamentation()) { - ItemInst* ornament = inst->GetOrnamentation(); + const ItemInst* ornament = inst->GetOrnamentation(); if (strlen(ornament->GetItem()->IDFile) > 2) { ns->spawn.equipment[MaterialPrimary]= atoi(&ornament->GetItem()->IDFile[2]); @@ -1925,7 +1925,7 @@ void Client::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) if ((inst = m_inv[SLOT_SECONDARY]) && inst->IsType(ItemClassCommon)) { if (inst->HasOrnamentation()) { - ItemInst* ornament = inst->GetOrnamentation(); + const ItemInst* ornament = inst->GetOrnamentation(); if (strlen(ornament->GetItem()->IDFile) > 2) { ns->spawn.equipment[MaterialPrimary]= atoi(&ornament->GetItem()->IDFile[2]); diff --git a/zone/command.cpp b/zone/command.cpp index 8c2192c87..0c4abd6a1 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -4707,7 +4707,15 @@ void command_iteminfo(Client *c, const Seperator *sep) const Item_Struct* item = inst->GetItem(); c->Message(0, "ID: %i Name: %s", item->ID, item->Name); c->Message(0, " Lore: %s ND: %i NS: %i Type: %i", (item->LoreFlag) ? "true":"false", item->NoDrop, item->NoRent, item->ItemClass); - c->Message(0, " IDF: %s Size: %i Weight: %i icon_id: %i Price: %i", item->IDFile, item->Size, item->Weight, item->Icon, item->Price); + if(inst->HasOrnamentation()) + { + c->Message(0, " IDF: %s Size: %i Weight: %i icon_id: %i Price: %i", inst->GetOrnamentation()->GetItem()->IDFile, item->Size, item->Weight, item->Icon, item->Price); + } + else + { + c->Message(0, " IDF: %s Size: %i Weight: %i icon_id: %i Price: %i", item->IDFile, item->Size, item->Weight, item->Icon, item->Price); + } + if (c->Admin() >= 200) c->Message(0, "MinStatus: %i", item->MinStatus); if (item->ItemClass==ItemClassBook) diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 7bb2a4905..4f1bcdb8b 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -1886,6 +1886,7 @@ void Client::DyeArmor(DyeStruct* dye){ Save(); } + int32 Client::GetEquipmentMaterial(uint8 material_slot) const { // Moofta: Only supporting primary and secondary. next stage is heros forge. which could be any! @@ -1901,7 +1902,7 @@ int32 Client::GetEquipmentMaterial(uint8 material_slot) const { if (inst->HasOrnamentation()) { - ItemInst* ornament = inst->GetOrnamentation(); + const ItemInst* ornament = inst->GetOrnamentation(); if (strlen(ornament->GetItem()->IDFile) > 2) { return atoi(&ornament->GetItem()->IDFile[2]);