[UT2004] how bright is the place I am?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Postal

I apear to have lost my pin.
Nov 14, 1999
1,388
0
0
WoD.BeyondUnreal.com
punk129 said:
hey guys,
is there any chance to get the brightness of the player's position?

want my bots only see the player, if it's bright enough there.

Back in 2k3 I had a weapon that used light to reload. Heres the code I used, kinda laggy though.

Code:
Function Float FindLight()
{
	Local Actor L;
	Local Float Lx,Ly,Lz,D,LB,F;
	Local Vector Loc;

	Loc=Owner.Location;
	Foreach VisibleActors(Class'Actor',L,/*optional float Radius*/,Loc)
	{
		If(L.LightType!=LT_None)
		{
			Lx=(L.Location.x-Loc.x);
			Ly=(L.Location.y-Loc.y);
			Lz=(L.Location.z-Loc.z);
			D=Lx+Ly+Lz;	
			LB=L.LightBrightness*L.LightRadius;
			F=LB/D;
			If(F>1) F=1;
			If(F<0) F=0;
		}
	}
	Return (F);
}
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
You could probably optimize that by replacing the VisibleActors() if () part with this:
Code:
foreach RadiusActors(Class'Actor', L, Radius,Loc)
  if ( L.LightType != LT_None && FastTrace(Loc, L.Location) ) {
    // remaining code here
  }
This way it only traces actual light sources, which should be much faster than tracing all actors first and then check the visible actors for their LightType.
 

Mr Evi1

New Member
Mar 22, 2002
336
0
0
UK
come.to
Won't both of those methods miss out on sunlight actors, assuming the usual practice of putting them in the skybox?
 

Hazard.ep

New Member
Oct 7, 2003
166
0
0
Wormbo said:
Yes, but how are you going to check whether an actor in the skybox can be seen from somewhere inside the regular map area?

I just had an idea about the Sunlightactors. It works! Like this for example:
Code:
exec function CheckForSun()
{
	local Actor Other;
	local SunLight SL;
	local Vector X, End, HitLocation, HitNormal,Start;
	local Material HitMat;

	Start = Location;

	foreach AllActors(Class'SunLight',SL)
	{
		if ( (SL != None) && (SL.Region.Zone.IsA('SkyZoneInfo')) )
		{
			X = (Vector(SL.Rotation))* -1;
			End = Start + 50000 * X;
			Other = Trace(HitLocation, HitNormal, End, Start, true,, HitMat);
			If ( (Other!=None) && (HitMat==Texture'MyPackage.MySkyTexture') )
				ClientMessage("Saw Sun");
                                //You are affected by a sunlightactor!
		}
	}
}

The basic idea is, that you put one texture (I called it MySkyTexture here) on every surface you want to handle with fakebackdrop, so the code knows that the skybox is there. So if you can see the skybox at the angle opposing the rotation of the sunlightactor, the sunlight actor shines on you!
 
Last edited: