Smelting Gives Experience (#4094)
* Smelting Exp Smelting now gives experience * Furnace.txt update Exp rewards are entered in furnace.txt, Reward calculation is now done is the furnaceentity class * furnace.txt update Changed alignment tabs to spaces Included documentation of exp in recipe * Updated StringToFloat changed strtod to strtof * Explicit Float to Int * Reworked Smelting Rewards * No C casts -Adds new function to the api -Sets reward counter to 0 in furnace constructor * Style and exp lock removed -Fixed style mistakes accoring to PR notes -XP isn't locked to a single player anymore * No Smelter API -Removed SetLastSmelter and GetLastSmelter -Fixed comments -Fixed log reward amounts
This commit is contained in:
committed by
Alexander Harkness
parent
1e312296cc
commit
a0896c63d7
@@ -32,6 +32,7 @@ cFurnaceEntity::cFurnaceEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, in
|
||||
m_TimeCooked(0),
|
||||
m_FuelBurnTime(0),
|
||||
m_TimeBurned(0),
|
||||
m_RewardCounter(0),
|
||||
m_IsLoading(false)
|
||||
{
|
||||
m_Contents.AddListener(*this);
|
||||
@@ -173,6 +174,23 @@ bool cFurnaceEntity::ContinueCooking(void)
|
||||
|
||||
|
||||
|
||||
int cFurnaceEntity::GetAndResetReward(void)
|
||||
{
|
||||
int Reward = FloorC(m_RewardCounter);
|
||||
float Remainder = m_RewardCounter - static_cast<float>(Reward);
|
||||
// Remainder is used as the percent chance of getting an extra xp point
|
||||
if (GetRandomProvider().RandBool(Remainder))
|
||||
{
|
||||
Reward++;
|
||||
}
|
||||
m_RewardCounter = 0.0;
|
||||
return Reward;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cFurnaceEntity::BroadcastProgress(short a_ProgressbarID, short a_Value)
|
||||
{
|
||||
cWindow * Window = GetWindow();
|
||||
@@ -189,6 +207,7 @@ void cFurnaceEntity::BroadcastProgress(short a_ProgressbarID, short a_Value)
|
||||
void cFurnaceEntity::FinishOne()
|
||||
{
|
||||
m_TimeCooked = 0;
|
||||
m_RewardCounter += m_CurrentRecipe->Reward;
|
||||
|
||||
if (m_Contents.GetSlot(fsOutput).IsEmpty())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user