Flashlight/lighting bug

Locked
McTash
Registered user
Posts: 6
Joined: 20 Jan 2015, 20:11

Flashlight/lighting bug

Post by McTash » 11 Mar 2015, 22:24

Bug Description:
A concise description of what the problem is. Pure description, no narrative or conversational language.
When attaching my light to my smg I turn it on and go about figuring out what happened on the Nostromo with other marines. But when I pull a flare, pick up another flashlight, or have any light source on (in hand or pocket) when I remove it or shut it off or it goes out, (flare) the light on my gun goes off as well. And I have to turn it on again and in those few seconds of darkness aliens have pounced on me.

Steps to Reproduce:
  1. Step by step instructions on how to reproduce this bug.
  2. Do not assume anything, the more detailed your list of instructions, the easier it is for the developer to track down the problem!
-Attach light to smg, go in dark area.
-Turn light on (I usually turn it on aboard the shuttle) pull flare, (turn on another light, pick up already on light, or already lit flare).
-Get rid of light source. (Wait for flare to go out, shut off light, I usually drop light or flare)
-Then the light on your gun goes out as well. You have to go through weapon tab, turn it off then on again. Very annoying process especially when you drop a different light source you had in your hand to engage and alien and it gets really dark.

(Optional) Other notes:
If you can't reproduce the issue ask me and I'll show you. Don't know how well I explained this here, but its a very annoying bug. Almost got me captured by aliens a few times. Just pm me here if you need me to show you, or in game, or over Byond. Usually on 4 pm central time to about 8ish pm. Should be on most of this Friday not to sure yet. Just hit me up whenever and I'll try and help you fix this, I am not aware of any one else running into the problem or if they have nothing has been mentioned about it.
Last edited by McTash on 11 Mar 2015, 22:30, edited 1 time in total.

Caroes
Registered user
Posts: 16
Joined: 17 Feb 2015, 13:10

RE: Flashlight/lighting bug

Post by Caroes » 12 Mar 2015, 00:25

I encounter this bug a lot as well, I think it happens with all weapons, not just the SMG.

User avatar
Mycroft Macarthur
Donor
Donor
Posts: 256
Joined: 19 Feb 2015, 14:05
Location: this small blue-green planet called earth, came here for the beer and the bitches.
Byond: Feodrich
Contact:

RE: Flashlight/lighting bug

Post by Mycroft Macarthur » 12 Mar 2015, 02:10

it doesn't only happen with weapons, i keep both pockets filled with flashlights so i can always see with any gun (shotgun flashlights are still broken far as i know), if i ever use a flare then throw it (or pick up a lit one) then my flashlights stop working, if i have to go into space to set the engine i BETTER not accidentally turn on the inbuilt hardsuit helmet or, flashlights suddenly break, pick up a third flashlight? sometimes the other two stop working, have one in the pocket and a second on an m41a? better not drop it or get pounced or both lights go out.

i've wanted to report this bug for ages but i wasn't sure how to list the steps in a way the admins would get, well done on bringing it to their attention.
Image

User avatar
TopHatPenguin
Community Contributor
Community Contributor
Posts: 2383
Joined: 14 Dec 2014, 18:06
Location: Forever Editing The Wiki.
Byond: TopHatPenguin
Contact:

RE: Flashlight/lighting bug

Post by TopHatPenguin » 12 Mar 2015, 03:25

It happens alot when use a falre and flashlight but honestly i have now gotten use to it
Shit cm memes: Image
Image
Image
Image
That guy called Wooki.
Resident Santa.
(THP)

User avatar
apophis775
Host
Host
Posts: 6985
Joined: 22 Aug 2014, 18:05
Location: Ice Colony
Byond: Apophis775
Contact:

RE: Flashlight/lighting bug

Post by apophis775 » 12 Mar 2015, 18:28

This happens with ANY lightsources, because of the code to transfer the light.

It's sort of because of how light is coded into byond itself.

Specifically, an object with light (like a flare), actually generates no light whatsoever when it's in your hand, instead, it's luminosity value, replaces the players value (which is 0 by default), when the player tosses away an object with lumonsity or drops it, it resets the players Luminosity value, to 0.

If anyone has suggestions, on how to fix this system, I'd be interested in hearing them.
ImageImage
flamecow wrote: "unga dunga me want the attachment" - average marine

User avatar
Davidchan
Registered user
Posts: 350
Joined: 20 Feb 2015, 22:08

RE: Flashlight/lighting bug

Post by Davidchan » 13 Mar 2015, 22:08

Removing flares and adding shoulder lamps would be one idea.

User avatar
tristan1333
Registered user
Posts: 32
Joined: 23 Jan 2015, 12:31

RE: Flashlight/lighting bug

Post by tristan1333 » 13 Mar 2015, 22:41

You could have a backup variable that keeps track of the overall lightsource to replace the luminosity when it is set to 0 so it gets set again.
Slagathor coming to kill yo children

User avatar
apophis775
Host
Host
Posts: 6985
Joined: 22 Aug 2014, 18:05
Location: Ice Colony
Byond: Apophis775
Contact:

RE: Flashlight/lighting bug

Post by apophis775 » 04 Apr 2015, 22:52

Any more suggestions? I really don't have a good idea on how to fix this easily. Even the backup light variable is kind of wonky.
ImageImage
flamecow wrote: "unga dunga me want the attachment" - average marine

User avatar
TopHatPenguin
Community Contributor
Community Contributor
Posts: 2383
Joined: 14 Dec 2014, 18:06
Location: Forever Editing The Wiki.
Byond: TopHatPenguin
Contact:

RE: Flashlight/lighting bug

Post by TopHatPenguin » 05 Apr 2015, 04:57

Could you make it so the first light you hold/Turn on has priority over the second..?
Last edited by TopHatPenguin on 05 Apr 2015, 04:57, edited 1 time in total.
Shit cm memes: Image
Image
Image
Image
That guy called Wooki.
Resident Santa.
(THP)

User avatar
apophis775
Host
Host
Posts: 6985
Joined: 22 Aug 2014, 18:05
Location: Ice Colony
Byond: Apophis775
Contact:

Re: Flashlight/lighting bug

Post by apophis775 » 30 Apr 2015, 18:36

I suppose, I could make an array, that tracks all the, light-sources your holding, and defaults to the highest.

But, that might cause lag and other issues, when changing light-sources.

User avatar
TopHatPenguin
Community Contributor
Community Contributor
Posts: 2383
Joined: 14 Dec 2014, 18:06
Location: Forever Editing The Wiki.
Byond: TopHatPenguin
Contact:

Re: Flashlight/lighting bug

Post by TopHatPenguin » 01 May 2015, 18:32

Hmm how about just have a continuous light source as in say you have a flashlight and you also hold a lamp the flashlights light would still be active as well as the lamp you are holding and then when you drop the lamp the flashlights light is still on ?

User avatar
HalfdeadKiller
Registered user
Posts: 468
Joined: 15 Oct 2014, 13:17

Re: Flashlight/lighting bug

Post by HalfdeadKiller » 01 May 2015, 21:37

I think the main issue is tracking it from a code perspective, Wooki. It can be difficult getting the game to understand what we want it to do, when it seems so simple to us. The poor game engine only sees data, and can only interact with the data when it is formatted in certain ways.

User avatar
TopHatPenguin
Community Contributor
Community Contributor
Posts: 2383
Joined: 14 Dec 2014, 18:06
Location: Forever Editing The Wiki.
Byond: TopHatPenguin
Contact:

Re: Flashlight/lighting bug

Post by TopHatPenguin » 02 May 2015, 06:23

HalfdeadKiller wrote:I think the main issue is tracking it from a code perspective, Wooki. It can be difficult getting the game to understand what we want it to do, when it seems so simple to us. The poor game engine only sees data, and can only interact with the data when it is formatted in certain ways.
Suppose so , ah well

User avatar
Abbysynth
Registered user
Posts: 465
Joined: 30 Apr 2015, 21:15
Location: Ottawa, Ontario

Re: Flashlight/lighting bug

Post by Abbysynth » 02 May 2015, 20:31

Huh? Why would you have to set it to 0? The code is supposed to add or subtract to the person's luminosity, not set it to 0 at any time.

Ie:

Default you are at 0.

Pick up a torch with lum 1, your luminosity is 1.

Pick up a flashlight with 2, and it's at 3. Drop the torch and it's at 2 again. Why would it ever be set to 0?

User avatar
apophis775
Host
Host
Posts: 6985
Joined: 22 Aug 2014, 18:05
Location: Ice Colony
Byond: Apophis775
Contact:

Re: Flashlight/lighting bug

Post by apophis775 » 03 May 2015, 15:06

That's not how the code works, otherwise, if you had 2 flares in your pockets, and a rifle in you back, all with lights on, your illum would be in the low 20s. Instead, here's the way it actually works:

Mind you, this is JUST for the light on the gun to function properly:

Code: Select all

/obj/item/weapon/gun/twohanded/projectile/Assault/verb/toggle_light()
	set name = "Toggle Flashlight"
	set category = "Weapon"

	if(haslight && !islighton) //Turns the light on
		usr << "\blue You turn the flashlight on."
		usr.SetLuminosity(gun_light)
		islighton = 1
	else if(haslight && islighton) //Turns the light off
		usr << "\blue You turn the flashlight off."
		usr.SetLuminosity(0)
		islighton = 0
	else if(!haslight) //Points out how stupid you are
		usr << "\red You foolishly look at where the flashlight would be, if it was attached..."

