當前位置: 首頁>>代碼示例>>C++>>正文


C++ Attack函數代碼示例

本文整理匯總了C++中Attack函數的典型用法代碼示例。如果您正苦於以下問題:C++ Attack函數的具體用法?C++ Attack怎麽用?C++ Attack使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Attack函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: CheckTarget

void MultiShot::Update( void ) {
	Attackable *temp;

	/* If we have Targets, check their status. */
	if( pTarget != NULL  || pTarget2 != NULL || pTarget3 != NULL )
		CheckTarget();

	/* Search for Targets. */
	if( pTarget == NULL || pTarget2 == NULL || pTarget3 == NULL )
		FindTarget();

	/* If we found a new Target, and they are in range.. */
	if( pTarget != NULL )
		Attack();

	/*Using a temp target to hold the pTarget. This way we don't have to override Attack().*/
	if( pTarget2 != NULL ) {
		temp = pTarget;
		pTarget = pTarget2;
		Attack();
		pTarget = temp;
	}

	if( pTarget3 != NULL ) {
		temp = pTarget;
		pTarget = pTarget3;
		Attack();
		pTarget = temp;
	}
}
開發者ID:dho1,項目名稱:Project,代碼行數:30,代碼來源:MultiShot.cpp

示例2: switch

/*
================
rvWeaponMachinegun::State_Fire
================
*/
stateResult_t rvWeaponMachinegun::State_Fire ( const stateParms_t& parms ) {
	enum {
		STAGE_INIT,
		STAGE_WAIT,
	};	

	switch ( parms.stage ) {
		case STAGE_INIT:
			if ( wsfl.zoom ) {
				nextAttackTime = gameLocal.time + (altFireRate * owner->PowerUpModifier ( PMOD_FIRERATE ));
				Attack ( true, 1, spreadZoom, 0, 1.0f );
				fireHeld = true;
			} else {
				nextAttackTime = gameLocal.time + (fireRate * owner->PowerUpModifier ( PMOD_FIRERATE ));
				Attack ( false, 1, spread, 0, 1.0f );
			}
			PlayAnim ( ANIMCHANNEL_ALL, "fire", 0 );	
			return SRESULT_STAGE ( STAGE_WAIT );
	
		case STAGE_WAIT:		
			if ( !fireHeld && wsfl.attack && gameLocal.time >= nextAttackTime && AmmoInClip() && !wsfl.lowerWeapon ) {
				SetState ( "Fire", 0 );
				return SRESULT_DONE;
			}
			if ( AnimDone ( ANIMCHANNEL_ALL, 0 ) ) {
				SetState ( "Idle", 0 );
				return SRESULT_DONE;
			}		
			if ( UpdateFlashlight ( ) ) {
				return SRESULT_DONE;
			}			
			return SRESULT_WAIT;
	}
	return SRESULT_ERROR;
}
開發者ID:Big-Zam,項目名稱:IT266-gameMod,代碼行數:40,代碼來源:WeaponMachinegun.cpp

示例3: OnKill

void Bot::OnAttack(int damage, Bot* attacker)
{
	unit->Hit(damage, normal);

	if (unit->GetHP() <= 0)
	{
		OnKill();
	}
	else if (unit->team == App->AI->playerTeam)
	{
		if (unit->ArrivedToDestination())
		{
			Attack(attacker);
		}
	}
	else if (father)
	{
		App->AI->OnUnitDanger(father, this);
	}
	else if (flees)
	{
		if (unit->GetHP() < unit->GetMaxHP() / 10)
			SetState(flee);
		else
			SetState(attack);
	}
	else if (state != attack)
		Attack(attacker);
}
開發者ID:The4Bros,項目名稱:Starcraft_AI,代碼行數:29,代碼來源:Bot.cpp

示例4: initPartyMemberC

void Party::initPartyMemberC() {
    std::vector<float> affinities = {1.5, 1.5, 1.5, 1, 1, 1, 1};
    std::vector<Attack> attacks;
    attacks.push_back(Attack("Arrow", 1, pierce));
    attacks.push_back(Attack("Lightning", 9, lightning));
    
    C = PartyMember("Mage", 50, 40, 2, attacks, affinities);
}
開發者ID:brookswithrow,項目名稱:RPG,代碼行數:8,代碼來源:Party.cpp

示例5: initPartyMemberB

void Party::initPartyMemberB() {
    std::vector<float> affinities = {0.5, 0.5, 0.5, 1, 1, 1, 1};
    std::vector<Attack> attacks;
    attacks.push_back(Attack("Crush", 8, crush));
    attacks.push_back(Attack("Water", 2, water));
    
    B = PartyMember("Tank", 50, 40, 2, attacks, affinities);
}
開發者ID:brookswithrow,項目名稱:RPG,代碼行數:8,代碼來源:Party.cpp

示例6: initPartyMemberA

void Party::initPartyMemberA() {
    std::vector<float> affinities = {1, 1, 1, 1, 1, 1, 1};
    std::vector<Attack> attacks;
    attacks.push_back(Attack("Punch", 2, pierce));
    attacks.push_back(Attack("Fire", 4, fire));
    attacks.push_back(Attack("Sword", 6, slash));
    
    A = PartyMember("DPS", 50, 40, 3, attacks, affinities);
}
開發者ID:brookswithrow,項目名稱:RPG,代碼行數:9,代碼來源:Party.cpp

示例7: StartSound

/*
================
rvMonsterStroggHover::DoNamedAttack
================
*/
void rvMonsterStroggHover::DoNamedAttack ( const char* attackName, jointHandle_t joint ) {
	if ( joint != INVALID_JOINT ) {
		StartSound ( va("snd_%s_fire",attackName), SND_CHANNEL_ANY, 0, false, NULL );
		PlayEffect ( va("fx_%s_flash",attackName), joint );
		Attack ( attackName, joint, GetEnemy() );
	}
}
開發者ID:ET-NiK,項目名稱:amxxgroup,代碼行數:12,代碼來源:Monster_StroggHover.cpp

示例8: SearchForRetreatPosition

bool SoulDestroyer::Advance( Unit *_unit )
{
    if( m_dead ) return AdvanceDead( _unit );
        
    if( m_panic > 0.0 )
    {
        m_targetEntity.SetInvalid();
        if( syncfrand(10.0) < 5.0 )
        {
            SearchForRetreatPosition();
        }
        m_panic -= SERVER_ADVANCE_PERIOD;
    }    
    else if( m_targetEntity.IsValid() )
    {
        WorldObject *target = g_app->m_location->GetEntity( m_targetEntity );
        if( target )
        {
            double distance = (target->m_pos - m_pos).Mag();
            m_targetPos = target->m_pos;            

            if( distance > SOULDESTROYER_MAXSEARCHRANGE )
            {
                m_targetEntity.SetInvalid();
            }
        }
        else
        {
            m_targetEntity.SetInvalid();
        }
    }

    m_retargetTimer -= SERVER_ADVANCE_PERIOD;

    bool arrived = AdvanceToTargetPosition();
    if( arrived || m_targetPos == g_zeroVector || m_retargetTimer < 0.0)
    {
        m_retargetTimer = 5.0;
        bool found = false;
        if( !found && m_panic < 0.1 ) found = SearchForTargetEnemy();
        if( !found ) found = SearchForRandomPosition();
    }

    RecordHistoryPosition();

    if( m_panic < 0.1 ) Attack( m_pos );

#ifdef USE_DIRECT3D
	if(g_deformEffect)
	{
		Vector3* pos1 = m_positionHistory.GetPointer(m_positionHistory.Size()-1);
		Vector3* pos2 = m_positionHistory.GetPointer(m_positionHistory.Size()-2);
		//if(pos1) g_deformEffect->AddTearing(*pos1,0.4);
		//if(pos1 && pos2) g_deformEffect->AddTearing((*pos1+*pos2)*0.5,0.4);
		if(pos1 && pos2) g_deformEffect->AddTearingPath(*pos1,*pos2,0.4);
	}
#endif

	return Entity::Advance(_unit);
}
開發者ID:gene9,項目名稱:Darwinia-and-Multiwinia-Source-Code,代碼行數:60,代碼來源:souldestroyer.cpp

示例9: GetCharacterMovement

// Called every frame
void AZombieCharacter::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	GetCharacterMovement()->MaxWalkSpeed = InitialMaxWalkSpeed;
	ZAnimInstance->Speed = InitialMaxWalkSpeed;

	//If the zombie is within the melee range cancel any movement animation so it's more realistic
	float Distance = FVector::Dist(GetActorLocation(),OurCharacter->GetActorLocation());
	if (Distance<= MeleeDistanceThreshold)
	{
		ZAnimInstance->Speed = 0;
	}

	//Enable the attack raycast sphere in zombies hand if the animation is valid
	if (ZAnimInstance->bEligibleForAttack)
	{
		Attack();
		if (GetCharacterMovement())
		{
			GetCharacterMovement()->MaxWalkSpeed = InitialMaxWalkSpeed;
		}
	}

	//Updates the alpha value if the zombie is dead to achieve over-time fade out
	if(!IsAlive())
	{
		//Ticks the alpha reduction timeline
		AlphaReductionTimeline.TickTimeline(DeltaTime);
	}

}
開發者ID:AbDoMoHaMmEd,項目名稱:PortfolioSnippets,代碼行數:32,代碼來源:ZombieCharacter.cpp

示例10: switch

void CObjectSentrygun::SentryThink( void )
{
	switch( m_iState )
	{
	case SENTRY_STATE_INACTIVE:
		break;

	case SENTRY_STATE_SEARCHING:
		SentryRotate();
		break;

	case SENTRY_STATE_ATTACKING:
		Attack();
		break;

	case SENTRY_STATE_UPGRADING:
		UpgradeThink();
		break;

	default:
		Assert( 0 );
		break;
	}

	SetContextThink( &CObjectSentrygun::SentryThink, gpGlobals->curtime + SENTRY_THINK_DELAY, SENTRYGUN_CONTEXT );
}
開發者ID:MrBoomer568,項目名稱:TF2Classic,代碼行數:26,代碼來源:tf_obj_sentrygun.cpp

示例11: CheckEventLostPlayer

void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
    super::Tick(a_Dt, a_Chunk);

    if (m_EMState == CHASING)
    {
        CheckEventLostPlayer();
    }
    else
    {
        CheckEventSeePlayer();
    }

    if (m_Target == nullptr)
    {
        return;
    }

    cTracer LineOfSight(GetWorld());
    Vector3d MyHeadPosition = GetPosition() + Vector3d(0, GetHeight(), 0);
    Vector3d AttackDirection(m_Target->GetPosition() + Vector3d(0, m_Target->GetHeight(), 0) - MyHeadPosition);


    if (TargetIsInRange() && !LineOfSight.Trace(MyHeadPosition, AttackDirection, static_cast<int>(AttackDirection.Length())) && (GetHealth() > 0.0))
    {
        // Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls)
        StopMovingToPosition();
        Attack(a_Dt);
    }
}
開發者ID:Nakkar,項目名稱:cuberite,代碼行數:30,代碼來源:AggressiveMonster.cpp

示例12: switch

void AIEnemyZombie::UseBrain()
{
	xtile = aiinput->GetXTilePos();
	ytile = aiinput->GetYTilePos();
	xpos = aiinput->GetXLoc();
	ypos = aiinput->GetYLoc();

	if(new_enemy){
		new_enemy=false;
		//if( (aiinput->lower_patrol_x > 0) && (aiinput->upper_patrol_x > 0)) use_patrol_bounds = true;
	}

	


	switch(GetState())
	{
	case AIS_CHASE:
		Chase();
		break;
	case AIS_ATTACK:
		Attack();
		break;
	case AIS_PATROL:
		Patrol();
		break;
	case AIS_MOVE:
		MoveToXTile(movetoxtile);
		break;
	case AIS_WAIT:
		Wait();
		break;

	}
}
開發者ID:shoematt,項目名稱:BladeofBetrayal,代碼行數:35,代碼來源:AIEnemyZombie.cpp

