User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 7 of 11

Thread: Patchless Item Extended Costs

  1. #1
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,536
    XP
    20,135,369
    Level
    500
    Thanks
    1,102
    Thanked 337 Times in 217 Posts

    Patchless Item Extended Costs

    in this tutorial I will briefly explain how to turn this:




    into this:







    On a lot of servers you will see custom ItemExtendedCosts for custom items.
    but many ppl don't want to download a patch when they are just scoping out a server.
    When they try to purchase a custom item it will return a single error of something they don't have and need . But it wont tell you how much of what you need. kind of a pain in the ,, `neck`. so then the player will farm for the honor points since that's all it tells them they need. then what now I need arena? ugh ok off I go to farm arena for a while . now i'm back and what-the... I need an item now!!! ugh you know if it just told me everything I needed in the first place I could just farm for everything first then return to the vendor for my purchase.

    Well I will show you how to make your server do this `Server-Side` in under 5 minutes with some very simple core edits. :D

    We are going to edit \src\server\game\Entities\Player\player.cpp

    so go ahead and open your solution and open player.cpp.

    Then find the function:
    Code:
    
    bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot)
    
    its roughly around line 21,292 about 3/4 of the way down the file.

    We will be working inside this function.

    Scroll down until you find this `if` block:
    Code:
    
    	if (crItem->ExtendedCost)
    
    this is where it will check for the required extended costs:


    Then we will add a line to start off our list of required extended costs :
    Code:
    
            ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
            if (!iece)
            {
                TC_LOG_ERROR("entities.player", "Item %u has wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost);
                return false;
            }
    
    	
    	ChatHandler(GetSession()).PSendSysMessage("The `%s` requires:", pProto->Name1);
    
    
    
    now we will add a detailed response for each Extended Cost requirement.

    for Honor Points price we add a line:
    Code:
    
    		ChatHandler(GetSession()).PSendSysMessage("The `%s` requires:", pProto->Name1);
    
    
    		if ((iece->reqhonorpoints * count) > 0) { ChatHandler(GetSession()).PSendSysMessage("Honor Points - %u/%u", GetHonorPoints(), (iece->reqhonorpoints * count)); };
    		if ((iece->reqarenapoints * count) > 0) { ChatHandler(GetSession()).PSendSysMessage("Arena Points - %u/%u", GetArenaPoints(), (iece->reqarenapoints * count)); };
    		if ((iece->reqpersonalarenarating) > 0) { ChatHandler(GetSession()).PSendSysMessage("Personal Arena Rating - %u/%u", GetMaxPersonalArenaRatingRequirement(iece->reqarenaslot), (iece->reqpersonalarenarating)); };
    	
    		for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
    		{
    			ItemTemplate const* iItem = sObjectMgr->GetItemTemplate(iece->reqitem[i]);
    
    			if (iItem) { ChatHandler(GetSession()).PSendSysMessage("%s - %u/%u", iItem->Name1, GetItemCount(iece->reqitem[i]), (iece->reqitemcount[i] * count)); };
    
    		}
    
    
    		// honor points price
    
    We will keep the responces outside the check so it will allways post what is required and how much even after you have collected enough.

    next we will remark out the center-of-screen response:
    Code:
    
    		// honor points price
    		if (GetHonorPoints() < (iece->reqhonorpoints * count))
    		{
    			//SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL);
    			return false;
    		}
    
    We will next edit Arena Points price the same way by remarking out the center-of-screen alert:
    Code:
    
    		// arena points price
    		if (GetArenaPoints() < (iece->reqarenapoints * count))
    		{
    			//SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL);
    			return false;
    		}
    
    Again we will do the same thing for Pesonal Arena rating:
    Code:
    
    		// check for personal arena rating requirement
    		if (GetMaxPersonalArenaRatingRequirement(iece->reqarenaslot) < iece->reqpersonalarenarating)
    		{
    			// probably not the proper equip err
    			//SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK, NULL, NULL);
    			return false;
    		}
    
    and remark out the center-of-screen alert and change the type of return:
    Code:
    
    		// item base price
    		for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
    		{
    			if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count)))
    			{
    				//SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
    				return false;
    			}
    		}
    





    Now if you would rather it only list what is left to farm then you would add the detailed responces inside the failed check block so only failed to have enough-for-requirement show as we do here with Honor Points Price:
    Code:
    
    		// honor points price
    		if (GetHonorPoints() < (iece->reqhonorpoints * count))
    		{
    			if ((iece->reqhonorpoints * count) > 0){ ChatHandler(GetSession()).PSendSysMessage("%u Honor Points.", (iece->reqhonorpoints * count)); };
    			//SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL);
    			return false;
    		}
    
    For items you would place the 2 lines insode the faild check block like so:
    Code:
    
    		// item base price
    		for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
    		{
    			if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count)))
    			{
    				ItemTemplate const* iItem = sObjectMgr->GetItemTemplate(iece->reqitem[i]);
    				if (iItem){ ChatHandler(GetSession()).PSendSysMessage("%u %s`s.", (iece->reqitemcount[i] * count), iItem->Name1); };
    
    				//SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
    				return false;
    			}
    		}
    



    Now all you need to do is compile your solution and startup your new updated worldserver.exe



    and your players will start seeing:




    Enjoy :D


    yeeaaaa my first tut \o/
    Last edited by slp13at420; 10-07-2016 at 10:37 PM.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  2. The Following 7 Users Say Thank You to slp13at420 For This Useful Post:


  3. #2
    Emulation Addict
    Join Date
    Mar 2016
    Posts
    7
    XP
    699
    Level
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    thanks for share this but i have a problem with this
    i can view the price from the items like you in the screenshots
    the unique problem is that i can't buy items with Price i don't know what i'm doing bad but i can buy items without price
    my rev is 59
    and here the edits
    Code:
    	if (crItem->ExtendedCost)
    	{
    		bool return_type = true;
    
    	    ChatHandler(GetSession()).PSendSysMessage("The `%s` requires:", pProto->Name1);
    
    		ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
    		if (!iece)
    		{
    			TC_LOG_ERROR("entities.player", "Item %u have wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost);
    			return false;
    		}
    
    		// honor points price
    		if ((iece->reqhonorpoints * count) > 0){ ChatHandler(GetSession()).PSendSysMessage("%u Honor Points.", (iece->reqhonorpoints * count)); };
    		if (GetHonorPoints() < (iece->reqhonorpoints * count))
    		{
    			//SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL);
    			//return false;
    			return_type = false;
    		}
    
    		// arena points price
    		if ((iece->reqarenapoints * count) > 0){ ChatHandler(GetSession()).PSendSysMessage("%u Arena Points.", (iece->reqarenapoints * count)); };
    		if (GetArenaPoints() < (iece->reqarenapoints * count))
    		{
    			//SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL);
    			//return false;
    			return_type = false;
    		}
    
    		// item base price
    		for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
    		{
    			ItemTemplate const* iItem = sObjectMgr->GetItemTemplate(iece->reqitem[i]);
    			if (iItem){ ChatHandler(GetSession()).PSendSysMessage("%u %s`s.", (iece->reqitemcount[i] * count), iItem->Name1); };
    
    			if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count)))
    			{
    				//SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
    				//return false;
    				return_type = false;
    			}
    		}
    
    		// check for personal arena rating requirement
    		if ((iece->reqpersonalarenarating) > 0){ ChatHandler(GetSession()).PSendSysMessage("%u Personal Arena Rating.", (iece->reqpersonalarenarating)); };
    		if (GetMaxPersonalArenaRatingRequirement(iece->reqarenaslot) < iece->reqpersonalarenarating)
    		{
    			// probably not the proper equip err
    			//SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK, NULL, NULL);
    			//return false;
    			return_type = false;
    		}
    	    return return_type;
    	}
    
    	uint32 price = 0;
    i dont know what am doing bad :)
    Last edited by slp13at420; 08-21-2016 at 04:08 PM.
    Achievements:
    Member 3 months registered Level V

  4. #3
    Original Poster
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,536
    XP
    20,135,369
    Level
    500
    Thanks
    1,102
    Thanked 337 Times in 217 Posts
    ok updated the tut,. back up, and try again.

    side note - please use code tags next time :) it makes it easier to stand out.
    Last edited by slp13at420; 09-04-2016 at 07:23 PM.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  5. #4
    Emulation Addict
    Join Date
    Mar 2016
    Posts
    7
    XP
    699
    Level
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    oh yeah now it work well thanks for this easy and good tutorial
    now, don't need a ugly patch. for custom prices, you. made my day very happy thanks again and sorry for respond later!

  6. The Following User Says Thank You to damiansp15 For This Useful Post:


  7. #5
    Original Poster
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,536
    XP
    20,135,369
    Level
    500
    Thanks
    1,102
    Thanked 337 Times in 217 Posts
    Quote Originally Posted by damiansp15 View Post
    oh yeah now it work well thanks for this easy and good tutorial
    now, don't need a ugly patch. for custom prices, you. made my day very happy thanks again and sorry for respond later!
    !Awsome! :) glad to hear you got it working :)
    Enjoy :)
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  8. The Following User Says Thank You to slp13at420 For This Useful Post:


  9. #6
    Moderator <span style='color: #FF1493'><span class='glow_000000'>Vitrex</span></span>'s Avatar

    Join Date
    Sep 2013
    Location
    Vilnius , Lithuania
    Posts
    1,068
    XP
    1,001,042
    Level
    174
    Thanks
    286
    Thanked 140 Times in 100 Posts
    Looks cool mate !
    Achievements:
    Shopper Got a Sticky! 1 year registered Member Level XL Level C Referrer
    Awards:
    Raffle Winner Donator Member of Staff Pot Head
    I won't create anything for you, i can only guide you to right direction.
    Don't forget to read rules before posting.
    Forum Rules
    Need and assistance with your issue? use this section to ask for assistance !
    -----
    My Portfolio
    Wanna learn PHP ? check out my One-Page project


  10. The Following User Says Thank You to Vitrex For This Useful Post:


  11. #7
    Original Poster
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,536
    XP
    20,135,369
    Level
    500
    Thanks
    1,102
    Thanked 337 Times in 217 Posts
    Quote Originally Posted by Vitrex View Post
    Looks cool mate !
    Thanx :D
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •