예제 #1
0
파일: GCastle.cpp 프로젝트: daoopp/WebGame
void GCastle::ReceveAttack(gint32 iDamage)
{
	if( mCastleStateFlag == eDestroy )
		return;
	
	mCurrentHP -= iDamage;
	if( GetCurrentHP() <= 0 )
	{
		mCastleStateFlag = eDestroy;
		SetCurrentState();
		return;
	}
	else if( GetCurrentHP() < GetHP() / 2 )
	{
		mCastleStateFlag = eBreak;
		SetCurrentState();
	}	
	GetCastleGege()->SetProgressPercent( (float)GetCurrentHP() / (float)GetHP() * 100.0f );
	
	if( mIsDamage == false )
	{
		mIsDamage = true;
		mpTopDamageEffect->SetVisible( true );
		mpBottomDamageEffect->SetVisible( true );
		GnTimeController::StartTimeControllers( mpTopDamageEffect );
		GnTimeController::StartTimeControllers( mpBottomDamageEffect );
	}
}
예제 #2
0
VOID Obj_Monster::SendCharBaseDirectForHP()
{
	__ENTER_FUNCTION
	GCCharBaseAttrib msgPublicAttr;
	GCCharBaseAttrib msgProtectedAttr;

	BYTE yHPPercent = (GetMaxHP())?((BYTE)((GetHP()*100 + GetMaxHP() - 1)/GetMaxHP())):(0);

	msgPublicAttr.setObjID( GetID() );
	msgPublicAttr.setHPPercent( yHPPercent );
	msgProtectedAttr.setObjID( GetID() );
	msgProtectedAttr.setHPPercent( yHPPercent );
	m_AttrBackUp.m_HP = GetHP();
	
	if (GetHP() <= 0) // add by gh 2010/04/09 
	{
		BYTE yMPPercent = (GetMaxMP())?((BYTE)((GetMP()*100 + GetMaxMP() - 1)/GetMaxMP())):(0); 
		msgPublicAttr.setMPPercent( yMPPercent );
		m_AttrBackUp.m_MP = GetMP();
	} // end of add

	HUMANLIST listHuman;
	getScene()->ScanHuman( getZoneID(), MAX_REFESH_OBJ_ZONE_RADIUS, &(listHuman) );

	BYTE i;
	for ( i = 0; i < listHuman.m_Count; i++ )
	{
		Obj_Human *pTargetHuman = listHuman.m_aHuman[i];
		if ( IsCanViewMe( pTargetHuman ) )
		{
			ENUM_REFESH_ATTR_TYPE eType = CalcRefeshAttrType( this, pTargetHuman );
			switch( eType )
			{
			case REFESH_ATTR_TYPE_NONE:
				break;
			case REFESH_ATTR_TYPE_PUBLIC:
			case REFESH_ATTR_TYPE_PUBLIC_AND_LEVEL:
				{
					pTargetHuman->GetPlayer()->SendPacket( &msgPublicAttr );
				}
				break;
			case REFESH_ATTR_TYPE_PROTECTED:
				{
					pTargetHuman->GetPlayer()->SendPacket( &msgProtectedAttr );
				}
				break;
			default:
				break;
			}
		}
	}
	__LEAVE_FUNCTION
}
void CEnemy::Render(void)
{
	CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();

	if(GetHP() > 0)
		pTM->Draw(GetImageID(),GetPosX(),GetPosY(),1,1,NULL,GetWidth() / 2, GetHeight() /2,3.14f,D3DCOLOR_XRGB(255,255,255));
}
예제 #4
0
VOID Obj_Monster::InitBackupAttr()
{
__ENTER_FUNCTION

	m_AttrBackUp.m_bNameModified		= FALSE;
	m_AttrBackUp.m_bTitleModified		= FALSE;
	m_AttrBackUp.m_HP					= GetHP();
	m_AttrBackUp.m_MP					= GetMP();	//	add by gh 2010/03/25
	const _CAMP_DATA *pCampData = GetCampData();
	if ( pCampData != NULL )
		m_AttrBackUp.m_CampData			= *pCampData;
	m_AttrBackUp.m_MaxHp				= GetMaxHP();
	m_AttrBackUp.m_MaxMp				= GetMaxMP();	//	add by gh 2010/03/25
	m_AttrBackUp.m_MoveSpeed			= GetMoveSpeed();
	m_AttrBackUp.m_nDataID				= GetDataID();
	m_AttrBackUp.m_nModelID				= GetModelID();
	m_AttrBackUp.m_nMountID				= GetMountID();
	m_AttrBackUp.m_nAIType				= GetAIType();
	m_AttrBackUp.m_OwnerID				= GetOwnerID();
	m_AttrBackUp.m_OccupantGUID			= GetOccupantGUID();
	m_AttrBackUp.m_nStealthLevel		= GetStealthLevel();
	m_AttrBackUp.m_nMoodState			= GetMoodState();
	m_AttrBackUp.m_iHorseID				= GetHorseID();
	m_AttrBackUp.m_iWeaponID			= GetWeaponID();
__LEAVE_FUNCTION
}
예제 #5
0
void ZModule_HPAP::OnDamage(MUID uidAttacker,int damage, float fRatio)
{
	m_LastAttacker = uidAttacker;

#ifndef _PUBLISH
	if (CheckQuestCheet() == true) return;
#endif

	if(m_bRealDamage)
	{
		ZObject* pAttacker = ZGetObjectManager()->GetObject(uidAttacker);
		if ((pAttacker) && (!IsPlayerObject(pAttacker)))
		{
			ZActor* pActor = (ZActor*)pAttacker;
			damage = (int)(damage * (pActor->GetQL() * 0.2f + 1));
		}

		int nHPDamage = (int)((float)damage * fRatio);
		int nAPDamage = damage - nHPDamage;

		if ((GetAP() - nAPDamage) < 0)
		{
			nHPDamage += (nAPDamage - GetAP());
			nAPDamage -= (nAPDamage - GetAP());
		}

		SetHP(GetHP() - nHPDamage);
		SetAP(GetAP() - nAPDamage);
	}
}
예제 #6
0
bool Player::LevelUp()
{
	if (GetXP() < GetXPToLevelUp(level + 1))
		return false;

	level++;

	unsigned int statIncreases[3] = { 0, 0, 0 };
	float statMultipliers[3] = { 0, 0, 0 };
	statMultipliers[0] = 13.0f;
	statMultipliers[1] = className == "Fighter" ? 8.0f : 6.0f;
	statMultipliers[2] = className == "Rogue" ? 8.0f : 6.0f;

	for (int i = 0; i < 3; i++)
	{
		float base = std::tanh(level / 30.0) * ((level % 2) + 1);
		statIncreases[i] += static_cast<int>(1 + statMultipliers[i] * base);
	}

	SetHP(GetHP() + statIncreases[0]);
	SetMaxHP(GetMaxHP() + statIncreases[0]);
	SetStrength(GetStrength() + statIncreases[1]);
	SetAgility(GetAgility() + statIncreases[2]);

	std::cout << GetName() << " grew to level " << level << "!\n";
	std::cout << "Health   +" << statIncreases[0] << " -> " << GetMaxHP() << std::endl;
	std::cout << "Strength +" << statIncreases[1] << " -> " << GetStrength() << std::endl;
	std::cout << "Agility  +" << statIncreases[2] << " -> " << GetAgility() << std::endl;
	std::cout << "----------------\n";

	return true;
}
예제 #7
0
파일: Ship.cpp 프로젝트: abiles/BattleShip
HitResult Ship::CheckAttack(ShipPos attackedPos)
{
	_ASSERT(attackedPos.x < MAX_HORIZONTAL && attackedPos.x >= HORIZONTAL_ZERO);
	_ASSERT(attackedPos.y < MAX_VERTICAL && attackedPos.y >= VERTICAL_ZERO);
	if (!(attackedPos.x < MAX_HORIZONTAL &&
		attackedPos.x >= HORIZONTAL_ZERO))
	{
		return HIT_NONE;
	}
	if (!(attackedPos.y < MAX_VERTICAL &&
		attackedPos.y >= VERTICAL_ZERO))
	{
		return HIT_NONE;
	}

	for (int i = 0; i < GetSize(); ++i)
	{
		if (GetPos(i).x == attackedPos.x && GetPos(i).y == attackedPos.y)
		{
			HitResultApply();

			if (GetHP() == 0)
			{
				return DESTROY;
			}
			return HIT;
		}
	}

	return HIT_NONE;
}
예제 #8
0
void Shielder::Update()
{
    fixed s = _power ? M_PT_ZERO_ONE * 12 : M_PT_ZERO_ONE * 4;
    Rotate( s );
    GetShape( 9 ).Rotate( -2 * s );
    for ( int i = 0; i < 8; i++ )
        GetShape( i ).Rotate( -s );

    bool onScreen = false;
    if ( GetPosition()._x < 0 )
        _dir.Set( 1, 0 );
    else if ( GetPosition()._x > Lib::WIDTH )
        _dir.Set( -1, 0 );
    else if ( GetPosition()._y < 0 )
        _dir.Set( 0, 1 );
    else if ( GetPosition()._y > Lib::HEIGHT )
        _dir.Set( 0, -1 );
    else
        onScreen = true;

    if ( !onScreen && _rotate ) {
        _timer = 0;
        _rotate = false;
    }

    fixed speed = SPEED + ( _power ? M_PT_ONE * 3 : M_PT_ONE * 2 ) * ( 16 - GetHP() );
    if ( _rotate ) {
        Vec2 d( _dir );
        d.Rotate( ( _rDir ? 1 : -1 ) * ( TIMER - _timer ) * M_PI / ( M_TWO * TIMER ) );
        _timer--;
        if ( _timer <= 0 ) {
            _timer = 0;
            _rotate = false;
            _dir.Rotate( ( _rDir ? 1 : -1 ) * M_PI / M_TWO );
        }
        Move( d * speed );
    }
    else {
        _timer++;
        if ( _timer > TIMER * 2 ) {
            _timer = TIMER;
            _rotate = true;
            _rDir = GetLib().RandInt( 2 ) != 0;
        }
        if ( IsOnScreen() && _timer % TIMER == TIMER / 2 && _power ) {
            Player* p = GetNearestPlayer();
            Vec2 v = GetPosition();

            Vec2 d = p->GetPosition() - v;
            d.Normalise();
            Spawn( new SBBossShot( v, d * M_THREE, 0x33cc99ff ) );
            PlaySoundRandom( Lib::SOUND_BOSS_FIRE );
        }
        Move( _dir * speed );
    }
    _dir.Normalise();

}
예제 #9
0
void Wall::Update()
{
    if ( GetNonWallCount() == 0 && _timer % 8 < 2 ) {
        if ( GetHP() > 2 )
            PlaySound( Lib::SOUND_ENEMY_SPAWN );
        Damage( GetHP() - 2, false, 0 );
    }

    if ( _rotate ) {
        Vec2 d( _dir );
        d.Rotate( ( _rdir ? _timer - TIMER : TIMER - _timer ) * M_PI / ( M_FOUR * TIMER ) );
        SetRotation( d.Angle() );
        _timer--;
        if ( _timer <= 0 ) {
            _timer = 0;
            _rotate = false;
            _dir.Rotate( _rdir ? -M_PI / M_FOUR : M_PI / M_FOUR );
        }
        return;
    }
    else {
        _timer++;
        if ( _timer > TIMER * 6 ) {
            if ( IsOnScreen() ) {
                _timer = TIMER;
                _rotate = true;
            }
            else
                _timer = 0;
        }
    }

    Vec2 pos = GetPosition();
    if ( ( pos._x < 0 && _dir._x < -M_PT_ZERO_ONE ) ||
         ( pos._y < 0 && _dir._y < -M_PT_ZERO_ONE ) ||
         ( pos._x > Lib::WIDTH && _dir._x > M_PT_ZERO_ONE ) ||
         ( pos._y > Lib::HEIGHT && _dir._y > M_PT_ZERO_ONE ) ) {
        _dir = Vec2() - _dir;
        _dir.Normalise();
    }

    Move( _dir * SPEED );
    SetRotation( _dir.Angle() );
}
void CEnemyDemon::Render(void)
{
    CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();

    if(GetHP() > 0)
    {
        if (GetXFlip() == 1)
            pTM->Draw(GetImageID(),GetCollisionRect().left, GetCollisionRect().top, GetXFlip() * 1.5f,1.5f,&rEnemyRect,GetWidth() / 2, GetHeight() /2,0.0f,D3DCOLOR_XRGB(255,255,255));
        else if (GetXFlip() == -1)
            pTM->Draw(GetImageID(),GetCollisionRect().right, GetCollisionRect().top, GetXFlip() * 1.5f,1.5f,&rEnemyRect,GetWidth() / 2, GetHeight() /2,0.0f,D3DCOLOR_XRGB(255,255,255));
        //	pTM->Draw(GetImageID(),GetPosX() - GetWidth()/4, GetPosY() - GetHeight()/4, GetXFlip() * 1.5f,1.5f,&rEnemyRect,GetWidth() / 2, GetHeight() /2,0.0f,D3DCOLOR_XRGB(255,255,255));
    }
}
void CEnemyBusiness::Render(void)
{
	CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();
	CSGD_Direct3D *p3D = CSGD_Direct3D::GetInstance();
	CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();

	RECT r = GetCollisionRect();

	if(GetHP() > 0)
	{
		if (GetXFlip() == 1)
			pTM->Draw(GetImageID(),GetCollisionRect().left + m_nOffset, GetCollisionRect().top, GetXFlip() * 1.5f,1.5f,&rEnemyRect,GetWidth() / 2, GetHeight() /2,0.0f,D3DCOLOR_XRGB(255,255,255));
		else if (GetXFlip() == -1)
			pTM->Draw(GetImageID(),GetCollisionRect().right - m_nOffset, GetCollisionRect().top, GetXFlip() * 1.5f,1.5f,&rEnemyRect,GetWidth() / 2, GetHeight() /2,0.0f,D3DCOLOR_XRGB(255,255,255));
	}

}
예제 #12
0
void CPatroller::OnCollision()
{
	auto atk = task->GetComponent<CPlayerAttack>(CGameManager::Attack, 0);
	auto pos = (task->GetComponent<CScroll>(CGameManager::Scroll, 0)->transform.GetPos());
	auto patroller = task->GetComponent<CPatroller>(CEnemyManager::Patroller, 0);

	if (Collision::RectToRect(patroller->transform.GetPos() - pos, patroller->transform.GetScale(), atk->transform.GetPos(), atk->transform.GetScale())
		&& atk->isCollision)
	{
		patroller->HitAttack();
	}
	if (patroller->GetHP() <= 0)
	{
		state = State::None;
	}
	if (state == State::None)
	{
		atk->isEnemys[CPlayerAttack::EnemyName::Patroller] = true;
	}
}
예제 #13
0
void CTatteredId::OnCollision()
{
	auto atk = task->GetComponent<CPlayerAttack>(CGameManager::Attack, 0);
	auto pos = (task->GetComponent<CScroll>(CGameManager::Scroll, 0)->transform.GetPos());
	auto TatteredId = task->GetComponent<CTatteredId>(CEnemyManager::TatteredId, 0);

	if (Collision::RectToRect(TatteredId->transform.GetPos() - pos, TatteredId->transform.GetScale(), atk->transform.GetPos(), atk->transform.GetScale())
		&& atk->isCollision)
	{
		TatteredId->HitAttack();
	}
	if (TatteredId->GetHP() <= 0)
	{
		state = State::None;
	}
	if (state == State::None)
	{
		atk->isEnemys[CPlayerAttack::EnemyName::TatteredId] = true;
	}
}
//Alive flag
BOOL Obj_Character::IsAlive(VOID)
{
	if(0>=GetHP())
	{
		return FALSE;
	}
	if(TRUE==GetAliveDirtyFlag())
	{
		BOOL bValue = TRUE;
		if(TRUE==Impact_GetBoolAttrRefix(CharBoolAttrs_T::ATTR_ALIVE, bValue))
		{
			SetBoolAttr(CharBoolAttrs_T::ATTR_ALIVE, bValue);
		}
		else
		{
			SetBoolAttr(CharBoolAttrs_T::ATTR_ALIVE, TRUE);
		}
		ClearAliveDirtyFlag();
	}
	return GetBoolAttr(CharBoolAttrs_T::ATTR_ALIVE);
}
void CEnemyDemon::Update(float fElapsedTime)
{

    CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
    CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
    CGame *theGame = CGame::GetInstance();

    SetPosX(GetPosX() + GetVelX() * fElapsedTime);
    SetPosY(GetPosY() + GetVelY() * fElapsedTime);

    rCollisionRect.left = GetPosX();
    rCollisionRect.right = GetPosX() + GetWidth();
    rCollisionRect.top = GetPosY();
    rCollisionRect.bottom = GetPosY() + GetWidth();
    SetCollisionRect(rCollisionRect);

    if (GetPosX() < -32)
    {
        SetVelX(abs(GetVelX() * -1));
        SetXFlip(-abs(GetXFlip() * -1));
    }
    else if (GetPosX() > 640)
    {
        SetVelX(-abs(GetVelX() * -1));
        SetXFlip(abs(GetXFlip() * -1));
    }
    else if (GetPosY() > 480)
        SetVelY(-abs(GetVelY() * -1));
    else if (GetPosY() < -32)
        SetVelY(abs(GetVelY() * -1));


    DWORD timer = GetTickCount();

    if (abs(GetPosX() - CPlayerCharacter::GetInstance()->GetPosX()) < 128 && abs(GetPosY() - CPlayerCharacter::GetInstance()->GetPosY()) < 128)
        bIsClose = true;
    else
        bIsClose = false;

    if (!bIsClose)
    {
        if (timer % 525 <= 75)
        {
            rEnemyRect.left = 0;
            rEnemyRect.right = 48;
        }
        else if (timer % 525 > 75 && timer % 525 <= 150)
        {
            rEnemyRect.left = 51;
            rEnemyRect.right = 90;
        }
        else if (timer % 525 > 150 && timer % 525 <= 225)
        {
            rEnemyRect.left = 93;
            rEnemyRect.right = 138;
        }
        else if (timer % 525 > 225 && timer % 525 <= 300)
        {
            rEnemyRect.left = 142;
            rEnemyRect.right = 185;
        }
        else if (timer % 525 > 300 && timer % 525 <= 375)
        {
            rEnemyRect.left = 188;
            rEnemyRect.right = 234;
        }
        else if (timer % 525 > 375 && timer % 525 <= 450)
        {
            rEnemyRect.left = 237;
            rEnemyRect.right = 282;
        }
        else if (timer % 525 > 450)
        {
            rEnemyRect.left = 286;
            rEnemyRect.right = 332;
        }
    }
    else if (bIsClose)
    {
        if (timer % 600 <= 75)
        {
            rEnemyRect.left = 335;
            rEnemyRect.right = 372;
        }
        else if (timer % 600 > 75 && timer % 600 <= 150)
        {
            rEnemyRect.left = 375;
            rEnemyRect.right = 407;
        }
        else if (timer % 600 > 150 && timer % 600 <= 225)
        {
            rEnemyRect.left = 410;
            rEnemyRect.right = 445;
        }
        else if (timer % 600 > 225 && timer % 600 <= 300)
        {
            rEnemyRect.left = 448;
            rEnemyRect.right = 481;
        }
        else if (timer % 600 > 300 && timer % 600 <= 375)
        {
            rEnemyRect.left = 484;
            rEnemyRect.right = 515;
        }
        else if (timer % 600 > 375 && timer % 600 <= 450)
        {
            rEnemyRect.left = 518;
            rEnemyRect.right = 554;
            CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);

        }
        else if (timer % 600 > 450 && timer % 600 <= 525)
        {
            rEnemyRect.left = 558;
            rEnemyRect.right = 592;
        }
        else if (timer % 600 > 525)
        {
            rEnemyRect.left = 595;
            rEnemyRect.right = 636;
        }
    }
    SetHit(false);

    if (GetHP() <= 0)
    {
        CSGD_EventSystem::GetInstance()->SendEvent("spawn powerups", NULL);
        pMS->SendMsg(new CDestroyMessage(this));
    }

}
예제 #16
0
파일: exp.cpp 프로젝트: josheb/emu_dc
void Client::SetLevel(uint8 set_level, bool command)
{
        if (GetEXPForLevel(set_level) == 0xFFFFFFFF) {
                LogFile->write(EQEMuLog::Error,"Client::SetLevel() GetEXPForLevel(%i) = 0xFFFFFFFF", set_level);
                return;
        }

        EQApplicationPacket* outapp = new EQApplicationPacket(OP_LevelUpdate, sizeof(LevelUpdate_Struct));
        LevelUpdate_Struct* lu = (LevelUpdate_Struct*)outapp->pBuffer;
        lu->level = set_level;
        if(m_pp.level2 != 0)
                lu->level_old = m_pp.level2;
        else
                lu->level_old = level;

        level = set_level;

        if(IsRaidGrouped())
        {
                Raid *r = this->GetRaid();
                if(r){
                        r->UpdateLevel(GetName(), set_level);
                }
        }
        if(set_level > m_pp.level2)
        {
                if(m_pp.level2 == 0)
                        m_pp.points += 5;
                else
                        m_pp.points += (5 * (set_level - m_pp.level2));

                m_pp.level2 = set_level;
        }
        if(set_level > m_pp.level) {
            parse->EventPlayer(EVENT_LEVEL_UP, this, "", 0);
        }

        m_pp.level = set_level;
        if (command){
                m_pp.exp = GetEXPForLevel(set_level);
                Message(15, "Welcome to level %i!", set_level);
                lu->exp = 0;
        }
        else {
                float tmpxp = (float) ( (float) m_pp.exp - GetEXPForLevel( GetLevel() )) /
                                                ( (float) GetEXPForLevel(GetLevel()+1) - GetEXPForLevel(GetLevel()));
                lu->exp =  (uint32)(330.0f * tmpxp);
    }
        QueuePacket(outapp);
        safe_delete(outapp);
        this->SendAppearancePacket(AT_WhoLevel, set_level); // who level change

		LogFile->write(EQEMuLog::Normal,"Setting Level for %s to %i", GetName(), set_level);

        CalcBonuses();
        if(!RuleB(Character, HealOnLevel))
        {
                int mhp = CalcMaxHP();
                if(GetHP() > mhp)
                        SetHP(mhp);
        }
        else
        {
                SetHP(CalcMaxHP());             // Why not, lets give them a free heal
        }
		
		DoTributeUpdate();
        SendHPUpdate();
        SetMana(CalcMaxMana());
        UpdateWho();
		if(GetMerc())
			UpdateMercLevel();
        Save();
}
예제 #17
0
VOID Obj_Monster::SendMsg_RefeshAttrib( VOID )
{
__ENTER_FUNCTION

	BOOL bPublicAttrModified ;
	bPublicAttrModified		= FALSE;

	GCCharBaseAttrib msgPublicAttr, msgProtectedAttr;

	msgPublicAttr.setObjID( GetID() );
	msgProtectedAttr.setObjID( GetID() );

	//msgPublicAttr.setName( GetName() );
	//msgProtectedAttr.setName( GetName() );

	//msgPublicAttr.setTitle( GetTitle() );
	//msgProtectedAttr.setTitle( GetTitle() );

	if(m_AttrBackUp.m_HP != GetHP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_HP = GetHP();

		BYTE yHPPercent = (GetMaxHP())?((BYTE)((GetHP()*100 + GetMaxHP() - 1)/GetMaxHP())):(0);
		msgPublicAttr.setHPPercent( yHPPercent );
		msgProtectedAttr.setHPPercent( yHPPercent );
	}

	if(m_AttrBackUp.m_MaxHp != GetMaxHP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MaxHp = GetMaxHP();

		BYTE yHPPercent = (GetMaxHP())?((BYTE)((GetHP()*100 + GetMaxHP() - 1)/GetMaxHP())):(0);
		msgPublicAttr.setHPPercent( yHPPercent );
		msgProtectedAttr.setHPPercent( yHPPercent );
	}

	// add by gh 2010/03/30
	if(m_AttrBackUp.m_MP != GetMP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MP = GetMP();

		BYTE yMPPercent = (GetMaxMP())?((BYTE)((GetMP()*100 + GetMaxMP() - 1)/GetMaxMP())):(0);
		msgPublicAttr.setMPPercent( yMPPercent );
		msgProtectedAttr.setMPPercent( yMPPercent );
	}

	if(m_AttrBackUp.m_MaxMp != GetMaxMP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MaxMp = GetMaxMP();

		BYTE yMPPercent = (GetMaxMP())?((BYTE)((GetMP()*100 + GetMaxMP() - 1)/GetMaxMP())):(0);
		msgPublicAttr.setMPPercent( yMPPercent );
		msgProtectedAttr.setMPPercent( yMPPercent );
	}
	// end of add
	if(fabs(m_AttrBackUp.m_MoveSpeed-GetMoveSpeed()) > 0.001f)
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MoveSpeed = GetMoveSpeed();

		msgPublicAttr.setMoveSpeed( GetMoveSpeed() );
		msgProtectedAttr.setMoveSpeed( GetMoveSpeed() );
	}

	if(m_AttrBackUp.m_nDataID != GetDataID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nDataID = GetDataID();

	}

	const _CAMP_DATA *pCampData = GetCampData();
	if ( pCampData != NULL )
	{
		if(m_AttrBackUp.m_CampData != *pCampData)
		{
			bPublicAttrModified = TRUE;
			m_AttrBackUp.m_CampData = *pCampData;

			msgPublicAttr.setCampData( pCampData );
			msgProtectedAttr.setCampData( pCampData );
		}
	}

	if(m_AttrBackUp.m_OwnerID != GetOwnerID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_OwnerID = GetOwnerID();

		msgPublicAttr.setOwnerID( GetOwnerID() );
		msgProtectedAttr.setOwnerID( GetOwnerID() );
	}

	if(m_AttrBackUp.m_OccupantGUID != GetOccupantGUID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_OccupantGUID = GetOccupantGUID();

		msgPublicAttr.setOccupantGUID( GetOccupantGUID() );
		msgProtectedAttr.setOccupantGUID( GetOccupantGUID() );
	}

	if(m_AttrBackUp.m_nModelID != GetModelID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nModelID = GetModelID();
		msgPublicAttr.setModelID( GetModelID() );
		msgProtectedAttr.setModelID( GetModelID() );
	}

	if(m_AttrBackUp.m_nMountID != GetMountID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nMountID = GetMountID();
		msgPublicAttr.setMountID( GetMountID() );
		msgProtectedAttr.setMountID( GetMountID() );
	}

	if (m_AttrBackUp.m_nAIType != GetAIType() )
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nAIType = GetAIType();
		INT nRet = GetMonsterAIType();
		msgPublicAttr.setAIType(nRet);
		msgProtectedAttr.setAIType(nRet);
	}

	if(m_AttrBackUp.m_nStealthLevel != GetStealthLevel())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nStealthLevel = GetStealthLevel();

		msgPublicAttr.setStealthLevel( GetStealthLevel() );
		msgProtectedAttr.setStealthLevel( GetStealthLevel() );
	}

	if(m_AttrBackUp.m_nMoodState != GetMoodState())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nMoodState = GetMoodState();

		msgPublicAttr.setMoodState( GetMoodState() );
		msgProtectedAttr.setMoodState( GetMoodState() );
	}

	//if( m_AttrBackUp.m_iWeaponID != GetWeaponID() )
	//{
	//	bPublicAttrModified = TRUE;
	//	m_AttrBackUp.m_iWeaponID = GetWeaponID();
	//	//msgPublicAttr.setWeaponID( m_AttrBackUp.m_iWeaponID );
	//	msgProtectedAttr.setWeaponID( m_AttrBackUp.m_iWeaponID );
	//}

	if( m_AttrBackUp.m_iHorseID != GetHorseID() )
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_iHorseID = GetHorseID();
		msgPublicAttr.setMountID( m_AttrBackUp.m_iHorseID );
		msgProtectedAttr.setMountID( m_AttrBackUp.m_iHorseID );
	}

	if ( bPublicAttrModified )
	{
		if ( bPublicAttrModified )
		{
			m_PublicAttrVersion++;
		}

		if ( bPublicAttrModified || m_ProtectedAttrVersion )
		{
			m_ProtectedAttrVersion++;
		}

		HUMANLIST listHuman;
		getScene()->ScanHuman( getZoneID(), MAX_REFESH_OBJ_ZONE_RADIUS, &(listHuman) );

		BOOL bSendPublicMsg				= bPublicAttrModified;
		BOOL bSendProtectedMsg			= (BOOL)(bPublicAttrModified || m_ProtectedAttrVersion);
		BYTE i;
		for ( i = 0; i < listHuman.m_Count; i++ )
		{
			Obj_Human *pTargetHuman = listHuman.m_aHuman[i];
			if ( IsCanViewMe( pTargetHuman ) )
			{
				ENUM_REFESH_ATTR_TYPE eType = CalcRefeshAttrType( this, pTargetHuman );
				switch( eType )
				{
				case REFESH_ATTR_TYPE_NONE:
					break;
				case REFESH_ATTR_TYPE_PUBLIC:
				case REFESH_ATTR_TYPE_PUBLIC_AND_LEVEL:
					if ( bSendPublicMsg )
					{
						pTargetHuman->GetPlayer()->SendPacket( &msgPublicAttr );
					}
					break;
				case REFESH_ATTR_TYPE_PROTECTED:
					if ( bSendProtectedMsg )
					{
						pTargetHuman->GetPlayer()->SendPacket( &msgProtectedAttr );
					}
					break;
				default:
					break;
				}
			}
		}
	}

