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


C++ CClientWeapon类代码示例

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


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

示例1: OnPlayerDead

void CClientWeaponMgr::OnPlayerDead()
{
	// See if we are trying to throw a grenade...
	if( (!g_pPlayerMgr->IsSpectating( )) &&
		(g_pInterfaceMgr->GetGameState() == GS_PLAYING)  &&
		(g_pPlayerStats->GetCurrentGrenadeRecord( ) != NULL) &&
		(g_pPlayerStats->GetCurrentGrenadeCount( ) > 0) &&
		(m_pCurrentWeapon) && (m_pCurrentWeapon->GetState() == W_GREN_THROWING))
	{
		// Determine if the grenade may be dropped on death...
		HWEAPONDATA hGrenadeData = g_pWeaponDB->GetWeaponData( g_pPlayerStats->GetCurrentGrenadeRecord( ), !USE_AI_DATA );
		bool bDropGrenade = g_pWeaponDB->GetBool( hGrenadeData, WDB_WEAPON_bDropGrenadeOnDeath );
		
		CClientWeapon *pGrenade = CPlayerBodyMgr::Instance( ).GetGrenadeWeapon( );
		if( pGrenade && bDropGrenade )
		{
			pGrenade->DropGrenade( );
		}
	}

	// Since the player is dead they should no longer fire...

	if( m_pCurrentWeapon )
		m_pCurrentWeapon->ClearFiring();

	DisableWeapons();
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:27,代码来源:ClientWeaponMgr.cpp

示例2: SetWeaponConfig

void CElementRPCs::SetWeaponConfig ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    if ( pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        SWeaponConfiguration weaponConfig;

        if ( bitStream.ReadBit ( weaponConfig.bDisableWeaponModel ) &&
            bitStream.ReadBit ( weaponConfig.bInstantReload ) &&
            bitStream.ReadBit ( weaponConfig.bShootIfTargetBlocked ) &&
            bitStream.ReadBit ( weaponConfig.bShootIfTargetOutOfRange ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckBuildings ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckCarTires ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckDummies ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckObjects ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckPeds ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckVehicles ) &&
            bitStream.ReadBit ( weaponConfig.flags.bIgnoreSomeObjectsForCamera ) &&
            bitStream.ReadBit ( weaponConfig.flags.bSeeThroughStuff ) &&
            bitStream.ReadBit ( weaponConfig.flags.bShootThroughStuff ) )
        {
            pWeapon->SetFlags ( weaponConfig );
        }
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:25,代码来源:CElementRPCs.cpp

示例3: SetCustomWeaponTarget

void CElementRPCs::SetCustomWeaponTarget ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    ElementID elementID = INVALID_ELEMENT_ID;
    char cTargetBone = 0;
    bool bVector = false;
    CVector vecTarget;

    if ( bitStream.ReadBit ( bVector ) &&
        pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        if ( bVector )
        {
            if ( bitStream.ReadVector ( vecTarget.fX, vecTarget.fY, vecTarget.fZ ) )
            {
                pWeapon->SetWeaponTarget ( vecTarget );
            }
        }
        else
        {
            if ( bitStream.Read ( elementID ) && 
                bitStream.Read ( cTargetBone ) )
            {
                pWeapon->SetWeaponTarget ( CElementIDs::GetElement( elementID ), cTargetBone );
            }
        }
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:28,代码来源:CElementRPCs.cpp

示例4: GetWeaponTarget

int CLuaFunctionDefs::GetWeaponTarget ( lua_State* luaVM )
{
    CClientWeapon * pWeapon;
    CClientEntity * pTarget;
    CVector vecTarget;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWeapon );
    if ( !argStream.HasErrors () )
    {
        switch ( pWeapon->GetWeaponTargetType ( ) )
        {
            case TARGET_TYPE_VECTOR:
                vecTarget = pWeapon->GetWeaponVectorTarget ( );
                lua_pushnumber ( luaVM, vecTarget.fX );
                lua_pushnumber ( luaVM, vecTarget.fY );
                lua_pushnumber ( luaVM, vecTarget.fZ );
            return 3;
            case TARGET_TYPE_ENTITY:
                pTarget = pWeapon->GetWeaponEntityTarget ( );
                lua_pushelement ( luaVM, pTarget );
            return 1;
            case TARGET_TYPE_FIXED:
                lua_pushnil ( luaVM );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
    
    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:ntauthority,项目名称:openvice,代码行数:32,代码来源:CLuaFunctionDefs.Weapon.cpp

示例5: Open

bool CAmmoChooser::Open()
{
	// Don't allow the chooser to be opened if we're selecting/deselecting a
	// weapon...

	CClientWeapon *pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();

	WeaponState eState = pClientWeapon->GetState();
	if (W_DESELECT == eState || W_SELECT == eState) return false;


	if (m_bIsOpen)
        return true;


	m_hAmmo = pClientWeapon->GetAmmoRecord();

	if( m_hAmmo == pClientWeapon->GetNextAvailableAmmo() )
	{
		m_hAmmo = NULL;
        m_bIsOpen = false;
        return false;
	}
    m_bIsOpen = true;

	m_AutoCloseTimer.Start(kfDelayTime);
	g_pHUDMgr->QueueUpdate(kHUDChooser);
    return true;
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:29,代码来源:WeaponChooser.cpp

示例6: HandleBlocked

void CClientMeleeCollisionController::HandleBlocked(HOBJECT hTarget, const LTVector& vPos, const LTVector& vDir)
{
	// Get the proper weapon record...
	CClientWeapon* pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();
	HWEAPON hWeapon = pClientWeapon ? pClientWeapon->GetWeaponRecord() : NULL;	//!!ARL: Use Attacker's weapon instead?  (will need to be sent from server - probably along with block info)
	HWEAPONDATA hWeaponData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);

	// Spawn a block effect for it...
	const char* pszBlockFX = g_pWeaponDB->GetString(hWeaponData, "BlockFX");
	CLIENTFX_CREATESTRUCT fxcs(pszBlockFX, 0, LTRigidTransform(vPos, LTRotation(vDir, LTVector(0,1,0))));
	g_pGameClientShell->GetSimulationTimeClientFXMgr().CreateClientFX(NULL, fxcs, true);

	// Let the server objects know they've blocked / been blocked.
	CAutoMessage cMsg;
	cMsg.Writeuint8(MID_OBJECT_MESSAGE);
	cMsg.WriteObject(m_hObject);
	cMsg.Writeuint32(MID_MELEEBLOCK);
	cMsg.WriteObject(hTarget);
	g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED);

	// Disable attacker's collision (i.e. stop attacking).
	DisableCollisions();

	// For local player attackers, send a BlockRecoil stimulus so a proper animation can be played.
	if (m_hObject == g_pPlayerMgr->GetMoveMgr()->GetObject())
	{
		CPlayerBodyMgr::Instance().HandleAnimationStimulus("CS_RecoilFromBlock");
	}
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:29,代码来源:ClientMeleeCollisionController.cpp

示例7: SetWeaponOwner

int CLuaFunctionDefs::SetWeaponOwner ( lua_State* luaVM )
{
    CClientWeapon * pWeapon;
    CClientPlayer * pPlayer;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWeapon );
    if ( argStream.NextIsUserData() )
    {
        argStream.ReadUserData ( pPlayer );
        if ( !argStream.HasErrors () )
        {
            pWeapon->SetOwner( pPlayer );

            lua_pushboolean ( luaVM, true );
            return 1;
        }
    }
    else if ( argStream.NextIsNil() )
    {
        if ( !argStream.HasErrors () )
        {
            pWeapon->SetOwner( NULL );

            lua_pushboolean ( luaVM, true );
            return 1;
        }
    }
    if ( argStream.HasErrors() )
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushnil ( luaVM );
    return 1;
}
开发者ID:ntauthority,项目名称:openvice,代码行数:33,代码来源:CLuaFunctionDefs.Weapon.cpp

示例8: Render

void CHUDAmmo::Render()
{
	if( g_vtHUDAmmoRender.GetFloat( ) < 1.0f )
		return;

	bool bWeaponsEnabled = g_pClientWeaponMgr->WeaponsEnabled();
	CClientWeapon* pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();
	if (!pClientWeapon || !bWeaponsEnabled) return;

	if (!m_bDraw || pClientWeapon->GetState() == W_DESELECT) return;

	SetRenderState();

	if (!m_bInfinite)
	{
		m_Text.Render();
	}

	//render icon here
	if (m_hIconTexture)
	{
		g_pDrawPrim->SetTexture(m_hIconTexture);
		g_pDrawPrim->DrawPrim(&m_IconPoly,1);
	}
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:25,代码来源:HUDAmmo.cpp

示例9: FireCustomWeapon

void CElementRPCs::FireCustomWeapon ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    if ( pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        pWeapon->Fire ( true );
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:8,代码来源:CElementRPCs.cpp

示例10: GetCurrentClientWeapon

// GRENADE PROTOTYPE
WeaponState	CClientWeaponMgr::GetCurrentWeaponState() const
{
	CClientWeapon* pWpn = GetCurrentClientWeapon();

	if (!pWpn) return W_INACTIVE;

	return pWpn->GetState();
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:9,代码来源:ClientWeaponMgr.cpp

示例11: ResetCustomWeaponFiringRate

void CElementRPCs::ResetCustomWeaponFiringRate ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    if ( pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        pWeapon->ResetWeaponFireTime ( );
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:8,代码来源:CElementRPCs.cpp

示例12: SetCustomWeaponAmmo

void CElementRPCs::SetCustomWeaponAmmo ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    int iAmmo = 0;
    if ( bitStream.Read ( iAmmo ) &&
        pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        pWeapon->SetAmmo ( iAmmo );
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:10,代码来源:CElementRPCs.cpp

示例13: GetClientWeapon

CClientWeapon* CClientWeaponMgr::GetClientWeapon( HWEAPON hDesiredWeapon ) const
{
	for( uint32 iWeapon=0; iWeapon < m_nMaxWeapons; ++iWeapon )
	{
		CClientWeapon* pCur = m_apClientWeapon[iWeapon];
		if( pCur->GetWeaponRecord() == hDesiredWeapon )
			return m_apClientWeapon[iWeapon];
	}
	return NULL;
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:10,代码来源:ClientWeaponMgr.cpp

示例14: SetCustomWeaponFiringRate

void CElementRPCs::SetCustomWeaponFiringRate ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    int iFiringRate = 0;
    if ( bitStream.Read ( iFiringRate ) &&
        pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        pWeapon->SetWeaponFireTime ( iFiringRate );
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:10,代码来源:CElementRPCs.cpp

示例15: Update

void CHUDAmmo::Update()
{

	HWEAPON hWeapon = g_pPlayerStats->GetCurrentWeaponRecord();
	HAMMO hAmmo = g_pPlayerStats->GetCurrentAmmoRecord();

	m_bDraw = (hWeapon && hAmmo);

	if (hAmmo)
	{
		DamageType dtAmmoInstDamageType = g_pWeaponDB->GetAmmoInstDamageType( hAmmo);
		if (dtAmmoInstDamageType == DT_MELEE)
			m_bDraw = false;
	}

	if (!m_bDraw) return;

	CClientWeapon* pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon( );
	int nAmmoInClip = pClientWeapon ? pClientWeapon->GetAmmoInClips() : 0;
	int nAmmo = g_pPlayerStats->GetCurrentAmmoCount() - nAmmoInClip;

	HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);
	m_bInfinite = g_pWeaponDB->GetBool( hWpnData, WDB_WEAPON_bInfiniteAmmo );

	if (!m_bInfinite)
	{
		wchar_t wstr[32];
		FormatString("HUD_Ammo_Format",wstr,LTARRAYSIZE(wstr), nAmmoInClip, nAmmo < 0 ? 0 : nAmmo);

		if ((nAmmo > 0) || (nAmmoInClip > 0))
		{
			EnableFade(true);
		}
		else
		{
			ResetFade();
			EnableFade( false );
		}
		

		m_Text.SetText(wstr);
	}

	if (m_hLastAmmo != hAmmo)
	{
		HAMMODATA hAmmoData = g_pWeaponDB->GetAmmoData(hAmmo);
		m_hIconTexture.Load( g_pWeaponDB->GetString( hAmmoData, WDB_AMMO_sIcon ) );
		SetupQuadUVs(m_IconPoly, m_hIconTexture, 0.0f, 0.0f, 1.0f, 1.0f);
		m_hLastAmmo = hAmmo;
	}

	ResetFade();

}
开发者ID:Arc0re,项目名称:lithtech,代码行数:54,代码来源:HUDAmmo.cpp


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