Esempio n. 1
0
void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
{
	StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5);

	if (m_AttachedTo == NULL)
	{
		if (IsClimbing())
		{
			if (a_DeltaPos.y > 0.0)  // Going up
			{
				m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5));
			}
		}
		else if (IsSubmerged())
		{
			m_Stats.AddValue(statDistDove, Value);
			AddFoodExhaustion(0.00015 * (double)Value);
		}
		else if (IsSwimming())
		{
			m_Stats.AddValue(statDistSwum, Value);
			AddFoodExhaustion(0.00015 * (double)Value);
		}
		else if (IsOnGround())
		{
			m_Stats.AddValue(statDistWalked, Value);
			AddFoodExhaustion((m_IsSprinting ? 0.001 : 0.0001) * (double)Value);
		}
		else
		{
			if (Value >= 25)  // Ignore small/slow movement
			{
				m_Stats.AddValue(statDistFlown, Value);
			}
		}
	}
	else
	{
		switch (m_AttachedTo->GetEntityType())
		{
			case cEntity::etMinecart: m_Stats.AddValue(statDistMinecart, Value); break;
			case cEntity::etBoat:     m_Stats.AddValue(statDistBoat,     Value); break;
			case cEntity::etMonster:
			{
				cMonster * Monster = (cMonster *)m_AttachedTo;
				switch (Monster->GetMobType())
				{
					case cMonster::mtPig:   m_Stats.AddValue(statDistPig,   Value); break;
					case cMonster::mtHorse: m_Stats.AddValue(statDistHorse, Value); break;
					default: break;
				}
				break;
			}
			default: break;
		}
	}
}
Esempio n. 2
0
void cPawn::HandleAir(void)
{
	if (IsSubmerged() && HasEntityEffect(cEntityEffect::effWaterBreathing))
	{
		// Prevent the oxygen from decreasing
		return;
	}

	super::HandleAir();
}
Esempio n. 3
0
void cEntity::HandleAir(void)
{
	// Ref.: http://www.minecraftwiki.net/wiki/Chunk_format
	// See if the entity is /submerged/ water (block above is water)
	// Get the type of block the entity is standing in:

	if (IsSubmerged())
	{
		SetSpeedY(1); // Float in the water

		// Either reduce air level or damage player
		if (m_AirLevel < 1)
		{
			if (m_AirTickTimer < 1)
			{
				// Damage player 
				TakeDamage(dtDrowning, NULL, 1, 1, 0);
				// Reset timer
				m_AirTickTimer = DROWNING_TICKS;
			}
			else
			{
				m_AirTickTimer--;
			}
		}
		else
		{
			// Reduce air supply
			m_AirLevel--;
		}
	}
	else
	{
		// Set the air back to maximum
		m_AirLevel = MAX_AIR_LEVEL;
		m_AirTickTimer = DROWNING_TICKS;
	}
}
Esempio n. 4
0
void cPlayer::HandleAir(void)
{
    // Ref.: http://www.minecraftwiki.net/wiki/Chunk_format
    // see if the player is /submerged/ water (block above is water)
    // Get the type of block the player's standing in:

    if (IsSubmerged())
    {
        // either reduce air level or damage player
        if (m_AirLevel < 1)
        {
            if (m_AirTickTimer < 1)
            {
                // damage player
                TakeDamage(dtDrowning, NULL, 1, 1, 0);
                // reset timer
                m_AirTickTimer = DROWNING_TICKS;
            }
            else
            {
                m_AirTickTimer -= 1;
            }
        }
        else
        {
            // reduce air supply
            m_AirLevel -= 1;
        }
    }
    else
    {
        // set the air back to maximum
        m_AirLevel = MAX_AIR_LEVEL;
        m_AirTickTimer = DROWNING_TICKS;
    }
}