From 4746d2251c6204118e710c818d78b89c356a7427 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 28 Jul 2013 19:15:03 +0200 Subject: Implemented basic eating support. Food is now properly consumed and it takes 1.5 sec. --- source/Items/ItemHandler.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source/Items/ItemHandler.cpp') diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp index d99457029..acb6b6371 100644 --- a/source/Items/ItemHandler.cpp +++ b/source/Items/ItemHandler.cpp @@ -4,6 +4,7 @@ #include "../Item.h" #include "../World.h" #include "../Player.h" +#include "../FastRandom.h" // Handlers: #include "ItemBed.h" @@ -465,15 +466,17 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item) { FoodInfo Info = GetFoodInfo(); - if(Info.FoodLevel > 0 || Info.Saturation > 0.f) + if ((Info.FoodLevel > 0) || (Info.Saturation > 0.f)) { bool Success = a_Player->Feed(Info.FoodLevel, Info.Saturation); - if(Success && Info.PoisionChance > 0) + + // If consumed and there's chance of foodpoisoning, do it: + if (Success && (Info.PoisonChance > 0)) { - MTRand r1; - if((r1.randInt(100) - Info.PoisionChance) <= 0) - { //Unlucky guy :D - //TODO: Make player ill + cFastRandom r1; + if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0) + { + a_Player->FoodPoison(300); } } -- cgit v1.2.3