mirror of
https://github.com/EQEmu/Server.git
synced 2026-08-29 12:47:54 +00:00
Item Transformation now works!
This commit is contained in:
committed by
Michael Cook (mackal)
parent
ee7f88d247
commit
daec5bde66
@@ -1412,6 +1412,8 @@ ItemInst::ItemInst(const Item_Struct* item, int16 charges) {
|
||||
m_scaledItem = nullptr;
|
||||
m_evolveInfo = nullptr;
|
||||
m_scaling = false;
|
||||
m_ornamenticon = 0;
|
||||
m_ornamentidfile = 0;
|
||||
}
|
||||
|
||||
ItemInst::ItemInst(SharedDatabase *db, uint32 item_id, int16 charges) {
|
||||
@@ -1434,6 +1436,8 @@ ItemInst::ItemInst(SharedDatabase *db, uint32 item_id, int16 charges) {
|
||||
m_scaledItem = nullptr;
|
||||
m_evolveInfo = nullptr;
|
||||
m_scaling = false;
|
||||
m_ornamenticon = 0;
|
||||
m_ornamentidfile = 0;
|
||||
}
|
||||
|
||||
ItemInst::ItemInst(ItemInstTypes use_type) {
|
||||
@@ -1451,6 +1455,8 @@ ItemInst::ItemInst(ItemInstTypes use_type) {
|
||||
m_scaledItem = nullptr;
|
||||
m_evolveInfo = nullptr;
|
||||
m_scaling = false;
|
||||
m_ornamenticon = 0;
|
||||
m_ornamentidfile = 0;
|
||||
}
|
||||
|
||||
// Make a copy of an ItemInst object
|
||||
@@ -1501,6 +1507,8 @@ ItemInst::ItemInst(const ItemInst& copy)
|
||||
m_evolveInfo = nullptr;
|
||||
|
||||
m_scaling = copy.m_scaling;
|
||||
m_ornamenticon = copy.m_ornamenticon;
|
||||
m_ornamentidfile = copy.m_ornamentidfile;
|
||||
}
|
||||
|
||||
// Clean up container contents
|
||||
@@ -1789,6 +1797,54 @@ ItemInst* ItemInst::GetOrnamentationAug(int ornamentationAugtype) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ItemInst::CanTransform(const Item_Struct *ItemToTry, const Item_Struct *Container, bool AllowAll) {
|
||||
if (!ItemToTry || !Container) return false;
|
||||
|
||||
if (ItemToTry->ItemType == ItemTypeArrow || strnlen(Container->CharmFile, 30) == 0)
|
||||
return false;
|
||||
|
||||
if (AllowAll && Container->CharmFile != "ITEMTRANSFIGSHIELD" && Container->CharmFile != "ITEMTransfigBow") {
|
||||
switch (ItemToTry->ItemType) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 35:
|
||||
case 45:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static std::map<std::string, int> types = {
|
||||
{ "ITEMTransfig1HP", 2 },
|
||||
{ "ITEMTransfig1HS", 0 },
|
||||
{ "ITEMTransfig2HB", 4 },
|
||||
{ "ITEMTransfig2HP", 35 },
|
||||
{ "ITEMTransfig2HS", 1 },
|
||||
{ "ITEMTransfigBlunt", 3 },
|
||||
{ "ITEMTransfigBow", 5 },
|
||||
{ "ITEMTransfigHTH", 45 },
|
||||
{ "ITEMTRANSFIGSHIELD", 8 },
|
||||
{ "ITEMTransfigSlashing", 0 }
|
||||
};
|
||||
|
||||
auto i = types.find(Container->CharmFile);
|
||||
if (i != types.end() && i->second == ItemToTry->ItemType)
|
||||
return true;
|
||||
|
||||
static std::map<std::string, int> typestwo = {
|
||||
{ "ITEMTransfigBlunt", 4 },
|
||||
{ "ITEMTransfigSlashing", 1 }
|
||||
};
|
||||
|
||||
i = typestwo.find(Container->CharmFile);
|
||||
if (i != typestwo.end() && i->second == ItemToTry->ItemType)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 ItemInst::GetAugmentItemID(uint8 slot) const
|
||||
{
|
||||
uint32 id = NO_ITEM;
|
||||
|
||||
@@ -330,6 +330,7 @@ public:
|
||||
ItemInst* RemoveAugment(uint8 index);
|
||||
bool IsAugmented();
|
||||
ItemInst* GetOrnamentationAug(int ornamentationAugtype) const;
|
||||
static bool CanTransform(const Item_Struct *ItemToTry, const Item_Struct *Container, bool AllowAll = false);
|
||||
|
||||
// Has attack/delay?
|
||||
bool IsWeapon() const;
|
||||
@@ -392,6 +393,10 @@ public:
|
||||
void SetActivated(bool activated) { m_activated = activated; }
|
||||
int8 GetEvolveLvl() const { return m_evolveLvl; }
|
||||
void SetScaling(bool v) { m_scaling = v; }
|
||||
uint32 GetOrnamentationIcon() const { return m_ornamenticon; }
|
||||
void SetOrnamentIcon(uint32 ornament_icon) { m_ornamenticon = ornament_icon; }
|
||||
uint32 GetOrnamentationIDFile() const { return m_ornamentidfile; }
|
||||
void SetOrnamentationIDFile(uint32 ornament_idfile) { m_ornamentidfile = ornament_idfile; }
|
||||
|
||||
void Initialize(SharedDatabase *db = nullptr);
|
||||
void ScaleItem();
|
||||
@@ -436,6 +441,8 @@ protected:
|
||||
Item_Struct* m_scaledItem;
|
||||
EvolveInfo* m_evolveInfo;
|
||||
bool m_scaling;
|
||||
uint32 m_ornamenticon;
|
||||
uint32 m_ornamentidfile;
|
||||
|
||||
//
|
||||
// Items inside of this item (augs or contents);
|
||||
|
||||
@@ -4888,6 +4888,16 @@ namespace RoF
|
||||
//Icon
|
||||
ornaIcon = aug_weap->Icon;
|
||||
}
|
||||
else if (inst->GetOrnamentationIDFile() && inst->GetOrnamentationIcon()) {
|
||||
char tmp[30]; memset(tmp, 0x0, 30); sprintf(tmp, "IT%d", inst->GetOrnamentationIDFile());
|
||||
//Mainhand
|
||||
ss.write(tmp, strlen(tmp));
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
//Offhand
|
||||
ss.write(tmp, strlen(tmp));
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
ornaIcon = inst->GetOrnamentationIcon();
|
||||
}
|
||||
else {
|
||||
ss.write((const char*)&null_term, sizeof(uint8)); //no mh
|
||||
ss.write((const char*)&null_term, sizeof(uint8));//no of
|
||||
|
||||
@@ -3664,6 +3664,12 @@ namespace Underfoot
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
ornaIcon = aug_weap->Icon;
|
||||
}
|
||||
else if (inst->GetOrnamentationIDFile() && inst->GetOrnamentationIcon()) {
|
||||
char tmp[30]; memset(tmp, 0x0, 30); sprintf(tmp, "IT%d", inst->GetOrnamentationIDFile());
|
||||
ss.write(tmp, strlen(tmp));
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
ornaIcon = inst->GetOrnamentationIcon();
|
||||
}
|
||||
else {
|
||||
ss.write((const char*)&null_term, sizeof(uint8)); //no idfile
|
||||
}
|
||||
|
||||
@@ -586,6 +586,8 @@ RULE_CATEGORY( Inventory )
|
||||
RULE_BOOL ( Inventory, EnforceAugmentRestriction, true) // Forces augment slot restrictions
|
||||
RULE_BOOL ( Inventory, EnforceAugmentUsability, true) // Forces augmented item usability
|
||||
RULE_BOOL ( Inventory, EnforceAugmentWear, true) // Forces augment wear slot validation
|
||||
RULE_BOOL ( Inventory, DeleteTransformationMold, true) //False if you want mold to last forever
|
||||
RULE_BOOL ( Inventory, AllowAnyWeaponTransformation, false) //Weapons can use any weapon transformation
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY( Client )
|
||||
|
||||
+22
-5
@@ -199,14 +199,14 @@ bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, i
|
||||
// Update/Insert item
|
||||
std::string query = StringFormat("REPLACE INTO inventory "
|
||||
"(charid, slotid, itemid, charges, instnodrop, custom_data, color, "
|
||||
"augslot1, augslot2, augslot3, augslot4, augslot5) "
|
||||
"augslot1, augslot2, augslot3, augslot4, augslot5, ornamenticon, ornamentidfile) "
|
||||
"VALUES( %lu, %lu, %lu, %lu, %lu, '%s', %lu, "
|
||||
"%lu, %lu, %lu, %lu, %lu)",
|
||||
"%lu, %lu, %lu, %lu, %lu, %lu, %lu)",
|
||||
(unsigned long)char_id, (unsigned long)slot_id, (unsigned long)inst->GetItem()->ID,
|
||||
(unsigned long)charges, (unsigned long)(inst->IsInstNoDrop()? 1: 0),
|
||||
inst->GetCustomDataString().c_str(), (unsigned long)inst->GetColor(),
|
||||
(unsigned long)augslot[0], (unsigned long)augslot[1], (unsigned long)augslot[2],
|
||||
(unsigned long)augslot[3],(unsigned long)augslot[4]);
|
||||
(unsigned long)augslot[3],(unsigned long)augslot[4], (unsigned long)inst->GetOrnamentationIcon(), (unsigned long)inst->GetOrnamentationIDFile());
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
// Save bag contents, if slot supports bag contents
|
||||
@@ -488,7 +488,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||
bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
// Retrieve character inventory
|
||||
std::string query = StringFormat("SELECT slotid, itemid, charges, color, augslot1, "
|
||||
"augslot2, augslot3, augslot4, augslot5, instnodrop, custom_data "
|
||||
"augslot2, augslot3, augslot4, augslot5, instnodrop, custom_data, ornamenticon, ornamentidfile "
|
||||
"FROM inventory WHERE charid = %i ORDER BY slotid", char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
@@ -513,6 +513,9 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
|
||||
bool instnodrop = (row[9] && (uint16)atoi(row[9]))? true: false;
|
||||
|
||||
uint32 ornament_icon = (uint32)atoul(row[11]);
|
||||
uint32 ornament_idfile = (uint32)atoul(row[12]);
|
||||
|
||||
const Item_Struct* item = GetItem(item_id);
|
||||
|
||||
if (!item) {
|
||||
@@ -549,6 +552,11 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
value.push_back(v);
|
||||
}
|
||||
}
|
||||
if (ornament_icon > 0)
|
||||
inst->SetOrnamentIcon(ornament_icon);
|
||||
|
||||
if (ornament_idfile > 0)
|
||||
inst->SetOrnamentationIDFile(ornament_idfile);
|
||||
|
||||
if (instnodrop || (((slot_id >= EmuConstants::EQUIPMENT_BEGIN && slot_id <= EmuConstants::EQUIPMENT_END) || slot_id == MainPowerSource) && inst->GetItem()->Attuneable))
|
||||
inst->SetInstNoDrop(true);
|
||||
@@ -591,7 +599,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv) {
|
||||
// Retrieve character inventory
|
||||
std::string query = StringFormat("SELECT slotid, itemid, charges, color, augslot1, "
|
||||
"augslot2, augslot3, augslot4, augslot5, instnodrop, custom_data "
|
||||
"augslot2, augslot3, augslot4, augslot5, instnodrop, custom_data, ornamenticon, ornamentidfile "
|
||||
"FROM inventory INNER JOIN character_data ch "
|
||||
"ON ch.id = charid WHERE ch.name = '%s' AND ch.account_id = %i ORDER BY slotid",
|
||||
name, account_id);
|
||||
@@ -617,6 +625,9 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv)
|
||||
aug[4] = (uint32)atoi(row[8]);
|
||||
|
||||
bool instnodrop = (row[9] && (uint16)atoi(row[9])) ? true : false;
|
||||
uint32 ornament_icon = (uint32)atoul(row[11]);
|
||||
uint32 ornament_idfile = (uint32)atoul(row[12]);
|
||||
|
||||
const Item_Struct* item = GetItem(item_id);
|
||||
int16 put_slot_id = INVALID_INDEX;
|
||||
if(!item)
|
||||
@@ -651,6 +662,12 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (ornament_icon > 0)
|
||||
inst->SetOrnamentIcon(ornament_icon);
|
||||
|
||||
if (ornament_idfile > 0)
|
||||
inst->SetOrnamentationIDFile(ornament_idfile);
|
||||
|
||||
if (color > 0)
|
||||
inst->SetColor(color);
|
||||
|
||||
Reference in New Issue
Block a user