Jump to content
Official BF Editor Forums

Got Some Good News For The "laser Pointer Fans"


bergerkiller
 Share

Recommended Posts

By accident I found out that you can make an actual laserpointer inside Battlefield 2! This is how:

Clone the "UniqueTarget" (they are in weapons\targetobjects) and rename it to: "LaserPointerTarget".

Set the "timetolive" of the targetobject to 0.1 else it stays visible after you died.

Addtemplate a "glow effect" to the targetobject. You can also make your own effects for this.

I added:

ObjectTemplate.addTemplate glow4

Note that glows are quite large, you might have to re-make one smaller glow for this :D

Next, add the following LPTargetComp to a rifle:

rem ---BeginComp:LPTargetComp ---
ObjectTemplate.createComponent LPTargetComp
ObjectTemplate.target.maxDistance 9999
ObjectTemplate.target.setTargetAtMaxDistance 1
ObjectTemplate.target.targetSystem TSWireGuided
ObjectTemplate.target.targetObjectTemplate LaserPointerTarget
ObjectTemplate.target.disableGuidanceOnReload 1
rem ---EndComp ---

You could even make a projectile follow the laser like some of the laser guided AT weapons.

Only downside is that it doesn't create "laser beams", but those aren't visible in daylight anyways. It does create awesome pinpoint effects on your target, for example, you can make a dot appear on a soldiers' head. :D

Link to comment
Share on other sites

Yeah, well, the classic way (as demonstrated by DEVILMAN) to do it is really flawed, where you put it on the model (only the 1p so it wont go through the walls).

I really like this new idea though, it's a shame it has that dying problem, but unique targets aren't used very much anyway so it doesn't seem like a massive downside. Very nice work, definitely an improvement on the old way.

And having the glow object definitely makes a lot more sense than having a big red stick protruding from your gun model, since as you said; you're going to see the reflected light, not the beam itself.

Edited by UberWazuSoldier
Link to comment
Share on other sites

Thats the awesome thing, you could transform it into a weapon inside a vehicle! Maybe car lights are now possible. :P

And what about searchlights O_O! :o

EDIT

Currently making a video of a "gun with flashlight" in a chopper ;)

Sigh it does work, but the light just sits there when the gunner leaves :D

Guess the only cool thing you can do with this are "indestructable flashlights in camps", else this "target stays" bug just remains. Also, the target disappears when its timetolive is 0 and the weapon is destroyed. (it stayed longer because the weapon remained in the kits)

Edited by bergerkiller
Link to comment
Share on other sites

i dont know if either of these will work but its worth a shot.

try adding the below line of code to all soldier.tweaks...armour comp...

.

ObjectTemplate.armor.hideChildrenOnSpectacularDeath 1

.

in theory this should remove the issue of objects being left behind after death.

.

also something like ClearOnExit might resolve the issue of the pointer being left behind after exit.

Link to comment
Share on other sites

Nah thats not the problem. The targetobject stays there as long the firearm exists in any way in the game. So, if a soldier dies while aiming, the weapon stays in the kit and is not destroyed until the kit "fades" away, then the weapon is destroyed and the dot disappears. Same for vehicles, as long the vehicle exists in any form it is not destroyed.

It is useful for a permanent flashlight though. :D

Link to comment
Share on other sites

' date='05 October 2010 - 11:17 PM' timestamp='1286277454' post='101217']

Carlights have been possible for along time. In XWW2 we also have a pocket (flash-)light. But the lighting in BF2 is flawed unfortunately so that hitting a building or other static with the light looks odd sometimes. Its better with bundledmeshes ...

Wouldn't that be spreading out in all directions though? DICE has removed spotlight support from the game, and the shaders only support Gouraud shading for them (which further suggests it was removed), also none of the mesh types actually use the spot light stuff.

