您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CanAttack函数代码示例

51自学网 2021-06-01 20:09:13
  C++
这篇教程C++ CanAttack函数代码示例写得很实用,希望能帮到您。

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

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

示例1: AttackStart

void PetAI::AttackStart(Unit* target){    // Overrides Unit::AttackStart to correctly evaluate Pet states    // Check all pet states to decide if we can attack this target    if (!CanAttack(target))        return;    // Only chase if not commanded to stay or if stay but commanded to attack    DoAttack(target, (!m_creature->GetCharmInfo()->HasCommandState(COMMAND_STAY) || m_creature->GetCharmInfo()->IsCommandAttack()));}
开发者ID:Maduse,项目名称:server,代码行数:11,


示例2: TryRangedAttack

bool RPG_AiControllerComponent::TryRangedAttack(){  if(CanAttack())  {    m_lastAttackTime = Vision::GetTimer()->GetTime();    SetState(RPG_ControllerStateId::kRangedAttacking);    return true;  }  return false;}
开发者ID:RexBaribal,项目名称:projectanarchy,代码行数:11,


示例3: AttackStart

void PetAI::AttackStart(Unit* target){    // Overrides Unit::AttackStart to correctly evaluate Pet states    // Check all pet states to decide if we can attack this target    if (!CanAttack(target))        return;    if (Unit* owner = me->GetOwner())        owner->SetInCombatWith(target);    DoAttack(target, true);}
开发者ID:AlmasServer,项目名称:TrinityCore,代码行数:13,


示例4: ToTFPlayer

//-----------------------------------------------------------------------------// Purpose: Attempt to heal any player within range of the medikit//-----------------------------------------------------------------------------void CWeaponMedigun::PrimaryAttack( void ){	CTFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );	if ( !pOwner )		return;	if ( !CanAttack() )		return;#ifdef GAME_DLL	/*	// Start boosting ourself if we're not	if ( m_bChargeRelease && !m_bHealingSelf )	{		pOwner->m_Shared.Heal( pOwner, GetHealRate() * 2 );		m_bHealingSelf = true;	}	*/#endif#if !defined (CLIENT_DLL)	if ( tf_medigun_lagcomp.GetBool() )		lagcompensation->StartLagCompensation( pOwner, pOwner->GetCurrentCommand() );#endif	if ( FindAndHealTargets() )	{		// Start the animation		if ( !m_bHealing )		{#ifdef GAME_DLL			pOwner->SpeakWeaponFire();#endif			SendWeaponAnim( ACT_MP_ATTACK_STAND_PREFIRE );			pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRE );		}		m_bHealing = true;	}	else	{		RemoveHealingTarget();	}	#if !defined (CLIENT_DLL)	if ( tf_medigun_lagcomp.GetBool() )		lagcompensation->FinishLagCompensation( pOwner );#endif}
开发者ID:Navton,项目名称:TF2Classic,代码行数:54,


示例5: CanAttack

bool cCombatManager::ValidateEnemy(const int& unitID, UnitInfo* U, bool IdleIfInvalid){	if( U->enemyID == -1 || G->Enemies.find(U->enemyID) == G->Enemies.end() )	{	// old enemy target that doesn't exist		U->enemyID=-1;		if( IdleIfInvalid )			G->UpdateEventAdd(1,cb->GetCurrentFrame()+90,unitID,U);		return false;	}	float3 EPos = cb->GetUnitPos(U->enemyID);	if( U->group == 0 )	{	// keeping variables up-to-date, this is event-driven for groups		U->E = &G->Enemies.find(U->enemyID)->second;		U->enemyEff = CanAttack(U,U->E,EPos);	}	if( cb->GetUnitDef(U->enemyID) != 0 && cb->GetUnitAllyTeam(unitID) == cb->GetUnitAllyTeam(U->enemyID) )	{	// an enemy ID was reused by an ally team		if( U->E->inLOS || U->E->inRadar ) // ! Work Around:  Spring-Version(v0.72b1-0.76b1)		{	// OR an ally captures an enemy unit & no events were sent			*l<<"/nWARNING: ValidateEnemy(eID="<<U->enemyID<<"): an ally has captured an enemy unit";		}		G->EnemyDestroyed(U->enemyID,-1);		U->enemyID=-1;		return false;	}	if( EPos.x > 0 || EPos.z > 0 || EPos.y > 0 ) // Position is valid	{		if( !U->E->inLOS && !U->E->inRadar ) // ! Work Around:  Spring-Version(v0.72b1-0.76b1)		{			if( cb->GetUnitDef(U->enemyID) != 0 )			{				*l<<"/nWARNING: ValidateEnemy(eID="<<U->enemyID<<"): incorrect LOS status";				G->EnemyEnterLOS(U->enemyID);			}			else			{				*l<<"/nWARNING: ValidateEnemy(eID="<<U->enemyID<<"): incorrect radar status";				G->EnemyEnterRadar(U->enemyID);			}		}		return true;	}	if( !U->E->inLOS && !U->E->inRadar && cb->GetUnitPos(unitID).distance2D(U->E->position) > 300.0f )		return true;	G->EnemyRemove(U->enemyID,U->E);	U->enemyID=-1;	if( IdleIfInvalid )		G->UpdateEventAdd(1,cb->GetCurrentFrame()+90,unitID,U);	return false;}
开发者ID:Mocahteam,项目名称:SpringPP,代码行数:50,


示例6: AttackStart

void PetAI::AttackStart(Unit* target){    // Overrides Unit::AttackStart to correctly evaluate Pet states    // Check all pet states to decide if we can attack this target    if (!CanAttack(target))        return;    if (Unit* owner = me->GetCharmerOrOwner())        owner->RemoveAurasByType(SPELL_AURA_MOD_CAMOUFLAGE);    // Only chase if not commanded to stay or if stay but commanded to attack    DoAttack(target, (!me->GetCharmInfo()->HasCommandState(COMMAND_STAY) || me->GetCharmInfo()->IsCommandAttack()));}
开发者ID:Cailiaock,项目名称:5.4.7-Wow-source,代码行数:14,


示例7: DetermineWeaponState

void AWeapon::DetermineWeaponState(){	EWeaponState::Type NewState = EWeaponState::Idle;	if (IsEquiped())	{		if (bWantsToAttack && CanAttack())		{			NewState = EWeaponState::Attacking;		}	}	else if (bPendingEquip)	{		NewState = EWeaponState::Equipping;	}	SetCurrentState(NewState);}
开发者ID:belven,项目名称:Mutagen,代码行数:17,


示例8: PrimaryAttack

//-----------------------------------------------------------------------------// Purpose: Primary fire function//-----------------------------------------------------------------------------void CTFFlareGun::PrimaryAttack(void){	// Check for ammunition.	if (m_iClip1 <= 0 && m_iClip1 != -1)		return;	// Are we capable of firing again?	if (m_flNextPrimaryAttack > gpGlobals->curtime)		return;	if (!CanAttack())		return;	m_iWeaponMode = TF_WEAPON_PRIMARY_MODE;	LaunchProjectile();}
开发者ID:staticfox,项目名称:TF2Classic,代码行数:20,


示例9: if

int cCombatManager::GetClosestThreat(float3 Pos, UnitInfo* U){    sWeaponEfficiency* weTemp;    float distance,fTemp;    distance=0.0f;    float3 fE;    set<int> deletion;    for( map<int,EnemyInfo*>::iterator E=G->EThreat.begin(); E!=G->EThreat.end(); ++E )    {        fE=GetEnemyPosition(E->first,E->second);        if( E->second->baseThreatFrame > cb->GetCurrentFrame()+3600 ||                (E->second->baseThreatFrame > cb->GetCurrentFrame()+1200 && G->UImmobile.find(E->second->baseThreatID) == G->UImmobile.end() ) ||                (E->second->ud != 0 && G->UImmobile.find(E->second->baseThreatID) != G->UImmobile.end() && 1.3*E->second->ud->maxWeaponRange < fE.distance(cb->GetUnitPos(E->second->baseThreatID)) ) )        {            E->second->baseThreatID = -1;            E->second->baseThreatFrame = -1;            deletion.insert(E->first);        }        else if( (weTemp = CanAttack(U,E->second,fE)) != 0 )        {            fTemp=Pos.distance(fE);            if( U->enemyID == -1 || fTemp < distance )            {                U->enemyID=E->first;                U->E = E->second;                U->enemyEff = weTemp;                distance=fTemp;            }        }    }    while( int(deletion.size()) > 0 )    {        if( !G->UM->ActiveAttackOrders() )        {            EnemyInfo* E = G->EThreat.find(*deletion.begin())->second;            while( int(E->attackGroups.size()) > 0 )                G->UM->GroupRemoveEnemy(*deletion.begin(),E,*E->attackGroups.begin());        }        G->EThreat.erase(*deletion.begin());        deletion.erase(*deletion.begin());    }    if( U->enemyID != -1 && U->group != 0 )        G->UM->GroupAddEnemy(U->enemyID,U->E,U->group);    return U->enemyID;}
开发者ID:9heart,项目名称:spring,代码行数:45,


示例10: GetTFPlayerOwner

void CTFChainsaw::PrimaryAttack(void){	// Get the current player.	CTFPlayer *pPlayer = GetTFPlayerOwner();	if ( !pPlayer )		return;	if ( !CanAttack() )		return;	// Set the weapon usage mode - primary, secondary.	m_iWeaponMode = TF_WEAPON_PRIMARY_MODE;	m_bConnected = false;	bIsAttacking = true;	BaseClass::PrimaryAttack();}
开发者ID:TenmaPL,项目名称:TF2Classic,代码行数:18,


示例11: CanAttackSpell

//////////////////////////////////////////////////// [Serverside] Opposition: Unit can target a target with a harmful spell////// @note Relations API Tier 3////// This function is not intented to have client-side counterpart by original design./// It utilizes SpellEntry for additional target filtering./// Also an additional fine grained check needs to be done for AOE spells, because they/// need to skip PVP enabled targets in some special cases. (Chain spells, AOE)/////////////////////////////////////////////////bool Unit::CanAttackSpell(Unit const* target, SpellEntry const* spellInfo, bool isAOE) const{    if (spellInfo)    {        // inversealive is needed for some spells which need to be casted at dead targets (aoe)        if (!target->isAlive() && !spellInfo->HasAttribute(SPELL_ATTR_EX2_CAN_TARGET_DEAD))            return false;    }    if (CanAttack(target))    {        if (isAOE)        {            if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))            {                if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))                {                    const Player* thisPlayer = GetControllingPlayer();                    if (!thisPlayer)                        return true;                    const Player* unitPlayer = target->GetControllingPlayer();                    if (!unitPlayer)                        return true;                    if (thisPlayer->IsInDuelWith(unitPlayer))                        return true;                    if (unitPlayer->IsPvP() && (!isAOE || thisPlayer->IsPvP()))                        return true;                    if (thisPlayer->IsPvPFreeForAll() && unitPlayer->IsPvPFreeForAll())                        return true;                    return false;                }            }        }        return true;    }    return false;}
开发者ID:Tobschinski,项目名称:mangos-classic,代码行数:53,


示例12: ToBasePlayer

//-----------------------------------------------------------------------------// Purpose://-----------------------------------------------------------------------------void CTFPistol::PrimaryAttack( void ){#if 0	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );	if( pOwner )	{		// Each time the player fires the pistol, reset the view punch. This prevents		// the aim from 'drifting off' when the player fires very quickly. This may		// not be the ideal way to achieve this, but it's cheap and it works, which is		// great for a feature we're evaluating. (sjb)		//pOwner->ViewPunchReset();	}#endif	if ( !CanAttack() )		return;	BaseClass::PrimaryAttack();}
开发者ID:TenmaPL,项目名称:TF2Classic,代码行数:23,


示例13: GetTFPlayerOwner

// -----------------------------------------------------------------------------// Purpose:// -----------------------------------------------------------------------------void CTFWeaponBaseMelee::PrimaryAttack(){	// Get the current player.	CTFPlayer *pPlayer = GetTFPlayerOwner();	if ( !pPlayer )		return;	if ( !CanAttack() )		return;	// Set the weapon usage mode - primary, secondary.	m_iWeaponMode = TF_WEAPON_PRIMARY_MODE;	m_bConnected = false;	// Swing the weapon.	Swing( pPlayer );#if !defined( CLIENT_DLL ) 	pPlayer->SpeakWeaponFire();	CTF_GameStats.Event_PlayerFiredWeapon( pPlayer, IsCurrentAttackACritical() );#endif}
开发者ID:staticfox,项目名称:TF2Classic,代码行数:25,


示例14: GetPlayerOwner

void CDODBaseRocketWeapon::SecondaryAttack(){	CBasePlayer *pPlayer = GetPlayerOwner();	//if we're underwater, lower it	if( pPlayer->GetWaterLevel() > 2 )	{		if( IsDeployed() )			Lower();		return;	}	if( IsDeployed() )	{			Lower();	}	else	{		if ( CanAttack() )            Raise();	}	}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:22,


示例15: CanAttack

//////////////////////////////////////////////////// Opposition: Unit treats another unit as an enemy it can attack (immediate response)////// @note Relations API Tier 1////// Backported from TBC+ client-side counterpart: <tt>CGUnit_C::CanAttackNow(const CGUnit_C *this, const CGUnit_C *unit)</tt>/// Intended usage is to verify direct requests to attack something./// First appeared in TBC+ clients, backported for API unification between expansions./////////////////////////////////////////////////bool Unit::CanAttackNow(const Unit* unit) const{    // Simple sanity check    if (!unit)        return false;    // Original logic    // We can't initiate attack while dead or ghost    if (!isAlive())        return false;    // We can't initiate attack while mounted    if (IsMounted())        return false;    // We can't initiate attack on dead units    if (!unit->isAlive())        return false;    return CanAttack(unit);}
开发者ID:Tobschinski,项目名称:mangos-classic,代码行数:31,


示例16: ExecuteTask

EBTNodeResult::Type UShootAtEnemyTask::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory){	AMinionAIController* MinionController = Cast<AMinionAIController>(OwnerComp.GetAIOwner());	if (MinionController == NULL)	{		return EBTNodeResult::Failed;	}	AMinionCharacter* Minion = Cast<AMinionCharacter>(MinionController->GetPawn());	ABorderItem* Enemy = MinionController->GetEnemy();	if (CanAttack(Minion, Enemy))	{		AttackEnemy(Minion, Enemy);		return EBTNodeResult::InProgress;	}	else if (!Enemy)	{		return EBTNodeResult::Succeeded;	}	return EBTNodeResult::Failed;}
开发者ID:joshkay,项目名称:BorderSecurity,代码行数:23,


示例17: Update

bool CAttackState::Update(time_point tick){    auto PTarget = static_cast<CBattleEntity*>(GetTarget());    if (!PTarget || PTarget->isDead())    {        return true;    }    if (AttackReady())    {        //CanAttack may have set target id to 0 (disengage from out of range)        if (m_PEntity->GetBattleTargetID() == 0)        {            return true;        }        if (CanAttack(PTarget))        {            action_t action;            if (m_PEntity->OnAttack(*this, action))            {                m_PEntity->loc.zone->PushPacket(m_PEntity, CHAR_INRANGE_SELF, new CActionPacket(action));            }        }        else if (m_PEntity->OnAttackError(*this))        {            m_PEntity->HandleErrorMessage(m_errorMsg);        }        if (m_PEntity->GetBattleTargetID() == 0)        {            return true;        }    }    else    {        m_attackTime -= (m_PEntity->PAI->getTick() - m_PEntity->PAI->getPrevTick());    }    return false;}
开发者ID:Sacshop,项目名称:darkstar,代码行数:37,


示例18: PrimaryAttack

//-----------------------------------------------------------------------------// Purpose: //-----------------------------------------------------------------------------void CTFPipebombLauncher::PrimaryAttack( void ){	// Check for ammunition.	if ( m_iClip1 <= 0 && m_iClip1 != -1 )		return;	// Are we capable of firing again?	if ( m_flNextPrimaryAttack > gpGlobals->curtime )		return;	if ( !CanAttack() )	{		m_flChargeBeginTime = 0;		return;	}	if ( m_flChargeBeginTime <= 0 )	{		// Set the weapon mode.		m_iWeaponMode = TF_WEAPON_PRIMARY_MODE;		// save that we had the attack button down		m_flChargeBeginTime = gpGlobals->curtime;		SendWeaponAnim( ACT_VM_PULLBACK );	}	else	{		float flTotalChargeTime = gpGlobals->curtime - m_flChargeBeginTime;		if ( flTotalChargeTime >= TF_PIPEBOMB_MAX_CHARGE_TIME )		{			LaunchGrenade();		}	}}
开发者ID:Navton,项目名称:TF2Classic,代码行数:39,


示例19: min

void CBasePlayerWeapon::ItemPostFrame( void ){	if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )	{		// complete the reload. 		int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);			// Add them to the clip		m_iClip += j;		m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j;		m_pPlayer->TabulateAmmo();		m_fInReload = FALSE;	}	if ( !(m_pPlayer->pev->button & IN_ATTACK ) )	{		m_flLastFireTime = 0.0f;	}	if ((m_pPlayer->pev->button & IN_ATTACK2) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) )	{		if ( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] )		{			m_fFireOnEmpty = TRUE;		}		m_pPlayer->TabulateAmmo();		SecondaryAttack();		m_pPlayer->pev->button &= ~IN_ATTACK2;	}	else if ((m_pPlayer->pev->button & IN_ATTACK) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) )	{		if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) )		{			m_fFireOnEmpty = TRUE;		}		m_pPlayer->TabulateAmmo();		PrimaryAttack();	}	else if ( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) 	{		// reload when reload is pressed, or if no buttons are down and weapon is empty.		Reload();	}	else if ( !(m_pPlayer->pev->button & (IN_ATTACK|IN_ATTACK2) ) )	{		// no fire buttons down		m_fFireOnEmpty = FALSE;		if ( !IsUseable() && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) 		{			// weapon isn't useable, switch.			if ( !(iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) && g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) )			{				m_flNextPrimaryAttack = ( UseDecrement() ? 0.0 : gpGlobals->time ) + 0.3;				return;			}		}		else		{			// weapon is useable. Reload if empty and weapon has waited as long as it has to after firing			if ( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) )			{				Reload();				return;			}		}		WeaponIdle( );		return;	}		// catch all	if ( ShouldWeaponIdle() )	{		WeaponIdle();	}}
开发者ID:AMeEeRo,项目名称:halflife,代码行数:82,


示例20: ToTFPlayer

//-----------------------------------------------------------------------------// Purpose: //-----------------------------------------------------------------------------void CTFMinigun::SharedAttack(){	CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );	if ( !pPlayer )		return;	if ( !CanAttack() )	{		WeaponIdle();		return;	}	if ( pPlayer->m_nButtons & IN_ATTACK )	{		m_iWeaponMode = TF_WEAPON_PRIMARY_MODE;	}	else if ( pPlayer->m_nButtons & IN_ATTACK2 )	{		m_iWeaponMode = TF_WEAPON_SECONDARY_MODE;	}	switch ( m_iWeaponState )	{	default:	case AC_STATE_IDLE:		{			// Removed the need for cells to powerup the AC			WindUp();			m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;			m_flNextSecondaryAttack = gpGlobals->curtime + 1.0;			m_flTimeWeaponIdle = gpGlobals->curtime + 1.0;			m_flStartedFiringAt = -1;			pPlayer->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRE );			break;		}	case AC_STATE_STARTFIRING:		{			// Start playing the looping fire sound			if ( m_flNextPrimaryAttack <= gpGlobals->curtime )			{				if ( m_iWeaponMode == TF_WEAPON_SECONDARY_MODE )				{					m_iWeaponState = AC_STATE_SPINNING;#ifdef GAME_DLL					pPlayer->SpeakWeaponFire( MP_CONCEPT_WINDMINIGUN );#endif				}				else				{					m_iWeaponState = AC_STATE_FIRING;#ifdef GAME_DLL					pPlayer->SpeakWeaponFire( MP_CONCEPT_FIREMINIGUN );#endif				}				m_flNextSecondaryAttack = m_flNextPrimaryAttack = m_flTimeWeaponIdle = gpGlobals->curtime + 0.1;			}			break;		}	case AC_STATE_FIRING:		{			if ( m_iWeaponMode == TF_WEAPON_SECONDARY_MODE )			{#ifdef GAME_DLL				pPlayer->ClearWeaponFireScene();				pPlayer->SpeakWeaponFire( MP_CONCEPT_WINDMINIGUN );#endif				m_iWeaponState = AC_STATE_SPINNING;				m_flNextSecondaryAttack = m_flNextPrimaryAttack = m_flTimeWeaponIdle = gpGlobals->curtime + 0.1;			}			else if ( pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )			{				m_iWeaponState = AC_STATE_DRYFIRE;			}			else			{				if ( m_flStartedFiringAt < 0 )				{					m_flStartedFiringAt = gpGlobals->curtime;				}#ifdef GAME_DLL				if ( m_flNextFiringSpeech < gpGlobals->curtime )				{					m_flNextFiringSpeech = gpGlobals->curtime + 5.0;					pPlayer->SpeakConceptIfAllowed( MP_CONCEPT_MINIGUN_FIREWEAPON );				}#endif				// Only fire if we're actually shooting				BaseClass::PrimaryAttack();		// fire and do timers				CalcIsAttackCritical();				m_bCritShot = IsCurrentAttackACrit();				pPlayer->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );//.........这里部分代码省略.........
开发者ID:Navton,项目名称:TF2Classic,代码行数:101,


示例21: UpdateAllies

//.........这里部分代码省略.........    if (!me->HasUnitState(UNIT_STAT_CASTING))    {        typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;        TargetSpellList targetSpellStore;        for (uint8 i = 0; i < me->GetPetAutoSpellSize(); ++i)        {            uint32 spellID = me->GetPetAutoSpellOnPos(i);            if (!spellID)                continue;            SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);            if (!spellInfo)                continue;            if (me->GetCharmInfo() && me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))                continue;            if (spellInfo->IsPositive())            {                // non combat spells allowed                // only pet spells have IsNonCombatSpell and not fit this reqs:                // Consume Shadows, Lesser Invisibility, so ignore checks for its                if (spellInfo->CanBeUsedInCombat())                {                    // allow only spell without spell cost or with spell cost but not duration limit                    int32 duration = spellInfo->GetDuration();                    if ((spellInfo->ManaCost || spellInfo->ManaCostPercentage || spellInfo->ManaPerSecond) && duration > 0)                        continue;                    // allow only spell without cooldown > duration                    int32 cooldown = spellInfo->GetRecoveryTime();                    if (cooldown >= 0 && duration >= 0 && cooldown > duration)                        continue;                }                Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);                bool spellUsed = false;                for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)                {                    Unit* target = ObjectAccessor::GetUnit(*me, *tar);                    //only buff targets that are in combat, unless the spell can only be cast while out of combat                    if (!target)                        continue;                    if (spell->CanAutoCast(target))                    {                        targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(target, spell));                        spellUsed = true;                        break;                    }                }                if (!spellUsed)                    delete spell;            }            else if (me->getVictim() && CanAttack(me->getVictim()) && spellInfo->CanBeUsedInCombat())            {                Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);                if (spell->CanAutoCast(me->getVictim()))                    targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(me->getVictim(), spell));                else                    delete spell;            }        }        //found units to cast on to        if (!targetSpellStore.empty())        {            uint32 index = urand(0, targetSpellStore.size() - 1);            Spell* spell  = targetSpellStore[index].second;            Unit*  target = targetSpellStore[index].first;            targetSpellStore.erase(targetSpellStore.begin() + index);            SpellCastTargets targets;            targets.SetUnitTarget(target);            if (!me->HasInArc(M_PI, target))            {                me->SetInFront(target);                if (target && target->GetTypeId() == TYPEID_PLAYER)                    me->SendUpdateToPlayer(target->ToPlayer());                if (owner && owner->GetTypeId() == TYPEID_PLAYER)                    me->SendUpdateToPlayer(owner->ToPlayer());            }            me->AddCreatureSpellCooldown(spell->m_spellInfo->Id);            spell->prepare(&targets);        }        // deleted cached Spell objects        for (TargetSpellList::const_iterator itr = targetSpellStore.begin(); itr != targetSpellStore.end(); ++itr)            delete itr->second;    }}
开发者ID:InkVisible,项目名称:Jzy-Blizzlike,代码行数:101,


示例22: min

void CBasePlayerWeapon::ItemPostFrame( void ){	if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )	{		// complete the reload. 		int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);			// Add them to the clip		m_iClip += j;		m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j;		m_fInReload = FALSE;	}	if ((m_pPlayer->pev->button & IN_ATTACK2) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) )	{		if ( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] )		{			m_fFireOnEmpty = TRUE;		}		SecondaryAttack();		m_pPlayer->pev->button &= ~IN_ATTACK2;	}	else if ((m_pPlayer->pev->button & IN_ATTACK) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) )	{		if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) )		{			m_fFireOnEmpty = TRUE;		}		PrimaryAttack();	}	else if ( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) 	{		// reload when reload is pressed, or if no buttons are down and weapon is empty.		Reload();	}	else if ( !(m_pPlayer->pev->button & (IN_ATTACK|IN_ATTACK2) ) )	{		// no fire buttons down		if ( !m_bPlayedIdleAnim )		{			m_bPlayedIdleAnim = TRUE;			SendWeaponAnim( 0, 1 );			if ( m_pPlayer->m_iQuakeWeapon == IT_LIGHTNING )			{				 PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_pPlayer->m_usLightning, 0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 1, 0, 0 );				 if ( m_pPlayer->m_pActiveItem )					  ((CQuakeGun*)m_pPlayer->m_pActiveItem)->DestroyEffect();			}		}		WeaponIdle( );		return;	}		// catch all	if ( ShouldWeaponIdle() )	{		WeaponIdle();	}}
开发者ID:AMeEeRo,项目名称:halflife,代码行数:65,


示例23: UpdateAllies

//.........这里部分代码省略.........    if (!me->HasUnitState(UNIT_STATE_CASTING))    {        typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;        TargetSpellList targetSpellStore;        for (uint8 i = 0; i < me->GetPetAutoSpellSize(); ++i)        {            uint32 spellID = me->GetPetAutoSpellOnPos(i);            if (!spellID)                continue;            SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);            if (!spellInfo)                continue;            // Check global cooldown            if (me->GetCharmInfo() && me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))                continue;            // Check spell cooldown            if (me->HasSpellCooldown(spellInfo->Id))                continue;            // Check if pet is in combat and if spell can be cast            if (me->isInCombat() && !spellInfo->CanBeUsedInCombat())                continue;            // Prevent spells like Furious Howl from constantly casting out of            //  combat when the cooldown is up            if (!me->isInCombat() && !spellInfo->NeedsToBeTriggeredByCaster())                continue;            // We have a spell we can cast, let's pick a target            if (spellInfo->IsPositive())            {                // These would be buff spells like Furious Howl, Consume Shadows, etc.                Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);                bool spellUsed = false;                for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)                {                    Unit* target = ObjectAccessor::GetUnit(*me, *tar);                    if (!target)                        continue;                    if (spell->CanAutoCast(target))                    {                        targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(target, spell));                        spellUsed = true;                        break;                    }                }                if (!spellUsed)                    delete spell;            }            else if (me->getVictim() && CanAttack(me->getVictim()))            {                // These would be offensive spells like Claw, Bite, Torment, Fireball, etc.                Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);                if (spell->CanAutoCast(me->getVictim()))                    targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(me->getVictim(), spell));                else                    delete spell;            }        }        //found units to cast on to        if (!targetSpellStore.empty())        {            uint32 index = urand(0, targetSpellStore.size() - 1);            Spell* spell  = targetSpellStore[index].second;            Unit*  target = targetSpellStore[index].first;            targetSpellStore.erase(targetSpellStore.begin() + index);            SpellCastTargets targets;            targets.SetUnitTarget(target);            if (!me->HasInArc(M_PI, target))            {                me->SetInFront(target);                if (target && target->GetTypeId() == TYPEID_PLAYER)                    me->SendUpdateToPlayer(target->ToPlayer());                if (owner && owner->GetTypeId() == TYPEID_PLAYER)                    me->SendUpdateToPlayer(owner->ToPlayer());            }            me->AddCreatureSpellCooldown(spell->m_spellInfo->Id);            spell->prepare(&targets);        }        // deleted cached Spell objects        for (TargetSpellList::const_iterator itr = targetSpellStore.begin(); itr != targetSpellStore.end(); ++itr)            delete itr->second;    }}
开发者ID:HkLuna,项目名称:ArkCORE2,代码行数:101,


示例24: UpdateAllies

//.........这里部分代码省略.........                continue;            SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);            if (!spellInfo)                continue;            if (me->GetCharmInfo() && me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))                continue;            if (spellInfo->IsPositive())            {                if (spellInfo->CanBeUsedInCombat())                {                    // check spell cooldown                    if (me->HasSpellCooldown(spellInfo->Id))                        continue;                    // Check if we're in combat or commanded to attack                    if (!me->isInCombat() && !me->GetCharmInfo()->IsCommandAttack())                        continue;                }                Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);                bool spellUsed = false;                // Some spells can target enemy or friendly (DK Ghoul's Leap)                // Check for enemy first (pet then owner)                Unit* target = me->getAttackerForHelper();                if (!target && owner)                    target = owner->getAttackerForHelper();                if (target)                {                    if (CanAttack(target) && spell->CanAutoCast(target))                    {                        targetSpellStore.push_back(std::make_pair(target, spell));                        spellUsed = true;                    }                }                // No enemy, check friendly                if (!spellUsed)                {                    for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)                    {                        Unit* ally = ObjectAccessor::GetUnit(*me, *tar);                        //only buff targets that are in combat, unless the spell can only be cast while out of combat                        if (!ally)                            continue;                        if (spell->CanAutoCast(ally))                        {                            targetSpellStore.push_back(std::make_pair(ally, spell));                            spellUsed = true;                            break;                        }                    }                }                // No valid targets at all                if (!spellUsed)                    delete spell;            }            else if (me->getVictim() && CanAttack(me->getVictim()) && spellInfo->CanBeUsedInCombat())            {
开发者ID:AlmasServer,项目名称:TrinityCore,代码行数:67,


示例25: ToTFPlayer

//-----------------------------------------------------------------------------// Purpose://-----------------------------------------------------------------------------void CTFWeaponBaseGun::PrimaryAttack( void ){	// Check for ammunition.	if ( m_iClip1 <= 0 && m_iClip1 != -1 )		return;	// Are we capable of firing again?	if ( m_flNextPrimaryAttack > gpGlobals->curtime )		return;	// Get the player owning the weapon.	CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );	if ( !pPlayer )		return;	if ( !CanAttack() )		return;	CalcIsAttackCritical();#ifndef CLIENT_DLL	pPlayer->RemoveInvisibility();	pPlayer->RemoveDisguise();	// Minigun has custom handling	if ( GetWeaponID() != TF_WEAPON_MINIGUN )	{		pPlayer->SpeakWeaponFire();	}	CTF_GameStats.Event_PlayerFiredWeapon( pPlayer, IsCurrentAttackACrit() );#endif	// Set the weapon mode.	m_iWeaponMode = TF_WEAPON_PRIMARY_MODE;	SendWeaponAnim( ACT_VM_PRIMARYATTACK );	pPlayer->SetAnimation( PLAYER_ATTACK1 );	FireProjectile( pPlayer );	m_flLastFireTime  = gpGlobals->curtime;	// Set next attack times.	m_flNextPrimaryAttack = gpGlobals->curtime + m_pWeaponInfo->GetWeaponData( m_iWeaponMode ).m_flTimeFireDelay;	// Don't push out secondary attack, because our secondary fire	// systems are all separate from primary fire (sniper zooming, demoman pipebomb detonating, etc)	//m_flNextSecondaryAttack = gpGlobals->curtime + m_pWeaponInfo->GetWeaponData( m_iWeaponMode ).m_flTimeFireDelay;	// Set the idle animation times based on the sequence duration, so that we play full fire animations	// that last longer than the refire rate may allow.	if ( Clip1() > 0 )	{		SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() );	}	else	{		SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() );	}	// Check the reload mode and behave appropriately.	if ( m_bReloadsSingly )	{		m_iReloadMode.Set( TF_RELOAD_START );	}}	
开发者ID:Navton,项目名称:TF2Classic,代码行数:70,


示例26: UpdateAllies

//.........这里部分代码省略.........            SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);            if (!spellInfo)                continue;            if (me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))                continue;            // check spell cooldown, this should be checked in CheckCast...            if (me->HasSpellCooldown(spellInfo->Id))                continue;            if (spellInfo->IsPositive())            {                if (spellInfo->CanBeUsedInCombat())                {                    // Check if we're in combat or commanded to attack                    if (!me->IsInCombat() && !me->GetCharmInfo()->IsCommandAttack())                        continue;                }                Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);                spell->LoadScripts(); // xinef: load for CanAutoCast (calling CheckPetCast)                bool spellUsed = false;                // Some spells can target enemy or friendly (DK Ghoul's Leap)                // Check for enemy first (pet then owner)                Unit* target = me->getAttackerForHelper();                if (!target && owner)                    target = owner->getAttackerForHelper();                if (target)                {                    if (CanAttack(target) && spell->CanAutoCast(target))                    {                        targetSpellStore.push_back(std::make_pair(target, spell));                        spellUsed = true;                    }                }                // No enemy, check friendly                if (!spellUsed)                {                    for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)                    {                        Unit* ally = ObjectAccessor::GetUnit(*me, *tar);                        //only buff targets that are in combat, unless the spell can only be cast while out of combat                        if (!ally)                            continue;                        if (spell->CanAutoCast(ally))                        {                            targetSpellStore.push_back(std::make_pair(ally, spell));                            spellUsed = true;                            break;                        }                    }                }                // No valid targets at all                if (!spellUsed)                    delete spell;            }            else if (me->GetVictim() && CanAttack(me->GetVictim(), spellInfo) && spellInfo->CanBeUsedInCombat())            {
开发者ID:rynnokung,项目名称:azerothcore-wotlk,代码行数:67,


示例27: UpdateAllies

//.........这里部分代码省略.........                continue;            SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);            if (!spellInfo)                continue;            if (me->GetCharmInfo() && me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))                continue;            if (spellInfo->IsPositive())            {                if (spellInfo->CanBeUsedInCombat())                {                    // check spell cooldown                    if (me->HasSpellCooldown(spellInfo->Id))                        continue;                    // Check if we're in combat or commanded to attack                    if (!me->isInCombat() && !me->GetCharmInfo()->IsCommandAttack())                        continue;                }                Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);                bool spellUsed = false;                // Some spells can target enemy or friendly (DK Ghoul's Leap)                // Check for enemy first (pet then owner)                Unit* target = me->getAttackerForHelper();                if (!target && owner)                    target = owner->getAttackerForHelper();                if (target)                {                    if (CanAttack(target) && spell->CanAutoCast(target))                    {                        targetSpellStore.push_back(std::make_pair(target, spell));                        spellUsed = true;                    }                }                if (spellInfo->HasEffect(SPELL_EFFECT_JUMP_DEST))                    continue; // Pets must only jump to target                // No enemy, check friendly                if (!spellUsed)                {                    for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)                    {                        Unit* ally = ObjectAccessor::GetUnit(*me, *tar);                        //only buff targets that are in combat, unless the spell can only be cast while out of combat                        if (!ally)                            continue;                        if (spell->CanAutoCast(ally))                        {                            targetSpellStore.push_back(std::make_pair(ally, spell));                            spellUsed = true;                            break;                        }                    }                }                // No valid targets at all                if (!spellUsed)                    delete spell;
开发者ID:Ne3x,项目名称:TrinityCore,代码行数:67,


示例28: ToTFPlayer

//-----------------------------------------------------------------------------// Purpose: Start placing or building the currently selected object//-----------------------------------------------------------------------------void CTFWeaponBuilder::PrimaryAttack( void ){	CTFPlayer *pOwner = ToTFPlayer( GetOwner() );	if ( !pOwner )		return;	if ( !CanAttack() )		return;	// Necessary so that we get the latest building position for the test, otherwise	// we are one frame behind.	UpdatePlacementState();	// What state should we move to?	switch( m_iBuildState )	{	case BS_IDLE:		{			// Idle state starts selection			SetCurrentState( BS_SELECTING );		}		break;	case BS_SELECTING:		{			// Do nothing, client handles selection			return;		}		break;	case BS_PLACING:		{			if ( m_hObjectBeingBuilt )			{				int iFlags = m_hObjectBeingBuilt->GetObjectFlags();				// Tricky, because this can re-calc the object position and change whether its a valid 				// pos or not. Best not to do this only in debug, but we can be pretty sure that this				// will give the same result as was calculated in UpdatePlacementState() above.				Assert( IsValidPlacement() );				// If we're placing an attachment, like a sapper, play a placement animation on the owner				if ( m_hObjectBeingBuilt->MustBeBuiltOnAttachmentPoint() )				{					pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_GRENADE );				}				StartBuilding();				// Should we switch away?				if ( iFlags & OF_ALLOW_REPEAT_PLACEMENT )				{					// Start placing another					SetCurrentState( BS_PLACING );					StartPlacement(); 				}				else				{					SwitchOwnersWeaponToLast();				}			}		}		break;	case BS_PLACING_INVALID:		{			if ( m_flNextDenySound < gpGlobals->curtime )			{				CSingleUserRecipientFilter filter( pOwner );				EmitSound( filter, entindex(), "Player.DenyWeaponSelection" );				m_flNextDenySound = gpGlobals->curtime + 0.5;			}		}		break;	}	m_flNextPrimaryAttack = gpGlobals->curtime + 0.2f;}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:82,


示例29: min

void CBasePlayerWeapon::ItemPostFrame( void ){	if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )	{		// Pcjoe: Regular HL weapon		if(!MMWeapon())		{			// complete the reload. 			int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);				// Add them to the clip			m_iClip += j;						// Removed by Pcjoe		/*	m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j;			m_pPlayer->TabulateAmmo();*/		}		// Pcjoe: Reload MM weapon		else if(((CMMWeapon*)this)->RapidFireWeapon())		{	CBaseRapidFireGun *pWeapon = (CBaseRapidFireGun*)this;			// Reload ammo for non-power weapons			if(!pWeapon->UsePowerPrimary())			{	pWeapon->m_iPrimaryCur = pWeapon->MaxRounds();				pWeapon->m_iClip = pWeapon->MaxRounds();			}			if(!pWeapon->UsePowerSecondary())			{	pWeapon->m_iSecondaryCur = pWeapon->m_iSecondaryMax;			}		}		m_fInReload = FALSE;	}	// Edited by Pcjoe//	if ((m_pPlayer->pev->button & IN_ATTACK2) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) )	if ((m_pPlayer->pev->button & IN_ATTACK2) && !m_pPlayer->m_fImpact && !m_pPlayer->m_fBoost && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) )	{		if ( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] )		{			m_fFireOnEmpty = TRUE;		}		// Removed by Pcjoe//		m_pPlayer->TabulateAmmo();		SecondaryAttack();		m_pPlayer->pev->button &= ~IN_ATTACK2;	}	// Edited by Pcjoe//	else if ((m_pPlayer->pev->button & IN_ATTACK) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) )	else if ((m_pPlayer->pev->button & IN_ATTACK) && !m_pPlayer->m_fImpact && !m_pPlayer->m_fBoost && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) )	{		if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) )		{			m_fFireOnEmpty = TRUE;		}		// Removed by Pcjoe//		m_pPlayer->TabulateAmmo();		PrimaryAttack();	}	else if ( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) 	{		// reload when reload is pressed, or if no buttons are down and weapon is empty.		Reload();	}	else if ( !(m_pPlayer->pev->button & (IN_ATTACK|IN_ATTACK2) ) )	{		// no fire buttons down		m_fFireOnEmpty = FALSE;		if ( !IsUseable() && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) 		{			// weapon isn't useable, switch.			if ( !(iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) && g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) )			{				m_flNextPrimaryAttack = ( UseDecrement() ? 0.0 : gpGlobals->time ) + 0.3;				return;			}		}		else		{			// weapon is useable. Reload if empty and weapon has waited as long as it has to after firing			if ( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) )			{	Reload();				// Pcjoe: Allow mm weapons to call idle				if(!MMWeapon())				{	return;				}			}		}		WeaponIdle( );		return;	}		// catch all	if ( ShouldWeaponIdle() )	{//.........这里部分代码省略.........
开发者ID:vermagav,项目名称:mechmod,代码行数:101,


示例30: GetItemPrototype

void CUser::Attack(Packet & pkt){	int16 sid = -1, tid = -1, damage, delaytime, distance;		uint8 bType, bResult = 0;		Unit * pTarget = nullptr;	pkt >> bType >> bResult >> tid >> delaytime >> distance;	//	delaytime = delaytime / 100.0f;	//	distance = distance / 10.0f;	if (isIncapacitated())		return;	if (isInSafetyArea())		return;	if (m_bInvisibilityType != INVIS_NONE)	{		CMagicProcess::RemoveStealth(this, INVIS_DISPEL_ON_MOVE);		CMagicProcess::RemoveStealth(this, INVIS_DISPEL_ON_ATTACK);	}	// If you're holding a weapon, do a client-based (ugh, do not trust!) delay check.	_ITEM_TABLE *pTable = GetItemPrototype(RIGHTHAND);	if (pTable != nullptr) 	{		if (delaytime < (pTable->m_sDelay + 10) // client adds 0.1 onto the interval (0.1 of 100 is 10)			|| distance > pTable->m_sRange)			return;		}	// Empty handed.	else if (delaytime < 100)		return;				pTarget = g_pMain->GetUnitPtr(tid);	bResult = ATTACK_FAIL;	if (pTarget != nullptr 		&& isInAttackRange(pTarget)		&& CanAttack(pTarget))	{		if (isAttackable(pTarget) && CanCastRHit(GetSocketID()))		{			if (isInTempleEventZone())				if (GetUserGroup() != -1 && !isSameUserGroup(pTarget))					return;			CUser *pUser = g_pMain->GetUserPtr(GetSocketID());			if (pUser != nullptr)				pUser->m_RHitRepeatList.insert(std::make_pair(GetSocketID(), UNIXTIME));			damage = GetDamage(pTarget);			// Can't use R attacks in the Snow War.			if (GetZoneID() == ZONE_SNOW_BATTLE 				&& g_pMain->m_byBattleOpen == SNOW_BATTLE)				damage = 0;			if (damage > 0)			{				pTarget->HpChange(-damage, this);				if (pTarget->isDead())					bResult = ATTACK_TARGET_DEAD;				else					bResult = ATTACK_SUCCESS;				// Every attack takes a little of your weapon's durability.				ItemWoreOut(ATTACK, damage);				// Every hit takes a little of the defender's armour durability.				if (pTarget->isPlayer())					TO_USER(pTarget)->ItemWoreOut(DEFENCE, damage);			}		}	}	Packet result(WIZ_ATTACK, bType);	result << bResult << GetSocketID() << tid;	SendToRegion(&result);}
开发者ID:drCihaTKAYA,项目名称:koserver,代码行数:81,



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


C++ CanFireForActivator函数代码示例
C++ CanAccessMovie函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。