• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

TrinityCore 3.3.5 Patchless Item Extended Costs

slp13at420

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

4Wol4Rs.png



into this:

jduVMa4.png





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:
[COLOR="#808080"]
bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot)
[/COLOR]
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:
[COLOR="#808080"]
	if (crItem->ExtendedCost)
[/COLOR]

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:
[COLOR="#808080"]
        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;
        }

[COLOR="#DAA520"]	
	ChatHandler(GetSession()).PSendSysMessage("The `%s` requires:", pProto->Name1);
[/COLOR]

[/COLOR]

now we will add a detailed response for each Extended Cost requirement.

for Honor Points price we add a line:
Code:
[COLOR="#808080"]
		ChatHandler(GetSession()).PSendSysMessage("The `%s` requires:", pProto->Name1);
[COLOR="#DAA520"]

		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)); };

		}
[/COLOR]

		// honor points price
[/COLOR]
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:
[COLOR="#808080"]
		// honor points price
		if (GetHonorPoints() < (iece->reqhonorpoints * count))
		{
			[COLOR="#FFD700"]//[/COLOR]SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL);
			return false;
		}
[/COLOR]

We will next edit Arena Points price the same way by remarking out the center-of-screen alert:
Code:
[COLOR="#808080"]
		// arena points price
		if (GetArenaPoints() < (iece->reqarenapoints * count))
		{
			[COLOR="#FFD700"]//[/COLOR]SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL);
			return false;
		}
[/COLOR]

Again we will do the same thing for Pesonal Arena rating:
Code:
[COLOR="#808080"]
		// check for personal arena rating requirement
		if (GetMaxPersonalArenaRatingRequirement(iece->reqarenaslot) < iece->reqpersonalarenarating)
		{
			// probably not the proper equip err
			[COLOR="#FFD700"]//[/COLOR]SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK, NULL, NULL);
			return false;
		}
[/COLOR]

and remark out the center-of-screen alert and change the type of return:
Code:
[COLOR="#808080"]
		// 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)))
			{
				[COLOR="#FFD700"]//[/COLOR]SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
				return false;
			}
		}
[/COLOR]





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:
[COLOR="#808080"]
		// honor points price
		if (GetHonorPoints() < (iece->reqhonorpoints * count))
		{
			[COLOR="#FFD700"]if ((iece->reqhonorpoints * count) > 0){ ChatHandler(GetSession()).PSendSysMessage("%u Honor Points.", (iece->reqhonorpoints * count)); };[/COLOR]
			//SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL);
			return false;
		}
[/COLOR]

For items you would place the 2 lines insode the faild check block like so:
Code:
[COLOR="#808080"]
		// 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)))
			{
				[COLOR="#FFD700"][/COLOR][COLOR="#FFD700"]ItemTemplate const* iItem = sObjectMgr->GetItemTemplate(iece->reqitem[i]);
				if (iItem){ ChatHandler(GetSession()).PSendSysMessage("%u %s`s.", (iece->reqitemcount[i] * count), iItem->Name1); };[/COLOR]

				[COLOR="#FFD700"]//[/COLOR]SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
				return false;
			}
		}
[/COLOR]



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



and your players will start seeing:

jduVMa4.png



Enjoy :D


yeeaaaa my first tut \o/
 
Last edited:

damiansp15

Emulation Addict
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 a moderator:

slp13at420

Mad Scientist
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:

damiansp15

Emulation Addict
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!
 

Tommy

Founder
preety useful but preety rough if you have to enum 100+ extended costs

True, doing this from code over and over again would get repetitive. You could come up with a small system for it via code for easy additions or you could make specific dbc(s) load from SQL instead for invisible currency and extendedcosts. I did that on ED's server; I made CurrencyTypes.dbc and ItemExtendedCosts.dbc load into the database like Spell.dbc for example and edit it through the DB without problems. The only thing is the currency, since it isn't updated via clientside it will be invisible, but that's no big deal as you can setup a custom error message for all invisible currency you add.

76c3bb1ec286483bac7e97f735b01866.png
 

darksoke

OnTop500
True, doing this from code over and over again would get repetitive. You could come up with a small system for it via code for easy additions or you could make specific dbc(s) load from SQL instead for invisible currency and extendedcosts. I did that on ED's server; I made CurrencyTypes.dbc and ItemExtendedCosts.dbc load into the database like Spell.dbc for example and edit it through the DB without problems. The only thing is the currency, since it isn't updated via clientside it will be invisible, but that's no big deal as you can setup a custom error message for all invisible currency you add.

76c3bb1ec286483bac7e97f735b01866.png

I tought the same actually :)) the concept is useful however :D
 
Top