コード例 #1
0
void COMMAND_EnterPassenger(const char* szCmdLine)
{
    // HACK: we don't want them to enter a vehicle if they're in cursor mode
    if (g_pClientGame && !g_pClientGame->AreCursorEventsEnabled())
    {
        // Disable passenger entry while reloading so it doesen't abort the animation
        CClientPlayer* pPlayer = g_pClientGame->GetPlayerManager()->GetLocalPlayer();
        if (pPlayer)
        {
            CWeapon* pWeapon = pPlayer->GetWeapon();
            if (pWeapon)
            {
                if (pWeapon->GetState() != WEAPONSTATE_RELOADING)
                {
                    g_pClientGame->ProcessVehicleInOutKey(true);
                }
            }
        }
    }
}
コード例 #2
0
int CScriptBind_Weapon::GetAccessory(IFunctionHandler *pH, const char *accessoryName)
{
	CWeapon *pWeapon = GetWeapon(pH);
	if (!pWeapon)
		return pH->EndFunction();

	CItem *pItem = pWeapon->GetAccessory(accessoryName);					
	
	if(!pItem)
		return 0;

	IEntity *pEntity  = pItem->GetEntity();

	if(!pEntity)
		return 0;
	
	IScriptTable *pScriptTable = pEntity->GetScriptTable();

	return pH->EndFunction( pScriptTable );
}
コード例 #3
0
void CCinematicInput::OnAction( const EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	const CGameActions& gameActions = g_pGame->Actions();

	if (actionId == gameActions.attack1_cine)
	{
		CWeapon* pPrimaryWeapon = GetWeapon( eWeapon_Primary );
		if (pPrimaryWeapon != NULL)
		{
			pPrimaryWeapon->OnAction( actorId, actionId, activationMode, value );
		}
	}
	else if (actionId == gameActions.attack2_cine)
	{
		CWeapon* pSecondaryWeapon = GetWeapon( eWeapon_Secondary );
		if (pSecondaryWeapon != NULL)
		{
			pSecondaryWeapon->OnAction( actorId, actionId, activationMode, value );
		}
	}
}
コード例 #4
0
//----------------------------------------------
void CC4Detonator::SelectC4()
{
	if (CActor *pOwner = GetOwnerActor())
	{
		EntityId c4Id = pOwner->GetInventory()->GetItemByClass(CItem::sC4Class);

		if (c4Id)
		{
			//Do not reselect C4 is there's no ammo
			IItem *pItem = m_pItemSystem->GetItem(c4Id);
			CWeapon *pWep = pItem ? static_cast<CWeapon *>(pItem->GetIWeapon()) : NULL;

			if(pWep && pWep->OutOfAmmo(false))
			{
				return;
			}

			pOwner->SelectItemByName("C4", false);
		}
	}
}
コード例 #5
0
bool  CCustomDetector::CheckCompatibilityInt(CHudItem* itm)
{
	if(itm==NULL)
		return true;

	CInventoryItem iitm				= itm->item();
	u32 slot						= iitm.GetSlot();
	bool bres = (slot==PISTOL_SLOT || slot==KNIFE_SLOT || slot==BOLT_SLOT);

	if(itm->GetState()!=CHUDState::eShowing)
		bres = bres && !itm->IsPending();

	if(bres)
	{
		CWeapon* W = smart_cast<CWeapon*>(itm);
		if(W)
			bres = bres && (W->GetState() != CHUDState::eBore) && (W->GetState() != CWeapon::eReload) &&
			(W->GetState() != CWeapon::eSwitch) && !W->IsZoomed();//+
	}
	return bres;
}
コード例 #6
0
//////////////////////////////////////////////////////////////////////////////////////////
//
// CVehicle::BurstTyre
//      (Used for CAutomobile and CBike hooks)
//
// Called when an inflated vehicle tyre is hit by a bullet
//
//////////////////////////////////////////////////////////////////////////////////////////
bool OnMY_CVehicle_BurstTyre( CVehicleSAInterface* pVehicle, uchar ucTyre )
{
    if ( m_pVehicleDamageHandler )
    {
        eWeaponType weaponType = WEAPONTYPE_INVALID;

        // Discover weapon if possible
        CPed* pInitiator = pGameInterface->GetPools()->GetPed ( (DWORD *)pBulletImpactInitiator );
        if ( pInitiator )
        {
            CWeapon* pWeapon = pInitiator->GetWeapon ( pInitiator->GetCurrentWeaponSlot () );
            if ( pWeapon )
                weaponType = pWeapon->GetType ();
        }

        if ( !m_pVehicleDamageHandler( pVehicle, 0, pBulletImpactInitiator, weaponType, vecSavedBulletImpactEndPosition, ucTyre ) )
            return false;
    }

    return true;
}
コード例 #7
0
ファイル: WeaponNodes.cpp プロジェクト: RenEvo/dead6
	void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		if(eFE_Activate == event && IsPortActive(pActInfo,0))
		{
			IActor* pActor = GetActor(pActInfo);
			if (pActor == 0)
				return;

			CWeapon* pWeapon = static_cast<CWeapon*> (GetWeapon(pActor));
			bool bZoomed = false;
			if (pWeapon != 0)
			{
				const string& weaponClass = GetPortString(pActInfo, 1);
				if (weaponClass.empty() == true || weaponClass == pWeapon->GetEntity()->GetClass()->GetName())
				{
					bZoomed = pWeapon->IsZoomed();
				}
			}
			ActivateOutput(pActInfo, bZoomed ? 1 : 0, true);			
		}
	}
コード例 #8
0
ファイル: prophet.cpp プロジェクト: jordandavidson/lithtech
DBOOL Prophet::Fire(DBOOL bAltFire)
{
    DBOOL bFire = DFALSE;
    CWeapon* pW = m_InventoryMgr.GetCurrentWeapon();

    if(pW == DNULL)
    {
        SetNewState(STATE_Idle);
        return DFALSE;
    }

    DVector vTargetVel, vVel;
    m_pServerDE->GetVelocity(m_hTarget, &vTargetVel);
    m_pServerDE->GetVelocity(m_hObject, &vVel);

    DFLOAT fTargetVel = VEC_MAG(vTargetVel);
    DFLOAT fVel = VEC_MAG(vVel);

    if(fTargetVel <= 5.0f && fVel <= 5.0f && pW->GetType() != WEAP_ASSAULTRIFLE
            && pW->GetType() != WEAP_NAPALMCANNON && pW->GetType() != WEAP_SNIPERRIFLE)
    {
        if(m_InventoryMgr.GetAmmoCount(pW->GetAmmoType(DFALSE)) >= pW->GetAltAmmoUse())
            bFire = DTRUE;
    }

//	DDWORD m_nFiredWeapon = m_InventoryMgr.FireCurrentWeapon(&m_MoveObj.GetPos(), &m_MoveObj.GetRotation(), bFire);

    return AI_Mgr::Fire(bFire);
}
コード例 #9
0
bool CLaser::GetProbableHit(EntityId weaponId, const IFireMode* pFireMode, Vec3& hit)
{
	if (!m_laserBeam.IsLaserActivated())
		return false;

	if(gEnv->bMultiplayer)
	{
		CWeapon* pParentWeapon = GetWeapon();
		if (pParentWeapon && pParentWeapon->IsZoomed())
		{
			return false;
		}
	}

	CWeapon* pWeapon = GetWeapon();
	int slot = pWeapon->IsOwnerFP() ? eIGS_FirstPerson : eIGS_ThirdPerson;

	Vec3 lastBeamHit = m_laserBeam.GetLastHit();
	Vec3 currentBeamPosition = pWeapon->GetSlotHelperPos(slot, "weapon_term", true);
	Matrix33 rotation = pWeapon->GetSlotHelperRotation(slot, "weapon_term", true);
	Vec3 currentBeamDirection = rotation.GetColumn1();

	const CFireMode* pCFireMode = static_cast<const CFireMode*>(pFireMode);
	const CSingle* pSingle = crygti_cast<const CSingle*>(pCFireMode);
	if (pSingle && pSingle->GetShared()->fireparams.laser_beam_uses_spread)
	{
		currentBeamDirection = pSingle->ApplySpread(currentBeamDirection, pSingle->GetSpread());
	}

	float distanceToLastHit = lastBeamHit.GetDistance(currentBeamPosition);
	hit = currentBeamPosition + currentBeamDirection * distanceToLastHit;

	return true;
}
コード例 #10
0
ファイル: PlayerStateUtil.cpp プロジェクト: Xydrel/Infected
bool CPlayerStateUtil::ShouldSprint( const CPlayer& player, const SActorFrameMovementParams& movement, IItem* pCurrentPlayerItem )
{
	bool shouldSprint = false;
	const SPlayerStats& stats = player.m_stats;
	const bool movingForward = IsMovingForward( player, movement );

	bool restrictSprint = player.IsJumping() || stats.bIgnoreSprinting || player.IsSliding() || player.IsCinematicFlagActive(SPlayerStats::eCinematicFlag_RestrictMovement);

	CWeapon* pWeapon = pCurrentPlayerItem ? static_cast<CWeapon*>(pCurrentPlayerItem->GetIWeapon()) : NULL;
	bool isZooming = pWeapon ? pWeapon->IsZoomed() && !pWeapon->IsZoomingInOrOut() : false;
	if (pWeapon && !pWeapon->CanSprint())
		restrictSprint = true;
	
	restrictSprint = restrictSprint || (player.GetSprintStaminaLevel() <= 0.f);
	//CryLogAlways("  restrictSprint = %d", restrictSprint);

	if (player.IsSprinting() == false)
	{
		shouldSprint = movingForward && !restrictSprint && !isZooming;
		CCCPOINT_IF(shouldSprint, PlayerMovement_SprintOn);
	}
	else
	{
		shouldSprint = movingForward && !restrictSprint && !isZooming;
		//CryLogAlways("  shouldSprint = %d", shouldSprint);

		shouldSprint = shouldSprint && (!(player.m_actions & ACTION_CROUCH));

		if(!shouldSprint && pWeapon)
		{
			pWeapon->ForcePendingActions();
		}
	}

	CCCPOINT_IF(!player.IsSprinting() && !shouldSprint && (player.m_actions & ACTION_SPRINT), PlayerMovement_SprintRequestIgnored);
	CCCPOINT_IF(player.IsSprinting() && !shouldSprint, PlayerMovement_SprintOff);

	//CryLogAlways("  returning (for \"%s\") shouldSprint = %d", m_player.GetEntity()->GetName(), shouldSprint);
	return shouldSprint;
}
コード例 #11
0
//-------------------------------------------
void CLaser::Update(SEntityUpdateContext& ctx, int slot)
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);

	if((slot == eIUS_General) && m_laserBeam.IsLaserActivated())
	{
		RequireUpdate(eIUS_General);

		CWeapon* pParentWeapon = GetWeapon();
		if (pParentWeapon)
		{
			CActor* pOwnerActor = pParentWeapon->GetOwnerActor();
			Vec3 laserPos, laserDir;
			GetLaserPositionAndDirection(pParentWeapon, laserPos, laserDir);

			CLaserBeam::SLaserUpdateDesc laserUpdateDesc(laserPos, laserDir, ctx.fFrameTime, pParentWeapon->GetEntity()->IsHidden());
			laserUpdateDesc.m_weaponZoomed = pParentWeapon->IsZoomed() || pParentWeapon->IsZoomingInOrOut();

			m_laserBeam.UpdateLaser(laserUpdateDesc);
		}
	}
}
コード例 #12
0
ファイル: ClientCommands.cpp プロジェクト: qaisjp/green-candy
void COMMAND_GiveWeapon ( const char *szCmdLine )
{
    if ( !(szCmdLine && szCmdLine[0]) )
        return;

    int nWeaponID = atoi(szCmdLine);
    /*
     * Check validity of the command line weapon id.
     */

    if ( !CClientPickupManager::IsValidWeaponID ( nWeaponID ) )
        return;

    CClientPed * pPed = g_pClientGame->GetManager()->GetPlayerManager()->GetLocalPlayer();
    if ( pPed )
    {
        CWeapon * pPlayerWeapon = pPed->GiveWeapon ( (eWeaponType)nWeaponID, 9999 );
        if ( pPlayerWeapon )
        {
            pPlayerWeapon->SetAsCurrentWeapon();
        }
    }
}
コード例 #13
0
bool CStalkerActionDead::fire			() const
{
    if (object().inventory().TotalWeight() <= 0)
        return							(false);

    CWeapon								*weapon = smart_cast<CWeapon*>(object().inventory().ActiveItem());
    if (!weapon)
        return							(false);

    if (!weapon->GetAmmoElapsed())
        return							(false);

    if (!object().hammer_is_clutched())
        return							(false);

    if (!object().character_physics_support()->can_drop_active_weapon())
        return							(true);

    if (Device.dwTimeGlobal - object().GetLevelDeathTime() > 500)
        return							(false);

    return								(true);
}
コード例 #14
0
ファイル: LuaUnitScript.cpp プロジェクト: eXLabT/spring
int CLuaUnitScript::CreateScript(lua_State* L)
{
	CUnit* unit = ParseUnit(L, __FUNCTION__, 1);
	if (unit == NULL) {
		LUA_TRACE("no such unit");
		return 0;
	}

	// check table of callIns
	// (we might not get a chance to clean up later on, if something is wrong)
	if (!lua_istable(L, 2)) {
		luaL_error(L, "%s(): error parsing callIn table", __FUNCTION__);
	}
	for (lua_pushnil(L); lua_next(L, 2) != 0; lua_pop(L, 1)) {
		if (!lua_israwstring(L, -2) || !lua_isfunction(L, -1)) {
			luaL_error(L, "%s(): error parsing callIn table", __FUNCTION__);
		}
	}

	// replace the unit's script (ctor parses callIn table)
	CLuaUnitScript* newScript = new CLuaUnitScript(L, unit);

	if (unit->script != &CNullUnitScript::value) {
		delete unit->script;
	}
	unit->script = newScript;

	// flush some caches (which store availability of certain script functions)
	for (std::vector<CWeapon*>::iterator wi = unit->weapons.begin(); wi != unit->weapons.end(); ++wi) {
		CWeapon* w = *wi;
		w->SetWeaponNum(w->weaponNum);
	}

	LUA_TRACE("script replaced with CLuaUnitScript");

	return 0;
}
コード例 #15
0
ファイル: OpheliaAI.cpp プロジェクト: Arc0re/lithtech
void OpheliaAI::MC_BestWeapon()
{
	CWeapon* pW	= m_InventoryMgr.GetCurrentWeapon();

    if (m_bAnimating == DFALSE)
    {
		if(pW)
		{
			if(m_InventoryMgr.GetAmmoCount(pW->GetAmmoType(DFALSE)) <= 0.0)
			{
				SetAnimation( m_pAnim_Sound->m_nAnim_SWITCH_WEAPON[pW->GetFireType()]);

				m_pServerDE->SetModelLooping(m_hObject, DFALSE);

				m_bAnimating = DTRUE;
			}
			else
			{
				m_bAnimating = DFALSE;
				Metacmd++;
			}
		}
	}
	else
	{
		//Are we done?
		if(m_pServerDE->GetModelPlaybackState(m_hObject) & MS_PLAYDONE)
        {
			if(pW->GetType() == WEAP_TESLACANNON)
			{
				m_InventoryMgr.ChangeWeapon(WEAP_SNIPERRIFLE);
				pW = m_InventoryMgr.GetCurrentWeapon();
				pW->ShowHandModel(DFALSE);
				SetAnimation( m_pAnim_Sound->m_nAnim_SWITCH_WEAPON[pW->GetFireType()]);
			}
			else
			{
				if(m_InventoryMgr.GetAmmoCount(pW->GetAmmoType(DFALSE)) <= 0.0)
				{
					SetNewState(STATE_FindAmmo);
				}
				else
				{
					m_bAnimating = DFALSE;
					Metacmd++;
				}
			}
        }
	}

	return;
}
コード例 #16
0
const CCoverPoint *CAI_Stalker::find_best_cover		(const Fvector &position_to_cover_from)
{
#ifdef _DEBUG
//	Msg									("* [%6d][%s] search for new cover performed",Device.dwTimeGlobal,*cName());
#endif
#ifdef _DEBUG
	++g_near_cover_search_count;
#endif
	float								minimum_enemy_distance, maximum_enemy_distance;
	compute_enemy_distances				(minimum_enemy_distance, maximum_enemy_distance);

	if (!best_weapon())
		m_ce_best->can_use_smart_covers	(false);
	else {
		CWeapon* weapon					= smart_cast<CWeapon*>(best_weapon());
		if (!weapon)
			m_ce_best->can_use_smart_covers	(false);
		else {
			if (weapon->BaseSlot() != INV_SLOT_3)
				m_ce_best->can_use_smart_covers	(false);
			else
				m_ce_best->can_use_smart_covers	(true);
		}
	}

	m_ce_best->setup					(position_to_cover_from, minimum_enemy_distance,maximum_enemy_distance,minimum_enemy_distance);
	const CCoverPoint					*point = ai().cover_manager().best_cover(Position(),10.f,*m_ce_best,CStalkerMovementRestrictor(this,true));
	if (point)
		return							(point);

#ifdef _DEBUG
	++g_far_cover_search_count;
#endif
	m_ce_best->setup					(position_to_cover_from, minimum_enemy_distance,maximum_enemy_distance,minimum_enemy_distance);
	point								= ai().cover_manager().best_cover(Position(),30.f,*m_ce_best,CStalkerMovementRestrictor(this,true));
	return								(point);
}
コード例 #17
0
ファイル: GunMount.cpp プロジェクト: Arc0re/lithtech
void GunMount::UpdateFiring( )
{
	SetNextUpdate( UPDATE_NEXT_FRAME );

	// If we're done, then go to post fire.
	if( m_nRoundsToFire == 0 )
	{
		StartPostFiring( );
		return;
	}

	CWeapon* pWeapon = m_Arsenal.GetCurWeapon( );
	if( !pWeapon )
	{
		StartPostFiring( );
		return;
	}

	// Check if we had a fire anim to go off of.
	HMODELANIM hAnim = pWeapon->GetFireAni( );
	if( hAnim != INVALID_ANI )
	{
		// Check if we're still finishing the fire animation.
		if( !IsAnimationComplete( ))
			return;

		// Start it up for the next fire.
		pWeapon->PlayAnimation( hAnim, true, false );
	}

	// Continue to fire weapon.
	if( !FireWeapon( ))
	{
		StartPostFiring( );
		return;
	}
}
コード例 #18
0
ファイル: WeaponInput.cpp プロジェクト: AiYong/CryGame
//------------------------------------------------------
void CWeapon::ForcePendingActions(uint8 blockedActions)
{
	CItem::ForcePendingActions(blockedActions);

	CActor* pOwner = GetOwnerActor();
	if(!pOwner || !pOwner->IsClient())
		return;

	//Force start firing, if needed and possible
	if(m_requestedFire)
	{
		if(!IsDualWield() && !IsWeaponRaised())
		{
			m_requestedFire = false;
			OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
		}
		else if(IsDualWield() && IsDualWieldMaster())
		{
			IItem *slave = GetDualWieldSlave();
			if(!IsWeaponRaised())
			{
				m_requestedFire = false;
				OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
			}
			else if(slave && slave->GetIWeapon())
			{
				CWeapon* dualwield = static_cast<CWeapon*>(slave);
				if(!dualwield->IsWeaponRaised())
				{
					m_requestedFire = false;
					OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
				}
			}
		}
	}
}
コード例 #19
0
void CWeaponRPCs::GiveWeaponAmmo ( NetBitStreamInterface& bitStream )
{
    ElementID ID;
    SWeaponTypeSync weaponType;
    if ( bitStream.ReadCompressed ( ID ) &&
         bitStream.Read ( &weaponType ) )
    {
        unsigned char ucWeaponID = weaponType.data.ucWeaponType;
        SWeaponAmmoSync ammo ( ucWeaponID, true, false );
        if ( bitStream.Read ( &ammo ) )
        {
            unsigned short usAmmo = ammo.data.usTotalAmmo;
            CClientPed * pPed = m_pPedManager->Get ( ID, true );
            if ( pPed )
            {
                // Valid weapon id?
                if ( !CClientPickupManager::IsValidWeaponID ( ucWeaponID ) ) return;

                // Do we have it?
                CWeapon* pPlayerWeapon = pPed->GetWeapon ( (eWeaponType) ucWeaponID );
                if ( pPlayerWeapon == NULL ) return;

                unsigned long ulWeaponAmmo = pPlayerWeapon->GetAmmoTotal ();
                ulWeaponAmmo += usAmmo;
                // Adjust the ammo to 9999 if it's above
                if ( ulWeaponAmmo > 9999 )
                {
                    ulWeaponAmmo = 9999;
                }

                // Add the weapon ammo
                pPlayerWeapon->SetAmmoTotal ( ulWeaponAmmo );
            }
        }
    }
}
コード例 #20
0
ファイル: CinematicInput.cpp プロジェクト: amrhead/eaascode
void CCinematicInput::OnAction( const EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	const CGameActions& gameActions = g_pGame->Actions();

	if (actionId == gameActions.attack1_cine)
	{
		CWeapon* pPrimaryWeapon = GetWeapon( eWeapon_Primary );
		if (pPrimaryWeapon != NULL)
		{
			pPrimaryWeapon->OnAction( actorId, actionId, activationMode, value );
		}
	}
	else if (actionId == gameActions.attack2_cine)
	{
		CWeapon* pSecondaryWeapon = GetWeapon( eWeapon_Secondary );
		if (pSecondaryWeapon != NULL)
		{
			pSecondaryWeapon->OnAction( actorId, actionId, activationMode, value );
		}
	}
	else if (actionId == gameActions.skip_cutscene)
	{
		const int playingSequences = gEnv->pMovieSystem->GetNumPlayingSequences();
		for (int i = 0; i < playingSequences; ++i)
		{
			IAnimSequence* pSeq = gEnv->pMovieSystem->GetPlayingSequence(i);
			if (pSeq && pSeq->GetFlags() & IAnimSequence::eSeqFlags_CutScene)
			{
				if (!(pSeq->GetFlags() & IAnimSequence::eSeqFlags_NoAbort))
				{
					gEnv->pMovieSystem->SetPlayingTime(pSeq, pSeq->GetTimeRange().end);
				}
			}
		}
	}
}
コード例 #21
0
ファイル: GunMount.cpp プロジェクト: Arc0re/lithtech
bool GunMount::GetFirePos( LTVector& vPos )
{
	CWeapon* pWeapon = m_Arsenal.GetCurWeapon( );
	if( !pWeapon )
		return false;

	HATTACHMENT hAttachment;
    if( g_pLTServer->FindAttachment(m_hObject, pWeapon->GetModelObject(), &hAttachment) != LT_OK )
	{
		return false;
	}

	HMODELSOCKET hSocket;
    if (g_pModelLT->GetSocket(pWeapon->GetModelObject(), "Flash", hSocket) != LT_OK)
	{
		return false;
	}

	LTTransform transform;
	g_pCommonLT->GetAttachedModelSocketTransform(hAttachment, hSocket, transform);
	vPos = transform.m_vPos;
	
	return true;
}
コード例 #22
0
ファイル: GunMount.cpp プロジェクト: Arc0re/lithtech
// ----------------------------------------------------------------------- //
//
//	ROUTINE:	GunMount::StartPostFiring
//
//	PURPOSE:	Starts the postfiring state.
//
// ----------------------------------------------------------------------- //
bool GunMount::StartPostFiring( )
{
	CWeapon* pWeapon = m_Arsenal.GetCurWeapon( );
	if( !pWeapon )
		return false;

	// Get the prefire animation.
	HMODELANIM hAnim = pWeapon->GetPostFireAni( );

	// If they don't have a postfire, just go to notfiring.
	if( hAnim == INVALID_ANI )
	{
		return StartNotFiring( );
	}

	// Begin prefire animation.
	pWeapon->PlayAnimation( hAnim, true, false );

	m_eFiringState = ePostFiring;

	SetNextUpdate( UPDATE_NEXT_FRAME );

	return true;
}
コード例 #23
0
ファイル: UIMpTradeWnd_wpn.cpp プロジェクト: 2asoft/xray
shared_str CUIMpTradeWnd::GetAddonNameSect(SBuyItemInfo* itm, item_addon_type at)
{
	CInventoryItem* item_	= (CInventoryItem*)itm->m_cell_item->m_pData;
	CWeapon* w				= smart_cast<CWeapon*>(item_);
	
	switch(at)
	{
	case at_scope:
		{
			return w->GetScopeName();
		}break;

	case at_silencer:
		{
			return w->GetSilencerName();
		}break;

	case at_glauncher:
		{
			return w->GetGrenadeLauncherName();
		}break;
	};
	return NULL;
}
コード例 #24
0
ファイル: FireModePlugin.cpp プロジェクト: aronarts/FireNET
//------------------------------------------------------------------------
void CFireModePlugin_Reject::OnShoot()
{
	const SEffectParams& rejectEffect = m_pParams->rejectEffect;
	CWeapon* pWeapon = m_pOwnerFiremode->GetWeapon();

	const int slot = pWeapon->GetStats().fp ? 0 : 1;
	const bool doRejectEffect = (g_pGameCVars->i_rejecteffects != 0) && (!rejectEffect.effect[slot].empty());

	if (doRejectEffect)
	{
		//First check if we can skip/cull the effect (not for the local player)
		if (!pWeapon->IsOwnerClient())
		{
			const CCamera& camera = gEnv->p3DEngine->GetRenderingCamera();
			const Vec3 cameraPos = camera.GetPosition();
			const Vec3 effectPosition = pWeapon->GetWorldPos();

			const float fDist2 = (cameraPos-effectPosition).len2();

			// Too far, skip
			if (fDist2 > g_pGameCVars->g_rejectEffectCullDistance)			
			{
				return; 
			}

			// Not in the view ?
			if(g_pGameCVars->g_rejectEffectVisibilityCull)
			{
				Sphere emitterSphere(effectPosition, 2.0f);
				if(camera.IsSphereVisible_F(emitterSphere) == false)
				{
					return;
				}
			}
		}

		IParticleEffect* pParticleEffect = gEnv->pParticleManager->FindEffect(rejectEffect.effect[slot].c_str());

		if (m_shellFXSpeed == 0.0f)
		{
			
			if (pParticleEffect)
			{
				const ParticleParams& particleParams = pParticleEffect->GetParticleParams();
				m_shellFXSpeed = particleParams.fSpeed.GetMaxValue();
			}
		}
		const Vec3 shellDirection = pWeapon->GetSlotHelperRotation(slot, rejectEffect.helper[slot].c_str(), true).GetColumn1();
		const Vec3 shellVelocity = m_shellHelperVelocity + (shellDirection * m_shellFXSpeed);

		EntityEffects::SEffectSpawnParams spawnParams(ZERO, shellVelocity.GetNormalized(), rejectEffect.scale[slot], shellVelocity.GetLength(), false);
		EntityEffects::SpawnParticleWithEntity(pWeapon->GetEntity(), slot, pParticleEffect, rejectEffect.helper[slot].c_str(), spawnParams);
	}
}
コード例 #25
0
ファイル: Actor.cpp プロジェクト: OLR-xray/XRay-NEW
float CActor::currentFOV()
{
	CWeapon* pWeapon = smart_cast<CWeapon*>(inventory().ActiveItem());	

	if (eacFirstEye == cam_active && pWeapon &&
		pWeapon->IsZoomed() && (!pWeapon->ZoomTexture() ||
		(!pWeapon->IsRotatingToZoom() && pWeapon->ZoomTexture())))
		return pWeapon->GetZoomFactor();
	else
		return DEFAULT_FOV;
}
コード例 #26
0
ファイル: AIVehicleStrategy.cpp プロジェクト: Arc0re/lithtech
LTBOOL CAIHelicopterStrategyShoot::Update()
{
	if ( !CAIHelicopterStrategy::Update() )
	{
        return LTFALSE;
	}

	if ( !m_hTarget )
	{
        return LTFALSE;
	}

	for ( int iWeapon = 0 ; iWeapon < GetAI()->GetNumWeapons() ; iWeapon++ )
	{
		CWeapon* pWeapon = GetAI()->GetWeapon(iWeapon);

		if ( m_aBursts[iWeapon].m_bFired && m_aBursts[iWeapon].m_bActive )
		{
			UpdateFiring(pWeapon, &m_aBursts[iWeapon]);

			m_aBursts[iWeapon].m_bFired = LTFALSE;
		}
		else
		{
			UpdateAiming(pWeapon, &m_aBursts[iWeapon]);
		}

		if ( 0 == pWeapon->GetAmmoInClip() )
		{
            pWeapon->ReloadClip(LTFALSE);
		}

		if ( 0 == pWeapon->GetParent()->GetAmmoCount(pWeapon->GetAmmoId()) )
		{
			pWeapon->GetParent()->AddAmmo(pWeapon->GetAmmoId(), 999999);
		}
	}

    return LTTRUE;
}
コード例 #27
0
void CWeaponRPCs::SetWeaponAmmo ( NetBitStreamInterface& bitStream )
{
    ElementID ID;
    SWeaponTypeSync weaponType;
    if ( bitStream.ReadCompressed ( ID ) &&
         bitStream.Read ( &weaponType ) )
    {
        unsigned char ucWeaponID = weaponType.data.ucWeaponType;
        SWeaponAmmoSync ammo ( ucWeaponID, true, true );

        if ( bitStream.Read ( &ammo ) )
        {
            unsigned short usAmmo = ammo.data.usTotalAmmo;
            unsigned short usAmmoInClip = ammo.data.usAmmoInClip;

            CClientPed * pPed = m_pPedManager->Get ( ID, true );
            if ( pPed )
            {
                // Valid weapon id?
                if ( !CClientPickupManager::IsValidWeaponID ( ucWeaponID ) ) return;

                // Do we have it?
                CWeapon* pPlayerWeapon = pPed->GetWeapon ( (eWeaponType) ucWeaponID );
                if ( pPlayerWeapon == NULL ) return;

                unsigned char ucAmmoInClip = static_cast < unsigned char > ( pPlayerWeapon->GetAmmoInClip () );
                pPlayerWeapon->SetAmmoInClip ( usAmmoInClip );
                pPlayerWeapon->SetAmmoTotal ( usAmmo );

                if ( !usAmmoInClip )
                {
                    if ( usAmmo > ucAmmoInClip )
                        pPlayerWeapon->SetAmmoInClip ( ucAmmoInClip );
                    else if ( usAmmo <= ucAmmoInClip )
                        pPlayerWeapon->SetAmmoInClip ( usAmmo );
                }
            }
        }
    }
}
コード例 #28
0
void CCustomDetector::UpdateVisibility()
{


	//check visibility
	attachable_hud_item* i0		= g_player_hud->attached_item(0);
	if(i0 && HudItemData())
	{
		CWeapon* wpn			= smart_cast<CWeapon*>(i0->m_parent_hud_item);
		if(wpn)
		{
			u32 state			= wpn->GetState();
			bool bClimb			= ( (Actor()->MovingState()&mcClimb) != 0 );
			if(bClimb || wpn->IsZoomed() || state==CWeapon::eReload || state==CWeapon::eSwitch)
			{
				HideDetector		(true);
				m_bNeedActivation	= true;
			}
		}
	}else
	if(m_bNeedActivation)
	{
		attachable_hud_item* i0		= g_player_hud->attached_item(0);
		bool bClimb					= ( (Actor()->MovingState()&mcClimb) != 0 );
		if(!bClimb)
		{
			CWeapon* wpn			= (i0)?smart_cast<CWeapon*>(i0->m_parent_hud_item) : NULL;
			if(	!wpn || 
				(	!wpn->IsZoomed() && 
					wpn->GetState()!=CWeapon::eReload && 
					wpn->GetState()!=CWeapon::eSwitch
				)
			)
			{
				ShowDetector		(true);
			}
		}
	}
}
コード例 #29
0
//--------------------------------------------
void CLaser::TurnOffLaser(bool manual /*= false*/)
{
	if(!m_laserBeam.IsLaserActivated())
		return;

	GetGameObject()->DisableUpdateSlot(this, eIUS_General);

	CWeapon* pParentWeapon = GetWeapon();
	if(pParentWeapon == NULL)
		return;
	bool ownerIsFP = pParentWeapon? pParentWeapon->IsOwnerFP(): false;

	m_laserBeam.TurnOffLaser();

	//Turn on crosshair
	if (pParentWeapon->IsOwnerClient())
	{
		pParentWeapon->SetCrosshairMode(CWeapon::eWeaponCrossHair_Default);
		pParentWeapon->FadeCrosshair(1.0f, g_pGame->GetUI()->GetCVars()->hud_Crosshair_laser_fadeInTime);
	}

	pParentWeapon->SetFiringLocator(0);
}
コード例 #30
0
ファイル: object_actions.cpp プロジェクト: 2asoft/xray
void CObjectActionReload::execute			()
{
	inherited::execute			();
	
	VERIFY						(m_item);
	VERIFY						(object().inventory().ActiveItem());
	VERIFY						(object().inventory().ActiveItem()->object().ID() == m_item->object().ID());
	
	CWeapon						*weapon = smart_cast<CWeapon*>(object().inventory().ActiveItem());
	VERIFY						(weapon);
	if (weapon->IsPending())
		return;
	
	if (weapon->GetAmmoElapsed()) {
		VERIFY					(weapon->GetSuitableAmmoTotal() >= weapon->GetAmmoElapsed());
		if (weapon->GetSuitableAmmoTotal() == weapon->GetAmmoElapsed())
			return;

		VERIFY					(weapon->GetAmmoMagSize() >= weapon->GetAmmoElapsed());
		if (weapon->GetAmmoMagSize() == weapon->GetAmmoElapsed())
			return;
	}

	object().inventory().Action	(kWPN_RELOAD,CMD_START);
}