当前位置: 首页>>代码示例>>C++>>正文


C++ CBaseGrenade::AddEffects方法代码示例

本文整理汇总了C++中CBaseGrenade::AddEffects方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseGrenade::AddEffects方法的具体用法?C++ CBaseGrenade::AddEffects怎么用?C++ CBaseGrenade::AddEffects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBaseGrenade的用法示例。


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

示例1: ThrowGrenade

//-----------------------------------------------------------------------------
// Purpose:
// Input  : *pPlayer -
//-----------------------------------------------------------------------------
void CWeaponFrag::ThrowGrenade( CBasePlayer *pPlayer, bool Invis /*= false*/ )
{
#ifndef CLIENT_DLL
    Vector	vecEye = pPlayer->EyePosition();
    Vector	vForward, vRight;

    pPlayer->EyeVectors( &vForward, &vRight, NULL );
    Vector vecSrc = vecEye + vForward * 18.0f + vRight * 8.0f;
    CheckThrowPosition( pPlayer, vecEye, vecSrc );
//	vForward[0] += 0.1f;
    vForward[2] += 0.1f;

    Vector vecThrow;
    pPlayer->GetVelocity( &vecThrow, NULL );
    //DHL - We're just gonna set the grenade off at vecSrc if it goes off "in their hand", so don't worry about velocity
    if ( !Invis )
        vecThrow += vForward * 1200;
    //DHL: Added conditional to last arg, to allow priming...
    //If we haven't hit the time we should explode yet, use the remaining time as the clock for the grenade
    //Otherwise (we're due to explode) throw (will be forced in the PostFrame function) and go off near immediately
    CBaseGrenade *pGrenade = Fraggrenade_Create( vecSrc, vec3_angle, vecThrow, AngularImpulse(600,random->RandomInt(-1200,1200),0), pPlayer, ( (flExplodeTime > gpGlobals->curtime) ? (flExplodeTime - gpGlobals->curtime) : 0.01f ), false );

    if ( pGrenade )
    {
        if ( pPlayer && pPlayer->m_lifeState != LIFE_ALIVE )
        {
            pPlayer->GetVelocity( &vecThrow, NULL );

            IPhysicsObject *pPhysicsObject = pGrenade->VPhysicsGetObject();
            if ( pPhysicsObject )
            {
                pPhysicsObject->SetVelocity( &vecThrow, NULL );
            }
        }

        pGrenade->SetDamage( GetHL2MPWpnData().m_iPlayerDamage );
        pGrenade->SetDamageRadius( GRENADE_DAMAGE_RADIUS );
        if ( Invis ) //DHL - Don't always want to be able to see the grenade
        {
            pGrenade->AddEffects( EF_NODRAW );
            pGrenade->SetMoveType( MOVETYPE_NONE );

            CUtlVector<CBaseEntity *> childrenList;
            GetAllChildren( pGrenade, childrenList );
            if ( childrenList.Count() ) // If there's any children in the list...
            {
                for ( int i = childrenList.Count()-1; i >= 0; --i )
                {
                    UTIL_Remove( childrenList[i] ); //Remove them all
                }
            }
            pGrenade->SetAbsVelocity( vec3_origin );
            pGrenade->SetAbsOrigin( vecSrc ); //Put the grenade right back in their hand incase it's moved
            pGrenade->Detonate();
        }
    }
#endif

    m_bRedraw = true;

    WeaponSound( SINGLE );

    // player "shoot" animation
    pPlayer->SetAnimation( PLAYER_ATTACK1 );
}
开发者ID:dreckard,项目名称:dhl2,代码行数:69,代码来源:weapon_frag.cpp


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