Exemplo n.º 1
0
//------------------------------------------------------------------------
Vec3 CGunTurret::GetTargetPos(IEntity *pEntity) const
{
	pEntity=ResolveTarget(pEntity);

	if(IPhysicalEntity *pPE = pEntity->GetPhysics())
	{
		pe_status_dynamics dyn;

		if(pPE->GetStatus(&dyn))
		{
			if(dyn.submergedFraction<=0.05f)
				return dyn.centerOfMass;

			Vec3 pos=dyn.centerOfMass;
			float waterLevel=gEnv->p3DEngine->GetWaterLevel(&pos);

			if(waterLevel>=pos.z)
				pos.z=waterLevel;

			return pos;
		}
	}

	return pEntity->GetWorldPos();
}
/**
 *	Initialize the parameters for the structure
 *
 *	@param	InTemplate		The ParticleEmitter to base the instance on
 *	@param	InComponent		The owning ParticleComponent
 *	@param	bClearResources	If true, clear all resource data
 */
void FParticleBeam2EmitterInstance::InitParameters(UParticleEmitter* InTemplate, UParticleSystemComponent* InComponent, bool bClearResources)
{
	FParticleEmitterInstance::InitParameters(InTemplate, InComponent, bClearResources);

	UParticleLODLevel* LODLevel	= InTemplate->GetLODLevel(0);
	check(LODLevel);
	BeamTypeData = CastChecked<UParticleModuleTypeDataBeam2>(LODLevel->TypeDataModule);
	check(BeamTypeData);

	//@todo. Determine if we need to support local space.
	if (LODLevel->RequiredModule->bUseLocalSpace)
	{
		LODLevel->RequiredModule->bUseLocalSpace	= false;
	}

	BeamModule_Source			= NULL;
	BeamModule_Target			= NULL;
	BeamModule_Noise			= NULL;
	BeamModule_SourceModifier	= NULL;
	BeamModule_TargetModifier	= NULL;

	// Always have at least one beam
	if (BeamTypeData->MaxBeamCount == 0)
	{
		BeamTypeData->MaxBeamCount	= 1;
	}

	BeamCount					= BeamTypeData->MaxBeamCount;
	FirstEmission				= true;
	TickCount					= 0;
	ForceSpawnCount				= 0;

	BeamMethod					= BeamTypeData->BeamMethod;

	TextureTiles.Empty();
	TextureTiles.Add(BeamTypeData->TextureTile);

	UserSetSourceArray.Empty();
	UserSetSourceTangentArray.Empty();
	UserSetSourceStrengthArray.Empty();
	DistanceArray.Empty();
	TargetPointArray.Empty();
	TargetPointSourceNames.Empty();
	UserSetTargetArray.Empty();
	UserSetTargetTangentArray.Empty();
	UserSetTargetStrengthArray.Empty();

	// Resolve any actors...
	ResolveSource();
	ResolveTarget();
}
Exemplo n.º 3
0
int
wmain(int argc, WCHAR *argv[])
{
    WSADATA wsaData;
    ULONG i;
    DWORD StrLen = 46;
    int Status;

    /* Initialize the Console Standard Streams */
    ConInitStdStreams();

    IpOptions.Ttl = 128;

    if (!ParseCmdLine(argc, argv))
        return 1;

    if (!SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE))
    {
        DPRINT("Failed to set control handler: %lu\n", GetLastError());
        return 1;
    }

    Status = WSAStartup(MAKEWORD(2, 2), &wsaData);
    if (Status != 0)
    {
        ConResPrintf(StdErr, IDS_WINSOCK_FAIL, Status);
        return 1;
    }

    if (!ResolveTarget(TargetName))
    {
        WSACleanup();
        return 1;
    }

    if (WSAAddressToStringW(Target->ai_addr, (DWORD)Target->ai_addrlen, NULL, Address, &StrLen) != 0)
    {
        DPRINT("WSAAddressToStringW failed: %d\n", WSAGetLastError());
        FreeAddrInfoW(Target);
        WSACleanup();
        return 1;
    }

    if (Family == AF_INET6)
        hIcmpFile = Icmp6CreateFile();
    else
        hIcmpFile = IcmpCreateFile();


    if (hIcmpFile == INVALID_HANDLE_VALUE)
    {
        DPRINT("IcmpCreateFile failed: %lu\n", GetLastError());
        FreeAddrInfoW(Target);
        WSACleanup();
        return 1;
    }

    if (*CanonName)
        ConResPrintf(StdOut, IDS_PINGING_HOSTNAME, CanonName, Address);
    else
        ConResPrintf(StdOut, IDS_PINGING_ADDRESS, Address);

    ConResPrintf(StdOut, IDS_PING_SIZE, RequestSize);

    Ping();

    i = 1;
    while (i < PingCount)
    {
        Sleep(1000);
        Ping();

        if (!PingForever)
            i++;
    }

    PrintStats();

    IcmpCloseHandle(hIcmpFile);
    FreeAddrInfoW(Target);
    WSACleanup();

    return 0;
}
Exemplo n.º 4
0
//------------------------------------------------------------------------
Vec3 CGunTurret::GetSweepPos(IEntity *pTarget, const Vec3 &shootPos)
{
	pTarget=ResolveTarget(pTarget);

	// sweep on ground
	int nhints = m_fireparams.hints.size();
	float sweepTime = m_turretparams.sweep_time / (float)nhints;
	float timeFiring = max(0.f, GetBurstTime() - sweepTime*(m_fireHint-1));
	float sweepRelTime = min(1.f, timeFiring/sweepTime);

	if(sweepRelTime == 1.f && m_fireHint == nhints)
		return shootPos;

	Vec3 wpos(GetWeaponPos());
	Vec3 dir = shootPos - wpos;
	Vec3 dir2d(dir.x, dir.y, 0.f);
	float dist2d = dir2d.GetLength();

	if(dist2d < 2.f*m_fireparams.hints[0].y)
		return shootPos; // don't sweep when target too close

	dir2d /= dist2d;
	Vec3 right = Vec3(0,0,-1) % dir2d;
	Vec3 zoffset(0,0,0);

	if(IPhysicalEntity *pPE = pTarget->GetPhysics())
	{
		pe_status_pos ppos;

		if(pPE->GetStatus(&ppos))
			zoffset=Vec3(0,0,-0.5f*(ppos.BBox[1].z-ppos.BBox[0].z));
	}

	Vec3 lastHintPos(shootPos);
	const Vec2 &lastHint = m_fireparams.hints[m_fireHint-1];
	lastHintPos += lastHint.y*-dir2d + lastHint.x*right + zoffset;

	Vec3 nextHintPos(shootPos);

	if(m_fireHint < nhints)
	{
		const Vec2 &nextHint = m_fireparams.hints[m_fireHint];
		nextHintPos += nextHint.y*-dir2d + nextHint.x*right + zoffset;
	}

	Vec3 currPos = Vec3::CreateLerp(lastHintPos, nextHintPos, sweepRelTime);

	if(sweepRelTime == 1.f && m_fireHint < nhints)
		++m_fireHint;

	if(g_pGameCVars->i_debug_turrets == eGTD_Sweep)
	{
		IRenderAuxGeom *pGeom = gEnv->pRenderer->GetIRenderAuxGeom();
		pGeom->SetRenderFlags(e_Def3DPublicRenderflags);
		ColorB col(0,255,255,128);
		pGeom->DrawSphere(currPos, 0.3f, col);
		pGeom->DrawSphere(lastHintPos, 0.3f, col);
		pGeom->DrawSphere(nextHintPos, 0.3f, col);
		pGeom->DrawLine(lastHintPos, col, nextHintPos, col);
		gEnv->pRenderer->DrawLabel(currPos, 1.4f, "sweep, hint %i, ratio %.2f)", m_fireHint, sweepRelTime);
	}

	return currPos;
}
Exemplo n.º 5
0
//------------------------------------------------------------------------
Vec3 CGunTurret::PredictTargetPos(IEntity *pTarget, bool sec)//sec - weapon to use
{
	pTarget = ResolveTarget(pTarget);
	Vec3 tpos = GetTargetPos(pTarget);

	if(m_turretparams.search_only || m_turretparams.prediction == 0.f)
		return tpos;

	IPhysicalEntity *pe = pTarget->GetPhysics();
	pe_status_dynamics dyn;

	if(!pe || !pe->GetStatus(&dyn))
		return tpos;

	Vec3 vel = dyn.v;
	Vec3 acc = dyn.a;
	float a = acc.len();

	if(a < 0.01f)
		a = 0.f;
	else
		acc /= a;

	Vec3 vpos = GetWeaponPos();
	Vec3 dist = tpos-vpos;
	float d = dist.len();

	if(d < 0.01f)
		return tpos;

	dist /= d;
	float d_speed = vel*dist;

	float speed = 800.0f;
	const SAmmoParams *ammo = g_pGame->GetWeaponSystem()->GetAmmoParams(GetFireMode(0)->GetAmmoType());

	if(!ammo)
		return tpos;

	if(ammo->physicalizationType == ePT_None)
		return tpos;

	speed = ammo->speed;

	float time_to = d/max(1.f, speed-d_speed);

	// MR: clamped acc prediction to reduce jerkyness when targetting objects that are able
	// to do near-instant velocity changes (like players)
	a = min(a, 25.f);

	Vec3 delta = vel*(time_to) + 0.5f*a*acc*time_to*time_to;
	delta *= m_turretparams.prediction;

	if(g_pGameCVars->i_debug_turrets == eGTD_Prediction)
	{
		IPersistantDebug *pDebug = gEnv->pGame->GetIGameFramework()->GetIPersistantDebug();
		pDebug->Begin("CGunTurret::PredictTargetPos", false);
		pDebug->AddSphere(tpos+delta, 0.2f, ColorF(1,0,0,1), 1.f);
		gEnv->pRenderer->DrawLabel(vpos, 1.4f, "Predict %s: speed %.1f (dspeed %.1f), acc %.1f, time %.1f", pTarget->GetName(), vel.len(), d_speed, a, time_to);
	}

	return tpos+delta;
}