Merge pull request #2027 from SweeperM/master

Fixes to lighting
This commit is contained in:
Jim "Apples"
2012-12-03 03:09:02 -08:00
15 changed files with 278 additions and 122 deletions
+28 -17
View File
@@ -5,9 +5,11 @@
icon_state = "candle1"
item_state = "candle1"
w_class = 1
light_on = 0
brightness_on = 3 //luminosity when on
var/wax = 200
var/lit = 0
proc
light(var/flavor_text = "\red [usr] lights the [name].")
@@ -19,7 +21,7 @@
else if(wax>80)
i = 2
else i = 3
icon_state = "candle[i][lit ? "_lit" : ""]"
icon_state = "candle[i][light_on ? "_lit" : ""]"
attackby(obj/item/weapon/W as obj, mob/user as mob)
@@ -30,30 +32,30 @@
light("\red [user] casually lights the [name] with [W], what a badass.")
else if(istype(W, /obj/item/weapon/lighter))
var/obj/item/weapon/lighter/L = W
if(L.lit)
if(L.light_on)
light()
else if(istype(W, /obj/item/weapon/match))
var/obj/item/weapon/match/M = W
if(M.lit)
if(M.light_on)
light()
else if(istype(W, /obj/item/candle))
var/obj/item/candle/C = W
if(C.lit)
if(C.light_on)
light()
light(var/flavor_text = "\red [usr] lights the [name].")
if(!src.lit)
src.lit = 1
if(!src.light_on)
src.light_on = 1
//src.damtype = "fire"
for(var/mob/O in viewers(usr, null))
O.show_message(flavor_text, 1)
SetLuminosity(CANDLE_LUM)
SetLuminosity(brightness_on)
processing_objects.Add(src)
process()
if(!lit)
if(!light_on)
return
wax--
if(!wax)
@@ -68,20 +70,29 @@
attack_self(mob/user as mob)
if(lit)
lit = 0
if(light_on)
light_on = 0
update_icon()
SetLuminosity(0)
user.SetLuminosity(user.luminosity - CANDLE_LUM)
user.SetLuminosity(search_light(user, src))
pickup(mob/user)
if(lit)
if(light_on)
if (user.luminosity < brightness_on)
user.SetLuminosity(brightness_on)
SetLuminosity(0)
user.SetLuminosity(user.luminosity + CANDLE_LUM)
dropped(mob/user)
if(lit)
user.SetLuminosity(user.luminosity - CANDLE_LUM)
SetLuminosity(CANDLE_LUM)
if(light_on)
if ((layer <= 3) || (loc != user.loc))
user.SetLuminosity(search_light(user, src))
SetLuminosity(brightness_on)
equipped(mob/user, slot)
if(light_on)
if (user.luminosity < brightness_on)
user.SetLuminosity(brightness_on)
SetLuminosity(0)
+27 -15
View File
@@ -13,6 +13,8 @@ var/global/list/obj/item/device/pda/PDAs = list()
w_class = 1.0
flags = FPRINT | TABLEPASS
slot_flags = SLOT_ID | SLOT_BELT
light_on = 0 //Is the flashlight function on?
brightness_on = 4 //Luminosity for the flashlight function
//Main variables
var/owner = null
@@ -22,8 +24,6 @@ var/global/list/obj/item/device/pda/PDAs = list()
//Secondary variables
var/scanmode = 0 //1 is medical scanner, 2 is forensics, 3 is reagent scanner.
var/fon = 0 //Is the flashlight function on?
var/f_lum = 4 //Luminosity for the flashlight function
var/silent = 0 //To beep or not to beep, that is the question
var/toff = 0 //If 1, messenger disabled
var/tnote = null //Current Texts
@@ -192,14 +192,22 @@ var/global/list/obj/item/device/pda/PDAs = list()
* The Actual PDA
*/
/obj/item/device/pda/pickup(mob/user)
if(fon)
if(light_on)
if(user.luminosity < brightness_on)
user.SetLuminosity(brightness_on)
SetLuminosity(0)
user.SetLuminosity(user.luminosity + f_lum)
/obj/item/device/pda/dropped(mob/user)
if(fon)
user.SetLuminosity(user.luminosity - f_lum)
SetLuminosity(f_lum)
if(light_on)
if ((layer <= 3) || (loc != user.loc))
user.SetLuminosity(search_light(user, src))
SetLuminosity(brightness_on)
/obj/item/device/pda/equipped(mob/user, slot)
if(light_on)
if(user.luminosity < brightness_on)
user.SetLuminosity(brightness_on)
SetLuminosity(0)
/obj/item/device/pda/New()
..()
@@ -320,7 +328,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
if (cartridge.access_remote_door)
dat += "<li><a href='byond://?src=\ref[src];choice=Toggle Door'><img src=pda_rdoor.png> Toggle Remote Door</a></li>"
dat += "<li><a href='byond://?src=\ref[src];choice=3'><img src=pda_atmos.png> Atmospheric Scan</a></li>"
dat += "<li><a href='byond://?src=\ref[src];choice=Light'><img src=pda_flashlight.png> [fon ? "Disable" : "Enable"] Flashlight</a></li>"
dat += "<li><a href='byond://?src=\ref[src];choice=Light'><img src=pda_flashlight.png> [light_on ? "Disable" : "Enable"] Flashlight</a></li>"
if (pai)
if(pai.loc != src)
pai = null
@@ -495,14 +503,18 @@ var/global/list/obj/item/device/pda/PDAs = list()
//MAIN FUNCTIONS===================================
if("Light")
if(fon)
fon = 0
if(src in U.contents) U.SetLuminosity(U.luminosity - f_lum)
else SetLuminosity(0)
if(light_on)
light_on = 0
if(src in U.contents)
U.SetLuminosity(search_light(U, src))
else
SetLuminosity(0)
else
fon = 1
if(src in U.contents) U.SetLuminosity(U.luminosity + f_lum)
else SetLuminosity(f_lum)
light_on = 1
if((src in U.contents) && (U.luminosity < brightness_on))
U.SetLuminosity(brightness_on)
else
SetLuminosity(brightness_on)
if("Medical Scan")
if(scanmode == 1)
scanmode = 0
+29 -19
View File
@@ -10,12 +10,13 @@
m_amt = 50
g_amt = 20
icon_action_button = "action_flashlight"
var/on = 0
var/brightness_on = 4 //luminosity when on
light_on = 0
brightness_on = 4 //luminosity when on
var brightness = 0
/obj/item/device/flashlight/initialize()
..()
if(on)
if(light_on)
icon_state = "[initial(icon_state)]-on"
SetLuminosity(brightness_on)
else
@@ -23,16 +24,16 @@
SetLuminosity(0)
/obj/item/device/flashlight/proc/update_brightness(var/mob/user = null)
if(on)
if(light_on)
icon_state = "[initial(icon_state)]-on"
if(loc == user)
user.SetLuminosity(user.luminosity + brightness_on)
if((loc == user) && (user.luminosity < brightness_on))
user.SetLuminosity(brightness_on)
else if(isturf(loc))
SetLuminosity(brightness_on)
else
icon_state = initial(icon_state)
if(loc == user)
user.SetLuminosity(user.luminosity - brightness_on)
user.SetLuminosity(search_light(user, src))
else if(isturf(loc))
SetLuminosity(0)
@@ -40,14 +41,14 @@
if(!isturf(user.loc))
user << "You cannot turn the light on while in this [user.loc]." //To prevent some lighting anomalities.
return
on = !on
light_on = !light_on
update_brightness(user)
return
/obj/item/device/flashlight/attack(mob/living/M as mob, mob/living/user as mob)
add_fingerprint(user)
if(on && user.zone_sel.selecting == "eyes")
if(light_on && user.zone_sel.selecting == "eyes")
if(((CLUMSY in user.mutations) || user.getBrainLoss() >= 60) && prob(50)) //too dumb to use flashlight properly
return ..() //just hit them in the head
@@ -88,15 +89,24 @@
/obj/item/device/flashlight/pickup(mob/user)
if(on)
user.SetLuminosity(user.luminosity + brightness_on)
if(light_on)
if (user.luminosity < brightness_on)
user.SetLuminosity(brightness_on)
SetLuminosity(0)
/obj/item/device/flashlight/dropped(mob/user)
if(on)
user.SetLuminosity(user.luminosity - brightness_on)
SetLuminosity(brightness_on)
if(light_on)
if ((layer <= 3) || (loc != user.loc))
user.SetLuminosity(search_light(user, src))
SetLuminosity(brightness_on)
/obj/item/device/flashlight/equipped(mob/user, slot)
if(light_on)
if (user.luminosity < brightness_on)
user.SetLuminosity(brightness_on)
SetLuminosity(0)
/obj/item/device/flashlight/pen
@@ -119,7 +129,7 @@
flags = FPRINT | TABLEPASS | CONDUCT
m_amt = 0
g_amt = 0
on = 1
light_on = 1
// green-shaded desk lamp
@@ -159,14 +169,14 @@
var/turf/pos = get_turf(src)
pos.hotspot_expose(produce_heat, 5)
fuel = max(fuel - 1, 0)
if(!fuel || !on)
if(!fuel || !light_on)
turn_off()
if(!fuel)
src.icon_state = "[initial(icon_state)]-empty"
processing_objects -= src
/obj/item/device/flashlight/flare/proc/turn_off()
on = 0
light_on = 0
src.force = initial(src.force)
src.damtype = initial(src.damtype)
if(ismob(loc))
@@ -182,12 +192,12 @@
if(!fuel)
user << "<span class='notice'>It's out of fuel.</span>"
return
if(!on)
if(!light_on)
user.visible_message("<span class='notice'>[user] activates the flare.</span>", "<span class='notice'>You pull the cord on the flare, activating it!</span>")
else
return
// All good, turn it on.
on = 1
light_on = 1
update_brightness(user)
src.force = on_damage
src.damtype = "fire"
@@ -85,12 +85,12 @@ ZIPPO
else if(istype(W, /obj/item/weapon/lighter/zippo))
var/obj/item/weapon/lighter/zippo/Z = W
if(Z.lit)
if(Z.light_on)
light("<span class='rose'>With a single flick of their wrist, [user] smoothly lights their [name] with their [W]. Damn they're cool.</span>")
else if(istype(W, /obj/item/weapon/lighter))
var/obj/item/weapon/lighter/L = W
if(L.lit)
if(L.light_on)
light("<span class='notice'>After some fiddling, [user] manages to light their [name] with [W].</span>")
else if(istype(W, /obj/item/weapon/match))
@@ -375,7 +375,8 @@ ZIPPO
flags = TABLEPASS | CONDUCT
slot_flags = SLOT_BELT
attack_verb = list("burnt", "singed")
var/lit = 0
light_on = 0
brightness_on = 2 //luminosity when on
/obj/item/weapon/lighter/zippo
name = "Zippo lighter"
@@ -394,8 +395,8 @@ ZIPPO
/obj/item/weapon/lighter/attack_self(mob/living/user)
if(user.r_hand == src || user.l_hand == src)
if(!lit)
lit = 1
if(!light_on)
light_on = 1
icon_state = icon_on
item_state = icon_on
if(istype(src, /obj/item/weapon/lighter/zippo) )
@@ -411,10 +412,11 @@ ZIPPO
user.apply_damage(2,BURN,"r_hand")
user.visible_message("<span class='notice'>After a few attempts, [user] manages to light the [src], they however burn their finger in the process.</span>")
user.SetLuminosity(user.luminosity + 2)
if (user.luminosity < brightness_on)
user.SetLuminosity(brightness_on)
processing_objects.Add(src)
else
lit = 0
light_on = 0
icon_state = icon_off
item_state = icon_off
if(istype(src, /obj/item/weapon/lighter/zippo) )
@@ -422,7 +424,7 @@ ZIPPO
else
user.visible_message("<span class='notice'>[user] quietly shuts off the [src].")
user.SetLuminosity(user.luminosity - 2)
user.SetLuminosity(search_light(user, src))
processing_objects.Remove(src)
else
return ..()
@@ -433,7 +435,7 @@ ZIPPO
if(!istype(M, /mob))
return
if(istype(M.wear_mask, /obj/item/clothing/mask/cigarette) && user.zone_sel.selecting == "mouth" && lit)
if(istype(M.wear_mask, /obj/item/clothing/mask/cigarette) && user.zone_sel.selecting == "mouth" && light_on)
var/obj/item/clothing/mask/cigarette/cig = M.wear_mask
if(M == user)
cig.attackby(src, user)
@@ -453,14 +455,24 @@ ZIPPO
/obj/item/weapon/lighter/pickup(mob/user)
if(lit)
if(light_on)
if (user.luminosity < brightness_on)
user.SetLuminosity(brightness_on)
SetLuminosity(0)
user.SetLuminosity(user.luminosity+2)
return
/obj/item/weapon/lighter/dropped(mob/user)
if(lit)
user.SetLuminosity(user.luminosity-2)
SetLuminosity(2)
if(light_on)
if ((layer <= 3) || (loc != user.loc))
user.SetLuminosity(search_light(user, src))
SetLuminosity(brightness_on)
return
/obj/item/weapon/lighter/equipped(mob/user, slot)
if(light_on)
if (user.luminosity < brightness_on)
user.SetLuminosity(brightness_on)
SetLuminosity(0)
return