• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Attack函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Attack函数的典型用法代码示例。如果您正苦于以下问题:C++ Attack函数的具体用法?C++ Attack怎么用?C++ Attack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Attack函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Vector3f

// What to do if in Chasing State
void cAggressiveMonster::InStateChasing(float a_Dt)
{
	super::InStateChasing(a_Dt);
	m_ChaseTime += a_Dt;
	if (m_Target != NULL)
	{
		if (m_Target->IsPlayer())
		{
			cPlayer * Player = (cPlayer *) m_Target;
			if (Player->IsGameModeCreative())
			{
				m_EMState = IDLE;
				return;
			}
		}

		Vector3f Pos = Vector3f( GetPosition() );
		Vector3f Their = Vector3f( m_Target->GetPosition() );
		if ((Their - Pos).Length() <= m_AttackRange)
		{
			Attack(a_Dt);
		}
		MoveToPosition(Their + Vector3f(0, 0.65f, 0));
	}
	else if (m_ChaseTime > 5.f)
	{
		m_ChaseTime = 0;
		m_EMState = IDLE;
	}	
} 
开发者ID:Hillvith,项目名称:MCServer,代码行数:31,代码来源:AggressiveMonster.cpp


示例17: CheckEventLostPlayer

void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);

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

	if (m_Target == NULL)
		return;

	cTracer LineOfSight(GetWorld());
	Vector3d AttackDirection(m_Target->GetPosition() - GetPosition());

	if (ReachedFinalDestination() && !LineOfSight.Trace(GetPosition(), AttackDirection, (int)AttackDirection.Length()))
	{
		// Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls)
		Attack(a_Dt / 1000);
	}
}
开发者ID:Jothle12,项目名称:MCServer,代码行数:25,代码来源:AggressiveMonster.cpp


示例18: Touch

void CXenTree :: Touch( CBaseEntity *pOther )
{
	if ( !pOther->IsPlayer() && FClassnameIs( pOther->pev, "monster_bigmomma" ) )
		return;

	Attack();
}
开发者ID:Arkshine,项目名称:NS,代码行数:7,代码来源:xen.cpp


示例19: main

int main(int argc, char* argv[])
{
	char *server;
	NETRESOURCE nr;
	char unc[MAX_PATH];
	char szPipe[MAX_PATH];
	HANDLE hFile;

	if (argc < 2)
	{
		printf("Usage: %s <host>\n", argv[0]);
		return 1;
	}
	server=argv[1];
	_snprintf(unc, sizeof(unc), "\\\\%s\\pipe", server);
	unc[sizeof(unc)-1] = 0;
	nr.dwType       = RESOURCETYPE_ANY;
	nr.lpLocalName  = NULL;
	nr.lpRemoteName = unc;
	nr.lpProvider   = NULL;
	WNetAddConnection2(&nr, "", "", 0);

	_snprintf(szPipe, sizeof(szPipe), "\\\\%s\\pipe\\browser",server);
	hFile = CreateFile(szPipe, GENERIC_READ|GENERIC_WRITE, 0, NULL, 
OPEN_EXISTING, 0, NULL);
	
BindRpcInterface(hFile,"8d9f4e40-a03d-11ce-8f69-
08003e30051b","1.0");

	//SendMalformed RPC request
	Attack(hFile);
	return 0;
}
开发者ID:BuddhaLabs,项目名称:PacketStorm-Exploits,代码行数:33,代码来源:ms05039.c


示例20: switch

/*
================
rvWeaponShotgun::State_Fire
================
*/
stateResult_t rvWeaponShotgun::State_Fire( const stateParms_t& parms ) {
	enum {
		STAGE_INIT,
		STAGE_WAIT,
	};	
	switch ( parms.stage ) {
		case STAGE_INIT:
			nextAttackTime = gameLocal.time + (fireRate * owner->PowerUpModifier ( PMOD_FIRERATE ));
			Attack( false, hitscans, spread, 0, 1.0f );
			PlayAnim( ANIMCHANNEL_ALL, "fire", 0 );	
			return SRESULT_STAGE( STAGE_WAIT );
	
		case STAGE_WAIT:
			if ( (!gameLocal.isMultiplayer && (wsfl.lowerWeapon || AnimDone( ANIMCHANNEL_ALL, 0 )) ) || AnimDone( ANIMCHANNEL_ALL, 0 ) ) {
				SetState( "Idle", 0 );
				return SRESULT_DONE;
			}									
			if ( wsfl.attack && gameLocal.time >= nextAttackTime && AmmoInClip() ) {
				SetState( "Fire", 0 );
				return SRESULT_DONE;
			}
			if ( clipSize ) {
				if ( (wsfl.netReload || (wsfl.reload && AmmoInClip() < ClipSize() && AmmoAvailable()>AmmoInClip())) ) {
					SetState( "Reload", 4 );
					return SRESULT_DONE;			
				}				
			}
			return SRESULT_WAIT;
	}
	return SRESULT_ERROR;
}
开发者ID:AliKalkandelen,项目名称:quake4,代码行数:36,代码来源:WeaponShotgun.cpp



注:本文中的Attack函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AttackStart函数代码示例发布时间:2022-05-30
下一篇:
C++ AttachedTransformation函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap