bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item) { UNUSED(a_Item); FoodInfo Info = GetFoodInfo(); if ((Info.FoodLevel > 0) || (Info.Saturation > 0.f)) { bool Success = a_Player->Feed(Info.FoodLevel, Info.Saturation); // If consumed and there's chance of foodpoisoning, do it: if (Success && (Info.PoisonChance > 0)) { cFastRandom r1; if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0) { a_Player->FoodPoison(300); } } return Success; } return false; }
bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item) { UNUSED(a_Item); if (!a_Player->IsGameModeCreative()) { a_Player->GetInventory().RemoveOneEquippedItem(); } FoodInfo Info = GetFoodInfo(); if ((Info.FoodLevel > 0) || (Info.Saturation > 0.f)) { bool Success = a_Player->Feed(Info.FoodLevel, Info.Saturation); // Give effects cEntityEffect::eType EffectType; int EffectDurationTicks; short EffectIntensity; float Chance; if (Success && GetEatEffect(EffectType, EffectDurationTicks, EffectIntensity, Chance)) { cFastRandom r1; if (r1.NextFloat() < Chance) { a_Player->AddEntityEffect(EffectType, EffectDurationTicks, EffectIntensity, Chance); } } return Success; } return false; }