Jump to content

[Not for GIT] RequiredName to equip a weapon


Guest caeruleaus

Recommended Posts

I decided to see if i could implement this through the mysql database and i did. This allows you to make a weapon only usable by a specific person so you can make custom super weapons for specific people.

to get it just pull my branch

git pull git://github.com/caeruleaus/mangos.git reqname

or apply the diff:

diff --git a/reqname.sql b/reqname.sql
new file mode 100644
index 0000000..7d960a5
--- /dev/null
+++ b/reqname.sql
@@ -0,0 +1 @@
+ALTER TABLE item_template ADD RequiredName VARCHAR(255) AFTER RequiredLevel;
\\ No newline at end of file
diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp
index 19b2c13..143b37d 100644
--- a/src/game/ItemHandler.cpp
+++ b/src/game/ItemHandler.cpp
@@ -283,6 +283,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data )
    {
        std::string Name        = pProto->Name1;
        std::string Description = pProto->Description;
+        std::string RequiredName = pProto->RequiredName;

        int loc_idx = GetSessionDbLocaleIndex();
        if ( loc_idx >= 0 )
diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h
index 4ee2831..8bae625 100644
--- a/src/game/ItemPrototype.h
+++ b/src/game/ItemPrototype.h
@@ -529,6 +529,7 @@ struct ItemPrototype
    uint32 AllowableRace;
    uint32 ItemLevel;
    uint32 RequiredLevel;
+    char*  RequiredName;                                    //Won't let anyone but specified name equip/use
    uint32 RequiredSkill;                                   // id from SkillLine.dbc
    uint32 RequiredSkillRank;
    uint32 RequiredSpell;                                   // id from Spell.dbc
@@ -642,6 +643,7 @@ struct ItemLocale
{
    std::vector<std::string> Name;
    std::vector<std::string> Description;
+    std::vector<std::string> RequiredName;
};

// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 2992f68..cda30fc 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -9999,7 +9999,7 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
    dest = 0;
    if( pItem )
    {
-        sLog.outDebug( "STORAGE: CanEquipItem slot = %u, item = %u, count = %u", slot, pItem->GetEntry(), pItem->GetCount());
+        sLog.outDebug( "STORAGE: CanEquipItem slot = %u, item = %u, count = %u, name = %s", slot, pItem->GetEntry(), pItem->GetCount(), pItem->GetProto()->RequiredName);
        ItemPrototype const *pProto = pItem->GetProto();
        if( pProto )
        {
@@ -10014,7 +10014,9 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
            uint8 res = CanTakeMoreSimilarItems(pItem);
            if(res != EQUIP_ERR_OK)
                return res;
-
+            std::string RequiredName = pItem->GetProto()->RequiredName;
+            if(RequiredName != "" && this->GetName() != RequiredName)
+                return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
            // check this only in game
            if(not_loading)
            {
diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp
index 9f8e32a..70cc572 100644
--- a/src/shared/Database/SQLStorage.cpp
+++ b/src/shared/Database/SQLStorage.cpp
@@ -33,8 +33,8 @@ const char CreatureInfoAddonInfofmt[]="iiiiiis";
const char EquipmentInfofmt[]="iiii";
const char GameObjectInfosrcfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis";
const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii";
-const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiiii";
-const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiii";
+const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiiii";
+const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiii";
const char PageTextfmt[]="isi";
const char InstanceTemplatesrcfmt[]="iiiiffffs";
const char InstanceTemplatedstfmt[]="iiiiffffi";

Link to comment
Share on other sites

Having an item to be "namebound", versus soulbound or bind to account, seems to have uses at first but, where does this feature really differ from an item being soulbound?

I could see this perhaps being a unique way of binding one-of-a-kind custom items. Perhaps something like Elric's legendary, sentient sword choosing him alone to be its wielder.

Link to comment
Share on other sites

yeah that was kind of the idea. It's more of a way to control GM's abusing special weapons and stuff meant for higher level gms but it would be fun for some form of role playing or something along that line. I was thinking of making it so you could do multiple names or possibly char GUID's but i just wanted to see if anyone would be interested in it. Or maybe restrict the item to specific GM levels.

Link to comment
Share on other sites

For role-play purposes this would add a new wrinkle to telling a story. Let's say the King of Stormwind rewards a character with a dusty weapon of ancient lineage for extraordinary heroism to the crown. After all, the current definition of "unique" for an item merely means you can possess only one but there's nothing to stop someone else from also having one.

Democracy and fairness might keep the majority of subscribers on retail happy but, it guts the potential to allow for those rare individuals that are a cut above the rest to set themselves apart by by earning rewards no other can have.

Sure, it's not official-like. I learned a long time ago as a Dungeon Master that sometimes you have to bend or even break the rules for the sake of a good narrative. However, I've noticed that games like these may label themselves as RPGs but 99% of all PC and console RPG games are not really...not in the same sense as the ones where you rolled dice and had a poorly-drawn doodle of your alter-ego on your character sheet. I prefer to call them "immersive adventure" games, that only differ from FPS games in the fact that there's a whole world to explore.

As for GMs... I've noticed that the .additem command is usually the first one that gets abused, which is why it's also the first command I set to level 3 when installing or upgrading my world database.

Link to comment
Share on other sites

yeah, I had originally just put a check directly into the equip item method but I just wanted to see what i could do to make it easier and more customizable. There are a few items that only 1 person can have (The Ahn'Quiraj Battle Tank for example) but that was only because you could only get it by opening the AQ gates. This takes it to a bit of a further level (you can still get the item, but you can only equip it if your name matches the item or whatever). Again if I had a few people posting about it i could go as far as adding a table to the quest_template that on complete makes it so the item you get is bound to the first person to finish it. It would be a lot of work but it would be fun to see how well I can do some c++ (I usually code in Java, but my programming class in college is doing c++ now)

Link to comment
Share on other sites

I'd say do it anyways. Most times, you'll find that creating something for your own growth and the joy of making is the best reason. Those who wait for the praise of others often find themselves feeling let down and even angry that nobody stood up to cheer when your work is unveiled.

I'd be willing to take such a project for a test drive, if the issue with custom items, post-3.3.0a, is ever resolved in a more satisfactory manner than having to match custom items up to similar unused items in the DBC files. At the very least, a list of all the unused IDs and types would save a lot of work but it will still impose a limit on just how many custom items you could have on a server.

Link to comment
Share on other sites

yeah :/ I was thinking of seeing if i could override it from the core somehow. I know it's a client problem but i was thinking maybe you could trick the client by sending a false id for broken items just for the use in spells. Like add it to the item_template like normal but have a check to see what equipment type it is and when the client expects a melee weapon (dagger, sword, etc), send a fake ID of a item with that equipment type. I havent looked into it yet but if i figure something out ill post it.

Link to comment
Share on other sites

Some sort of packet spoofing might do the job. I know it certainly works for cheaters!

However, such a method would still require using a list of legit IDs from the DBC, so we're back to digging through those files for unused IDs the same as we would when manually adding custom items.

Maybe a utility that would automatically scan the DBC files and compare against the templates in the database to generate a list of unused IDs by item type would be the best method. Otherwise, you'll need to find some sort of "skeleton key" flag that you can append to custom items that would allow the client to use them regardless of whether or not it's in the DBC.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use