示例13: FindDestroyDir

//이번턴의 결과값이 Destroy라면?
Position Player::DestroyFind( int size )
{
	//일단 공격한 위치를 Destroy리스트에 집어넣는다.
    m_DestroyPosList.push_back( m_LastHit );
    Position curPos = m_LastHit;
    MyDirection destroyDir = m_FindDir;
	//그리고 현재 방향에서부터 destroy된 배가 놓인 방향을 찾는다.
    FindDestroyDir( curPos , size , &destroyDir );
	//찾은 다음에 HitPosList에서 destroy된 배가 가진 위치들을 제외시킨다.
	//파괴된 배는 이제 더 이상 타겟이 아니기 때문
    RemoveDestroyedPath( curPos , size , destroyDir );

	//이렇게해서 남은 Hitpos가 없다면 HUNT모드로 전환하여 공격
    if( m_HitPosList.empty() )
    {
        m_AImode = HUNT;
        return Attack();
    }
	//아직 남아있다면 Origin을 변경시켜서 MissFind방법으로 다시 추적시작
    else
    {
        m_Origin = m_HitPosList.front();
        return MissFind();
    }
}
開發者ID:ozt88,項目名稱:BattleShip,代碼行數:26,代碼來源:Player.cpp

示例14: Attack

bool CActions::CopyAttack(int unit,set<int> tocopy){
	float3 p = G->GetUnitPos(unit);
	if(G->Map->CheckFloat3(p)==false){
		return false;
	}
	int* a = new int[10000];
	int n = G->cb->GetFriendlyUnits(a,p,900.0f);
	if(n > 1){
		//
		for(int i =0; i < n; i++){
			if(i == unit) continue;
			if(tocopy.find(i) == tocopy.end()) continue;
			const deque<Command>* vc = G->cb->GetCurrentUnitCommands(i);
			if(vc == 0) continue;
			if(vc->empty()) continue;
			for(deque<Command>::const_iterator q = vc->begin(); q != vc->end(); ++q){
				//
				if(q->id == CMD_ATTACK){
					delete [] a;
					int eu = (int)q->params.front();
					return Attack(unit,eu,false);
				}
			}
		}
	}
	delete [] a;
	return false;
}
開發者ID:genxinzou,項目名稱:svn-spring-archive,代碼行數:28,代碼來源:Actions.cpp

示例15: printf

bool SynthNote::AttackNote(
			SynthPartElement *				inPart,
			SynthGroupElement *				inGroup,
			NoteInstanceID					inNoteID, 
			UInt64							inAbsoluteSampleFrame, 
			UInt32							inOffsetSampleFrame, 
			const MusicDeviceNoteParams		&inParams)
{
#if DEBUG_PRINT
	printf("SynthNote::AttackNote %lu %lu abs frame %llu rel frame %lu\n", (UInt32)inGroup->GroupID(), (UInt32)inNoteID, inAbsoluteSampleFrame, inOffsetSampleFrame);
#endif
	mPart = inPart;
	mGroup = inGroup;
	mNoteID = inNoteID;

	mAbsoluteStartFrame = inAbsoluteSampleFrame;
	mRelativeStartFrame = inOffsetSampleFrame;
	mRelativeReleaseFrame = -1;
	mRelativeKillFrame = -1;

	mPitch = inParams.mPitch;
	mVelocity = inParams.mVelocity;
	
	
	return Attack(inParams);
}
開發者ID:pereckerdal,項目名稱:HSPad,代碼行數:26,代碼來源:SynthNote.cpp


注:本文中的Attack函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。