[Feature] Make ornamentations work with any augment type (#3281)

* [Feature] Make ornamentations work with any augment type

# Notes
- On Live there are augments that are not type 20/21 and are ornamentations.
- We also only allow a singular augment type to be ornamentation augment types, this will allow you to use any augment type as an ornamentation if it has a proper Hero's Forge model or a non-IT63/non-IT64 idfile.

* Update ruletypes.h

* Update client_packet.cpp

* Update item_instance.cpp

* Cleanup.
This commit is contained in:
Alex King 2023-04-16 10:26:19 -04:00 committed by GitHub
parent 93db35658a
commit fa3a5c7a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 144 additions and 109 deletions

View File

@ -17,6 +17,7 @@
*/ */
#include "inventory_profile.h" #include "inventory_profile.h"
#include "../common/data_verification.h"
//#include "classes.h" //#include "classes.h"
//#include "global_define.h" //#include "global_define.h"
//#include "item_instance.h" //#include "item_instance.h"
@ -527,78 +528,99 @@ EQ::ItemInstance* EQ::ItemInstance::GetAugment(uint8 augment_index) const
return nullptr; return nullptr;
} }
EQ::ItemInstance* EQ::ItemInstance::GetOrnamentationAug(int32 ornamentationAugtype) const bool EQ::ItemInstance::IsOrnamentationAugment(EQ::ItemInstance* augment) const
{ {
if (!m_item || !m_item->IsClassCommon()) { return nullptr; } if (!m_item || !m_item->IsClassCommon() || !augment) {
if (ornamentationAugtype == 0) { return nullptr; } return false;
for (int i = invaug::SOCKET_BEGIN; i <= invaug::SOCKET_END; i++)
{
if (GetAugment(i) && m_item->AugSlotType[i] == ornamentationAugtype)
{
const char *item_IDFile = GetAugment(i)->GetItem()->IDFile;
if (
(strncmp(item_IDFile, "IT64", strlen(item_IDFile)) == 0
|| strncmp(item_IDFile, "IT63", strlen(item_IDFile)) == 0)
&& GetAugment(i)->GetItem()->HerosForgeModel == 0
)
{
continue;
} }
return GetAugment(i);
const auto augment_item = augment->GetItem();
if (!augment_item) {
return false;
}
const std::string& idfile = augment_item->IDFile;
if (
EQ::ValueWithin(
augment->GetAugmentType(),
OrnamentationAugmentTypes::StandardOrnamentation,
OrnamentationAugmentTypes::SpecialOrnamentation
) ||
(
idfile != "IT63" &&
idfile != "IT64"
) ||
augment_item->HerosForgeModel
) {
return true;
}
return false;
}
EQ::ItemInstance* EQ::ItemInstance::GetOrnamentationAugment() const
{
if (!m_item || !m_item->IsClassCommon()) {
return nullptr;
}
for (int i = invaug::SOCKET_BEGIN; i <= invaug::SOCKET_END; i++) {
const auto augment = GetAugment(i);
if (augment && IsOrnamentationAugment(augment)) {
return augment;
} }
} }
return nullptr; return nullptr;
} }
uint32 EQ::ItemInstance::GetOrnamentHeroModel(int32 material_slot) const { uint32 EQ::ItemInstance::GetOrnamentHeroModel(int32 material_slot) const
{
// Not a Hero Forge item. // Not a Hero Forge item.
if (m_ornament_hero_model == 0 || material_slot < 0) if (m_ornament_hero_model == 0 || material_slot < 0) {
return 0; return 0;
}
// Item is using an explicit Hero Forge ID // Item is using an explicit Hero Forge ID
if (m_ornament_hero_model >= 1000) if (m_ornament_hero_model >= 1000) {
return m_ornament_hero_model; return m_ornament_hero_model;
}
// Item is using a shorthand ID // Item is using a shorthand ID
return (m_ornament_hero_model * 100) + material_slot; return (m_ornament_hero_model * 100) + material_slot;
} }
bool EQ::ItemInstance::UpdateOrnamentationInfo() { bool EQ::ItemInstance::UpdateOrnamentationInfo()
if (!m_item || !m_item->IsClassCommon()) {
if (!m_item || !m_item->IsClassCommon()) {
return false; return false;
bool ornamentSet = false;
int32 ornamentationAugtype = RuleI(Character, OrnamentationAugmentType);
if (GetOrnamentationAug(ornamentationAugtype))
{
const ItemData* ornamentItem;
ornamentItem = GetOrnamentationAug(ornamentationAugtype)->GetItem();
if (ornamentItem != nullptr)
{
SetOrnamentIcon(ornamentItem->Icon);
SetOrnamentHeroModel(ornamentItem->HerosForgeModel);
if (strlen(ornamentItem->IDFile) > 2)
{
SetOrnamentationIDFile(Strings::ToUnsignedInt(&ornamentItem->IDFile[2]));
} }
else
{ const auto augment = GetOrnamentationAugment();
if (augment) {
const auto augment_item = GetOrnamentationAugment()->GetItem();
if (augment_item) {
SetOrnamentIcon(augment_item->Icon);
SetOrnamentHeroModel(augment_item->HerosForgeModel);
if (strlen(augment_item->IDFile) > 2) {
SetOrnamentationIDFile(Strings::ToUnsignedInt(&augment_item->IDFile[2]));
} else {
SetOrnamentationIDFile(0); SetOrnamentationIDFile(0);
} }
ornamentSet = true;
return true;
} }
} }
else
{
SetOrnamentIcon(0); SetOrnamentIcon(0);
SetOrnamentHeroModel(0); SetOrnamentHeroModel(0);
SetOrnamentationIDFile(0); SetOrnamentationIDFile(0);
}
return ornamentSet; return false;
} }
bool EQ::ItemInstance::CanTransform(const ItemData *ItemToTry, const ItemData *Container, bool AllowAll) { bool EQ::ItemInstance::CanTransform(const ItemData *ItemToTry, const ItemData *Container, bool AllowAll) {

View File

@ -51,6 +51,11 @@ typedef enum {
byFlagNotSet //apply action if the flag is NOT set byFlagNotSet //apply action if the flag is NOT set
} byFlagSetting; } byFlagSetting;
enum OrnamentationAugmentTypes {
StandardOrnamentation = 20,
SpecialOrnamentation = 21
};
class SharedDatabase; class SharedDatabase;
// ######################################## // ########################################
@ -136,7 +141,8 @@ namespace EQ
bool IsAugmented(); bool IsAugmented();
bool ContainsAugmentByID(uint32 item_id); bool ContainsAugmentByID(uint32 item_id);
int CountAugmentByID(uint32 item_id); int CountAugmentByID(uint32 item_id);
ItemInstance* GetOrnamentationAug(int32 ornamentationAugtype) const; bool IsOrnamentationAugment(EQ::ItemInstance* augment) const;
ItemInstance* GetOrnamentationAugment() const;
bool UpdateOrnamentationInfo(); bool UpdateOrnamentationInfo();
static bool CanTransform(const ItemData *ItemToTry, const ItemData *Container, bool AllowAll = false); static bool CanTransform(const ItemData *ItemToTry, const ItemData *Container, bool AllowAll = false);

View File

@ -5218,7 +5218,6 @@ namespace RoF
/** /**
* Ornamentation * Ornamentation
*/ */
int ornamentation_augment_type = RuleI(Character, OrnamentationAugmentType);
uint32 ornamentation_icon = (inst->GetOrnamentationIcon() ? inst->GetOrnamentationIcon() : 0); uint32 ornamentation_icon = (inst->GetOrnamentationIcon() ? inst->GetOrnamentationIcon() : 0);
uint32 hero_model = 0; uint32 hero_model = 0;

View File

@ -5477,7 +5477,6 @@ namespace RoF2
/** /**
* Ornamentation * Ornamentation
*/ */
int ornamentation_augment_type = RuleI(Character, OrnamentationAugmentType);
uint32 ornamentation_icon = (inst->GetOrnamentationIcon() ? inst->GetOrnamentationIcon() : 0); uint32 ornamentation_icon = (inst->GetOrnamentationIcon() ? inst->GetOrnamentationIcon() : 0);
uint32 hero_model = 0; uint32 hero_model = 0;

View File

@ -3851,17 +3851,17 @@ namespace UF
ob.write((const char*)&evotop, sizeof(UF::structs::EvolvingItem)); ob.write((const char*)&evotop, sizeof(UF::structs::EvolvingItem));
} }
//ORNAMENT IDFILE / ICON - uint16 ornament_icon = 0;
int ornamentationAugtype = RuleI(Character, OrnamentationAugmentType); const auto augment = inst->GetOrnamentationAugment();
uint16 ornaIcon = 0;
if (inst->GetOrnamentationAug(ornamentationAugtype)) {
const EQ::ItemData *aug_weap = inst->GetOrnamentationAug(ornamentationAugtype)->GetItem();
ornaIcon = aug_weap->Icon;
ob.write(aug_weap->IDFile, strlen(aug_weap->IDFile)); if (augment) {
const auto augment_item = augment->GetItem();
ornament_icon = augment_item->Icon;
ob.write(augment_item->IDFile, strlen(augment_item->IDFile));
} }
else if (inst->GetOrnamentationIDFile() && inst->GetOrnamentationIcon()) { else if (inst->GetOrnamentationIDFile() && inst->GetOrnamentationIcon()) {
ornaIcon = inst->GetOrnamentationIcon(); ornament_icon = inst->GetOrnamentationIcon();
char tmp[30]; memset(tmp, 0x0, 30); sprintf(tmp, "IT%d", inst->GetOrnamentationIDFile()); char tmp[30]; memset(tmp, 0x0, 30); sprintf(tmp, "IT%d", inst->GetOrnamentationIDFile());
ob.write(tmp, strlen(tmp)); ob.write(tmp, strlen(tmp));
@ -3870,7 +3870,7 @@ namespace UF
UF::structs::ItemSerializationHeaderFinish hdrf; UF::structs::ItemSerializationHeaderFinish hdrf;
hdrf.ornamentIcon = ornaIcon; hdrf.ornamentIcon = ornament_icon;
hdrf.unknown060 = 0; //This is Always 0.. or it breaks shit.. hdrf.unknown060 = 0; //This is Always 0.. or it breaks shit..
hdrf.unknown061 = 0; //possibly ornament / special ornament hdrf.unknown061 = 0; //possibly ornament / special ornament
hdrf.isCopied = 0; //Flag for item to be 'Copied' hdrf.isCopied = 0; //Flag for item to be 'Copied'

View File

@ -136,7 +136,6 @@ RULE_BOOL(Character, EnableFoodRequirement, true, "If disabled, food is no longe
RULE_INT(Character, BaseInstrumentSoftCap, 36, "Softcap for instrument mods, 36 commonly referred to as 3.6 as well") RULE_INT(Character, BaseInstrumentSoftCap, 36, "Softcap for instrument mods, 36 commonly referred to as 3.6 as well")
RULE_BOOL(Character, UseSpellFileSongCap, true, "When they removed the AA that increased the cap they removed the above and just use the spell field") RULE_BOOL(Character, UseSpellFileSongCap, true, "When they removed the AA that increased the cap they removed the above and just use the spell field")
RULE_INT(Character, BaseRunSpeedCap, 158, "Base Run Speed Cap, on live it's 158% which will give you a runspeed of 1.580 hard capped to 225") RULE_INT(Character, BaseRunSpeedCap, 158, "Base Run Speed Cap, on live it's 158% which will give you a runspeed of 1.580 hard capped to 225")
RULE_INT(Character, OrnamentationAugmentType, 20, "Ornamentation Augment Type")
RULE_REAL(Character, EnvironmentDamageMulipliter, 1, "Multiplier for environmental damage like fall damage.") RULE_REAL(Character, EnvironmentDamageMulipliter, 1, "Multiplier for environmental damage like fall damage.")
RULE_BOOL(Character, UnmemSpellsOnDeath, true, "Setting whether at death all memorized Spells are forgotten") RULE_BOOL(Character, UnmemSpellsOnDeath, true, "Setting whether at death all memorized Spells are forgotten")
RULE_REAL(Character, TradeskillUpAlchemy, 2.0, "Alchemy skillup rate adjustment. Lower is faster") RULE_REAL(Character, TradeskillUpAlchemy, 2.0, "Alchemy skillup rate adjustment. Lower is faster")

View File

@ -5619,7 +5619,6 @@ void Client::ProcessInspectRequest(Client *requestee, Client *requester)
const EQ::ItemData *item = nullptr; const EQ::ItemData *item = nullptr;
const EQ::ItemInstance *inst = nullptr; const EQ::ItemInstance *inst = nullptr;
int ornamentation_augment_type = RuleI(Character, OrnamentationAugmentType);
for (int16 L = EQ::invslot::EQUIPMENT_BEGIN; L <= EQ::invslot::EQUIPMENT_END; L++) { for (int16 L = EQ::invslot::EQUIPMENT_BEGIN; L <= EQ::invslot::EQUIPMENT_END; L++) {
inst = requestee->GetInv().GetItem(L); inst = requestee->GetInv().GetItem(L);
@ -5629,13 +5628,15 @@ void Client::ProcessInspectRequest(Client *requestee, Client *requester)
if (item) { if (item) {
strcpy(insr->itemnames[L], item->Name); strcpy(insr->itemnames[L], item->Name);
const EQ::ItemData *aug_item = nullptr; const EQ::ItemData *augment_item = nullptr;
if (inst->GetOrnamentationAug(ornamentation_augment_type)) { const auto augment = inst->GetOrnamentationAugment();
aug_item = inst->GetOrnamentationAug(ornamentation_augment_type)->GetItem();
if (augment) {
augment_item = augment->GetItem();
} }
if (aug_item) { if (augment_item) {
insr->itemicons[L] = aug_item->Icon; insr->itemicons[L] = augment_item->Icon;
} else if (inst->GetOrnamentationIcon()) { } else if (inst->GetOrnamentationIcon()) {
insr->itemicons[L] = inst->GetOrnamentationIcon(); insr->itemicons[L] = inst->GetOrnamentationIcon();
} else { } else {

View File

@ -8613,47 +8613,51 @@ void Client::Handle_OP_Illusion(const EQApplicationPacket *app)
void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app)
{ {
if (app->size != sizeof(InspectResponse_Struct)) { if (app->size != sizeof(InspectResponse_Struct)) {
LogError("Wrong size: OP_InspectAnswer, size=[{}], expected [{}]", app->size, sizeof(InspectResponse_Struct)); LogError("Wrong size: OP_InspectAnswer, size=[{}], expected [{}]", app->size, sizeof(InspectResponse_Struct));
return; return;
} }
//Fills the app sent from client. //Fills the app sent from client.
EQApplicationPacket* outapp = app->Copy(); auto outapp = app->Copy();
InspectResponse_Struct* insr = (InspectResponse_Struct*)outapp->pBuffer; auto insr = (InspectResponse_Struct *) outapp->pBuffer;
Mob* tmp = entity_list.GetMob(insr->TargetID); auto tmp = entity_list.GetMob(insr->TargetID);
const EQ::ItemData* item = nullptr; const EQ::ItemData *item = nullptr;
int ornamentationAugtype = RuleI(Character, OrnamentationAugmentType);
for (int16 L = EQ::invslot::EQUIPMENT_BEGIN; L <= EQ::invslot::EQUIPMENT_END; L++) { for (int16 L = EQ::invslot::EQUIPMENT_BEGIN; L <= EQ::invslot::EQUIPMENT_END; L++) {
const EQ::ItemInstance* inst = GetInv().GetItem(L); const auto inst = GetInv().GetItem(L);
item = inst ? inst->GetItem() : nullptr; item = inst ? inst->GetItem() : nullptr;
if (item) { if (item) {
strcpy(insr->itemnames[L], item->Name); strcpy(insr->itemnames[L], item->Name);
if (inst && inst->GetOrnamentationAug(ornamentationAugtype)) { if (inst) {
const EQ::ItemData *aug_item = inst->GetOrnamentationAug(ornamentationAugtype)->GetItem(); const auto augment = inst->GetOrnamentationAugment();
insr->itemicons[L] = aug_item->Icon;
} if (augment) {
else if (inst->GetOrnamentationIcon()) { insr->itemicons[L] = augment->GetItem()->Icon;
} else if (inst->GetOrnamentationIcon()) {
insr->itemicons[L] = inst->GetOrnamentationIcon(); insr->itemicons[L] = inst->GetOrnamentationIcon();
} }
else { } else {
insr->itemicons[L] = item->Icon; insr->itemicons[L] = item->Icon;
} }
} else {
insr->itemicons[L] = 0xFFFFFFFF;
} }
else { insr->itemicons[L] = 0xFFFFFFFF; }
} }
InspectMessage_Struct* newmessage = (InspectMessage_Struct*)insr->text; auto message = (InspectMessage_Struct *) insr->text;
InspectMessage_Struct& playermessage = GetInspectMessage(); auto inspect_message = GetInspectMessage();
memcpy(&playermessage, newmessage, sizeof(InspectMessage_Struct));
database.SaveCharacterInspectMessage(CharacterID(), &playermessage);
if (tmp != 0 && tmp->IsClient()) { tmp->CastToClient()->QueuePacket(outapp); } // Send answer to requester memcpy(&inspect_message, message, sizeof(InspectMessage_Struct));
database.SaveCharacterInspectMessage(CharacterID(), &inspect_message);
return; if (
tmp &&
tmp->IsClient()
) {
tmp->CastToClient()->QueuePacket(outapp);
} // Send answer to requester
} }
void Client::Handle_OP_InspectMessageUpdate(const EQApplicationPacket *app) void Client::Handle_OP_InspectMessageUpdate(const EQApplicationPacket *app)

View File

@ -205,12 +205,10 @@ int32 Mob::GetTextureProfileHeroForgeModel(uint8 material_slot) const
int32 Mob::GetEquipmentMaterial(uint8 material_slot) const int32 Mob::GetEquipmentMaterial(uint8 material_slot) const
{ {
uint32 equipment_material = 0; uint32 equipment_material = 0;
int32 ornamentation_augment_type = RuleI(Character, OrnamentationAugmentType);
int32 texture_profile_material = GetTextureProfileMaterial(material_slot); int32 texture_profile_material = GetTextureProfileMaterial(material_slot);
Log(Logs::Detail, Logs::MobAppearance, LogMobAppearance(
"[%s] material_slot: %u texture_profile_material: %i", "[{}] material_slot: {} texture_profile_material: {}",
clean_name, clean_name,
material_slot, material_slot,
texture_profile_material texture_profile_material
@ -233,9 +231,12 @@ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const
} }
const auto* inst = CastToClient()->m_inv[inventory_slot]; const auto* inst = CastToClient()->m_inv[inventory_slot];
if (inst) { if (inst) {
if (inst->GetOrnamentationAug(ornamentation_augment_type)) { const auto augment = inst->GetOrnamentationAugment();
item = inst->GetOrnamentationAug(ornamentation_augment_type)->GetItem();
if (augment) {
item = augment->GetItem();
if (item && strlen(item->IDFile) > 2 && Strings::IsNumber(&item->IDFile[2])) { if (item && strlen(item->IDFile) > 2 && Strings::IsNumber(&item->IDFile[2])) {
equipment_material = Strings::ToInt(&item->IDFile[2]); equipment_material = Strings::ToInt(&item->IDFile[2]);
} }
@ -310,21 +311,20 @@ uint32 Mob::GetEquipmentColor(uint8 material_slot) const
int32 Mob::GetHerosForgeModel(uint8 material_slot) const int32 Mob::GetHerosForgeModel(uint8 material_slot) const
{ {
uint32 hero_model = 0; uint32 hero_model = 0;
if (material_slot >= 0 && material_slot < EQ::textures::weaponPrimary) { if (EQ::ValueWithin(material_slot, 0, EQ::textures::weaponPrimary)) {
uint32 ornamentation_aug_type = RuleI(Character, OrnamentationAugmentType);
const EQ::ItemData *item = database.GetItem(GetEquippedItemFromTextureSlot(material_slot)); const EQ::ItemData *item = database.GetItem(GetEquippedItemFromTextureSlot(material_slot));
int16 invslot = EQ::InventoryProfile::CalcSlotFromMaterial(material_slot); const auto slot = EQ::InventoryProfile::CalcSlotFromMaterial(material_slot);
if (item != nullptr && invslot != INVALID_INDEX) { if (item && slot != INVALID_INDEX) {
if (IsClient()) { if (IsClient()) {
const EQ::ItemInstance *inst = CastToClient()->m_inv[invslot]; const auto inst = CastToClient()->m_inv[slot];
if (inst) { if (inst) {
if (inst->GetOrnamentationAug(ornamentation_aug_type)) { const auto augment = inst->GetOrnamentationAugment();
item = inst->GetOrnamentationAug(ornamentation_aug_type)->GetItem();
if (augment) {
item = augment->GetItem();
hero_model = item->HerosForgeModel; hero_model = item->HerosForgeModel;
} } else if (inst->GetOrnamentHeroModel()) {
else if (inst->GetOrnamentHeroModel()) {
hero_model = inst->GetOrnamentHeroModel(); hero_model = inst->GetOrnamentHeroModel();
} }
} }
@ -341,8 +341,13 @@ int32 Mob::GetHerosForgeModel(uint8 material_slot) const
/** /**
* Robes require full model number, and should only be sent to chest, arms, wrists, and legs slots * Robes require full model number, and should only be sent to chest, arms, wrists, and legs slots
*/ */
if (hero_model > 1000 && material_slot != 1 && material_slot != 2 && material_slot != 3 && if (
material_slot != 5) { hero_model > 1000 &&
material_slot != EQ::textures::armorChest &&
material_slot != EQ::textures::armorArms &&
material_slot != EQ::textures::armorWrist &&
material_slot != EQ::textures::armorLegs
) {
hero_model = 0; hero_model = 0;
} }
} }
@ -354,7 +359,7 @@ int32 Mob::GetHerosForgeModel(uint8 material_slot) const
* Otherwise, use the exact Model if model is > 999 * Otherwise, use the exact Model if model is > 999
* Robes for example are 11607 to 12107 in RoF * Robes for example are 11607 to 12107 in RoF
*/ */
if (hero_model > 0 && hero_model < 1000) { if (EQ::ValueWithin(hero_model, 1, 999)) {
hero_model *= 100; hero_model *= 100;
hero_model += material_slot; hero_model += material_slot;
} }