Duke4.net Forums: Flashlight Effect - Duke4.net Forums

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Flashlight Effect  "It works"

User is offline   Darkus 

#1

After a long research, I finally managed to create a flashlight effect.

Update: Helixhorned fixed the bug in FLASHLIGHT2.CON. I also add a small fix for FLASHLIGHT1.CON and updated the *.txt files.

* Description/content

When pressing the 'Flashlight' key, you can activate/desactivate it and illuminate dark areas.
The effect does not come from center of the screen, but comes rather from the right shoulder, so you can better see the real-time shadows.
Work only with Polymer mode.

There are two versions included:

FLASHLIGHT1.CON
To make it work, you must include in your map a SECTOREFFECTOR with a lotag of 50, and a palette of 10 (no need to modify the hitag, xvel or other values). If it not there, there will be no effect.

FLASHLIGHT2.CON
This version should make the flashlight work in regular maps (no need to add SE).
But there is currently a bug that cast the APLAYER sprite instead of normal light, but I leave this version in case of the problem would be solved.
Thanks to Helixhorned, this should works normally now.

I have also included a very small map 'flashlight_test.map', to be used with FLASHLIGHT1.CON.


* How to install/make it work:

Simply copy the files into your EDuke32 directory.
Then you can either use the commande line (something like "EDUKE32.EXE -X FLASHLIGHT1.CON") or rename the FLASHLIGHT1/2.CON into EDUKE.CON an launch EDuke32.

Important: don't forget to bind a key for the flashlight! It replaces the 'turn around' key.

* Known Bugs:
- It may lag or glitch in some maps.
- When you're using security cameras, the flashlight is teleporting right to the camera that you're viewing.
- If you're using the HRP or any player model, you may get the player shadow interfering with flashlight. If this happens, check HRPModels_fix.txt to see how to correct this problem

* modification/permission

You can freely modify the code, either for use in your maps, mods or whatever, but don't forget to give credits.

Attached File  Flashlight_by_Darkus.zip (7.87K)
Number of downloads: 356

Some screenshots:

flashlight_test.map using FLASHLIGHT1.CON
http://s19.postimage.org/itpjdrcwz/flashlight1.png

modified E1L2 (SE 50 added with pal 10) dark hallway using FLASHLIGHT1.CON
http://s19.postimage.org/oj5ry2j37/flashlight2.png

unmodified E1L1 using FLASHLIGHT2.CON (showing the bug should be fixed now)
http://s19.postimage.org/a18kq2rs3/flashlight_bug.png

This post has been edited by Darkus: 12 November 2012 - 01:54 PM

7

#2

Ah, nice! I'm playing with it now... I don't have a use for it at present myself, but it looks good and is certainly useful as reference.
0

User is offline   LeoD 

  • Duke4.net topic/3513

#3

Good one. For shits and giggles I've added FLASHLIGHT1.CON to my local DukePlus, which seems to work as intended. But in conjunction with the HRP alone I get some nasty shadows of the player model, maybe related to the FLASHLIGHT2.CON issue. :D
Attached Image: duke0010.jpg
0

User is offline   blizzart 

#4

View PostLeoD, on 31 October 2012 - 01:08 PM, said:

Good one. For shits and giggles I've added FLASHLIGHT1.CON to my local DukePlus, which seems to work as intended. But in conjunction with the HRP alone I get some nasty shadows of the player model, maybe related to the FLASHLIGHT2.CON issue. :D
Attachment duke0010.jpg


I´ve got the same problem here. As long you´re looking up it doesn´t appear, but when you look straight ahead or down you look through the player model.
Attached Image: duke0001_1.jpg
Attached Image: duke0002_1.jpg

I´ve had to bind the flashlight to another key otherwise it couldn´t be activated at all.
0

User is offline   Plagman 

  • Former VP of Media Operations

#5

The flashlight really has to originate from the tip of the player's model RPG, or it will cast its shadow as you can see.
0

User is offline   Micky C 

  • Honored Donor

#6

View Postblizzart, on 31 October 2012 - 02:47 PM, said:

I´ve got the same problem here. As long you´re looking up it doesn´t appear, but when you look straight ahead or down you look through the player model.
Attachment duke0001_1.jpg
Attachment duke0002_1.jpg

I´ve had to bind the flashlight to another key otherwise it couldn´t be activated at all.


Btw if you're planning to use the flashlight effect in your mod, I'd recommend adding a light map so that it actually looks like light from a torch rather than a simple light, plus it should be made a bit more yellow. I'd show you a picture of what I mean but it's difficult to find on google. I'm talking about the pattern from the glass and mirrors that the torch use to focus the light.
0

User is offline   Plagman 

  • Former VP of Media Operations

#7

Just don't steal the one from Doom 3 like the S.T.A.L.K.E.R. devs :D
0

User is offline   Darkus 