/obj/item/weapon/gun/twohanded/projectile/Assault/pickup(mob/user)//Transfers the lum to the user when picked up
	..()
	if(islighton)
		SetLuminosity(0)
		usr.SetLuminosity(gun_light)

/obj/item/weapon/gun/twohanded/projectile/Assault/dropped(mob/user)//Transfers the Lum back to the gun when dropped
	..()
	if(islighton)
		SetLuminosity(gun_light)
		usr.SetLuminosity(0)
It's designed, so that, you can't just have like 10 light-sources at once, and the source in your hand is the priority.

User avatar
Abbysynth
Registered user
Posts: 465
Joined: 30 Apr 2015, 21:15
Location: Ottawa, Ontario

Re: Flashlight/lighting bug

Post by Abbysynth » 03 May 2015, 18:30

Here's how flashlights work:

Code: Select all

/obj/item/device/flashlight/proc/update_brightness(var/mob/user = null)
	if(on)
		icon_state = "[initial(icon_state)]-on"
		if(loc == user)
			user.SetLuminosity(user.luminosity + brightness_on)
		else if(isturf(loc))
			SetLuminosity(brightness_on)
	else
		icon_state = initial(icon_state)
		if(loc == user)
			user.SetLuminosity(user.luminosity - brightness_on)
		else if(isturf(loc))
			SetLuminosity(0)
Notice the - and +'s there? That's how light sources are supposed to work.

Notice how it never actually sets user.lum to 0, because doing so immediately wipes out all other light sources on you even if they're turned on. It just adds or subtracts from it.

User avatar
apophis775
Host
Host
Posts: 6985
Joined: 22 Aug 2014, 18:05
Location: Ice Colony
Byond: Apophis775
Contact:

Re: Flashlight/lighting bug

Post by apophis775 » 04 May 2015, 02:28

Notice how, that means you can stack flashlights for nearly infinity light?

User avatar
HalfdeadKiller
Registered user
Posts: 468
Joined: 15 Oct 2014, 13:17

Re: Flashlight/lighting bug

Post by HalfdeadKiller » 04 May 2015, 03:55

Couldn't you cap the players lightsource to a certain number, to prevent going over that number? Then, no amount of adding or subtracting would matter, and the light source would still function balanced like. I dunno though, just throwing an idea out there.

User avatar
Abbysynth
Registered user
Posts: 465
Joined: 30 Apr 2015, 21:15
Location: Ottawa, Ontario

Re: Flashlight/lighting bug

Post by Abbysynth » 04 May 2015, 11:53

apophis775 wrote:Notice how, that means you can stack flashlights for nearly infinity light?
This is the way it's always been, for every SS13 game.

And it's not "nearly infinity" light, you only have so many slots for equipment. Two hands, two pockets, armor slot, maybe a firefighter helmet, belt. It's been like that for literally decades.

User avatar
apophis775
Host
Host
Posts: 6985
Joined: 22 Aug 2014, 18:05
Location: Ice Colony
Byond: Apophis775
Contact:

Re: Flashlight/lighting bug

Post by apophis775 » 04 May 2015, 17:41

Well, if you think you can fix it, apply for the dev team.

I've got literally PILES of shit I'm always working on.

User avatar
valzargaming
Registered user
Posts: 89
Joined: 10 May 2015, 21:09

Re: Flashlight/lighting bug

Post by valzargaming » 10 May 2015, 22:16

This is a long-standing bug with the lighting code itself. The flashlights passively add a light source on your person. It is possible to reach the mathematical ceiling for lighting which effectively disables the affects of your flashlight when re-entering in a lit high-value area. There is no loop to check lighting for this every tick as it would be very laggy when you have 20 mobs running around with flashlights. The way that flashlights affect lighting need to be changed to allow for ambient lighting levels above the current coding ceiling while still keeping the effective ceiling the same.

mosshadow
Registered user
Posts: 74
Joined: 12 Apr 2015, 19:42

Re: Flashlight/lighting bug

Post by mosshadow » 15 May 2015, 11:11

How do other servers handle this? TG has no issues with lights stopping?

User avatar
Abbysynth
Registered user
Posts: 465
Joined: 30 Apr 2015, 21:15
Location: Ottawa, Ontario

Re: Flashlight/lighting bug

Post by Abbysynth » 16 May 2015, 18:48

This has all been fixed, it's no longer an issue. GO TEAM VENTURE CODERS

Locked