Core/Items: Added custom flags field to item_template, currently 2 flag values are available
* ITEM_FLAGS_CU_DURATION_REAL_TIME determines item duration counts even if offline (replaced ugly negative duration workaround, easy to lose data when importing fresh wdb) * ITEM_FLAGS_CU_IGNORE_QUEST_STATUS quest status will not affect this item appearing in loot, currently needed for Arena Master trinket
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE `item_template` ADD `flagsCustom` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `maxMoneyLoot`;
|
||||||
|
UPDATE `item_template` SET `flagsCustom`=`flagsCustom`|0x1 WHERE `Duration`<0;
|
||||||
|
UPDATE `item_template` SET `duration`=ABS(`duration`);
|
||||||
|
ALTER TABLE `item_template` CHANGE `Duration` `duration` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `ArmorDamageModifier`;
|
||||||
@@ -274,7 +274,7 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
|||||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
SetSpellCharges(i, itemProto->Spells[i].SpellCharges);
|
SetSpellCharges(i, itemProto->Spells[i].SpellCharges);
|
||||||
|
|
||||||
SetUInt32Value(ITEM_FIELD_DURATION, abs(itemProto->Duration));
|
SetUInt32Value(ITEM_FIELD_DURATION, itemProto->Duration);
|
||||||
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, 0);
|
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -420,7 +420,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
|
|||||||
// update duration if need, and remove if not need
|
// update duration if need, and remove if not need
|
||||||
if ((proto->Duration == 0) != (duration == 0))
|
if ((proto->Duration == 0) != (duration == 0))
|
||||||
{
|
{
|
||||||
SetUInt32Value(ITEM_FIELD_DURATION, abs(proto->Duration));
|
SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);
|
||||||
need_save = true;
|
need_save = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -192,6 +192,12 @@ enum ItemFlagsExtra
|
|||||||
ITEM_FLAGS_EXTRA_NEED_ROLL_DISABLED = 0x00000100
|
ITEM_FLAGS_EXTRA_NEED_ROLL_DISABLED = 0x00000100
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ItemFlagsCustom
|
||||||
|
{
|
||||||
|
ITEM_FLAGS_CU_DURATION_REAL_TIME = 0x0001, // Item duration will tick even if player is offline
|
||||||
|
ITEM_FLAGS_CU_IGNORE_QUEST_STATUS = 0x0002, // No quest status will be checked when this item drops
|
||||||
|
};
|
||||||
|
|
||||||
enum BAG_FAMILY_MASK
|
enum BAG_FAMILY_MASK
|
||||||
{
|
{
|
||||||
BAG_FAMILY_MASK_NONE = 0x00000000,
|
BAG_FAMILY_MASK_NONE = 0x00000000,
|
||||||
@@ -644,7 +650,7 @@ struct ItemTemplate
|
|||||||
uint32 GemProperties; // id from GemProperties.dbc
|
uint32 GemProperties; // id from GemProperties.dbc
|
||||||
uint32 RequiredDisenchantSkill;
|
uint32 RequiredDisenchantSkill;
|
||||||
float ArmorDamageModifier;
|
float ArmorDamageModifier;
|
||||||
int32 Duration; // negative = realtime, positive = ingame time
|
uint32 Duration;
|
||||||
uint32 ItemLimitCategory; // id from ItemLimitCategory.dbc
|
uint32 ItemLimitCategory; // id from ItemLimitCategory.dbc
|
||||||
uint32 HolidayId; // id from Holidays.dbc
|
uint32 HolidayId; // id from Holidays.dbc
|
||||||
uint32 ScriptId;
|
uint32 ScriptId;
|
||||||
@@ -652,6 +658,7 @@ struct ItemTemplate
|
|||||||
uint32 FoodType;
|
uint32 FoodType;
|
||||||
uint32 MinMoneyLoot;
|
uint32 MinMoneyLoot;
|
||||||
uint32 MaxMoneyLoot;
|
uint32 MaxMoneyLoot;
|
||||||
|
uint32 FlagsCu;
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
bool CanChangeEquipStateInCombat() const
|
bool CanChangeEquipStateInCombat() const
|
||||||
|
|||||||
@@ -13665,7 +13665,7 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly)
|
|||||||
Item* item = *itr;
|
Item* item = *itr;
|
||||||
++itr; // current element can be erased in UpdateDuration
|
++itr; // current element can be erased in UpdateDuration
|
||||||
|
|
||||||
if ((realtimeonly && item->GetTemplate()->Duration < 0) || !realtimeonly)
|
if (!realtimeonly || item->GetTemplate()->FlagsCu & ITEM_FLAGS_CU_DURATION_REAL_TIME)
|
||||||
item->UpdateDuration(this, time);
|
item->UpdateDuration(this, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2111,9 +2111,9 @@ void ObjectMgr::LoadItemTemplates()
|
|||||||
// 118 119 120 121 122 123 124 125
|
// 118 119 120 121 122 123 124 125
|
||||||
"TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, "
|
"TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, "
|
||||||
// 126 127 128 129 130 131 132 133
|
// 126 127 128 129 130 131 132 133
|
||||||
"GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, Duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, "
|
"GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, "
|
||||||
// 134 135 136
|
// 134 135 136
|
||||||
"FoodType, minMoneyLoot, maxMoneyLoot FROM item_template");
|
"FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom FROM item_template");
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@@ -2230,7 +2230,7 @@ void ObjectMgr::LoadItemTemplates()
|
|||||||
itemTemplate.GemProperties = fields[126].GetUInt32();
|
itemTemplate.GemProperties = fields[126].GetUInt32();
|
||||||
itemTemplate.RequiredDisenchantSkill = uint32(fields[127].GetInt16());
|
itemTemplate.RequiredDisenchantSkill = uint32(fields[127].GetInt16());
|
||||||
itemTemplate.ArmorDamageModifier = fields[128].GetFloat();
|
itemTemplate.ArmorDamageModifier = fields[128].GetFloat();
|
||||||
itemTemplate.Duration = fields[129].GetInt32();
|
itemTemplate.Duration = fields[129].GetUInt32();
|
||||||
itemTemplate.ItemLimitCategory = uint32(fields[130].GetInt16());
|
itemTemplate.ItemLimitCategory = uint32(fields[130].GetInt16());
|
||||||
itemTemplate.HolidayId = fields[131].GetUInt32();
|
itemTemplate.HolidayId = fields[131].GetUInt32();
|
||||||
itemTemplate.ScriptId = sObjectMgr->GetScriptId(fields[132].GetCString());
|
itemTemplate.ScriptId = sObjectMgr->GetScriptId(fields[132].GetCString());
|
||||||
@@ -2238,6 +2238,7 @@ void ObjectMgr::LoadItemTemplates()
|
|||||||
itemTemplate.FoodType = uint32(fields[134].GetUInt8());
|
itemTemplate.FoodType = uint32(fields[134].GetUInt8());
|
||||||
itemTemplate.MinMoneyLoot = fields[135].GetUInt32();
|
itemTemplate.MinMoneyLoot = fields[135].GetUInt32();
|
||||||
itemTemplate.MaxMoneyLoot = fields[136].GetUInt32();
|
itemTemplate.MaxMoneyLoot = fields[136].GetUInt32();
|
||||||
|
itemTemplate.FlagsCu = fields[137].GetUInt32();
|
||||||
|
|
||||||
// Checks
|
// Checks
|
||||||
|
|
||||||
@@ -2645,6 +2646,12 @@ void ObjectMgr::LoadItemTemplates()
|
|||||||
itemTemplate.HolidayId = 0;
|
itemTemplate.HolidayId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemTemplate.FlagsCu & ITEM_FLAGS_CU_DURATION_REAL_TIME && !itemTemplate.Duration)
|
||||||
|
{
|
||||||
|
sLog->outErrorDb("Item (Entry %u) has flag ITEM_FLAGS_CU_DURATION_REAL_TIME but it does not have duration limit", entry);
|
||||||
|
itemTemplate.FlagsCu &= ~ITEM_FLAGS_CU_DURATION_REAL_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
while (result->NextRow());
|
while (result->NextRow());
|
||||||
@@ -2731,7 +2738,7 @@ void ObjectMgr::LoadItemSetNames()
|
|||||||
if (setEntry->itemId[i])
|
if (setEntry->itemId[i])
|
||||||
itemSetItems.insert(setEntry->itemId[i]);
|
itemSetItems.insert(setEntry->itemId[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 1 2
|
// 0 1 2
|
||||||
QueryResult result = WorldDatabase.Query("SELECT `entry`, `name`, `InventoryType` FROM `item_set_names`");
|
QueryResult result = WorldDatabase.Query("SELECT `entry`, `name`, `InventoryType` FROM `item_set_names`");
|
||||||
|
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recv_data)
|
|||||||
data << pProto->GemProperties;
|
data << pProto->GemProperties;
|
||||||
data << pProto->RequiredDisenchantSkill;
|
data << pProto->RequiredDisenchantSkill;
|
||||||
data << pProto->ArmorDamageModifier;
|
data << pProto->ArmorDamageModifier;
|
||||||
data << uint32(abs(pProto->Duration)); // added in 2.4.2.8209, duration (seconds)
|
data << pProto->Duration; // added in 2.4.2.8209, duration (seconds)
|
||||||
data << pProto->ItemLimitCategory; // WotLK, ItemLimitCategory
|
data << pProto->ItemLimitCategory; // WotLK, ItemLimitCategory
|
||||||
data << pProto->HolidayId; // Holiday.dbc?
|
data << pProto->HolidayId; // Holiday.dbc?
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
|
|||||||
@@ -356,18 +356,9 @@ bool LootItem::AllowedForPlayer(Player const* player) const
|
|||||||
if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE)
|
if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (needs_quest)
|
// check quest requirements
|
||||||
{
|
if (!(pProto->FlagsCu & ITEM_FLAGS_CU_IGNORE_QUEST_STATUS) && ((needs_quest || (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE)) && !player->HasQuestForItem(itemid)))
|
||||||
// Checking quests for quest-only drop (check only quests requirements in this case)
|
return false;
|
||||||
if (!player->HasQuestForItem(itemid))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Not quest only drop (check quest starting items for already accepted non-repeatable quests)
|
|
||||||
if (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user