aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorNay <dnpd.dd@gmail.com>2012-08-01 02:46:32 +0100
committerNay <dnpd.dd@gmail.com>2012-08-01 02:46:32 +0100
commitcecde87c325547f8bc6f71a4aea8d9b50746c1b5 (patch)
tree4dc809c4ba4b4f7ddf318779123910cd12b90cee /src/server/game/Entities
parentac252899dedfb2e0f9bb0b6ad68f04ca3bddda06 (diff)
Core/Misc: Basic implemention of Transmogrification
TODO: charge money and fix some quirks and bugs Thanks to Shauren for finding item flags and proper validation
Diffstat (limited to 'src/server/game/Entities')
-rwxr-xr-xsrc/server/game/Entities/Item/Item.cpp111
-rwxr-xr-xsrc/server/game/Entities/Item/Item.h7
-rwxr-xr-xsrc/server/game/Entities/Item/ItemPrototype.h3
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h1
4 files changed, 122 insertions, 0 deletions
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp
index 248b080bfdd..130aac50935 100755
--- a/src/server/game/Entities/Item/Item.cpp
+++ b/src/server/game/Entities/Item/Item.cpp
@@ -1196,3 +1196,114 @@ bool Item::CheckSoulboundTradeExpire()
return false;
}
+
+bool Item::CanBeTransmogrified() const
+{
+ ItemTemplate const* proto = GetTemplate();
+
+ if (!proto)
+ return false;
+
+ if (proto->Quality == ITEM_QUALITY_LEGENDARY)
+ return false;
+
+ if (proto->Class != ITEM_CLASS_ARMOR &&
+ proto->Class != ITEM_CLASS_WEAPON)
+ return false;
+
+ if (proto->Class == ITEM_CLASS_WEAPON && proto->SubClass == ITEM_SUBCLASS_WEAPON_FISHING_POLE)
+ return false;
+
+ if (proto->Flags2 & ITEM_FLAGS_EXTRA_CANNOT_BE_TRANSMOG)
+ return false;
+
+ if (!HasStats())
+ return false;
+
+ return true;
+}
+
+bool Item::CanTransmogrify() const
+{
+ ItemTemplate const* proto = GetTemplate();
+
+ if (!proto)
+ return false;
+
+ if (proto->Flags2 & ITEM_FLAGS_EXTRA_CANNOT_TRANSMOG)
+ return false;
+
+ if (proto->Quality == ITEM_QUALITY_LEGENDARY)
+ return false;
+
+ if (proto->Class != ITEM_CLASS_ARMOR &&
+ proto->Class != ITEM_CLASS_WEAPON)
+ return false;
+
+ if (proto->Class == ITEM_CLASS_WEAPON && proto->SubClass == ITEM_SUBCLASS_WEAPON_FISHING_POLE)
+ return false;
+
+ if (proto->Flags2 & ITEM_FLAGS_EXTRA_CAN_TRANSMOG)
+ return true;
+
+ if (!HasStats())
+ return false;
+
+ return true;
+}
+
+bool Item::CanTransmogrifyItemWithItem(Item const* transmogrified, Item const* transmogrifier)
+{
+ if (!transmogrifier || !transmogrified)
+ return false;
+
+ ItemTemplate const* proto1 = transmogrifier->GetTemplate(); // source
+ ItemTemplate const* proto2 = transmogrified->GetTemplate(); // dest
+
+ if (proto1->ItemId == proto2->ItemId)
+ return false;
+
+ if (!transmogrified->CanTransmogrify() || !transmogrifier->CanBeTransmogrified())
+ return false;
+
+ if (proto1->InventoryType == INVTYPE_BAG ||
+ proto1->InventoryType == INVTYPE_RELIC ||
+ proto1->InventoryType == INVTYPE_BODY ||
+ proto1->InventoryType == INVTYPE_FINGER ||
+ proto1->InventoryType == INVTYPE_TRINKET ||
+ proto1->InventoryType == INVTYPE_AMMO ||
+ proto1->InventoryType == INVTYPE_QUIVER)
+ return false;
+
+ if (proto1->SubClass != proto2->SubClass && (proto1->Class != ITEM_CLASS_WEAPON || !transmogrified->IsRangedWeapon() || !transmogrifier->IsRangedWeapon()))
+ return false;
+
+ if (proto1->InventoryType != proto2->InventoryType &&
+ (proto1->Class != ITEM_CLASS_WEAPON || (proto2->InventoryType != INVTYPE_WEAPONMAINHAND && proto2->InventoryType != INVTYPE_WEAPONOFFHAND)))
+ return false;
+
+ return true;
+}
+
+bool Item::HasStats() const
+{
+ if (GetItemRandomPropertyId() != 0)
+ return true;
+
+ for (uint8 i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
+ if (GetTemplate()->ItemStat[i].ItemStatValue != 0)
+ return true;
+
+ return false;
+}
+
+bool Item::IsRangedWeapon() const
+{
+ ItemTemplate const* proto = GetTemplate();
+ if (proto && proto->Class == ITEM_CLASS_WEAPON)
+ return proto->SubClass == ITEM_SUBCLASS_WEAPON_BOW ||
+ proto->SubClass == ITEM_SUBCLASS_WEAPON_GUN ||
+ proto->SubClass == ITEM_SUBCLASS_WEAPON_CROSSBOW;
+
+ return false;
+}
diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h
index d38e8c32e30..2f9d10bb9d5 100755
--- a/src/server/game/Entities/Item/Item.h
+++ b/src/server/game/Entities/Item/Item.h
@@ -317,10 +317,12 @@ class Item : public Object
bool hasQuest(uint32 quest_id) const { return GetTemplate()->StartQuest == quest_id; }
bool hasInvolvedQuest(uint32 /*quest_id*/) const { return false; }
+ bool HasStats() const;
bool IsPotion() const { return GetTemplate()->IsPotion(); }
bool IsWeaponVellum() const { return GetTemplate()->IsWeaponVellum(); }
bool IsArmorVellum() const { return GetTemplate()->IsArmorVellum(); }
bool IsConjuredConsumable() const { return GetTemplate()->IsConjuredConsumable(); }
+ bool IsRangedWeapon() const;
// Item Refund system
void SetNotRefundable(Player* owner, bool changestate = true, SQLTransaction* trans = NULL);
@@ -343,6 +345,11 @@ class Item : public Object
void BuildUpdate(UpdateDataMapType&);
uint32 GetScriptId() const { return GetTemplate()->ScriptId; }
+
+ bool CanBeTransmogrified() const;
+ bool CanTransmogrify() const;
+ static bool CanTransmogrifyItemWithItem(Item const* transmogrified, Item const* transmogrifier);
+
private:
std::string m_text;
uint8 m_slot;
diff --git a/src/server/game/Entities/Item/ItemPrototype.h b/src/server/game/Entities/Item/ItemPrototype.h
index 9e14dcb7733..7bfe43e0691 100755
--- a/src/server/game/Entities/Item/ItemPrototype.h
+++ b/src/server/game/Entities/Item/ItemPrototype.h
@@ -197,6 +197,9 @@ enum ItemFlagsExtra
ITEM_FLAGS_EXTRA_NEED_ROLL_DISABLED = 0x00000100,
ITEM_FLAGS_EXTRA_CASTER_WEAPON = 0x00000200,
ITEM_FLAGS_EXTRA_BNET_ACCOUNT_BOUND = 0x00020000,
+ ITEM_FLAGS_EXTRA_CANNOT_BE_TRANSMOG = 0x00200000,
+ ITEM_FLAGS_EXTRA_CANNOT_TRANSMOG = 0x00400000,
+ ITEM_FLAGS_EXTRA_CAN_TRANSMOG = 0x00800000,
};
enum ItemFlagsCustom
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index a010a119017..3133d75fa07 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -662,6 +662,7 @@ enum NPCFlags
UNIT_NPC_FLAG_SPELLCLICK = 0x01000000, // cause client to send 1015 opcode (spell click)
UNIT_NPC_FLAG_PLAYER_VEHICLE = 0x02000000, // players with mounts that have vehicle data should have it set
UNIT_NPC_FLAG_REFORGER = 0x08000000, // reforging
+ UNIT_NPC_FLAG_TRANSMOGRIFIER = 0x10000000, // transmogrification
UNIT_NPC_FLAG_VAULTKEEPER = 0x20000000, // void storage
};