PDA

View Full Version : TrinityCore 3.3.5 Patchless Item Extended Costs



slp13at420
05-08-2016, 09:05 PM
in this tutorial I will briefly explain how to turn this:

http://i.imgur.com/4Wol4Rs.png


into this:

http://i.imgur.com/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:



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:



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 :



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:



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:



// 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:



// 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:



// 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:



// 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:



// 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:



// 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:

http://i.imgur.com/jduVMa4.png


Enjoy :D


yeeaaaa my first tut \o/

damiansp15
08-19-2016, 11:37 AM
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


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 :)

slp13at420
08-21-2016, 02:56 AM
ok updated the tut,. back up, and try again.

side note - please use code tags next time :) it makes it easier to stand out.

damiansp15
09-28-2016, 09:36 AM
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!

slp13at420
09-29-2016, 02:13 AM
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 :)

Vitrex
10-01-2016, 11:02 PM
Looks cool mate !

slp13at420
10-01-2016, 11:37 PM
Looks cool mate !

Thanx :D

darksoke
10-28-2016, 08:41 PM
preety useful but preety rough if you have to enum 100+ extended costs

Tommy
10-30-2016, 04:50 PM
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.

http://image.prntscr.com/image/76c3bb1ec286483bac7e97f735b01866.png

darksoke
11-02-2016, 08:23 AM
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.

http://image.prntscr.com/image/76c3bb1ec286483bac7e97f735b01866.png

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

blackmetal
11-10-2016, 09:41 AM
So good. Loved it :D