#8

I knew there was a problem like that, I should have tested this before...
I found two solutions:

1) Try to modify the values that are inside the EVENT_GAME block, to make the flashlight upper, lower, or left handed (I've reuploaded the mod with an additional file that describe that). But the player shadow can still appear if the player is moving, so there the other solution:

2) The second solution is to remove the player shadow when the flashlight is active, but it requires that you modify both the GAME.CON and FLASHLIGHT1/2.CON. Here's how to proceed:

First, open GAME.CON and add this just below the "APLAYER MAXPLAYERHEALTH PSTAND 0 0" line:
  getactor[THISACTOR].mdflags temp
  orvar temp 16
  setactor[THISACTOR].mdflags temp


Save and then open the FLASHLIGHT1/2.CON and add this to the bottom of the file:
onevent EVENT_ANIMATESPRITES
  ifvare flashlighton 1
  { getplayer[THISACTOR].i temp
    { gettspr[temp].tsprcstat temp2
      orvar temp2 8192
      settspr[temp].tsprcstat temp2
    }
  }
endevent

And don't forget to move the 'gamevar temp 0 0' line above the 'include GAME.CON' one since this file used the 'temp' variable.

Now you should be able to use the flashlight using the HRP, without having the player shadow which interferes with the light, but the player will not cast shadow until the flashlight is turned off.
This is an advantage and a drawback.
0

User is offline   Mark 

#9

This is so cool. I'll have to add your modifications and try again. It does give me freezes in a number of places in my map.

Attached thumbnail(s)

  • Attached Image: duke0001.jpg

1

User is offline   Mark 

#10

I don't have a GAME.CON file in my folder. Do I just extract a copy from the DUKE3D.GRP file and put it in the folder? And then add your code to it?

This post has been edited by Marked: 31 October 2012 - 03:45 PM

0

User is offline   Darkus 

#11

View PostMarked, on 31 October 2012 - 03:45 PM, said:

I don't have a GAME.CON file in my folder. Do I just extract a copy from the DUKE3D.GRP file and put it in the folder? And then add your code to it?
Yes, you must extract the original GAME.CON from the DUKE3D.GRP at the same folder and apply the modification.

But be aware that if you remove the flashlight mod, the variable 'temp' is used in GAME.CON, but declared in FLASHLIGHT1/2.CON, so don't forget to avoid problems.
0

User is offline   Mark 

#12

Thankyou.
0

User is offline   Mark 

#13

I'll have to start over. I'm getting con error messages and the game won't load. Hopefully I can figure it out.
0

User is offline   Mark 

#14

I figured it out. Now I will play around with size, color etc...

Attached thumbnail(s)

  • Attached Image: graveyard1.jpg
  • Attached Image: graveyard2.jpg
  • Attached Image: graveyard3.jpg
  • Attached Image: graveyard4jpg.jpg

0

User is online   OpenMaw 

  • Judge Mental

#15

I'm using a clean install, EDUKE32_LATEST off the eduke32.com website. It's in polymer mode. (Which is working fine.)

Fired up the test map included with FLASHLIGHT1.CON renamed to EDUKE.CON.

I rebound turnaround to F (after hitting the default key backspace a few times and seeing nothing.).

In either case i'm getting the following error.



"gamefunc_TurnAround" is not a valid command or cvar

I made no changes to the con files other than to rename the file itself. Clean dump install. So. Is this related to the version of EDUKE I procured, or...?


EDIT: Okay, odd. I restarted the game again and it works now. Just like that... Huh. Very strange.

This post has been edited by Commando Nukem: 01 November 2012 - 07:18 PM

0

User is online   OpenMaw 

  • Judge Mental

#16

Sorry for the semi-noobish behavior but I wanted to give this thread a bump.

Does anyone know whether this mod will work with additional map-based spot lights hanging around? Because I was fiddling around with the flashlight test map, and I had a red spot light I put in near the beginning. It seems to "instantly disappear" when I turn on the light preview mode in Mapster. When I change it from a spot light to a point light though, it works just fine.

I did not make any changes to the con code. So it's nothing like that.
0

User is offline   Mark 

#17

I've been having a blast with the flashlight mod for a couple of weeks that I first noticed this today. When using the flashlight it looks like the shadows cast by models are created in "thin air" right behind the model giving the illusion of casting its shadow on areas behind. Here is a pic to try and explain what I mean. Has this always been the case with spotlights? And just not as noticible to me since before this mod they were alway static. I can't quite put my finger on it, but something just doesn't look right. Maybe its because the light source is so close to the ground? Or am I just goofy?

Also, I have been trying to figure out why I get occasional freezes in my map when using the mod. I went so far as to remove all enemies and all Polymer lights. It still happens. I'll have to try it in other maps without TROR and see if somehow that is the culprit. I doubt it but I'm running out of ideas.

Attached thumbnail(s)

  • Attached Image: duke0004.jpg


This post has been edited by Marked: 11 November 2012 - 05:40 AM

0

User is offline   Diaz 

#18

That's how a shadow would look IRL, I think. The same thing happens in HL2.
0

User is offline   Mblackwell 

  • Evil Overlord

#19

There's no other light in the scene, and there's no radiosity so you get that nice black stencil effect.
0

User is offline   Darkus 

#20

Marked said:

I've been having a blast with the flashlight mod for a couple of weeks that I first noticed this today. When using the flashlight it looks like the shadows cast by models are created in "thin air" right behind the model giving the illusion of casting its shadow on areas behind. Here is a pic to try and explain what I mean. Has this always been the case with spotlights? And just not as noticible to me since before this mod they were alway static. I can't quite put my finger on it, but something just doesn't look right. Maybe its because the light source is so close to the ground? Or am I just goofy?
I assure you, this is normal. You can verify this when creating a small dark test map with a mirror, you can see in the mirror the shadows of the objects moving.

Marked said:

Also, I have been trying to figure out why I get occasional freezes in my map when using the mod. I went so far as to remove all enemies and all Polymer lights. It still happens. I'll have to try it in other maps without TROR and see if somehow that is the culprit. I doubt it but I'm running out of ideas.
I also did some tests and I also have the same problem on some levels, such as E2L6. Those freezes occur when I enter over a 'sector-over-sector' effect, but it seem to work fine in TROR maps. An engine bug maybe? :P/>
0

User is offline   Mark 

#21

In my custom map the freezes are happening in different types of areas. Sometimes in wide open areas, sometimes in a maze of narrow tunnels where not a lot is rendered at one time. I didn't use any SOS in the map. Just TROR. Just for grins I also disabled the shadow casting of the SE50 flashlight and it made no difference of any kind.
0

User is offline   Mblackwell 

  • Evil Overlord

#22

Does it make any different if you change line 51 to:

setactor[isflashlight].sectnum player[THISACTOR].cursectnum


?
0

User is offline   Plagman 

  • Former VP of Media Operations

#23

Don't set the sectnum directly, there's commands to do that.
0

User is offline   Mblackwell 

  • Evil Overlord

#24

Actually setting the sectnum uses changespritesect. It's just obscured from the coder.
0

User is offline   Plagman 

  • Former VP of Media Operations

#25

Oh, cool; didn't know that.
0

User is offline   Mblackwell 

  • Evil Overlord

#26

Yeah, not sure who made that change but it was definitely a smart one.
0

User is offline   Helixhorned 

  • EDuke32 Senior Developer

#27

View PostDarkus, on 31 October 2012 - 10:52 AM, said:

FLASHLIGHT2.CON
This version should make the flashlight work in regular maps (no need to add SE).
But there is currently a bug that cast the APLAYER sprite instead of normal light, but I leave this version in case of the problem would be solved.

This is because Polymer uses actor[].picnum (known as "htpicnum" in CON), which is set to the spawning actor's tile on "espawn", in this case APLAYER. (Plagman: is this intended?)
The attached modified version also fixes a bug where the flashlight can not be triggered after having died with it turned on.

Attached File(s)


0

User is offline   Darkus 

#28

Thanks Helixhorned! I've just tested the fixed FLASHLIGHT2.CON, and it works perfectly. I'll update my mod. I did not know it was "htpicnum" that was causing problems.
0

User is offline   Mark 

#29

View PostMblackwell, on 11 November 2012 - 06:26 PM, said:

Does it make any different if you change line 51 to:

setactor[isflashlight].sectnum player[THISACTOR].cursectnum


?

Beacause of the seemingly random nature of the slowdowns, pauses and freezes its hard to tell for sure. There are 2 different versions of the flashlight. I happen to be using the other one than what you looked at. Instead of using your line of code in line 51 it was actually line 74 in the version I'm using. With your code there seemed to be less freezing but still slowdowns and slight pauses. With your line added I also noticed that sometimes when crossing from one sector to another or climbing stairs the flashlight will flicker on and off. BTW, looking at the code in general is there any obvious reason why activating the mod greatly reduces overall framerate regardless of if the flashlight is on or off?
0

User is offline   Mblackwell 

  • Evil Overlord

#30

Potentially because the light always exists. It is never removed from the map, it just is given a very small range. Also that code line shouldn't necessarily cause any flickering, but either way it was mostly a test to see if it fixed the crashes when crossing sector boundaries or TROR/SOS (which would indicate that updatesectorz is potentially not getting the right sector/an out of bounds one).

Another alternative would be to move

addvar zpos 2048
setactor[isflashlight].z zpos


after the call to updatesectorz > change sectnum. It might be getting pushed into the wrong sector if the difference is within 2048 units from posz.
0

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options