int CScriptBind_Weapon::GetAttachmentHelperPos(IFunctionHandler *pH, const char *helperName)
{
	CWeapon *pWeapon = GetWeapon(pH);
	if (!pWeapon)
		return pH->EndFunction();

	Vec3 pos = pWeapon->GetSlotHelperPos(eIGS_FirstPerson, helperName, false);
	Vec3 tpos = pWeapon->GetSlotHelperPos(eIGS_FirstPerson, helperName, true);
	//gEnv->pRenderer->DrawPoint(tpos.x, tpos.y, tpos.z, 10.0f);
	//CryLogAlways("helperName: %s pos: x=%f y=%f z=%f", helperName, tpos.x, tpos.y, tpos.z);
	//gEnv->pRenderer->DrawBall(tpos, 0.2f);
	//gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(tpos, 0.075f, ColorB( 255, 10, 10, 255 ));
	//gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(pWeapon->GetOwner()->GetWorldPos(), ColorB(0, 0, 255, 255), tpos, ColorB(255, 255, 0, 255));
	return pH->EndFunction(tpos);
}
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;
}
Exemple #3
0
//------------------------------------------------------------------------
bool CFireModePlugin_Reject::Update(float frameTime, uint32 frameId)
{
	CWeapon* pWeapon = m_pOwnerFiremode->GetWeapon();

	if(pWeapon->IsOwnerClient())
	{
		const int slot = pWeapon->GetStats().fp ? 0 : 1;
		const SEffectParams& rejectEffect = m_pParams->rejectEffect;
		Vec3 lastShellFXPosition = m_lastShellFXPosition;

		const Vec3 helperLocalPosition = pWeapon->GetSlotHelperPos(slot, rejectEffect.helper[slot].c_str(), true);
		
		if (lastShellFXPosition.IsZero())
		{
			lastShellFXPosition = helperLocalPosition;
		}
		
		const Vec3 positionDifferential = helperLocalPosition - lastShellFXPosition;
		m_shellHelperVelocity = positionDifferential * (1.0f / frameTime);

		m_lastShellFXPosition = helperLocalPosition;
	}

	return false;
}
bool CLaser::GetFiringPos(EntityId weaponId, const IFireMode* pFireMode, Vec3& pos)
{
	CWeapon* pParentWeapon = GetWeapon();

	if (!m_laserBeam.IsLaserActivated())
		return false;
	
	if (pParentWeapon && (!gEnv->bMultiplayer ||!pParentWeapon->IsZoomed()))
	{
		int slot = pParentWeapon->IsOwnerFP() ? eIGS_FirstPerson : eIGS_ThirdPerson;

		pos = pParentWeapon->GetSlotHelperPos(slot, "weapon_term", true);
		return true;
	}

	return false;
}