How to make custom shops easily (__ADDSHOPITEM)

Results 1 to 15 of 15
  1. #1
    Member LonesomeNoob is offline
    MemberRank
    Aug 2019 Join Date
    In a caveLocation
    30Posts

    big grin How to make custom shops easily (__ADDSHOPITEM)

    How to make custom shops easily (__ADDSHOPITEM)
    I had a LOT of trouble trying to understand the whole "AddVendorItem( 0, IK3_SWD, 1, 15, 27, 50 );" thing and wanted to have my own custom npc for certain items, and well i finally figured it out. I couldn't find a straight answer and only scattered forum posts with dead links, so i decided to make a small tutorial for those who were in my same spot.

    Adding a new npc:
    I followed RynoKabbage's guide, but i found that his link for flyfftools was dead, so you can use this link for dyoManager or the link in the comments on his guide.

    Adding "__ADDSHOPITEM":
    note:I'm assuming whoever is reading this already knows how to compile there source.

    This is how i made it work, i'm not sure if there's an easier way but in the folders: accountserver, cacheserver, certifier, coreserver, databaseserver, neuz, and world server there are files named "versioncommon.h". In the first few lines you should see lines like "#define __Server", well within those you need to add "#define __ADDSHOPITEM" to each versioncommon.h in every one of those folders.

    ​Mover.cpp part:
    Spoiler:
    now in your _COMMON folder you're going to want to open "mover.cpp". Start by searching for "#endif //__CSC_VER11_3" there should be 3 occurrences of that bit of text, the second one is the one you want to start with.

    where it looks like this:
    Code:
    #if __VER >= 11 // __CSC_VER11_3
                    }
    #endif //__CSC_VER11_3
    Directly under that #endif paste the code below:
    Code:
    #ifdef __ADDSHOPITEM
                    if( pCharacter->m_venderItemAry3[i].GetSize() )
                    {
                        fShop = TRUE;
                        for( int j = 0; j < pCharacter->m_venderItemAry3[i].GetSize(); j++)
                        {
                            pVendor    = (LPVENDOR_ITEM)pCharacter->m_venderItemAry3[i].GetAt(j);
                            CItemElem itemElem;
                            itemElem.m_dwItemId    = pVendor->m_dwItemId;
                            itemElem.m_nItemNum    = (short)( prj.GetItemProp( pVendor->m_dwItemId )->dwPackMax );
                            itemElem.m_nHitPoint = prj.GetItemProp( pVendor->m_dwItemId )->dwEndurance;
                            if( m_ShopInventory[i]->Add( &itemElem ) == FALSE )
                                break;
                        }
                    }
    #endif
    it should look like
    Code:
    #if __VER >= 11 // __CSC_VER11_3
                    }
    #endif //__CSC_VER11_3
    #ifdef __ADDSHOPITEM
                    if( pCharacter->m_venderItemAry3[i].GetSize() )
    note: the example above is just the start of the clip of code and not the whole thing.

    now on the 3rd occurrence of that line your searched you're going to do the same thing you did above, right below the "#endif" you paste the code below.
    Code:
    #ifdef __ADDSHOPITEM
        for( int i = 0; i < MAX_VENDOR_INVENTORY_TAB; i++ )
        {
            if( pCharacter->m_venderItemAry3[i].GetSize() )
                return TRUE;
        }
    #endif


    Project.cpp part:

    Spoiler:

    Now in your _COMMON folder you're going to want to open "Project.cpp". Start by searching for "#endif //__CSC_VER11_3" there should be 3 occurrences of that bit of text, the first one is the one you want.

    Just as the mover.cpp, you need to paste the code below directly under the "#endif //__CSC_VER11_3".
    Code:
    #ifdef __ADDSHOPITEM
            for( j = 0; j < MAX_VENDOR_INVENTORY_TAB; j++ )
            {
                for( i = 0; i < lpCharacter->m_venderItemAry3[ j ].GetSize(); i++)
                    safe_delete( (LPVENDOR_ITEM)lpCharacter->m_venderItemAry3[ j ].GetAt(i) );
            }
    #endif
    Now you're going to search again in "Project.cpp" for "#endif // __TELEPORTER", the second occurrence towards the middle is what you want. You'll as always post the snip of code directly under the searched term.

    Code:
    #ifdef __ADDSHOPITEM
                else if( script.Token == "AddShopItem" )
                {
                    script.GetToken(); // (
                    int nSlot = script.GetNumber(); script.GetToken(); // 
                    DWORD dwId = script.GetNumber(); script.GetToken(); //
                    if (script.Token == ",")
            {
                DWORD dwCost = script.GetNumber();
                script.GetToken(); // )
                ItemProp* pItem = prj.GetItemProp(dwId);
                if (pItem)
                pItem->dwCost = dwCost;
            }
                    LPVENDOR_ITEM pVendorItem = new VENDOR_ITEM;
                    pVendorItem->m_dwItemId = dwId;
                    lpCharacter->m_venderItemAry3[ nSlot ].Add( pVendorItem );
                }
    #endif

    Project.h part:
    Spoiler:


    Now in your _COMMON folder you're going to want to open "Project.h". Start by searching for "#endif // __TELEPORTER". There should be 1 occurrence, that's one you want.

    And for the last thing you need to do, one last time, directly under the "#endif" you need to paste the code below:
    Code:
    #ifdef __ADDSHOPITEM    
    
    CPtrArray m_venderItemAry3[4];
    
    #endif


    When you're done with those parts above you'll need to compile your source, and then you're done!

    Adding items:

    note:At this point you should have a compiled source with the code provided, and a npc you'd like to add an item to a shop.


    You need to make your way to your resource folder in your server folder. Open your "character.inc" file and follow along.

    This is the config for the npc "Is"

    Code:
    MaFl_Is{
        setting
        {
            AddMenu( MMI_DIALOG );
            AddMenu( MMI_TRADE  );
            AddVendorItem( 0, IK3_MASK, -1, 1, 2, 100 );
            SetImage
            (
            IDS_CHARACTER_INC_000064
            );
            m_szDialog= "MaFl_Is.txt";
        }
        SetName
        (
        IDS_CHARACTER_INC_000065
        );
        AddVendorSlot( 0,
        IDS_CHARACTER_INC_000066
        );
    }
    the snip of code you need to add items now is "AddShopItem( 0, PUT_ITEM_ID_HERE );".

    You place it where you see "AddVendorItem( 0, IK3_MASK, -1, 1, 2, 100 );"

    Once you've done all of that, you'll need to use merge.exe to get new res files and put them in your client folder for the shops to load.

    Of course you put the id of the item you want where it tells you to, and the 0 is the vender slot number. You can find item id's in the file "propItem.txt". Some things can't be sold and you'll have to go through your "propItem.txt" with the id you found and change the shopable value to 1. You also go into that file to change prices.

    Edit:
    Looking around i found a snip of code that lets you change the price of the item in the character.inc, but it's a little wonky and it only lets you change the price once. So two different shops with the addshopitem line and a price change, they'd both have the price of the first query. "AddShopItem( 0, PUT_ITEM_ID_HERE, X);" The X is where the price goes, you don't have to have it in your line, only if you want to change the price for said item.


    Hope this helps anyone honestly.
    Last edited by LonesomeNoob; 19-08-19 at 05:33 PM. Reason: New Code


  2. #2
    Registered aminus is offline
    MemberRank
    May 2014 Join Date
    8Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    Is this for custom currency or just a tut on how to add items in npcs?
    If it's the latter, it's actually pretty easy. Just edit the item rarity.
    No need to complicate things.
    If not, then :/

  3. #3
    Member LonesomeNoob is offline
    MemberRank
    Aug 2019 Join Date
    In a caveLocation
    30Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    Quote Originally Posted by aminus View Post
    Is this for custom currency or just a tut on how to add items in npcs?
    If it's the latter, it's actually pretty easy. Just edit the item rarity.
    No need to complicate things.
    If not, then :/
    Well, some people just can't figure out how to get it to work with item rarity, and when this code is implemented you don't need to edit anything, you just put the vendor slot and the id and it's done.

  4. #4
    ‎‎‎‎ Ketchup is offline
    ModeratorRank
    Jan 2009 Join Date
    1,539Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    Well thought out and nicely written.

    Community here needs a bit more of this tbh.

  5. #5
    Registered shearjovan is offline
    MemberRank
    Sep 2014 Join Date
    19Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    So I copied everything you did step by step, compiled with no errors. Went into my resource and into the character.inc file. I went scrolled down till I found the npc is and decided to place the item"II_SYS_SYS_SCR_BXMKNT120SET" which can also be found in the Npc Wafor which I think means that the item is already shopable. I save the file and merge the resource. Get the res files into the client and start the server then go in game. However, I don't see the item which I have tried to add. Why is that? Pic below for the character.inc code

    https://ibb.co/pQqt5Ym

  6. #6
    ‎‎‎‎ Ketchup is offline
    ModeratorRank
    Jan 2009 Join Date
    1,539Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    Quote Originally Posted by shearjovan View Post
    So I copied everything you did step by step, compiled with no errors. Went into my resource and into the character.inc file. I went scrolled down till I found the npc is and decided to place the item"II_SYS_SYS_SCR_BXMKNT120SET" which can also be found in the Npc Wafor which I think means that the item is already shopable. I save the file and merge the resource. Get the res files into the client and start the server then go in game. However, I don't see the item which I have tried to add. Why is that? Pic below for the character.inc code

    https://ibb.co/pQqt5Ym
    Send a pm with your discord and when i get home from work ill try to help you.

  7. #7
    Registered shearjovan is offline
    MemberRank
    Sep 2014 Join Date
    19Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    Quote Originally Posted by Ketchup View Post
    Send a pm with your discord and when i get home from work ill try to help you.
    alright, sent you one. Thank you

  8. #8
    Account Upgraded | Title Enabled! Ratpack is offline
    True MemberRank
    May 2011 Join Date
    316Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    First thank you for this.

    An importend thing i want to know is: How to setup the Shop NPC with male or female Fashion?
    For the female Fashion it wont work. Anyone have a fix?

  9. #9
    Member wulaofa is offline
    MemberRank
    Mar 2020 Join Date
    39Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    I compiled successfully like this, but type in incAddShopItem (0, II_SYS_SYS_SCR_BXMKNT120SET, 100);This item does not appear in the NPC store.The data file has been updated.

  10. #10
    Registered jinazareno is offline
    MemberRank
    Jul 2020 Join Date
    7Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    Thank you for this!

  11. #11
    Registered donsito is offline
    MemberRank
    Jan 2021 Join Date
    13Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    I Have the same problem...


    AddShopItem( 0, II_SYS_SYS_SCR_SUPERLEADERPARTY );

  12. #12
    ‎‎‎‎ Ketchup is offline
    ModeratorRank
    Jan 2009 Join Date
    1,539Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    Quote Originally Posted by donsito View Post
    I Have the same problem...


    AddShopItem( 0, II_SYS_SYS_SCR_SUPERLEADERPARTY );
    Copy:
    Code:
    __ADDSHOPITEM								
    __VENDOR_UPDATE
    From this source: As Flyff

    Then it'll be:
    Code:
    AddShopItem( TAB, ITEM, COST );

  13. #13
    Registered donsito is offline
    MemberRank
    Jan 2021 Join Date
    13Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    Thanks for the Answer.

    Where i found all the Addshopitem and vendort update codes?

    Only the Mover.pp, Project.cpp, Project.h ?

  14. #14
    ‎‎‎‎ Ketchup is offline
    ModeratorRank
    Jan 2009 Join Date
    1,539Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    Quote Originally Posted by donsito View Post
    Thanks for the Answer.

    Where i found all the Addshopitem and vendort update codes?

    Only the Mover.pp, Project.cpp, Project.h ?
    Searching the source will tell you where they all are.

  15. #15
    Registered donsito is offline
    MemberRank
    Jan 2021 Join Date
    13Posts

    Re: How to make custom shops easily (__ADDSHOPITEM)

    The AsFlyff source have a VersionCommon.h and ServerCommon.h file in _Common Folder.

    i miss both of this files completly in this files.

    So i musst copy this and create this files new? because there are a lot of stuff in there, that are not in the server...


    EDIT: it works! Thank you.
    Last edited by donsito; 06-03-21 at 06:53 PM.



Advertisement