PDA

View Full Version : Food/Drink Stats - Fixed


trevius
11-24-2008, 06:28 AM
Tonight, I finally got around to looking into why food stats weren't adding to actual stats (shown in #showstats). It turns out that all of the code to calculate food was already there, but the code for calculating item bonuses wasn't allowing food/drink to work.

In bonuses.cpp around line 182, after this:
if (!inst->IsEquipable(GetBaseRace(),GetClass()))
{

Add this line:
if ((!inst->GetItem()->ItemType == ItemTypeFood) && (!inst->GetItem()->ItemType == ItemTypeFood))


And that whole IF should look like this when you are done adding it:

if (!inst->IsEquipable(GetBaseRace(),GetClass()))
{
if ((!inst->GetItem()->ItemType == ItemTypeFood) && (!inst->GetItem()->ItemType == ItemTypeFood))
return;
}

If anyone has any issues with this or thinks it may cause a problem or open possible exploits, let me know. I can't think of any. Also, if someone knows of a better way to write it that might be easier on the CPU, feel free to post it. Otherwise, I will get this added to SVN very soon. And, just in time for Thanksgiving too *WINK*

AndMetal
11-24-2008, 07:25 AM
Tonight, I finally got around to looking into why food stats weren't adding to actual stats (shown in #showstats). It turns out that all of the code to calculate food was already there, but the code for calculating item bonuses wasn't allowing food/drink to work.

In bonuses.cpp around line 182, after this:
if (!inst->IsEquipable(GetBaseRace(),GetClass()))
{

Add this line:
if ((!inst->GetItem()->ItemType == ItemTypeFood) && (!inst->GetItem()->ItemType == ItemTypeFood))


And that whole IF should look like this when you are done adding it:

if (!inst->IsEquipable(GetBaseRace(),GetClass()))
{
if ((!inst->GetItem()->ItemType == ItemTypeFood) && (!inst->GetItem()->ItemType == ItemTypeFood))
return;
}

If anyone has any issues with this or thinks it may cause a problem or open possible exploits, let me know. I can't think of any. Also, if someone knows of a better way to write it that might be easier on the CPU, feel free to post it. Otherwise, I will get this added to SVN very soon. And, just in time for Thanksgiving too *WINK*

I think I would recommend moving that part below where we convert the item instance (inst) to an item (item), that way we basically don't have to convert multiple times:


void Client::AddItemBonuses(const ItemInst *inst, StatBonuses* newbon, bool isAug) {
if(!inst || !inst->IsType(ItemClassCommon))
{
return;
}
if(inst->GetAugmentType()==0 && isAug == true)
{
return;
}

const Item_Struct *item = inst->GetItem();

if (GetLevel() < item->ReqLevel)
{
return;
}
if (!inst->IsEquipable(GetBaseRace(),GetClass()) && item->ItemType != ItemTypeFood && item->ItemType != ItemTypeFood)
{

return;
}

trevius
11-24-2008, 07:53 AM
Ahh lol, good idea! I didn't even notice that conversion was there. Looks like this take a little extra work out of checking req level too :D I will test out the code and see how it goes. If all seems ok, I think this should be ready for adding to SVN at any time.

Though, I think maybe keeping it like this might be slightly better. This way, it doesn't have to check equipable items to see if they are food. Pretty minor, but every bit helps:

const Item_Struct *item = inst->GetItem();

if (GetLevel() < item->ReqLevel)
{
return;
}

if (!inst->IsEquipable(GetBaseRace(),GetClass()))
{
if (item->ItemType != ItemTypeFood && item->ItemType != ItemTypeDrink)
return;
}

Oh, and while looking at the code I submitted above, I can't for the life of me figure out why it is actually working for Drinks too. I checked and confirmed that it is indeed the same code I am running on the server now. And, it is only checking for ItemTypeFood, but doing it twice... And somehow, Drinks still work.

Either way, I will get this tested and submitted tonight if it looks good.

NostalgiaEQ
10-10-2016, 11:55 PM
This is the current server code and it doesn't look like bonus' are working. any thoughts?

const EQEmu::ItemBase *item = inst->GetItem();

if (!isTribute && !inst->IsEquipable(GetBaseRace(), GetClass())) {
if (item->ItemType != EQEmu::item::ItemTypeFood && item->ItemType != EQEmu::item::ItemTypeDrink)
return;

Uleat
10-11-2016, 08:07 PM
I don't think that we handle food/drink correctly...

It will be addressed in the inventory rework since I'm having to rewrite all code that touches items.

NostalgiaEQ
10-12-2016, 12:00 AM
I don't think that we handle food/drink correctly...

It will be addressed in the inventory rework since I'm having to rewrite all code that touches items.

Much appreciated :)