Пример #1
0
//------------------------------------------------------------------------
void CVehicleMountedWeapon::StartUse(EntityId userId)
{
	IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId);
	if (!IsRippingOff() && pVehicle)
	{ 
		m_pOwnerSeat = pVehicle->GetWeaponParentSeat(GetEntityId());
		m_pSeatUser = pVehicle->GetSeatForPassenger(userId);

		IActor* pOwner = GetOwnerActor();
		if (pOwner && !pOwner->IsPlayer())
		{
			SHUDEvent hudEvent(eHUDEvent_AddEntity);
			hudEvent.AddData((int)pVehicle->GetEntityId());
			CHUDEventDispatcher::CallEvent(hudEvent);
		}

		ClearItemFlags(eIF_InformClientsAboutUse);
 	}

	CHeavyMountedWeapon::StartUse(userId);

	CActor* pActor = GetOwnerActor();
	if (pActor && pActor->IsPlayer())
	{
		static_cast<CPlayer*>(pActor)->RefreshVisibilityState();
	}
}
Пример #2
0
//------------------------------------------------------------------------
void CItem::SetDualSlaveAccessory(bool noNetwork)
{
	if(!gEnv->bMultiplayer || (GetOwnerActor() && GetOwnerActor()->IsClient()))
	{
		CItem *pSlave = static_cast<CItem *>(GetDualWieldSlave());
		if (!pSlave)
			return;

		//Detach current accessories of the slave
		TAccessoryMap temp = pSlave->m_accessories;
		for (TAccessoryMap::const_iterator it=temp.begin(); it!=temp.end(); ++it)
		{
			if(m_accessories.find(it->first)==m_accessories.end())
				pSlave->SwitchAccessory(it->first.c_str()); //Only remove if not in the master
		}

		//Attach on the slave same accessories as "parent"
		for (TAccessoryMap::const_iterator it=m_accessories.begin(); it!=m_accessories.end(); ++it)
		{
			if(pSlave->m_accessories.find(it->first)==pSlave->m_accessories.end())
			{
				if(noNetwork)
					pSlave->AttachAccessory(it->first.c_str(), true, true, true);
				else
					pSlave->SwitchAccessory(it->first.c_str()); //Only add if not already attached
			}
		}
	}
}
Пример #3
0
void CBinocular::OnDropped(EntityId actorId)
{
	ResetState();

	if(GetOwnerActor() == NULL)
		return;

	GetOwnerActor()->SelectLastItem(true, true);
}
Пример #4
0
//------------------------------------------------------
void CWeapon::SetInputFlag(uint8 actionFlag) 
{ 
	CRY_ASSERT(GetOwnerActor() && ( GetOwnerActor()->IsClient() || !GetOwnerActor()->IsPlayer() ) );

	if (!s_lockActionRequests) 
	{
		s_requestedActions |= actionFlag;
	} 
}
Пример #5
0
//========================================
void CRocketLauncher::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory, const char *setup)
{

	CWeapon::PickUp(pickerId,sound,select,keepHistory, setup);

	if(m_auxSlotUsed)
	{
		DrawSlot(eIGS_ThirdPersonAux,false);
		m_auxSlotUsed = false;
	}

	if(GetOwnerActor() && !GetOwnerActor()->IsPlayer())
		m_stats.first_selection = false;
}
//------------------------------------------------------------------------
IMPLEMENT_RMI(CItem, SvRequestAttachAccessory)
{
	if (IInventory *pInventory=GetActorInventory(GetOwnerActor()))
	{
		char accessoryName[129] = {0};
		bool result = g_pGame->GetIGameFramework()->GetNetworkSafeClassName(accessoryName, 128, params.accessoryClassId);

#if !defined(_RELEASE)
	if(!result)
	{
		char errorMsg[256];
		sprintf(errorMsg, "CItem::SvRequestAttachAccessory failed to find network safe class name for id %d", params.accessoryClassId);
		CRY_ASSERT_MESSAGE(result, errorMsg);
	}
#endif

		if (accessoryName[0] != '\0' && pInventory->GetCountOfClass(accessoryName)>0)
		{
			DoSwitchAccessory(accessoryName);
			GetGameObject()->InvokeRMI(ClAttachAccessory(), params, eRMI_ToAllClients|eRMI_NoLocalCalls);

			return true;
		}
	}
	
	return true; // set this to false later
}
//------------------------------------------------------------------------
IMPLEMENT_RMI(CItem, SvRequestDetachAccessory)
{
	if (IInventory *pInventory=GetActorInventory(GetOwnerActor()))
	{
		char accessoryName[129] = {0};
		bool result = g_pGame->GetIGameFramework()->GetNetworkSafeClassName(accessoryName, 128, params.accessoryClassId);

#if !defined(_RELEASE)
		if(!result)
		{
			char errorMsg[256];
			sprintf(errorMsg, "CItem::SvRequestDetachAccessory failed to find network safe class name for id %d", params.accessoryClassId);
			CRY_ASSERT_MESSAGE(result, errorMsg);
		}
#endif

		if (accessoryName[0] != '\0')
		{
			AttachAccessory(accessoryName, false, true, true);
			GetGameObject()->InvokeRMI(ClDetachAccessory(), params, eRMI_ToRemoteClients);

			return true;
		}
	}
	return true; 
}
Пример #8
0
//---------------------------------------------------------------------------
void CVehicleWeapon::CheckForFriendlyPlayers(float frameTime)
{
	CActor *pOwner = GetOwnerActor();

	if(pOwner && pOwner->IsPlayer() && gEnv->bMultiplayer)
	{
		m_timeToUpdate-=frameTime;

		if(m_timeToUpdate>0.0f)
			return;

		m_timeToUpdate = 0.15f;

		if(IMovementController *pMC = pOwner->GetMovementController())
		{
			SMovementState info;
			pMC->GetMovementState(info);

			ray_hit rayhit;
			IPhysicalEntity *pSkipEnts[10];
			int nSkip = CSingle::GetSkipEntities(this, pSkipEnts, 10);

			int intersect = gEnv->pPhysicalWorld->RayWorldIntersection(info.weaponPosition, info.aimDirection * 150.0f, ent_all,
							rwi_stop_at_pierceable|rwi_colltype_any, &rayhit, 1, pSkipEnts, nSkip);

			IEntity *pLookAtEntity = NULL;

			if(intersect && rayhit.pCollider)
				pLookAtEntity = m_pEntitySystem->GetEntityFromPhysics(rayhit.pCollider);

			bool bFriendly = false;
		}
	}
}
Пример #9
0
void CHeavyMountedWeapon::SetRippingOff(bool ripOff)
{
	if(ripOff && !m_rippingOff && !m_rippedOff)
	{
		PerformRipOff(GetOwnerActor());
	}
}
Пример #10
0
void CHeavyMountedWeapon::ProcessEvent(SEntityEvent& event)
{
	if ((event.event == ENTITY_EVENT_XFORM) && IsMounted() && GetOwnerId())
	{
		const float Z_EPSILON = 0.01f;
		const Ang3& worldAngles = GetEntity()->GetWorldAngles();
		float xAngle = worldAngles.x;
		float zAngle = worldAngles.z;
		bool xAnglesAreEquivalent = (fabs(xAngle-m_lastXAngle)<Z_EPSILON);
		bool zAnglesAreEquivalent = (fabs(zAngle-m_lastZAngle)<Z_EPSILON);
		if (!xAnglesAreEquivalent || !zAnglesAreEquivalent)
		{
			if (m_rotatingSoundID==INVALID_SOUNDID)
				m_rotatingSoundID = PlayRotationSound();
			m_RotationSoundTimeOut = 0.15f;
			RequireUpdate( eIUS_General );
			m_lastXAngle = xAngle;
			m_lastZAngle = zAngle;
		}
			
		int flags = (int)event.nParam[0];
		if ((flags & ENTITY_XFORM_FROM_PARENT) && !(flags & ENTITY_XFORM_USER))
		{
			if (CActor* pOwnerActor = GetOwnerActor())
			{
				pOwnerActor->UpdateMountedGunController(true);
			}
		}
	}

	BaseClass::ProcessEvent(event);
}
Пример #11
0
void CHeavyMountedWeapon::SetUnMountedConfiguration()
{
	SwitchToRippedOffFireMode();

	IFireMode * pMountedFireMode = GetFireMode(0);
	assert(pMountedFireMode);
	
	pMountedFireMode->Enable(false);

	ExitZoom(true);

	//Second zoom mode is supposed to be unmounted
	if(GetZoomMode(1))
	{
		EnableZoomMode(1, true);
		SetCurrentZoomMode(1);
	}

	//Just in case, it was not clear properly
	CActor* pOwner = GetOwnerActor();
	if ((pOwner != NULL) && pOwner->IsClient())
	{
		float defaultFov = 55.0f;
		gEnv->pRenderer->EF_Query(EFQ_SetDrawNearFov,defaultFov);
	}
}
Пример #12
0
//---------------------------------------------------------------------------------
bool CWeapon::OnActionFiremode(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	CActor* pOwner = GetOwnerActor();
	CPlayer* pPlayer = pOwner && pOwner->IsPlayer() ? static_cast<CPlayer*>(pOwner) : 0;
	if (pPlayer && (pPlayer->IsCinematicFlagActive(SPlayerStats::eCinematicFlag_LowerWeapon) || pPlayer->IsCinematicFlagActive(SPlayerStats::eCinematicFlag_LowerWeaponMP)) )
		return true;

	bool incompatibleZommMode = (m_secondaryZmId != 0 && (IsZoomed() || IsZoomingInOrOut()));

	if (AreAnyItemFlagsSet(eIF_BlockActions) || incompatibleZommMode)
	{
		return true;
	}

	if (activationMode == eAAM_OnPress)
	{
		IFireMode* pNewFiremode = GetFireMode(GetNextFireMode(GetCurrentFireMode()));
		if (pNewFiremode == m_fm)
		{
			if(pPlayer && pPlayer->CanSwitchItems())
			{
				pPlayer->SwitchToWeaponWithAccessoryFireMode();
			}
		}
		else if (!IsReloading())
		{
			StartChangeFireMode();
		}
	}

	return true;
}
Пример #13
0
//--------------------------------------------------------------------
bool CWeapon::OnActionSprint(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	//If zoomed, you can not sprint (in SP only)
	if ((gEnv->bMultiplayer == false) && IsZoomed())
		return false;

	CActor* pOwnerActor = GetOwnerActor();
	CPlayer *pPlayer = 0;
	SPlayerStats *pStats = 0;
	if (pOwnerActor && pOwnerActor->IsPlayer())
	{
		pPlayer = static_cast<CPlayer*>(pOwnerActor);
		pStats = static_cast<SPlayerStats*>(pPlayer->GetActorStats());
	}

	if (activationMode == eAAM_OnPress)
	{
		if (pPlayer)
		{
			if (pStats && pStats->bIgnoreSprinting && !m_isFiring && m_delayedFireActionTimeOut <= 0.f && m_delayedMeleeActionTimeOut <= 0.f)
				pStats->bIgnoreSprinting = false;
		}
	}

	return false;
}
Пример #14
0
bool CWeapon::CheckSprint()
{
	CPlayer *pPlayer = static_cast<CPlayer*>(GetOwnerActor());
	if(!pPlayer || pPlayer->IsSliding())
		return false;

	SPlayerStats *pStats = static_cast<SPlayerStats*>(pPlayer->GetActorStats());
	assert(pStats);

	if(pPlayer->IsSprinting())
	{
		pStats->bIgnoreSprinting = true;

		float delayScale = pPlayer->GetModifiableValues().GetValue(kPMV_WeaponFireFromSprintTimeScale);
		m_delayedFireActionTimeOut = GetParams().sprintToFireDelay * delayScale;

		return true;
	}
	else if (m_delayedFireActionTimeOut > 0.f)
	{
		return true;
	}

	return false;
}
Пример #15
0
//------------------------------------------------------------------------
void CItem::UpdateFPPosition(float frameTime)
{
	CActor* pActor = GetOwnerActor();
	if (!pActor)
		return;

	SPlayerStats *pStats = static_cast<SPlayerStats *>(pActor->GetActorStats());
	if (!pStats)
		return;

	Matrix34 tm = Matrix33::CreateRotationXYZ(pStats->FPWeaponAngles);

	Vec3 offset(0.0f,0.0f,0.0f);

	float right(g_pGameCVars->i_offset_right);
	float front(g_pGameCVars->i_offset_front);
	float up(g_pGameCVars->i_offset_up);

	if (front!=0.0f || up!=0.0f || right!=0.0f)
	{
		offset += tm.GetColumn(0).GetNormalized() * right;
		offset += tm.GetColumn(1).GetNormalized() * front;
		offset += tm.GetColumn(2).GetNormalized() * up;
	}

	tm.SetTranslation(pStats->FPWeaponPos + offset);
	GetEntity()->SetWorldTM(tm);

	//CryLogAlways("weaponpos: %.3f,%.3f,%.3f // weaponrot: %.3f,%.3f,%.3f", tm.GetTranslation().x,tm.GetTranslation().y,tm.GetTranslation().z, pStats->FPWeaponAngles.x, pStats->FPWeaponAngles.y, pStats->FPWeaponAngles.z);
}
Пример #16
0
//--------------------------------------------------------------------
bool CWeapon::PreActionAttack(bool startFire)
{
	// Melee while pressing SHIFT for SP
	CPlayer *pPlayer = static_cast<CPlayer*>(GetOwnerActor());
	if(!pPlayer)
		return false;
/*
	//if(gEnv->bMultiplayer)
	{
		if(startFire && pPlayer->IsSprinting())
		{
			//Stop sprinting, start firing
			SPlayerStats *pStats = static_cast<SPlayerStats*>(pPlayer->GetActorStats());
			if(pStats)
			{
				pStats->bSprinting = false;
				pStats->bIgnoreSprinting = true;
			}
		}
		else if(!startFire)
		{
			//Stop firing, continue sprinting
			SPlayerStats *pStats = static_cast<SPlayerStats*>(pPlayer->GetActorStats());
			if(pStats)
				pStats->bIgnoreSprinting = false;

		}
	}

	return false;
	*/

	if(startFire && pPlayer->IsSprinting()) return true;
	else return false;
}
Пример #17
0
//---------------------------------------------------------------
void CFists::CollisionFeeback(Vec3 &pos, int eFAS)
{

	CPlayer *pPlayer = static_cast<CPlayer*>(GetOwnerActor());
	if(pPlayer)
	{
		switch(eFAS)
		{
			case eFAS_RUNNING:
				pPlayer->PlaySound(CPlayer::ESound_Hit_Wall,true,true,"speed",0.4f);
				break;

			case eFAS_JUMPING:
				pPlayer->PlaySound(CPlayer::ESound_Hit_Wall,true,true,"speed",0.8f);
				break;

			default:
				break;
		}
	}

	//FX feedback
	IParticleEffect *pEffect = gEnv->pParticleManager->FindEffect("collisions.footsteps.dirt");
	if (pEffect)
	{
		Matrix34 tm = IParticleEffect::ParticleLoc(pos);
		pEffect->Spawn(true,tm);
	}	
}
Пример #18
0
//------------------------------------------------------------------------
void CParachute::Close(bool drop/*=false*/)
{
    // not used any more
    return;

    CryLog("Closing Parachute..");

    if (m_actorId)
    {
        IEntity* pEnt = m_pEntitySystem->GetEntity(m_actorId);
        if (pEnt && pEnt->GetParent()->GetId() == m_canvasId)
        {
            pEnt->DetachThis();
        }
        m_actorId = 0;
    }

    CActor* pActor = GetOwnerActor();
    if (pActor)
    {
        pActor->LinkToVehicle(0);
        if (IsOpened())
        {
            if (drop)
                pActor->DropItem(GetEntity()->GetId(), 1.0f, false);
        }
    }

    m_isOpened = false;
}
Пример #19
0
//---------------------------------------------------------------
void CAmmoPickup::ShouldSwitchGrenade(IEntityClass* pClass)
{
	bool flashbang = (pClass==CItem::sFlashbangGrenade);
	bool smoke     = (pClass==CItem::sSmokeGrenade);
	bool emp       = (pClass==CItem::sEMPGrenade);
	bool explosive = (pClass==CItem::sExplosiveGrenade);

	if(!flashbang && !smoke && !emp && !explosive)
		return;

	CActor* pPlayer = GetOwnerActor();
	
	if(!pPlayer)
		return;

	COffHand* pOffHand = static_cast<COffHand*>(pPlayer->GetWeaponByClass(CItem::sOffHandClass));

	if(pOffHand)
	{
		if(IFireMode* fm = pOffHand->GetFireMode(pOffHand->GetCurrentFireMode()))
		{
			if(fm->OutOfAmmo())
			{
				if(explosive)
					pOffHand->RequestFireMode(EXPLOSIVE_GRENADE);
				else if(smoke)
					pOffHand->RequestFireMode(SMOKE_GRENADE);
				else if(flashbang)
					pOffHand->RequestFireMode(FLASHBANG_GRENADE);
				else if(emp)
					pOffHand->RequestFireMode(EMP_GRENADE);
			}
		}
	}
}
Пример #20
0
//------------------------------------------------------------------------
bool CC4::CanSelect() const
{
	bool canSelect = (CWeapon::CanSelect() && !OutOfAmmo(false));

	//Check for remaining projectiles to detonate
	if(!canSelect)
	{
		CActor *pOwner = GetOwnerActor();

		if(!pOwner)
			return false;

		EntityId detonatorId = pOwner->GetInventory()?pOwner->GetInventory()->GetItemByClass(CItem::sDetonatorClass):0;

		//Do not re-select detonator again
		if(detonatorId && (detonatorId==pOwner->GetCurrentItemId()))
			return false;

		IFireMode *pFM = GetFireMode(GetCurrentFireMode());

		if(pFM)
		{
			//CC4::Select will select the detonator in this case
			EntityId projectileId = pFM->GetProjectileId();

			if(projectileId && g_pGame->GetWeaponSystem()->GetProjectile(projectileId))
				return true;

		}
	}

	return canSelect;
};
Пример #21
0
//------------------------------------------------------------------------
void CItem::InitClient(int channelId)
{
	// send the differences between the current, and the initial setup
	for(TAccessoryMap::iterator it=m_accessories.begin(); it != m_accessories.end(); ++it)
		GetGameObject()->InvokeRMI(ClAttachAccessory(), RequestAttachAccessoryParams(it->first.c_str()), eRMI_ToClientChannel, channelId);

	IActor *pOwner=GetOwnerActor();

	if(!pOwner)
		return;

	// only send the pickup message if the player is connecting
	// for items spawned during gameplay, CItem::PickUp is already sending the pickup message
	INetChannel *pNetChannel=m_pGameFramework->GetNetChannel(channelId);

	if(pNetChannel && pNetChannel->GetContextViewState()<eCVS_InGame)
	{
		if(!m_stats.mounted && !m_stats.used)
		{
			pOwner->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(),
					CActor::PickItemParams(GetEntityId(), m_stats.selected, false), eRMI_ToClientChannel, GetEntityId(), channelId);
			//GetOwnerActor()->GetGameObject()->InvokeRMI(CActor::ClPickUp(),
			//	CActor::PickItemParams(GetEntityId(), m_stats.selected, false), eRMI_ToClientChannel, channelId);
		}
	}

	if(m_stats.mounted && m_stats.used)
	{
		pOwner->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClStartUse(),
				CActor::ItemIdParam(GetEntityId()), eRMI_ToClientChannel, GetEntityId(), channelId);
	}
}
Пример #22
0
void CJaw::PostSerialize()
{
	BaseClass::PostSerialize();

	if(m_auxSlotUsed)
	{
		SetViewMode(0);
		DrawSlot(eIGS_ThirdPersonAux,true);
	}
	else if (GetOwner() != 0 && !IsAttachedToBack() && !IsAttachedToHand())
	{
		Hide(true);
	}
	else if (!IsOwnerFP())
	{
		SetViewMode(eIVM_ThirdPerson);
		DrawSlot(eIGS_ThirdPerson, true);
		DrawSlot(eIGS_ThirdPersonAux,false);
	}

	if (m_smokeActive)
	{
		Pickalize(false, true);
	}

	if (GetOwner() != 0)
	{
		CActor* pOwner = GetOwnerActor();
		IInventory* pInventory = pOwner ? pOwner->GetInventory() : 0;
		UnregisterUsedAmmoWithInventory(pInventory);
		RegisterUsedAmmoWithInventory(pInventory);
	}
}
Пример #23
0
void CJaw::OnShoot(EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType, const Vec3 &pos, const Vec3 &dir, const Vec3 &vel)
{
	BaseClass::OnShoot(shooterId, ammoId, pAmmoType, pos, dir, vel);

	CActor *pOwnerActor = GetOwnerActor();
	if (pOwnerActor)
	{
		// Set the projectile to target the forced entity
		if (m_forcedTargetId > 0)
		{
			CProjectile *pProjectile = g_pGame->GetWeaponSystem()->GetProjectile(ammoId);
			if (pProjectile)
			{
				pProjectile->SetDestination(m_forcedTargetId);
			}
		}

		if (pOwnerActor->IsClient() && m_laserGuider.IsLaserActivated())
		{
			SHUDEvent event(eHUDEvent_InfoSystemsEvent);
			event.AddData(SHUDEventData(1));
			event.AddData(SHUDEventData(2.f));
			event.AddData(SHUDEventData("@hud_guided"));
			CHUDEventDispatcher::CallEvent(event);
		}

		if (pOwnerActor->IsClient())
			m_fired = true;
	}

	SvActivateMissileCountermeasures(shooterId, pos, dir);
}
//------------------------------------------------------------------------
void CWeapon::RequestFireMode(int fmId)
{
    if(fmId==GetCurrentFireMode())
        return;

    CActor *pActor=GetOwnerActor();

    if (gEnv->IsClient() && pActor && pActor->IsClient())
    {
        float animationTime = GetCurrentAnimationTime(eIGS_Owner)/1000.0f;
        m_switchFireModeTimeStap = gEnv->pTimer->GetCurrTime() + animationTime;

        if(gEnv->bServer)
        {
            SetCurrentFireMode(fmId);
        }
        else
        {
            if(m_fm)
            {
                m_fm->Activate(false);
            }
            GetGameObject()->InvokeRMI(SvRequestFireMode(), SvRequestFireModeParams(fmId), eRMI_ToServer);
        }
        StartVerificationSample(gEnv->pTimer->GetAsyncCurTime());
        SHUDEvent event(eHUDEvent_OnWeaponFireModeChanged);
        event.AddData(SHUDEventData(fmId));
        CHUDEventDispatcher::CallEvent(event);
    }
}
//------------------------------------------------------------------------
void CWeapon::RequestStartMeleeAttack(bool weaponMelee, bool boostedAttack, int8 attackIndex /*= -1*/)
{

    CActor *pActor=GetOwnerActor();

    if (!gEnv->bServer && pActor && pActor->IsClient())
    {
        GetGameObject()->InvokeRMI(CWeapon::SvRequestStartMeleeAttack(), MeleeRMIParams(boostedAttack,attackIndex), eRMI_ToServer);

#ifndef _RELEASE
        if(g_pGameCVars->pl_pickAndThrow.environmentalWeaponComboDebugEnabled)
        {
            CryLogAlways("COMBO - RequestStartMeleeAttack - called by NON SERVER client with attack index [%d]",attackIndex);
            CryLogAlways("COMBO - RequestStartMeleeAttack - calling SvRequestStartMeleeAttack");
        }
#endif //#ifndef _RELEASE

    }
    else if (IsServer())
    {
        m_attackIndex		= attackIndex;
        m_meleeCounter	= (m_meleeCounter + 1) % kMeleeCounterMax;
#ifndef _RELEASE
        if(g_pGameCVars->pl_pickAndThrow.environmentalWeaponComboDebugEnabled)
        {
            CryLogAlways("COMBO - RequestStartMeleeAttack - called by server, about to netserialising to clients w A.Index. [%d]", m_attackIndex);
        }
#endif //#ifndef _RELEASE
        CHANGED_NETWORK_STATE(this, ASPECT_MELEE);
    }
}
Пример #26
0
//------------------------------------------------------------------------
void CPlayerFeature::OnReset()
{
	CItem::OnReset();

	CActor *pActor=GetOwnerActor();
	for (std::vector<string>::const_iterator it=m_features.begin(); it!=m_features.end(); ++it)
		ActivateFeature(pActor, it->c_str());
}
//------------------------------------------------------------------------
void CDebugGun::Shoot(bool bPrimary)
{   
  CWeapon::StartFire();
  
  // console cmd      
  string cmd;  

  cmd = (bPrimary) ? g_pGameCVars->i_debuggun_1->GetString() : g_pGameCVars->i_debuggun_2->GetString();  
  cmd += " ";        
        
  unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
  
  if (m_fireModes[m_fireMode].first == "pierceability")
  { 
    flags = (unsigned int)m_fireModes[m_fireMode].second & rwi_pierceability_mask;
  }
  
  IPhysicalWorld* pWorld = gEnv->pPhysicalWorld;
  IPhysicalEntity *pSkip = GetOwnerActor()->GetEntity()->GetPhysics();
  ray_hit rayhit;

  CCamera& cam = GetISystem()->GetViewCamera();
  Vec3 pos = cam.GetPosition()+cam.GetViewdir();
  Vec3 dir = cam.GetViewdir() * HIT_RANGE;

  IEntity* pEntity = 0;

  if (pWorld->RayWorldIntersection(pos, dir, ent_all, flags, &rayhit, 1, &pSkip, 1))
  {
    pEntity = (IEntity*)rayhit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY);        
  }
  
  cmd.append(pEntity ? pEntity->GetName() : "0");   
  
  // if we execute an AI command take care of ai_debugdraw
  if (cmd.substr(0, 3) == "ai_")
  {
    if (pEntity && m_pAIDebugDraw->GetIVal() == 0)
      m_pAIDebugDraw->Set(1);
    else if(!pEntity && m_aiDebugDrawPrev == 0 && m_pAIDebugDraw->GetIVal() == 1)
      m_pAIDebugDraw->Set(0);
  }

  gEnv->pConsole->ExecuteString(cmd.c_str());

  // if 2nd button hits a vehicle, enable movement profiling  
  if (!bPrimary)
  {
    static IVehicleSystem* pVehicleSystem = g_pGame->GetIGameFramework()->GetIVehicleSystem();
     
    string vehicleCmd = "v_debugVehicle ";
    vehicleCmd.append((pEntity && pVehicleSystem->GetVehicle(pEntity->GetId())) ? pEntity->GetName() : "0");
    
    gEnv->pConsole->ExecuteString(vehicleCmd.c_str());
  }

  OnShoot(GetOwnerId(), 0, 0, pos, dir, Vec3(ZERO));
}
Пример #28
0
//------------------------------------------------------------------------
void CVehicleWeapon::SetAmmoCount(IEntityClass* pAmmoType, int count)
{ 
  IActor* pOwner = GetOwnerActor();
  
  if (pOwner && !pOwner->IsPlayer() && count < m_ammo[pAmmoType])
    return;
  
  CWeapon::SetAmmoCount(pAmmoType, count);    
}
Пример #29
0
//=======================================================================
void CC4::SelectDetonator()
{
	if (CActor *pOwner=GetOwnerActor())
	{
		EntityId detonatorId = pOwner->GetInventory()->GetItemByClass(CItem::sDetonatorClass);
		if (detonatorId)
			pOwner->SelectItemByName("Detonator", false);
	}
}
Пример #30
0
//------------------------------------------------------------------------
void CVehicleMountedWeapon::SetAmmoCount(IEntityClass* pAmmoType, int count)
{ 
 	IActor* pOwner = GetOwnerActor();
 
	if (pOwner && !pOwner->IsPlayer() && count < SWeaponAmmoUtils::GetAmmoCount(m_ammo, pAmmoType))
 		return;

	CHeavyMountedWeapon::SetAmmoCount(pAmmoType, count);    
}