Exemplo n.º 1
0
Player::Player (Game *game) :
_name( "Nameless hero" ),
_level( START_LEVEL ),
_exp(0),
_initiative(0),
_selectedItem( nullptr ),
_target( nullptr ),
_game( game )
{
	_powerups[static_cast<uint8_t>(Powerups::HEALTH)] = 0;
	_powerups[static_cast<uint8_t>(Powerups::MANA)] = 0;
	_powerups[static_cast<uint8_t>(Powerups::DAMAGE)] = 0;
	for (uint8_t i = 0; i < 4; ++i) _inventory[i] = nullptr;
	Field *field = nullptr;
	while (true)
	{
		field = _game->GetBattlefield()->GetRandomField();
		if (field->HaveEnemy() || field->HaveItem() || field->HavePowerup() ) continue;
		break;
	}
	_position = field;

	CalculateStats();
	Heal();
	Recover();
	LookAround();
}
Exemplo n.º 2
0
void cWither::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);
	if (!IsTicking())
	{
		// The base class tick destroyed us
		return;
	}

	if (m_WitherInvulnerableTicks > 0)
	{
		unsigned int NewTicks = m_WitherInvulnerableTicks - 1;

		if (NewTicks == 0)
		{
			m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this);
		}

		m_WitherInvulnerableTicks = NewTicks;

		if ((NewTicks % 10) == 0)
		{
			Heal(10);
		}
	}

	m_World->BroadcastEntityMetadata(*this);
}
Exemplo n.º 3
0
nofPassiveSoldier::nofPassiveSoldier(const nofSoldier& soldier) : nofSoldier(soldier),
    healing_event(0)
{
    // Soldat von einer Mission nach Hause gekommen --> ggf heilen!
    Heal();
    // Laufevent nullen, laufen ja nicht mehr
    current_ev = 0;
}
Exemplo n.º 4
0
void CDestructable::HandleHeal(HOBJECT hSender, HMESSAGEREAD hRead)
{
	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE) return;

	DFLOAT fAmount = pServerDE->ReadFromMessageFloat(hRead);

	Heal(fAmount);
}
Exemplo n.º 5
0
void cPlayer::HandleFood(void)
{
    // Ref.: http://www.minecraftwiki.net/wiki/Hunger

    // Remember the food level before processing, for later comparison
    int LastFoodLevel = m_FoodLevel;

    // Heal or damage, based on the food level, using the m_FoodTickTimer:
    if ((m_FoodLevel > 17) || (m_FoodLevel <= 0))
    {
        m_FoodTickTimer++;
        if (m_FoodTickTimer >= 80)
        {
            m_FoodTickTimer = 0;

            if (m_FoodLevel >= 17)
            {
                // Regenerate health from food, incur 3 pts of food exhaustion:
                Heal(1);
                m_FoodExhaustionLevel += 3;
            }
            else if (m_FoodLevel <= 0)
            {
                // Damage from starving
                TakeDamage(dtStarving, NULL, 1, 1, 0);
            }
        }
    }

    // Apply food poisoning food exhaustion:
    if (m_FoodPoisonedTicksRemaining > 0)
    {
        m_FoodPoisonedTicksRemaining--;
        m_FoodExhaustionLevel += 0.025;  // 0.5 per second = 0.025 per tick
    }

    // Apply food exhaustion that has accumulated:
    if (m_FoodExhaustionLevel >= 4)
    {
        m_FoodExhaustionLevel -= 4;

        if (m_FoodSaturationLevel >= 1)
        {
            m_FoodSaturationLevel -= 1;
        }
        else
        {
            m_FoodLevel = std::max(m_FoodLevel - 1, 0);
        }
    }

    if (m_FoodLevel != LastFoodLevel)
    {
        SendHealth();
    }
}
Exemplo n.º 6
0
void Player::LevelUp()
{
 	while (_exp >= _expMax)
 	{
 	 	_level++;
 	 	_exp -= _expMax;
		CalculateStats();
 	 	Heal();
 	 	Recover();
 	}
}
Exemplo n.º 7
0
void cPlayer::HandleFood(void)
{
	// Ref.: http://www.minecraftwiki.net/wiki/Hunger

	if (IsGameModeCreative())
	{
		// Hunger is disabled for Creative
		return;
	}

	// Apply food exhaustion that has accumulated:
	if (m_FoodExhaustionLevel > 4.0)
	{
		m_FoodExhaustionLevel -= 4.0;

		if (m_FoodSaturationLevel > 0.0)
		{
			m_FoodSaturationLevel = std::max(m_FoodSaturationLevel - 1.0, 0.0);
		}
		else
		{
			SetFoodLevel(m_FoodLevel - 1);
		}
	}

	// Heal or damage, based on the food level, using the m_FoodTickTimer:
	if ((m_FoodLevel >= 18) || (m_FoodLevel <= 0))
	{
		m_FoodTickTimer++;
		if (m_FoodTickTimer >= 80)
		{
			m_FoodTickTimer = 0;

			if ((m_FoodLevel >= 18) && (GetHealth() < GetMaxHealth()))
			{
				// Regenerate health from food, incur 3 pts of food exhaustion:
				Heal(1);
				AddFoodExhaustion(3.0);
			}
			else if ((m_FoodLevel <= 0) && (m_Health > 1))
			{
				// Damage from starving
				TakeDamage(dtStarving, NULL, 1, 1, 0);
			}
		}
	}
	else
	{
		m_FoodTickTimer = 0;
	}
}
Exemplo n.º 8
0
// 080910 LUJ, 데미지 상태 처리를 RESULTINFO 구조체를 받아 처리하도록 함
void CObjectActionManager::ApplyResult(CObject* pObject,CObject* pOperator,RESULTINFO* pRInfo,BYTE DamageKind)
{
	if(pRInfo->RealDamage)
	{
		Damage(pObject,pOperator,DamageKind,pRInfo->RealDamage,*pRInfo);
		if(pObject->IsDied())
			Die(pObject,pOperator,FALSE,pRInfo->bCritical,pRInfo->bDecisive);
	}
	// 100223 ShinJS --- 마나 데미지 추가
	if(pRInfo->ManaDamage)
	{
		ManaDamage(pObject,pOperator,DamageKind,pRInfo->ManaDamage,*pRInfo);
	}
	if(pRInfo->CounterDamage)
	{
		const RESULTINFO emptyResult = { 0 };
		Damage(pOperator,pObject,eDamageKind_Counter,pRInfo->CounterDamage,emptyResult);
		if(pOperator->IsDied())
			Die(pOperator,pObject,FALSE,FALSE,FALSE);
	}
	if(pRInfo->HealLife)
		Heal(pObject,pOperator,DamageKind,pRInfo->HealLife);
	if(pRInfo->RechargeMana)
		Recharge(pObject,pOperator,0,pRInfo->RechargeMana);	
	
	if(pRInfo->StunTime)
	
	if(pRInfo->Vampiric_Life)
	{
		if(pOperator->GetID() == gHeroID)
			HERO->ChangeLife(pRInfo->Vampiric_Life);
		else
			pOperator->SetLife(pOperator->GetLife()+pRInfo->Vampiric_Life);
	}
	
	if(pRInfo->Vampiric_Mana)
	{
		pOperator->SetMana(pOperator->GetMana()+pRInfo->Vampiric_Mana);
	}
}
Exemplo n.º 9
0
void cWither::Tick(float a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);

	if (m_WitherInvulnerableTicks > 0)
	{
		unsigned int NewTicks = m_WitherInvulnerableTicks - 1;

		if (NewTicks == 0)
		{
			m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this);
		}

		m_WitherInvulnerableTicks = NewTicks;

		if ((NewTicks % 10) == 0)
		{
			Heal(10);
		}
	}

	m_World->BroadcastEntityMetadata(*this);
}
Exemplo n.º 10
0
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CScientist :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
	switch( pEvent->event )
	{		
	case SCIENTIST_AE_HEAL:		// Heal my target (if within range)
		Heal();
		break;
	case SCIENTIST_AE_NEEDLEON:
		{
		int oldBody = pev->body;
		pev->body = (oldBody % NUM_SCIENTIST_HEADS) + NUM_SCIENTIST_HEADS * 1;
		}
		break;
	case SCIENTIST_AE_NEEDLEOFF:
		{
		int oldBody = pev->body;
		pev->body = (oldBody % NUM_SCIENTIST_HEADS) + NUM_SCIENTIST_HEADS * 0;
		}
		break;

	default:
		CTalkMonster::HandleAnimEvent( pEvent );
	}
}
Exemplo n.º 11
0
void cWolf::OnRightClicked(cPlayer & a_Player)
{
	const cItem & EquippedItem = a_Player.GetEquippedItem();
	const int EquippedItemType = EquippedItem.m_ItemType;

	if (!IsTame() && !IsAngry())
	{
		// If the player is holding a bone, try to tame the wolf:
		if (EquippedItemType == E_ITEM_BONE)
		{
			if (!a_Player.IsGameModeCreative())
			{
				a_Player.GetInventory().RemoveOneEquippedItem();
			}

			if (GetRandomProvider().RandBool(0.125))
			{
				// Taming succeeded
				SetMaxHealth(20);
				SetIsTame(true);
				SetOwner(a_Player.GetName(), a_Player.GetUUID());
				m_World->BroadcastEntityStatus(*this, esWolfTamed);
				m_World->BroadcastParticleEffect("heart", static_cast<Vector3f>(GetPosition()), Vector3f{}, 0, 5);
			}
			else
			{
				// Taming failed
				m_World->BroadcastEntityStatus(*this, esWolfTaming);
				m_World->BroadcastParticleEffect("smoke", static_cast<Vector3f>(GetPosition()), Vector3f{}, 0, 5);
			}
		}
	}
	else if (IsTame())
	{
		// Feed the wolf, restoring its health, or dye its collar:
		switch (EquippedItemType)
		{
			case E_ITEM_RAW_BEEF:
			case E_ITEM_STEAK:
			case E_ITEM_RAW_PORKCHOP:
			case E_ITEM_COOKED_PORKCHOP:
			case E_ITEM_RAW_CHICKEN:
			case E_ITEM_COOKED_CHICKEN:
			case E_ITEM_ROTTEN_FLESH:
			{
				if (m_Health < m_MaxHealth)
				{
					Heal(ItemHandler(EquippedItemType)->GetFoodInfo(&EquippedItem).FoodLevel);
					if (!a_Player.IsGameModeCreative())
					{
						a_Player.GetInventory().RemoveOneEquippedItem();
					}
				}
				break;
			}
			case E_ITEM_DYE:
			{
				if (a_Player.GetUUID() == m_OwnerUUID)  // Is the player the owner of the dog?
				{
					SetCollarColor(EquippedItem.m_ItemDamage);
					if (!a_Player.IsGameModeCreative())
					{
						a_Player.GetInventory().RemoveOneEquippedItem();
					}
				}
				break;
			}
			default:
			{
				if (a_Player.GetUUID() == m_OwnerUUID)  // Is the player the owner of the dog?
				{
					SetIsSitting(!IsSitting());
				}
			}
		}
	}

	m_World->BroadcastEntityMetadata(*this);
}
Exemplo n.º 12
0
void EnemyKingPumpkin::DeadPlayerAction(){
	Heal(8);
}
Exemplo n.º 13
0
void cPlayer::HandleFood(void)
{
	// Ref.: http://www.minecraftwiki.net/wiki/Hunger
	
	if (IsGameModeCreative())
	{
		// Hunger is disabled for Creative
		return;
	}
	
	// Remember the food level before processing, for later comparison
	int LastFoodLevel = m_FoodLevel;
	
	// Heal or damage, based on the food level, using the m_FoodTickTimer:
	if ((m_FoodLevel > 17) || (m_FoodLevel <= 0))
	{
		m_FoodTickTimer++;
		if (m_FoodTickTimer >= 80)
		{
			m_FoodTickTimer = 0;

			if (m_FoodLevel >= 17)
			{
				// Regenerate health from food, incur 3 pts of food exhaustion:
				Heal(1);
				m_FoodExhaustionLevel += 3;
			}
			else if ((m_FoodLevel <= 0) && (m_Health > 1))
			{
				// Damage from starving
				TakeDamage(dtStarving, NULL, 1, 1, 0);
			}
		}
	}
	
	// Apply food poisoning food exhaustion:
	if (m_FoodPoisonedTicksRemaining > 0)
	{
		m_FoodPoisonedTicksRemaining--;
		m_FoodExhaustionLevel += 0.025;  // 0.5 per second = 0.025 per tick
	}
	else
	{
		m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER); // Remove the "Hunger" effect.
	}

	// Apply food exhaustion that has accumulated:
	if (m_FoodExhaustionLevel >= 4)
	{
		m_FoodExhaustionLevel -= 4;

		if (m_FoodSaturationLevel >= 1)
		{
			m_FoodSaturationLevel -= 1;
		}
		else
		{
			m_FoodLevel = std::max(m_FoodLevel - 1, 0);
		}
	}
	
	if (m_FoodLevel != LastFoodLevel)
	{
		SendHealth();
	}
}
Exemplo n.º 14
0
//-----------------------------------------------------------------------------
//! 更新(コマンドによって変わる)(今はかわらない)
//-----------------------------------------------------------------------------
void AllyHealer::UpdateByCommand()
{

	//---- プレイヤー情報取得
	Player*	pPlayer   = IObjDataManager()->_pPlayer;
	Vector3 playerPos = pPlayer->getPosition();

	// 回復中なら更新しない
	if( !_isHeal ) {
		// ターゲットの検索、設定
		if( searchAndSetTarget() )
		{
			// ターゲットが見つからなければ
			_keyUpdate = false;
		}
	}


	s32	currentAnimation = _pTaskModel->getAnimation();
		
	// プレイヤーの周りにいるならば
	if( _keyUpdate ){
		
		// キーの更新
		_key->Update();

		// 角度を求める
		// 3D上ではxzの順番で角度が求められる
		Vector3	StickState = _key->getVector();
	
		// ヒールコマンドがONならヒールする
		if( _key->getPushState("Heal") )
		{
			// 攻撃アニメーション再生(1はヒール)
			_pTaskModel->setAnimation(_aniHeal);
		}else if ( currentAnimation == _aniHeal ) {
			// ヒール再生中なら
			// 再生比率取得
			f32	aniRate = _pTaskModel->getAnimationRate();
			// 再生が半分いったら
			if( aniRate >= 0.1f && !_isHeal) {
				// ヒール
				Heal(_target);
			}
		}else{
			_isHeal = false;
		}


		// 移動があれば更新
		if( abs(atan2f(StickState._x, StickState._z) ) > 0.0f )
		{
			_rotation._y = atan2f( StickState._x, StickState._z );
			Status::Param* myParam = _myStatus->getParam();
			_speed = myParam->_speedMAX;
		}else{
			_speed = 0.0f;
		}

	} else {
		// それ以外は通常通り
		UpdateNormal(playerPos);
	}

	// 当たり判定処理とダメージ計算
	s32 damage = calcDamageAndCollision();


	if( damage > 0 ) {
		// ダメージ処理
		Damage(damage);
		_pTaskModel->setAnimation(_aniDamage);
	}else if( currentAnimation == _aniDamage ){
		_isDamage = false;
	}
	_pTaskModel->update();
}
Exemplo n.º 15
0
void CDestructable::Reset()
{
	AddWard(m_fMaxArmorPoints);
	Heal(m_fMaxHitPoints);
}