__LEAVE_FUNCTION
}
BOOL Obj_Character::IsAliveInDeed(VOID)
{
	return 0<GetHP();
}
예제 #19
0
void ZModule_HPAP::OnDamage(MUID uidAttacker,float fDamage, float fRatio)
{
	_ASSERT(fDamage >= 0);
	if (fDamage < 0) fDamage *= -1.f;	// 해킹으로 음수대미지를 넣어서 회복할 수 있으므로..

	m_LastAttacker = uidAttacker;

	// 퀘스트 테스트용 치트 체크
#ifndef _PUBLISH
	if (CheckQuestCheet() == true) return;
#endif
	//jintriple3 디버그 레지스터 핵 방지 코드
	//내 캐릭터가 아니거나 npc가 아니면....
	//m_bRealDamage의 경우 내 클라이언트에서 실제로 데미지를 적용하나 안하나를 체크하는 변수.
	//MyCharacter 이거나 NPC만 내 클라이언트에서 데미지 적용.
	if(!m_bRealDamage.Ref())	
		PROTECT_DEBUG_REGISTER(!m_bRealDamage_DebugRegister)	//이걸 위해 새로운 변수 하나 더 사용.
			return;

	// NPC의 난이도 조절계수때문에 넣음
	ZObject* pAttacker = ZGetObjectManager()->GetObject(uidAttacker);
	if ((pAttacker) && (!IsPlayerObject(pAttacker)))
	{
		ZActor* pActor = (ZActor*)pAttacker;
		//fDamage = (int)(fDamage * (pActor->GetTC()));
		fDamage = fDamage * (pActor->GetQL() * 0.2f + 1);
	}

	// 내가 죽기전까지 얻은 데미지를 누적한다(일단 듀얼토너먼트 전용임)
	if(IsAccumulationDamage())
	{
		AccumulateDamage(fDamage);
#ifndef _PUBLISH	// 내부빌드에서 누적 대미지 정보 출력
		char szAccumulationDamagePrint[256];
		sprintf(szAccumulationDamagePrint, "피해 당한 누적대미지[%2.1f]", GetAccumulationDamage());
		ZChatOutput(MCOLOR(255, 200, 100), szAccumulationDamagePrint);
#endif
	}


	float fHPDamage = (float)((float)fDamage * fRatio);
	float fAPDamage = fDamage - fHPDamage;

	if ((GetAP() - fAPDamage) < 0)
	{
		fHPDamage += (fAPDamage - GetAP());
		fAPDamage -= (fAPDamage - GetAP());
	}

	SetHP(GetHP() - fHPDamage);
	SetAP(GetAP() - fAPDamage);
	
//jintriple3
/*	if(m_bRealDamage)
	{
		// NPC의 난이도 조절계수때문에 넣음
		ZObject* pAttacker = ZGetObjectManager()->GetObject(uidAttacker);
		if ((pAttacker) && (!IsPlayerObject(pAttacker)))
		{
			ZActor* pActor = (ZActor*)pAttacker;
			//damage = (int)(damage * (pActor->GetTC()));
			damage = (int)(damage * (pActor->GetQL() * 0.2f + 1));
		}*/

/*
		float fHPDamage = 0, fAPDamage = 0;

		fHPDamage = damage * fRatio;
		fAPDamage = damage * (1.0f - fRatio);

*/
	//jintripl3
/*
		int nHPDamage = (int)((float)damage * fRatio);
		int nAPDamage = damage - nHPDamage;

		if ((GetAP() - nAPDamage) < 0)
		{
			nHPDamage += (nAPDamage - GetAP());
			nAPDamage -= (nAPDamage - GetAP());
		}

		SetHP(GetHP() - nHPDamage);
		SetAP(GetAP() - nAPDamage);
	}*/
}
예제 #20
0
void CObject_Appletree::Update()
{
	Center = WorldX + GetWidth()/2;
	SetAttackBox(0, 0, 0, 0);

	if(HeroForEnemy->GetWorldX()+100 < Center && !b_Attack)	// Hero가 왼쪽에 있을 때
	{
		b_left = true;
		b_right = false;
	}
	else if(HeroForEnemy->GetWorldX()+100 > Center && !b_Attack)
	{
		b_left = false;
		b_right = true;
	}

	// 인식범위 설정
	int RcnzX = Center;
	if(b_left) {
		RcnzX -= RecognizeRange;
	}
	else if(b_right) {
		RcnzX += RecognizeRange;
	}
	
	// 공격범위 설정
	int AtkX = Center;
	if(b_left) {
		AtkX -= AttackRange;
	}
	else if(b_right) {
		AtkX += AttackRange;
	}

	// 인식범위 내에서의 행동따윈 필요없다.

	// 공격범위 내에서의 행동
	if(GetHP() > 0)
	{
		if(HeroForEnemy->GetWorldX()+100 > AtkX && b_left)
		{
			if(AttackCount == -1 ) {
				SetAttack(true);
				AttackCount = 0;
			}
			if(Poison->GetCount() >= 1 && Poison->GetCount() <= 2) {
				SetAttackBox((int)GetDrawX()+30, (int)GetDrawY()+250, 191, 220);
			}

			for(int i=0; i<2; i++)
			{
				if(Break[i]->GetCount() >=1 && Break[i]->GetCount() <= 3) {
					SetAttackBox((int)GetDrawX()+25, (int)GetDrawY()+400, 180, 100);
				}
			}

			b_apple[0] = true;
		}
		else if(HeroForEnemy->GetWorldX()+100 < AtkX && b_right)
		{
			if(AttackCount == -1 ) {
				SetAttack(true);
				AttackCount = 0;
			}
			if(Poison->GetCount() >= 1 && Poison->GetCount() <= 2) {
				SetAttackBox((int)GetDrawX()+30, (int)GetDrawY()+250, 250, 220);
			}
			
		}

		if(AttackCount != -1) {
			AttackCount++;
		}
		
		if(Poison->GetCount() >= 6) {
			Poison->SetCount(0);
			SetAttack(false);
		}
		

		if(AttackCount > AttackDelay) {
			AttackCount = -1;
			Poison->SetCount(0);
			SetAttack(false);
		}
	}



	
	// 충돌박스 설정
	SetBoundBox((int)GetDrawX()+100, (int)GetDrawY()+50, 158, 400);
	
	// Hero와의 충돌판정
	if(GetHP() > 0)
	{
		if(CCollision::GetCollision()->Box_n_Box(
			HeroForEnemy->GetBoundX()-1, HeroForEnemy->GetBoundY(), HeroForEnemy->GetBoundX()+HeroForEnemy->GetBoundWidth()+1, HeroForEnemy->GetBoundY()+HeroForEnemy->GetBoundHeight(),
			GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()))
		{
			if(HeroForEnemy->GetWorldX()+100 < Center)	// Hero가 왼쪽에 있을 때
			{
				//HeroForEnemy->MoveTo(GetWorldX() + (int)((GetWidth()-GetBoundWidth())/2) - HeroForEnemy->GetWidth() + (int)((HeroForEnemy->GetWidth() - HeroForEnemy->GetBoundWidth())/2), HeroForEnemy->GetWorldY());
				HeroForEnemy->MoveTo(GetWorldX() + (int)((GetWidth()-GetBoundWidth())/2) - 115, HeroForEnemy->GetWorldY());
			}
			
			else if(HeroForEnemy->GetWorldX()+100 >= Center)	// Hero가 오른쪽에 있을 때
			{
				HeroForEnemy->MoveTo(GetWorldX() + GetWidth() - (int)((GetWidth()-GetBoundWidth())/2) - (int)((HeroForEnemy->GetWidth()-HeroForEnemy->GetBoundWidth())/2), HeroForEnemy->GetWorldY());
			}
			
		}
	}

	
	// Hero에게 공격판정
	if(CCollision::GetCollision()->Box_n_Box(
		HeroForEnemy->GetBoundX(), HeroForEnemy->GetBoundY(), HeroForEnemy->GetBoundX()+HeroForEnemy->GetBoundWidth(), HeroForEnemy->GetBoundY()+HeroForEnemy->GetBoundHeight(),
		GetAttackX(), GetAttackY(), GetAttackX()+GetAttackWidth(), GetAttackY()+GetAttackHeight()))
	{
		if(!HeroForEnemy->GetHit())
		{
			int dmg = (int)GetDmg();
			if(b_left)
			{
				if(HeroForEnemy->GetWay() == 1 && HeroForEnemy->GetGuard()) {
					dmg = (int)(dmg * 0.3f);
					HeroForEnemy->SetGuardHit(TRUE);
				}
			}
			else if(b_right)
			{
				if(HeroForEnemy->GetWay() == 0 && HeroForEnemy->GetGuard()) {
					dmg = (int)(dmg * 0.3f);
					HeroForEnemy->SetGuardHit(TRUE);
				}
			}
			HeroForEnemy->SetHP(HeroForEnemy->GetHP() - dmg);
			HeroForEnemy->SetHit(true);
			//SetAttack(false);
			if(HeroKnockbackCount == -1)
			{
				HeroKnockbackCount = 0;
			}
		}
	}
	
	// 넉백
	if(HeroKnockbackCount != -1)
	{
		if(HeroForEnemy->GetWorldX()+100 < Center)		// Hero가 왼쪽에 있을 때
		{
			if(HeroForEnemy->GetGuard()) {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()-2, HeroForEnemy->GetWorldY());
			}
			else {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()-3, HeroForEnemy->GetWorldY());
			}
		}
		else if(HeroForEnemy->GetWorldX()+100 > Center)	// Hero가 오른쪽에 있을 때
		{
			if(HeroForEnemy->GetGuard()) {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()+2, HeroForEnemy->GetWorldY());
			}
			else {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()+3, HeroForEnemy->GetWorldY());
			}
		}

		if(HeroKnockbackCount >= 15) {
			HeroKnockbackCount = -1;
			Hit->SetCount(0);
		}
		else {
			HeroKnockbackCount++;
		}
	}
	
	// Hero에게 피격판정
	if(GetHP() > 0)
	{
		if(CCollision::GetCollision()->Box_n_Box(
			HeroForEnemy->GetAttackX(), HeroForEnemy->GetAttackY(), HeroForEnemy->GetAttackX()+HeroForEnemy->GetAttackWidth(), HeroForEnemy->GetAttackY()+HeroForEnemy->GetAttackHeight(),
			GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()) ||
			CCollision::GetCollision()->Box_n_Box(
			HeroForEnemy->GetSkillX(), HeroForEnemy->GetSkillY(), HeroForEnemy->GetSkillX()+HeroForEnemy->GetSkillWidth(), HeroForEnemy->GetSkillY()+HeroForEnemy->GetSkillHeight(),
			GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()) )
		{
			b_apple[1] = true;
			Poison->SetCount(0);
			SetHit(true);
			if(HitCount == -1) {
				HitCount = 0;

				SetHP(GetHP() - HeroForEnemy->GetDmg());
			}

			if(KnockbackCount == -1) {
				KnockbackCount = 0;
			}
		}
		/*
		if(KnockbackCount != -1)
		{
			if(HeroForEnemy->GetWorldX()+100 < Center)		// Hero가 왼쪽에 있을 때
			{
				MoveTo(GetWorldX()+2, GetWorldY());

			}
			else if(HeroForEnemy->GetWorldX()+100 > Center)	// Hero가 오른쪽에 있을 때
			{
				MoveTo(GetWorldX()-2, GetWorldY());
			}

			if(KnockbackCount >= 10) {
				KnockbackCount = -1;
			}
			else {
				KnockbackCount++;
			}
		}

		if(GetHP() <= 0)
		{
			HeroForEnemy->SetExp(HeroForEnemy->GetExp() + GetExp());
		}
		*/
		if(HitCount >= 0)
		{
			HitCount++;
			if(HitCount >= 20) {
				HitCount = -1;
				SetHit(false);
				//HitEffect->SetCount(0);
			}
		}
	}
	/*
	// 벽
	if(GetWorldX() < -76)
	{
		WorldX = -76;
	}
	*/
	if(GetHP() < 0)
	{
		Opacity -= 6;
		b_Move = false;
		b_Attack = false;
	}
}
예제 #21
0
bool CHARACTER::UpdateAffect()
{
	// affect_event 에서 처리할 일은 아니지만, 1초짜리 이벤트에서 처리하는 것이
	// 이것 뿐이라 여기서 물약 처리를 한다.
	if (GetPoint(POINT_HP_RECOVERY) > 0)
	{
		if (GetMaxHP() <= GetHP())
		{
			PointChange(POINT_HP_RECOVERY, -GetPoint(POINT_HP_RECOVERY));
		}
		else
		{
			int iVal = 0;

			if (LC_IsYMIR())
			{
				iVal = MIN(GetPoint(POINT_HP_RECOVERY), GetMaxHP() * 9 / 100);
			}
			else
			{
				iVal = MIN(GetPoint(POINT_HP_RECOVERY), GetMaxHP() * 7 / 100);
			}

			PointChange(POINT_HP, iVal);
			PointChange(POINT_HP_RECOVERY, -iVal);
		}
	}

	if (GetPoint(POINT_SP_RECOVERY) > 0)
	{
		if (GetMaxSP() <= GetSP())
			PointChange(POINT_SP_RECOVERY, -GetPoint(POINT_SP_RECOVERY));
		else 
		{
			int iVal;

			if (!g_iUseLocale)
				iVal = MIN(GetPoint(POINT_SP_RECOVERY), GetMaxSP() * 7 / 100);
			else
				iVal = MIN(GetPoint(POINT_SP_RECOVERY), GetMaxSP() * 7 / 100);

			PointChange(POINT_SP, iVal);
			PointChange(POINT_SP_RECOVERY, -iVal);
		}
	}

	if (GetPoint(POINT_HP_RECOVER_CONTINUE) > 0)
	{
		PointChange(POINT_HP, GetPoint(POINT_HP_RECOVER_CONTINUE));
	}

	if (GetPoint(POINT_SP_RECOVER_CONTINUE) > 0)
	{
		PointChange(POINT_SP, GetPoint(POINT_SP_RECOVER_CONTINUE));
	}

	AutoRecoveryItemProcess( AFFECT_AUTO_HP_RECOVERY );
	AutoRecoveryItemProcess( AFFECT_AUTO_SP_RECOVERY );

	// 스테미나 회복
	if (GetMaxStamina() > GetStamina())
	{
		int iSec = (get_dword_time() - GetStopTime()) / 3000;
		if (iSec)
			PointChange(POINT_STAMINA, GetMaxStamina()/1);    
	}


	// ProcessAffect는 affect가 없으면 true를 리턴한다.
	if (ProcessAffect())
		if (GetPoint(POINT_HP_RECOVERY) == 0 && GetPoint(POINT_SP_RECOVERY) == 0 && GetStamina() == GetMaxStamina())
		{
			m_pkAffectEvent = NULL;
			return false;
		}

	return true;
}
예제 #22
0
파일: exp.cpp 프로젝트: regneq/Server
void Client::SetLevel(uint8 set_level, bool command)
{
	if (GetEXPForLevel(set_level) == 0xFFFFFFFF) {
		Log.Out(Logs::General, Logs::Error, "Client::SetLevel() GetEXPForLevel(%i) = 0xFFFFFFFF", set_level);
		return;
	}

	EQApplicationPacket* outapp = new EQApplicationPacket(OP_LevelUpdate, sizeof(LevelUpdate_Struct));
	LevelUpdate_Struct* lu = (LevelUpdate_Struct*)outapp->pBuffer;
	lu->level = set_level;
	if(m_pp.level2 != 0)
		lu->level_old = m_pp.level2;
	else
		lu->level_old = level;

	level = set_level;

	if(IsRaidGrouped()) {
		Raid *r = this->GetRaid();
		if(r){
			r->UpdateLevel(GetName(), set_level);
		}
	}
	if(set_level > m_pp.level2) {
		if(m_pp.level2 == 0)
			m_pp.points += 5;
		else
			m_pp.points += (5 * (set_level - m_pp.level2));

		m_pp.level2 = set_level;
	}
	if(set_level > m_pp.level) {
		parse->EventPlayer(EVENT_LEVEL_UP, this, "", 0);
		/* QS: PlayerLogLevels */
		if (RuleB(QueryServ, PlayerLogLevels)){
			std::string event_desc = StringFormat("Leveled UP :: to Level:%i from Level:%i in zoneid:%i instid:%i", set_level, m_pp.level, this->GetZoneID(), this->GetInstanceID());
			QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc); 
		}
	}
	else if (set_level < m_pp.level){
		/* QS: PlayerLogLevels */
		if (RuleB(QueryServ, PlayerLogLevels)){
			std::string event_desc = StringFormat("Leveled DOWN :: to Level:%i from Level:%i in zoneid:%i instid:%i", set_level, m_pp.level, this->GetZoneID(), this->GetInstanceID());
			QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc);
		}
	}

	m_pp.level = set_level;
	if (command){
		m_pp.exp = GetEXPForLevel(set_level);
		Message(CC_Yellow, "Welcome to level %i!", set_level);
		lu->exp = 0;
	}
	else {
		float tmpxp = (float) ( (float) m_pp.exp - GetEXPForLevel( GetLevel() )) / ( (float) GetEXPForLevel(GetLevel()+1) - GetEXPForLevel(GetLevel()));
		lu->exp = (uint32)(330.0f * tmpxp);
	}
	QueuePacket(outapp);
	safe_delete(outapp);
	this->SendAppearancePacket(AT_WhoLevel, set_level); // who level change

	Log.Out(Logs::General, Logs::Normal, "Setting Level for %s to %i", GetName(), set_level);

	CalcBonuses();

	if(!RuleB(Character, HealOnLevel)) {
		int mhp = CalcMaxHP();
		if(GetHP() > mhp)
			SetHP(mhp);
	}
	else {
		SetHP(CalcMaxHP()); // Why not, lets give them a free heal
	}
	if(!RuleB(Character, ManaOnLevel))
	{
		int mp = CalcMaxMana();
		if(GetMana() > mp)
			SetMana(mp);
	}
	else
	{
		SetMana(CalcMaxMana()); // Why not, lets give them a free heal
	}

	SendHPUpdate();
	SendManaUpdate();
	UpdateWho();
	Save();
}
void CEnemyBusiness::Update(float fElapsedTime)
{

	CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
	CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
	CSGD_EventSystem *pES= CSGD_EventSystem::GetInstance();
	CGame *theGame = CGame::GetInstance();

	SetPosX(GetPosX() + GetVelX() * fElapsedTime);
	SetPosY(GetPosY() + GetVelY() * fElapsedTime);

	rCollisionRect.left = GetPosX();
	rCollisionRect.right = GetPosX() + GetWidth();
	rCollisionRect.top = GetPosY();
	rCollisionRect.bottom = GetPosY() + GetHeight();
	SetCollisionRect(rCollisionRect);

	DWORD timer = GetTickCount();

	if (GetHit())
	{
		m_nOffset = 32;
		m_fHitTimer = 1.0f;
		SetVelX(0);
		rEnemyRect.left = 442;
		rEnemyRect.right = 463;
	}

	else if (!GetHit() && m_fHitTimer <= 0)
	{
		m_nOffset = 0;
		m_fFireReady -= fElapsedTime;
		SetVelX(GetXFlip() * -100);
		if (timer % 700 <= 100)
		{
			rEnemyRect.left = 2;
			rEnemyRect.right = 54;
		}
		else if (timer % 700 > 100 && timer % 700 <= 200)
		{
			rEnemyRect.left = 58;
			rEnemyRect.right = 115;
		}
		else if (timer % 700 > 200 && timer % 700 <= 300)
		{
			rEnemyRect.left = 119;
			rEnemyRect.right = 163;
		}
		else if (timer % 700 > 300 && timer % 700 <= 400)
		{
			rEnemyRect.left = 700;
			rEnemyRect.right = 753;
		}
		else if (timer % 700 > 400 && timer % 700 <= 500)
		{
			rEnemyRect.left = 756;
			rEnemyRect.right = 795;
		}
		else if (timer % 700 > 500 && timer % 700 <= 600)
		{
			rEnemyRect.left = 798;
			rEnemyRect.right = 850;
		}
		else if (timer % 700 > 600)
		{
			rEnemyRect.left = 853;
			rEnemyRect.right = 899;
		}
	}

	if (m_fFireReady <=0 && !GetHit() && GetHP() > 0)
		pES->SendEvent("businessman fire",&fElapsedTime);

	if (bIsFiring)
	{
		rEnemyRect.left = 329;
		rEnemyRect.right = 397;
		m_fFiringTimer -= fElapsedTime;
		SetVelX(0);
	}

	if (m_fFiringTimer <= 0)
	{
		bIsFiring = false;
		m_fFiringTimer = 1.0f;
	}

	if (GetPosX() < -32)
	{
		SetVelX(abs(GetVelX() * -1));
		SetXFlip(-abs(GetXFlip() * -1));
	}
	else if (GetPosX() > 640)
	{
		SetVelX(-abs(GetVelX() * -1));
		SetXFlip(abs(GetXFlip() * -1));
	}
	else if (GetPosY() > 480)
		SetVelY(-abs(GetVelY() * -1));
	else if (GetPosY() < -32)
		SetVelY(abs(GetVelY() * -1));

	m_fHitTimer -= fElapsedTime;

	SetHit(false);

	if (GetHP() <= 0)
	{
		CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);

		CSGD_EventSystem::GetInstance()->SendEvent("spawn powerups", NULL);
		pMS->SendMsg(new CDestroyMessage(this));

	}

}
예제 #24
0
//--------------------------------------------------------------------------------------------------
void Be5::DoAction4(BeUnit* Unit, BRect dest)
{//dynamite
	BBitmap* Frame[9];
	Frame[0] = GetAnim(Type, 2, 0, PlayerColor); //placement ->
	Frame[1] = GetAnimFlip(Type, 2, 0, PlayerColor); //placement <-
	Frame[2] = GetAnim(Type, 0, 2, PlayerColor); //protect himself
	Frame[3] = GetAnimFlip(Type, 7, 0, PlayerColor); //dynamite 1
	Frame[4] = GetAnimFlip(Type, 8, 0, PlayerColor); //dynamite 2
	Frame[5] = GetAnimFlip(Type, 9, 0, PlayerColor); //dynamyte 3
	Frame[6] = GetAnimFlip(Type, 10, 0, PlayerColor); //explosion
	Frame[7] = GetAnim(Type, 2, 0, PlayerColor);
	Frame[8] = GetAnim(Type, 4, 1, PlayerColor);
	
	int direction;
	BRect Target = dest;

	if(Position.left > dest.left || dest.left == 0)
	{dest.OffsetBy(32,0); direction = 1;}
	
	else
	{dest.OffsetBy(-32,0); direction = 0;}

	DoAction1(this, dest);
	BBitmap* idle = CurrentImage;
	CurrentImage = Frame[7];
	Update(Position); 
	snooze(SPEED * 2);

	SEffect()->Position = Position; 
	SEffect()->CurrentImage = Frame[8];
	SEffect()->Valid = true;

	rgb_color c;
	for(int a = 15; a != 255; a+=16)
	{
		for(int i = 0; i < 32; i++)
			for(int j = 0; j < 32; j++)
			{
				c = ((rgb_color *)SEffect()->CurrentImage->Bits())[(i*32 + j)];
				if(!(c.red == 255 && c.green == 0 && c.blue == 255))
					((rgb_color *)SEffect()->CurrentImage->Bits())[(i*32 + j)].alpha = a;
			}
		Update(Position);
		snooze((int)(SPEED/2));
	}

	//place dynamite
	SEffect()->CurrentImage = Frame[3];
	SEffect()->Position = Target;
	SEffect()->Update(Target);

	CurrentImage = Frame[0+direction];
	Update(Position); //back idle
	snooze(SPEED*2); 

	SEffect()->CurrentImage = Frame[4];
	SEffect()->Update(Target);
	snooze(SPEED*4);

	//protect himself
	CurrentImage = Frame[2];
	Update(Position); 
	snooze(SPEED*2); 

	SEffect()->CurrentImage = Frame[5];
	SEffect()->Update(Target);
	snooze(SPEED*4);

	SEffect()->CurrentImage = Frame[6];
	Unit->Hit(!((bool) direction));
	Update(Target); 
	snooze(SPEED*4);

	SEffect()->Position = Position;
	Hit(!((bool) direction));
	Update(Position); 
	snooze(SPEED*2);

	SEffect()->Valid = false;
	CurrentImage = idle; 
	Update(Target);
	Update(Position);

	Unit->SetHP(-Unit->GetHP()); //Max dammage 
	SetHP(-GetHP());

	//clean up
	delete Frame[0];
	delete Frame[1];
	delete Frame[2];
	delete Frame[3];
	delete Frame[4];
	delete Frame[5];
	delete Frame[6];
	delete Frame[7];
	delete Frame[8];
}
void CEnemyPsycrow::Update(float fElapsedTime)
{
	COptions *op = COptions::GetInstance();
	CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
	CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
	CSGD_EventSystem *pES= CSGD_EventSystem::GetInstance();
	CGame *theGame = CGame::GetInstance();

	if (m_nState % 2 == 0)
	{
		SetVelY(sin(m_fSineFloat) * 50 * op->GetDifficulty() * (m_nState + 0.5));
		rEnemyRect.top = 507;
		rEnemyRect.bottom = 561;
		rEnemyRect.left = 584;
		rEnemyRect.right = 650;

		if (!bIsFiring)
			m_fFireReady -= fElapsedTime;
		
		if (m_fFireReady <= 0)
			bIsFiring = true;

		if (bIsFiring)
		{
			m_fFiringTimer -= fElapsedTime;
			if (m_fFiringTimer <= 0.5f && m_fFiringTimer > 0.4f)
			{
				rEnemyRect.top = 507;
				rEnemyRect.bottom = 561;
				rEnemyRect.left = 494;
				rEnemyRect.right = 566;
				if (!bIsFired)
				{
					pES->SendEvent("psycrow fire", NULL);
					bIsFired = true;

				}
			}
			else if (m_fFiringTimer <= 0.4f && m_fFiringTimer > 0.3f)
			{
				rEnemyRect.top = 507;
				rEnemyRect.bottom = 567;
				rEnemyRect.left = 790;
				rEnemyRect.right = 856;
			}
			else if (m_fFiringTimer <= 0.3f && m_fFiringTimer > 0.2f)
			{
				rEnemyRect.top = 511;
				rEnemyRect.bottom = 564;
				rEnemyRect.left = 873;
				rEnemyRect.right = 935;
			}
			else if (m_fFiringTimer <= 0.2f && m_fFiringTimer > 0.1f)
			{
				rEnemyRect.top = 581;
				rEnemyRect.bottom = 641;
				rEnemyRect.left = 502;
				rEnemyRect.right = 573;
			}
			else if (m_fFiringTimer <= 0.1f)
			{
				rEnemyRect.top = 579;
				rEnemyRect.bottom = 639;
				rEnemyRect.left = 601;
				rEnemyRect.right = 673;
				bIsFiring = false;
				bIsFired = false;
				m_fFireReady = 5.0f;
				m_fFiringTimer = 0.5f;
			}

		}
	}
	else if (m_nState % 2 == 1)
	{
		rEnemyRect.top = 666;
		rEnemyRect.bottom = 726;
		DWORD timer = GetTickCount();
		if (timer % 300 <= 100)
		{
			rEnemyRect.left = 494;
			rEnemyRect.right = 533;
		}
		else if (timer % 300 > 100 && timer % 300 <= 200)
		{
			rEnemyRect.left = 542;
			rEnemyRect.right = 581;
		}
		else if (timer % 300 > 200)
		{
			rEnemyRect.left = 591;
			rEnemyRect.right = 630;
		}
	}

	if (GetHP() < op->GetDifficulty() * 200 && m_nState == PSYCROW_STATE1)
	{
		rEnemyRect.top = 674;
		rEnemyRect.bottom = 726;
		m_fHitTimer -= fElapsedTime;
		if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f)
		{
			CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);
			rEnemyRect.left = 649;
			rEnemyRect.right = 708;
		}
		else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f)
		{
			rEnemyRect.left = 719;
			rEnemyRect.right = 772;
		}
		else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f)
		{
			rEnemyRect.left = 787;
			rEnemyRect.right = 844;
		}
		else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f)
		{
			rEnemyRect.left = 861;
			rEnemyRect.right = 912;
		}

		if (m_fHitTimer < 0)
			pES->SendEvent("state transition 1");
	}
	if (GetHP() < op->GetDifficulty() * 150 && m_nState == PSYCROW_STATE2)
	{
		rEnemyRect.top = 674;
		rEnemyRect.bottom = 726;
		m_fHitTimer -= fElapsedTime;
		if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f)
		{
			CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);
			rEnemyRect.left = 649;
			rEnemyRect.right = 708;
		}
		else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f)
		{
			rEnemyRect.left = 719;
			rEnemyRect.right = 772;
		}
		else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f)
		{
			rEnemyRect.left = 787;
			rEnemyRect.right = 844;
		}
		else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f)
		{
			rEnemyRect.left = 861;
			rEnemyRect.right = 912;
		}

		if (m_fHitTimer < 0)
			pES->SendEvent("state transition 2");
	}
	if (GetHP() < op->GetDifficulty() * 100 && m_nState == PSYCROW_STATE3)
	{
		rEnemyRect.top = 674;
		rEnemyRect.bottom = 726;
		m_fHitTimer -= fElapsedTime;
		if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f)
		{
			CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);
			rEnemyRect.left = 649;
			rEnemyRect.right = 708;
		}
		else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f)
		{
			rEnemyRect.left = 719;
			rEnemyRect.right = 772;
		}
		else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f)
		{
			rEnemyRect.left = 787;
			rEnemyRect.right = 844;
		}
		else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f)
		{
			rEnemyRect.left = 861;
			rEnemyRect.right = 912;
		}

		if (m_fHitTimer < 0)
			pES->SendEvent("state transition 3");
	}
	if (GetHP() < op->GetDifficulty() * 50 && m_nState == PSYCROW_STATE4)
	{
		rEnemyRect.top = 674;
		rEnemyRect.bottom = 726;
		m_fHitTimer -= fElapsedTime;
		if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f)
		{
			CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);
			rEnemyRect.left = 649;
			rEnemyRect.right = 708;
		}
		else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f)
		{
			rEnemyRect.left = 719;
			rEnemyRect.right = 772;
		}
		else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f)
		{
			rEnemyRect.left = 787;
			rEnemyRect.right = 844;
		}
		else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f)
		{
			rEnemyRect.left = 861;
			rEnemyRect.right = 912;
		}

		if (m_fHitTimer < 0)
			pES->SendEvent("state transition 4");
	}
	if (GetHP() <= 0 && m_nState == PSYCROW_STATE5)
	{
		pMS->SendMsg(new CDestroyMessage(this));
	}

	if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX())
		SetXFlip(-1);
	else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX())
		SetXFlip(1);

	SetPosX(GetPosX() + GetVelX() * fElapsedTime);
	SetPosY(GetPosY() + GetVelY() * fElapsedTime);

	if (m_fSineFloat <= -3.14f)
		m_fSineFloat = 3.14f;

	m_fSineFloat -= fElapsedTime;

	rCollisionRect.left = GetPosX();
	rCollisionRect.right = GetPosX() + GetWidth();
	rCollisionRect.top = GetPosY();
	rCollisionRect.bottom = GetPosY() + GetHeight();
	SetCollisionRect(rCollisionRect);

	if (GetPosX() < -32)
	{
		SetVelX(-1 * GetVelX());
		SetPosX(-31);
	}
	else if (GetPosX() > 600)
	{
		SetVelX(-1 * GetVelX());
		SetPosX(599);
	}
	if (GetPosY() < 0)
	{
		SetVelY(-1 * GetVelY());
		SetPosY(1);
	}
	else if (GetPosY() > 400)
	{
		SetVelY(-abs(GetVelY()));
		SetPosY(399);
	}

	DWORD timer = GetTickCount();

}
예제 #26
0
void CObject_Appletree::Render()
{
	SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
	Conversion();

	if(GetHP() > 0)
	{
		if(b_Hit)
		{
			Hit->DrawSprite((int)fDrawX, (int)fDrawY, FALSE);
			Stand->SetCount(0);
		}
		
		else if(b_Attack)
		{
			Stand->DrawSprite((int)fDrawX, (int)fDrawY);
			Poison->DrawSprite((int)fDrawX-35, (int)fDrawY+115);
		}
		
		else
		{
			Stand->DrawSprite((int)fDrawX, (int)fDrawY);
		}



		if(!b_apple[0]) {
			Apple[0]->DrawSprite((int)fDrawX+35, (int)fDrawY+100, TRUE, 0);
		}
		else {
			tempY[0] += 11;

			if(tempY[0] > 420) {
				tempY[0] = 420;
				if(Break[0]->GetCount() != 5) {
					Break[0]->DrawSprite((int)fDrawX+35, (int)tempY[0]+100, FALSE);
				}
				else {
				}

				Boom[0]->DrawSprite((int)fDrawX-5, (int)tempY[0]-50, FALSE);
			}
			else {
				Apple[0]->DrawSprite((int)fDrawX+35, (int)tempY[0]+125, TRUE, 0);
			}
		}
		

		if(!b_apple[1]) {
			Apple[1]->DrawSprite((int)fDrawX+95, (int)fDrawY+120, TRUE, 0);
		}
		else {
			tempY[1] += 11;

			if(tempY[1] > 420) {
				tempY[1] = 420;
				if(Break[1]->GetCount() != 5) {
					Break[1]->DrawSprite((int)fDrawX+95, (int)tempY[1]+100, FALSE);
				}
				else {
				}

				Boom[1]->DrawSprite((int)fDrawX+55, (int)tempY[1]-50, FALSE);
			}
			else {
				Apple[1]->DrawSprite((int)fDrawX+95, (int)tempY[1]+145, TRUE, 0);
			}
		}



		/*
		// 데미지 출력
		if(GetHit())
		{
			Hit->DrawSprite((int)fDrawX, (int)fDrawY);

			SetDrawBlendMode(DX_BLENDMODE_ADD, 255-(10*KnockbackCount));
			SetDrawBright(255, 255, 255);
			Func->DrawNum((int)fDrawX+140, (int)fDrawY-20-(KnockbackCount*2), (int)HeroForEnemy->GetDmg());
			SetDrawBright(*Bright, *Bright, *Bright);
		}
		*/
	}
	else
	{
		
		SetDrawBlendMode(DX_BLENDMODE_ALPHA, Opacity);
		Death->DrawSprite((int)fDrawX, (int)fDrawY, FALSE);
	}

	SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
}