[CPP] Patchless Item Extended Costs
Page 1 of 1
[CPP] 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 in under 5 minutes with some very simple edits.
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:
We will be working inside this function.
Scroll down until you find this if block:
this is where it will check for the required extended costs:
first we are going to change how the returns are handled using a variable.
So at the start of this if block, edit it so it looks like this:
Then we will add a line to start off our list of required extended costs:
now we will add a detailed response for each Extended Cost requirement.
for Honor Points price we add a line:
next we will remark out the center-of-screen response and change the return for Honor Points price:
We will next edit Arena Points price the same way by adding the detailed response , remarking out the center-of-screen alert and changing the style of the return:
Again we will do the same thing for Pesonal Arena rating:
Now item will be handled a little bit differently. We will have to build the template of each item to be able to item->name1 call its name. So inside the loop but before the check we will add 2 lines and remark out the center-of-screen alert and change the type of return:
now last but not least. We must return our return_type variable. this will tell tohe core can it continue yes/no true/false. so at the end of the if block and inside it add 1 line to return the variable:
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:
For items you would place the 2 lines inside the failed check block like so:
Now all you need to do is compile your solution and startup your new updated worldserver.exe
and your players will start seeing:
Enjoy
yeeaaaa my first tut \o/
Grumbo , slp13at420 , cpp , TrinityCore , World of Warcraft , 335a , wotlk
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 in under 5 minutes with some very simple edits.
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)
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:
first we are going to change how the returns are handled using a variable.
So at the start of this if block, edit it so it looks like this:
- Code:
if (crItem->ExtendedCost)
{
bool return_type = true;
Then we will add a line to start off our list of required extended costs:
- 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)
{
now we will add a detailed response for each Extended Cost requirement.
for Honor Points price we add a line:
- Code:
// honor points price
if ((iece->reqhonorpoints * count) > 0){ ChatHandler(GetSession()).PSendSysMessage("%u Honor Points.", (iece->reqhonorpoints * count)); };
if (GetHonorPoints() < (iece->reqhonorpoints * count))
{
next we will remark out the center-of-screen response and change the return for Honor Points price:
- Code:
// 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;
}
We will next edit Arena Points price the same way by adding the detailed response , remarking out the center-of-screen alert and changing the style of the return:
- Code:
// 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;
}
[/COLOR]
Again we will do the same thing for Pesonal Arena rating:
- Code:
// 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;
}
Now item will be handled a little bit differently. We will have to build the template of each item to be able to item->name1 call its name. So inside the loop but before the check we will add 2 lines 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)
{
ItemTemplate const* iItem = sObjectMgr->GetItemTemplate(iece->reqitem[i]);
if (iItem){ ChatHandler(GetSession()).PSendSysMessage("%u %s`s.", (iece->reqitemcount[i] * count), iItem->Name1); };[/COLOR]
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;
}
}
now last but not least. We must return our return_type variable. this will tell tohe core can it continue yes/no true/false. so at the end of the if block and inside it add 1 line to return the variable:
- Code:
}
return return_type;
}
uint32 price = 0;
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;
return_type = false;
}
For items you would place the 2 lines inside the failed 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); };[/COLOR]
//SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
//return false;
return_type = 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
yeeaaaa my first tut \o/
Grumbo , slp13at420 , cpp , TrinityCore , World of Warcraft , 335a , wotlk
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Fri Nov 15, 2019 8:00 pm by Grumbo
» TrinityCore 2 Gold Max Work-Around
Tue Mar 21, 2017 9:14 pm by Grumbo
» [CPP][Conv] Dedicated World Chat Channel
Tue Mar 21, 2017 8:56 pm by Grumbo
» Cool [CPP] Grumbo'z VIP System
Tue Mar 21, 2017 8:03 pm by Grumbo
» [CPP] EmuDevs Premium System
Tue Mar 21, 2017 7:18 pm by Grumbo
» [TC]255 server stats edit! By Frost - Thanx
Tue Mar 21, 2017 6:27 pm by Grumbo
» [Eluna] Grumbo`z VIP System
Tue Mar 21, 2017 6:20 pm by Grumbo
» [CPP] Grumbo'z Capture the Flag System
Tue Mar 21, 2017 5:14 pm by Grumbo
» Black Wolfs Den
Mon Mar 20, 2017 10:07 pm by Grumbo