One thing that's been bugging me about lights is how Battlefield 2 doesn't have shadows for any lights other than the sun. Battlefield 2 could look as good as Call of Duty 4 if they hadn't set their terrain to use a separate pass for lightmaps (so I can't generate normalmaps and have the lights illuminate them), also the terrain doesn't get any information on light direction, so there is no chance for specular lighting. But most annoying is that lack of shadows for point lights, it would have made the game so much better - their crappy culling system keeps culling lighting when you face directly away from it, and doesn't cull skinnedmeshes and bundledmeshes at the same time (so sometimes your soldier is illuminated but not your gun, and sometimes the other way around). Like I mentioned earlier, they also broke point lights for bundledmeshes (no colour for them), and skinnedmeshes (they used the wrong function so the light doesn't drop off properly).

Point lights may be the only way to do it, but that's far from ideal.

Edited by UberWazuSoldier
Link to comment
Share on other sites

  • 1 month later...

Wouldn't that be spreading out in all directions though? DICE has removed spotlight support from the game, and the shaders only support Gouraud shading for them (which further suggests it was removed), also none of the mesh types actually use the spot light stuff.

...

Point lights may be the only way to do it, but that's far from ideal.

Sorry for the late answer but i'm struggling with net connection here in my new home.

I use non-damaging projectiles with lightsources attached to them to work around the spotlight limit. The projectiles are emitted very fast ( lightspeed would be ideal but is too fast for the engine ) The TTL of the projectile determines the range of your lightbeam. Making the light emitter ( headlights or the pocket lamp ) a weapon also has the advantage of being able to shut it down again . The downside is that it takes away one fire button in vehicles for the 'light operator' which is usually the driver.

As they are projectiles they are stopped by the first object in the firing line which mostly gets rid of the 'lights through walls' problem.

Edited by mschoeldgen[Xww2]
Link to comment
Share on other sites

But most annoying is that lack of shadows for point lights, it would have made the game so much better

I hope you understand the basics behind the generation of dynamic shadows :D

It has to do a pixel-to vertice translation for every single pixel in every static that is affected by the light source. Then, it has to determine the impact spots of every vertice, make a shadow volume out of this and actually cast the shadow onto the meshes using some planes.

In an example I found it even lags if you have 3 light sources and 3 objects rendered...so I pretty much understand they only use the sun as lightsource :D

Indeed, on these machines it is quite easy to render multiple light shadows, but at the time it was a new thing and hard to do efficiently. Mind the "hard shadows" casted by the engine. ;)

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

I hope you understand the basics behind the generation of dynamic shadows :D

It has to do a pixel-to vertice translation for every single pixel in every static that is affected by the light source. Then, it has to determine the impact spots of every vertice, make a shadow volume out of this and actually cast the shadow onto the meshes using some planes.

In an example I found it even lags if you have 3 light sources and 3 objects rendered...so I pretty much understand they only use the sun as lightsource :D

Indeed, on these machines it is quite easy to render multiple light shadows, but at the time it was a new thing and hard to do efficiently. Mind the "hard shadows" casted by the engine. ;)

Don't worry, I'm quite familiar with the process. ;)

3 light sources ought not to lag with 3 objects. Battlefield 2 is one of the last FPS games to not have shadows for point lights. Using a shadow volume is a way to get very accurate shadows, but they look very sharp and it's definitely a sub-optimal way to do it. A far more typical setup for newer games consists of rendering onto 2 or 6 planes with a simple shader, and then doing a pass for the objects to compare the calculated depth to that of the depth buffer. If it is within a certain margin of error, it is assumed to be illuminated, otherwise it is in shadow. Because of the simplicity of the shaders and the fact that the shadow buffers don't need to be all that big, it doesn't have a particularly massive impact on performance if used sparingly. BF2 clearly already had systems in place for this, and it's clear they had planned to have conical lights and such. Indeed, there are rudimentary shaders lying around which make it seem as though DICE started down that path.

So yeah, the two-plane approach is using paraboloid mapping, and the six-plane would be using cube mapping. Either way, it allows for 360 degree shadow mapping. Conical shadows are the easiest, as they involve only one plane. The actual transformation of vertices is no trouble for any hardware, and you don't need to create and destroy surfaces because you can just recycle the same ones each frame. So no, I would disagree with you about the performance being a huge factor. I suspect it's more of an effort thing, and DICE probably didn't initially plan to have night maps (so no need for headlights or flashlights).

Edited by UberWazuSoldier
Link to comment
Share on other sites

Ever get this laser pointer to work over the network? I tried adding networkables to everything, but it just wouldn't work. Oh and I swapped out that glow effect for a small sphere; works a lot better and doesn't disappear inside walls and things. With a little neon glow it would be pretty awesome.

Link to comment
Share on other sites

I'm not sure if it works over the network, but afraid it isn't. Guess DICE never sends targetobject information over the internet. Added to a networked object is no problem, but when it's stand-alone (like in the target comp) I guess no info is sent over. (why would the other guys want to know on what you are aiming with your eryx?)

Link to comment
Share on other sites

  • 4 weeks later...

Just make/use a red glow. You can clone an existing glow and change the texture of it, or you can model your own.

Problem with some standard glows is that it "disappears" when looking at it in a certain angle.

Glows are in Objects\Common\Glow. You just change the addtemplate in your target object:

ObjectTemplate.create TargetObject FlashTarget
rem ObjectTemplate.setNetworkableInfo LaserTargetInfo
ObjectTemplate.createdInEditor 1
ObjectTemplate.timeToLive 500
ObjectTemplate.targetType TTUnique
ObjectTemplate.addTemplate glow_red

I'd say clone and rename the "glowshit" glow to "glow_red" and change the texture of the bundledmesh (also clone bundledmesh) to Objects\Common\glow\glow5.dds. The standard glow5 is extremely large (some sort of sun-like glow), so add-tempalting the glow5 wouldn't do for a laser target.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...