[Can't fix] LWM's Flashlight is Broken 4.2.1

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

LWM's Flashlight is Broken 4.2.1

Postby Enjay » Tue Sep 10, 2019 1:50 pm

Years ago, LilWhiteMouse made a flashlight that uses a script to spawn a stream of actors with dynamic lights attached to act as a flashlight. Although other, more modern, flashlights are now available, I still like and still use this one (aside from anything else, it acts independently to the weapons). However, with 4.2.1 it has stopped working. It worked with 4.2.0.

Here it is working in 4.2.0


But it doesn't work in 4.2.1. However, it is just the dynamic lights that are failing. The actors are being spawned.

Here is a screenshot of the map in 4.2.1 with the AM_Cheat active:


I have attached a cut down version of the flashlight that works in 4.2.0. To use it, load the pk3 and type

+uselwmflashlight

at the console.
Attachments
lwmfl.pk3
(3.39 KiB) Downloaded 17 times
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: LWM's Flashlight is Broken 4.2.1

Postby Nash » Tue Sep 10, 2019 2:00 pm

While I am not dismissing this as a possible bug, why do you not prefer modern spotlight-based flashlights? Not only is it more performance-friendly, as it's only a single light actor, but it would also light things in a more physically accurate way, and lastly, will generate proper shadows if shadowmaps are enabled.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: LWM's Flashlight is Broken 4.2.1

Postby Enjay » Tue Sep 10, 2019 2:09 pm

One stumbling block is that I don't know how to make one that acts independently of the weapons. With this one, I can bind a key to it and the key runs the flashlight regardless of which weapon is selected or whether I'm firing or not. (I have it bound so that I have to hold the flashlight button to keep it on rather than toggling it on/off so I can't just leave it on all the time).

The other thing is that, actually, I simply haven't found a modern flashlight implementation that I like. Dodopod's one is pretty good but when I tried modifying it to work in the same way as I used LWM's one, i just got horribly lost and it didn't look that much better to me anyway.

A simple, clean modern version would, of course, be preferable but it would need to be activated in the same way, would need to illuminate things just as well (IMO of course).


However, the merits of the different types of lights aside, I can't figure out why this isn't working. The actors are spawning, but the lights are not showing. Other actors spawn with lights just fine so I'm not sure what the difference is.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: LWM's Flashlight is Broken 4.2.1

Postby Enjay » Tue Sep 10, 2019 2:17 pm

Aha! Progress!

I have found how to make the light work again.

If I change line 86 in the DECORATE from:
Code: Select allExpand view
NONE A 1

to
Code: Select allExpand view
NONE A 2

The lights appear. So, for some reason, I guess that in 4.2.1 that actor isn't around long enough for the light to appear. Maybe?

(BTW a sprite called NONEA0.png is included)
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: LWM's Flashlight is Broken 4.2.1

Postby Nash » Tue Sep 10, 2019 2:27 pm

Enjay: Maybe Steve's Flashlight Mod is more suitable for you. Works exactly the way you describe it; doesn't depend on weapons, has a bindable key. Much simpler than Dodopod's one. viewtopic.php?f=43&t=59429

Anyway, that said, carry on with the current investigation. Anything that used to work before but now doesn't, is always worth reporting. :)
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: LWM's Flashlight is Broken 4.2.1

Postby Enjay » Tue Sep 10, 2019 3:11 pm

Thanks, I'll check out Steve's one. :)
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: LWM's Flashlight is Broken 4.2.1

Postby Caligari87 » Tue Sep 10, 2019 7:08 pm

At risk of sounding narcissistic, gonna just plug DarkDoomZ as well. The flashlight is lightly customizable with simple good looking presets, one-key toggle, and the darkening effects are completely optional. Also not to toot my own horn too much but I think it's one of the better-looking implementations; I spent a lot of time tweaking the preset values.

8-)
User avatar
Caligari87
I'm just here for the community
User Accounts Assistant
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA
Discord: Caligari87#3089

Re: LWM's Flashlight is Broken 4.2.1

Postby Nash » Fri Sep 13, 2019 3:57 am

Code: Select allExpand view
class LADGunLight Actor
{
    Default
    {
        +
NOINTERACTION
    
}

    
States
    
{
    
Spawn:
        
TNT1 A 2 Light("Light_GunLight");
        
Stop;
    }
}
 


Seems like I ran into this problem, too. This was an actor that gets spawned when I fired my weapon to generate muzzle flash lighting. The light just doesn't appear anymore, even though the actor is spawned correctly.

Changing TNT1 A 2 to TNT1 A 3 - so 1 additional state tic - will "fix" the lighting.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: LWM's Flashlight is Broken 4.2.1

Postby Graf Zahl » Sun Oct 20, 2019 6:24 am

A few things to note here:

I can of course add a check for a freshly spawned actor to create its lights immediately. That should fix Nash's problem, but in Enjay's case it won't help because that thing comes with an empty dummy state before the relevant one that practically defeats all attempts to fix this.

Nash's problem is caused by spawn tic randomization. For an actor whose first state's length must be fixed, adding the SYNCHRONIZED flag is necessary. In this case the duration got simply truncated to 1 and the light never showed up.

Update: Turns out I was wrong. The entire thing here is caused by some fundamental misconception about what a tic means.
"1 Tic" does not mean to stay around for 1/35th of a second, it really means, "destroy after being ticked once."
So what happens is simply that the actor might create its light when being spawned but then getting removed before it even hits the renderer for the first time, i.e. it is never drawn! The same applies to the light. In the old code it was the light actor that removed itself when its owner was gone - but since STAT_DLIGHT is one of the lower statnums this happens with a one tic delay.

The new light information is just dumb data owned by the actor, so once the actor is gone, so is the light.
I'm sorry but this qualifies as "Can't fix". TBH, I never realized myself before what precisely the behavior of a one-tic-actor really is.

What this boils down to is that setting a light in a terminating state with a one-tic-duration simply cannot work in a system where the actor controls the lifetime of the light.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: LWM's Flashlight is Broken 4.2.1

Postby Nash » Sun Oct 20, 2019 7:19 am

Alright, noted. I figured things are different now ever since you rewrote the dynamic light code. Thanks for the detailed explanation.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: LWM's Flashlight is Broken 4.2.1

Postby Enjay » Sun Oct 20, 2019 8:49 am

Graf Zahl wrote:Update: Turns out I was wrong. The entire thing here is caused by some fundamental misconception about what a tic means.
"1 Tic" does not mean to stay around for 1/35th of a second, it really means, "destroy after being ticked once."


That's useful information. Although I didn't make this flashlight, I certainly had that misconception too. My fundamental misunderstanding can be summed up by me thinking that a tic was simply a unit of time and in Doom it was 1/35 of a second. I suspect many people think similarly.

So, for further clarification, what exactly does "being ticked" mean. Is is something like "the engine has acknowledged this thing exists"?
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: LWM's Flashlight is Broken 4.2.1

Postby Graf Zahl » Sun Oct 20, 2019 9:21 am

"Being ticked" means that the engine runs its ticker once over each actor.
But here's the tricky part: It counts down the current state's duration and if that reaches 0, the actor is destroyed. So far, so good - but for freshly spawned actors the ticking is performed in the same tic it gets spawned. I guess you can do the math from there...
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: LWM's Flashlight is Broken 4.2.1

Postby Enjay » Sun Oct 20, 2019 9:58 am

I'm following what you're saying and I understand what the problem was, but the bit that's still missing for me is - what does the ticker actually do?

i.e. what happens when the engine "runs its ticker once over each actor"? What is the engine/the ticker actually doing at that point?

I've tried googling it but my Google-fu is failing me. I'm mostly getting things about horizontal scrolling LED displays. :lol:
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: LWM's Flashlight is Broken 4.2.1

Postby Graf Zahl » Sun Oct 20, 2019 10:23 am

What can I say other than "It's calling the actor's Tick() function"?
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: LWM's Flashlight is Broken 4.2.1

Postby Enjay » Sun Oct 20, 2019 10:29 am

Seems obvious now. Thanks.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests