mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-16 05:02:42 +00:00
New defines in setup.dm: This revision changes the following things: - Hot is no longer defined as 'higher temperature than 310.15K' but is defined as 'higher temperature than my body temperature'. The opposite applies for cold. - Removed heat_transfer_coefficient and protective_temperature - Added heat_protection and cold_protection flag variables to obj/item, which define which areas of your body are protected from heat. - Added max_heat_protection_temperature and min_cold_protection_temperature which define up to which temperature the item protects when worn (NOTE that it only protects on the locations specified by the heat_protection flags!) and down to which temperature it protects from the cold. - REMEMBER! hot and cold were redefined to mean 'which way your body temperature should be moving based on the air around you'. - Each tick, your body now 'corrects' your body temperature towards 310.15K which is the ideal temperature. The correction is max( difference/12, 10 ), so either a twelfth of the difference between your body temperature and 310.15K, or 10K, whichever is higher. This ensures your body temperature stabilizes over time. - Most notable changes in the amount of protection you get from common items are these: Space suits now ONLY protect from cold and fire suits now ONLY protect from heat. Now what this means is obviously that firesuits will be useless in space, but also that if you find yourself in a fire with a high body temperature and you put a firesuit on, your temperature will no longer stagnate at the high temperature, due to temperature not going up nor down, but rather it will get lower. Instead it will be protected from rising, it will however gradually get lowered by your body's 'auto-correct' attempts, as described in the last point. Additionally, if you wear a fire suit and enter an area with a good temperature (for isntance 290K) and you have a high body temperature, due to just escaping from a fire, the fire suit will not make your body temperature stagnate. Because it does not protect you from cold, and cold being defined as 'colder than your body temperature', you will actually successfully cool down to the optimal temperature. - The opposite applies to space suits. They protect from cold and don't protect from heat. If you find yourself in space and your temperature drops and put on the space suit with your temperature still low, you will recover over time. If you enter an area with a good temperature, you will recover faster, since the space suit does not protect you from heat. - In short, space suits are now better at dealing with space and fire suits are better at dealing with fires. - You will NEED a fire helmet to be protected from heat and you will NEED a space suit helmet to be protected from cold. There is no 'but'. Fire helmets are red or white hardhats, found in all fire closets. - The 'heat up' coefficients are defined in setup.dm, they are: - - head = 30% - - lower and upper torso = 15% each = 30% - - legs and arms = 7.5% each = 30% - - feet and hands = 2.5% each = 10% - Gloves cover hands - Shoes cover feet - Space-worthy jumpsuits cover legs, arms, upper and lower torso - Space suits cover legs, arms, hands, feet, upper and lower torso - Headgear covers heads - Removed the HEADSPACE and SUITSPACE flags, due to being moved to the new variables. This frees up the flag value 4. . The amount of damage heated gas and heated areas do can now be set in human/life.dm. The values are: (The different levels are based on breath temperature or body temperature.) #define HEAT_DAMAGE_LEVEL_1 2 #define HEAT_DAMAGE_LEVEL_2 4 #define HEAT_DAMAGE_LEVEL_3 8 #define COLD_DAMAGE_LEVEL_1 1 #define COLD_DAMAGE_LEVEL_2 2 #define COLD_DAMAGE_LEVEL_3 4 //Note that gas heat damage is only applied once every FOUR ticks. #define HEAT_GAS_DAMAGE_LEVEL_1 2 #define HEAT_GAS_DAMAGE_LEVEL_2 4 #define HEAT_GAS_DAMAGE_LEVEL_3 8 #define COLD_GAS_DAMAGE_LEVEL_1 1 #define COLD_GAS_DAMAGE_LEVEL_2 2 #define COLD_GAS_DAMAGE_LEVEL_3 4 The speed at which your body temperature raises or falls can be altered with the following defines: #define BODYTEMP_AUTORECOVERY_DIVISOR 12 #define BODYTEMP_AUTORECOVERY_MINIMUM 10 #define BODYTEMP_COLD_DIVISOR 6 #define BODYTEMP_HEAT_DIVISOR 6 The divisors determins by how big a difference between your body temperature and the surrounding air (or 310.15 in the case of autorecovery) will your body temperature change. The autorecovery_minimum means what the minimum recovery is, if difference / 12 is less than 10, it will recover by 10. Was all this needed to fix Issue 44? Yes..... yes... it was... Some things are consequences of decisions made while fixing it, but all of it was necessary to completely fix the issue. I found it did not remain on the tracker for this long for nothing. I'm sorry for the essay, but there was a lot of work involved and a lot of changes happened, so I had to write a lot... git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4428 316c924e-a436-60f5-8080-3fe189b3f50e
767 lines
20 KiB
Plaintext
767 lines
20 KiB
Plaintext
// The lighting system
|
|
//
|
|
// consists of light fixtures (/obj/machinery/light) and light tube/bulb items (/obj/item/weapon/light)
|
|
|
|
|
|
// status values shared between lighting fixtures and items
|
|
#define LIGHT_OK 0
|
|
#define LIGHT_EMPTY 1
|
|
#define LIGHT_BROKEN 2
|
|
#define LIGHT_BURNED 3
|
|
|
|
|
|
|
|
/obj/item/light_fixture_frame
|
|
name = "light fixture frame"
|
|
desc = "Used for building lights."
|
|
icon = 'icons/obj/lighting.dmi'
|
|
icon_state = "tube-construct-item"
|
|
flags = FPRINT | TABLEPASS| CONDUCT
|
|
var/fixture_type = "tube"
|
|
var/obj/machinery/light/newlight = null
|
|
var/sheets_refunded = 2
|
|
|
|
/obj/item/light_fixture_frame/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
|
if (istype(W, /obj/item/weapon/wrench))
|
|
new /obj/item/stack/sheet/metal( get_turf(src.loc), sheets_refunded )
|
|
del(src)
|
|
return
|
|
..()
|
|
|
|
/obj/item/light_fixture_frame/proc/try_build(turf/on_wall)
|
|
if (get_dist(on_wall,usr)>1)
|
|
return
|
|
var/ndir = get_dir(usr,on_wall)
|
|
if (!(ndir in cardinal))
|
|
return
|
|
var/turf/loc = get_turf_loc(usr)
|
|
if (!istype(loc, /turf/simulated/floor))
|
|
usr << "\red [src.name] cannot be placed on this spot."
|
|
return
|
|
usr << "Attaching [src] to the wall."
|
|
playsound(src.loc, 'click.ogg', 75, 1)
|
|
var/constrdir = usr.dir
|
|
var/constrloc = usr.loc
|
|
if (!do_after(usr, 30))
|
|
return
|
|
switch(fixture_type)
|
|
if("bulb")
|
|
newlight = new /obj/machinery/light_construct/small(constrloc)
|
|
if("tube")
|
|
newlight = new /obj/machinery/light_construct(constrloc)
|
|
newlight.dir = constrdir
|
|
newlight.fingerprints = src.fingerprints
|
|
newlight.fingerprintshidden = src.fingerprintshidden
|
|
newlight.fingerprintslast = src.fingerprintslast
|
|
|
|
usr.visible_message("[usr.name] attaches [src] to the wall.", \
|
|
"You attach [src] to the wall.")
|
|
del(src)
|
|
|
|
/obj/item/light_fixture_frame/small
|
|
name = "small light fixture frame"
|
|
desc = "Used for building small lights."
|
|
icon = 'icons/obj/lighting.dmi'
|
|
icon_state = "bulb-construct-item"
|
|
flags = FPRINT | TABLEPASS| CONDUCT
|
|
fixture_type = "bulb"
|
|
sheets_refunded = 1
|
|
|
|
/obj/machinery/light_construct
|
|
name = "light fixture frame"
|
|
desc = "A light fixture under construction."
|
|
icon = 'icons/obj/lighting.dmi'
|
|
icon_state = "tube-construct-stage1"
|
|
anchored = 1
|
|
layer = 5
|
|
var/stage = 1
|
|
var/fixture_type = "tube"
|
|
var/sheets_refunded = 2
|
|
var/obj/machinery/light/newlight = null
|
|
|
|
/obj/machinery/light_construct/New()
|
|
..()
|
|
if (fixture_type == "bulb")
|
|
icon_state = "bulb-construct-stage1"
|
|
|
|
/obj/machinery/light_construct/examine()
|
|
set src in view()
|
|
..()
|
|
if (!(usr in view(2))) return
|
|
switch(src.stage)
|
|
if(1)
|
|
usr << "It's an empty frame."
|
|
return
|
|
if(2)
|
|
usr << "It's wired."
|
|
return
|
|
if(3)
|
|
usr << "The casing is closed."
|
|
return
|
|
|
|
/obj/machinery/light_construct/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
|
src.add_fingerprint(user)
|
|
if (istype(W, /obj/item/weapon/wrench))
|
|
if (src.stage == 1)
|
|
playsound(src.loc, 'Ratchet.ogg', 75, 1)
|
|
usr << "You begin deconstructing [src]."
|
|
if (!do_after(usr, 30))
|
|
return
|
|
new /obj/item/stack/sheet/metal( get_turf(src.loc), sheets_refunded )
|
|
user.visible_message("[user.name] deconstructs [src].", \
|
|
"You deconstruct [src].", "You hear a noise.")
|
|
playsound(src.loc, 'Deconstruct.ogg', 75, 1)
|
|
del(src)
|
|
if (src.stage == 2)
|
|
usr << "You have to remove the wires first."
|
|
return
|
|
|
|
if (src.stage == 3)
|
|
usr << "You have to unscrew the case first."
|
|
return
|
|
|
|
if(istype(W, /obj/item/weapon/wirecutters))
|
|
if (src.stage != 2) return
|
|
src.stage = 1
|
|
switch(fixture_type)
|
|
if ("tube")
|
|
src.icon_state = "tube-construct-stage1"
|
|
if("bulb")
|
|
src.icon_state = "bulb-construct-stage1"
|
|
new /obj/item/weapon/cable_coil(get_turf(src.loc), 1, "red")
|
|
user.visible_message("[user.name] removes the wiring from [src].", \
|
|
"You remove the wiring from [src].", "You hear a noise.")
|
|
playsound(src.loc, 'Wirecutter.ogg', 100, 1)
|
|
return
|
|
|
|
if(istype(W, /obj/item/weapon/cable_coil))
|
|
if (src.stage != 1) return
|
|
var/obj/item/weapon/cable_coil/coil = W
|
|
coil.use(1)
|
|
switch(fixture_type)
|
|
if ("tube")
|
|
src.icon_state = "tube-construct-stage2"
|
|
if("bulb")
|
|
src.icon_state = "bulb-construct-stage2"
|
|
src.stage = 2
|
|
user.visible_message("[user.name] adds wires to [src].", \
|
|
"You add wires to [src].")
|
|
return
|
|
|
|
if(istype(W, /obj/item/weapon/screwdriver))
|
|
if (src.stage == 2)
|
|
switch(fixture_type)
|
|
if ("tube")
|
|
src.icon_state = "tube-empty"
|
|
if("bulb")
|
|
src.icon_state = "bulb-empty"
|
|
src.stage = 3
|
|
user.visible_message("[user.name] closes [src]'s casing.", \
|
|
"You close [src]'s casing.", "You hear a noise.")
|
|
playsound(src.loc, 'Screwdriver.ogg', 75, 1)
|
|
|
|
switch(fixture_type)
|
|
|
|
if("tube")
|
|
newlight = new /obj/machinery/light/built(src.loc)
|
|
if ("bulb")
|
|
newlight = new /obj/machinery/light/small/built(src.loc)
|
|
|
|
newlight.dir = src.dir
|
|
src.transfer_fingerprints_to(newlight)
|
|
del(src)
|
|
return
|
|
..()
|
|
|
|
/obj/machinery/light_construct/small
|
|
name = "small light fixture frame"
|
|
desc = "A small light fixture under construction."
|
|
icon = 'icons/obj/lighting.dmi'
|
|
icon_state = "bulb-construct-stage1"
|
|
anchored = 1
|
|
layer = 5
|
|
stage = 1
|
|
fixture_type = "bulb"
|
|
sheets_refunded = 1
|
|
|
|
// the standard tube light fixture
|
|
/obj/machinery/light
|
|
name = "light fixture"
|
|
icon = 'icons/obj/lighting.dmi'
|
|
var/base_state = "tube" // base description and icon_state
|
|
icon_state = "tube1"
|
|
desc = "A lighting fixture."
|
|
anchored = 1
|
|
layer = 5 // They were appearing under mobs which is a little weird - Ostaf
|
|
use_power = 2
|
|
idle_power_usage = 2
|
|
active_power_usage = 20
|
|
power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list
|
|
var/on = 0 // 1 if on, 0 if off
|
|
var/on_gs = 0
|
|
var/brightness = 8 // luminosity when on, also used in power calculation
|
|
var/status = LIGHT_OK // LIGHT_OK, _EMPTY, _BURNED or _BROKEN
|
|
var/flickering = 0
|
|
var/light_type = /obj/item/weapon/light/tube // the type of light item
|
|
var/fitting = "tube"
|
|
var/switchcount = 0 // count of number of times switched on/off
|
|
// this is used to calc the probability the light burns out
|
|
|
|
var/rigged = 0 // true if rigged to explode
|
|
|
|
// the smaller bulb light fixture
|
|
|
|
/obj/machinery/light/small
|
|
icon_state = "bulb1"
|
|
base_state = "bulb"
|
|
fitting = "bulb"
|
|
brightness = 3
|
|
desc = "A small lighting fixture."
|
|
light_type = /obj/item/weapon/light/bulb
|
|
|
|
|
|
/obj/machinery/light/spot
|
|
name = "spotlight"
|
|
fitting = "large tube"
|
|
light_type = /obj/item/weapon/light/tube/large
|
|
brightness = 15
|
|
|
|
/obj/machinery/light/built/New()
|
|
status = LIGHT_EMPTY
|
|
update(0)
|
|
..()
|
|
|
|
/obj/machinery/light/small/built/New()
|
|
status = LIGHT_EMPTY
|
|
update(0)
|
|
..()
|
|
|
|
// create a new lighting fixture
|
|
/obj/machinery/light/New()
|
|
..()
|
|
|
|
spawn(2)
|
|
switch(fitting)
|
|
if("tube")
|
|
brightness = 8
|
|
if(prob(10))
|
|
broken(1)
|
|
if("bulb")
|
|
brightness = 4
|
|
if(prob(25))
|
|
broken(1)
|
|
spawn(1)
|
|
update(0)
|
|
|
|
/obj/machinery/light/Del()
|
|
var/area/A = get_area(src)
|
|
if(A)
|
|
on = 0
|
|
// A.update_lights()
|
|
..()
|
|
|
|
/obj/machinery/light/update_icon()
|
|
|
|
switch(status) // set icon_states
|
|
if(LIGHT_OK)
|
|
icon_state = "[base_state][on]"
|
|
if(LIGHT_EMPTY)
|
|
icon_state = "[base_state]-empty"
|
|
on = 0
|
|
if(LIGHT_BURNED)
|
|
icon_state = "[base_state]-burned"
|
|
on = 0
|
|
if(LIGHT_BROKEN)
|
|
icon_state = "[base_state]-broken"
|
|
on = 0
|
|
return
|
|
|
|
// update the icon_state and luminosity of the light depending on its state
|
|
/obj/machinery/light/proc/update(var/trigger = 1)
|
|
|
|
update_icon()
|
|
if(!on)
|
|
use_power = 1
|
|
else
|
|
use_power = 2
|
|
var/oldlum = luminosity
|
|
|
|
//luminosity = on * brightness
|
|
sd_SetLuminosity(on * brightness) // *DAL*
|
|
|
|
// if the state changed, inc the switching counter
|
|
if(oldlum != luminosity)
|
|
switchcount++
|
|
|
|
// now check to see if the bulb is burned out
|
|
if(status == LIGHT_OK && trigger)
|
|
if(on && rigged)
|
|
explode()
|
|
if( prob( min(60, switchcount*switchcount*0.01) ) )
|
|
status = LIGHT_BURNED
|
|
icon_state = "[base_state]-burned"
|
|
on = 0
|
|
sd_SetLuminosity(0)
|
|
active_power_usage = (luminosity * 20)
|
|
if(on != on_gs)
|
|
on_gs = on
|
|
// var/area/A = get_area(src)
|
|
// if(A)
|
|
// A.update_lights()
|
|
|
|
|
|
// attempt to set the light's on/off status
|
|
// will not switch on if broken/burned/empty
|
|
/obj/machinery/light/proc/seton(var/s)
|
|
on = (s && status == LIGHT_OK)
|
|
update()
|
|
|
|
// examine verb
|
|
/obj/machinery/light/examine()
|
|
set src in oview(1)
|
|
if(usr && !usr.stat)
|
|
switch(status)
|
|
if(LIGHT_OK)
|
|
usr << "[desc] It is turned [on? "on" : "off"]."
|
|
if(LIGHT_EMPTY)
|
|
usr << "[desc] The [fitting] has been removed."
|
|
if(LIGHT_BURNED)
|
|
usr << "[desc] The [fitting] is burnt out."
|
|
if(LIGHT_BROKEN)
|
|
usr << "[desc] The [fitting] has been smashed."
|
|
|
|
|
|
|
|
// attack with item - insert light (if right type), otherwise try to break the light
|
|
|
|
/obj/machinery/light/attackby(obj/item/W, mob/user)
|
|
|
|
//Light replacer code
|
|
if(istype(W, /obj/item/device/lightreplacer))
|
|
var/obj/item/device/lightreplacer/LR = W
|
|
if(isliving(user))
|
|
var/mob/living/U = user
|
|
LR.ReplaceLight(src, U)
|
|
return
|
|
|
|
// attempt to insert light
|
|
if(istype(W, /obj/item/weapon/light))
|
|
if(status != LIGHT_EMPTY)
|
|
user << "There is a [fitting] already inserted."
|
|
return
|
|
else
|
|
src.add_fingerprint(user)
|
|
var/obj/item/weapon/light/L = W
|
|
if(istype(L, light_type))
|
|
status = L.status
|
|
user << "You insert the [L.name]."
|
|
switchcount = L.switchcount
|
|
rigged = L.rigged
|
|
brightness = L.brightness
|
|
on = has_power()
|
|
update()
|
|
|
|
user.drop_item() //drop the item to update overlays and such
|
|
del(L)
|
|
|
|
if(on && rigged)
|
|
explode()
|
|
else
|
|
user << "This type of light requires a [fitting]."
|
|
return
|
|
|
|
// attempt to break the light
|
|
//If xenos decide they want to smash a light bulb with a toolbox, who am I to stop them? /N
|
|
|
|
else if(status != LIGHT_BROKEN && status != LIGHT_EMPTY)
|
|
|
|
|
|
if(prob(1+W.force * 5))
|
|
|
|
user << "You hit the light, and it smashes!"
|
|
for(var/mob/M in viewers(src))
|
|
if(M == user)
|
|
continue
|
|
M.show_message("[user.name] smashed the light!", 3, "You hear a tinkle of breaking glass", 2)
|
|
if(on && (W.flags & CONDUCT))
|
|
//if(!user.mutations & COLD_RESISTANCE)
|
|
if (prob(12))
|
|
electrocute_mob(user, get_area(src), src, 0.3)
|
|
broken()
|
|
|
|
else
|
|
user << "You hit the light!"
|
|
|
|
// attempt to stick weapon into light socket
|
|
else if(status == LIGHT_EMPTY)
|
|
if(istype(W, /obj/item/weapon/screwdriver)) //If it's a screwdriver open it.
|
|
playsound(src.loc, 'Screwdriver.ogg', 75, 1)
|
|
user.visible_message("[user.name] opens [src]'s casing.", \
|
|
"You open [src]'s casing.", "You hear a noise.")
|
|
var/obj/machinery/light_construct/newlight = null
|
|
switch(fitting)
|
|
if("tube")
|
|
newlight = new /obj/machinery/light_construct(src.loc)
|
|
newlight.icon_state = "tube-construct-stage2"
|
|
|
|
if("bulb")
|
|
newlight = new /obj/machinery/light_construct/small(src.loc)
|
|
newlight.icon_state = "bulb-construct-stage2"
|
|
newlight.dir = src.dir
|
|
newlight.stage = 2
|
|
newlight.fingerprints = src.fingerprints
|
|
newlight.fingerprintshidden = src.fingerprintshidden
|
|
newlight.fingerprintslast = src.fingerprintslast
|
|
del(src)
|
|
return
|
|
|
|
user << "You stick \the [W] into the light socket!"
|
|
if(has_power() && (W.flags & CONDUCT))
|
|
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
|
s.set_up(3, 1, src)
|
|
s.start()
|
|
//if(!user.mutations & COLD_RESISTANCE)
|
|
if (prob(75))
|
|
electrocute_mob(user, get_area(src), src, rand(0.7,1.0))
|
|
|
|
|
|
// returns whether this light has power
|
|
// true if area has power and lightswitch is on
|
|
/obj/machinery/light/proc/has_power()
|
|
var/area/A = src.loc.loc
|
|
return A.master.lightswitch && A.master.power_light
|
|
|
|
/obj/machinery/light/proc/flicker(var/amount = rand(10, 20))
|
|
if(flickering) return
|
|
flickering = 1
|
|
spawn(0)
|
|
if(on && status == LIGHT_OK)
|
|
for(var/i = 0; i < amount; i++)
|
|
if(status != LIGHT_OK) break
|
|
on = !on
|
|
update(0)
|
|
sleep(rand(5, 15))
|
|
on = (status == LIGHT_OK)
|
|
update(0)
|
|
flickering = 0
|
|
|
|
// ai attack - make lights flicker, because why not
|
|
|
|
/obj/machinery/light/attack_ai(mob/user)
|
|
src.flicker(1)
|
|
return
|
|
|
|
// Aliens smash the bulb but do not get electrocuted./N
|
|
/obj/machinery/light/attack_alien(mob/living/carbon/alien/humanoid/user)//So larva don't go breaking light bulbs.
|
|
if(status == LIGHT_EMPTY||status == LIGHT_BROKEN)
|
|
user << "\green That object is useless to you."
|
|
return
|
|
else if (status == LIGHT_OK||status == LIGHT_BURNED)
|
|
for(var/mob/M in viewers(src))
|
|
M.show_message("\red [user.name] smashed the light!", 3, "You hear a tinkle of breaking glass", 2)
|
|
broken()
|
|
return
|
|
|
|
/obj/machinery/light/attack_animal(mob/living/simple_animal/M)
|
|
if(M.melee_damage_upper == 0) return
|
|
if(status == LIGHT_EMPTY||status == LIGHT_BROKEN)
|
|
M << "\red That object is useless to you."
|
|
return
|
|
else if (status == LIGHT_OK||status == LIGHT_BURNED)
|
|
for(var/mob/O in viewers(src))
|
|
O.show_message("\red [M.name] smashed the light!", 3, "You hear a tinkle of breaking glass", 2)
|
|
broken()
|
|
return
|
|
// attack with hand - remove tube/bulb
|
|
// if hands aren't protected and the light is on, burn the player
|
|
|
|
/obj/machinery/light/attack_hand(mob/user)
|
|
|
|
add_fingerprint(user)
|
|
|
|
if(status == LIGHT_EMPTY)
|
|
user << "There is no [fitting] in this light."
|
|
return
|
|
|
|
// make it burn hands if not wearing fire-insulated gloves
|
|
if(on)
|
|
var/prot = 0
|
|
var/mob/living/carbon/human/H = user
|
|
|
|
if(istype(H))
|
|
|
|
if(H.gloves)
|
|
var/obj/item/clothing/gloves/G = H.gloves
|
|
if(G.max_heat_protection_temperature)
|
|
prot = (G.max_heat_protection_temperature > 360)
|
|
else
|
|
prot = 1
|
|
|
|
if(prot > 0 || (COLD_RESISTANCE in user.mutations))
|
|
user << "You remove the light [fitting]"
|
|
else
|
|
user << "You try to remove the light [fitting], but you burn your hand on it!"
|
|
|
|
var/datum/organ/external/affecting = H.get_organ("[user.hand ? "l" : "r" ]_arm")
|
|
|
|
if(affecting.take_damage( 0, 5 )) // 5 burn damage
|
|
H.UpdateDamageIcon()
|
|
H.updatehealth()
|
|
return // if burned, don't remove the light
|
|
|
|
// create a light tube/bulb item and put it in the user's hand
|
|
var/obj/item/weapon/light/L = new light_type()
|
|
L.status = status
|
|
L.rigged = rigged
|
|
L.brightness = src.brightness
|
|
|
|
// light item inherits the switchcount, then zero it
|
|
L.switchcount = switchcount
|
|
switchcount = 0
|
|
|
|
L.update()
|
|
L.add_fingerprint(user)
|
|
|
|
user.put_in_active_hand(L) //puts it in our active hand
|
|
|
|
status = LIGHT_EMPTY
|
|
update()
|
|
|
|
// break the light and make sparks if was on
|
|
|
|
/obj/machinery/light/proc/broken(var/skip_sound_and_sparks = 0)
|
|
if(status == LIGHT_EMPTY)
|
|
return
|
|
|
|
if(!skip_sound_and_sparks)
|
|
if(status == LIGHT_OK || status == LIGHT_BURNED)
|
|
playsound(src.loc, 'Glasshit.ogg', 75, 1)
|
|
if(on)
|
|
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
|
s.set_up(3, 1, src)
|
|
s.start()
|
|
status = LIGHT_BROKEN
|
|
update()
|
|
|
|
// explosion effect
|
|
// destroy the whole light fixture or just shatter it
|
|
|
|
/obj/machinery/light/ex_act(severity)
|
|
switch(severity)
|
|
if(1.0)
|
|
del(src)
|
|
return
|
|
if(2.0)
|
|
if (prob(75))
|
|
broken()
|
|
if(3.0)
|
|
if (prob(50))
|
|
broken()
|
|
return
|
|
|
|
//blob effect
|
|
|
|
/obj/machinery/light/blob_act()
|
|
if(prob(75))
|
|
broken()
|
|
|
|
|
|
// timed process
|
|
// use power
|
|
|
|
#define LIGHTING_POWER_FACTOR 20 //20W per unit luminosity
|
|
|
|
/obj/machinery/light/process()
|
|
if(on)
|
|
use_power(luminosity * LIGHTING_POWER_FACTOR, LIGHT)
|
|
|
|
// called when area power state changes
|
|
/obj/machinery/light/power_change()
|
|
spawn(10)
|
|
var/area/A = src.loc.loc
|
|
A = A.master
|
|
seton(A.lightswitch && A.power_light)
|
|
|
|
// called when on fire
|
|
|
|
/obj/machinery/light/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
|
|
if(prob(max(0, exposed_temperature - 673))) //0% at <400C, 100% at >500C
|
|
broken()
|
|
|
|
// explode the light
|
|
|
|
/obj/machinery/light/proc/explode()
|
|
var/turf/T = get_turf(src.loc)
|
|
spawn(0)
|
|
broken() // break it first to give a warning
|
|
sleep(2)
|
|
explosion(T, 0, 0, 2, 2)
|
|
sleep(1)
|
|
del(src)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// the light item
|
|
// can be tube or bulb subtypes
|
|
// will fit into empty /obj/machinery/light of the corresponding type
|
|
|
|
/obj/item/weapon/light
|
|
icon = 'icons/obj/lighting.dmi'
|
|
flags = FPRINT | TABLEPASS
|
|
force = 2
|
|
throwforce = 5
|
|
w_class = 1
|
|
var/status = 0 // LIGHT_OK, LIGHT_BURNED or LIGHT_BROKEN
|
|
var/base_state
|
|
var/switchcount = 0 // number of times switched
|
|
m_amt = 60
|
|
var/rigged = 0 // true if rigged to explode
|
|
var/brightness = 2 //how much light it gives off
|
|
|
|
/obj/item/weapon/light/tube
|
|
name = "light tube"
|
|
desc = "A replacement light tube."
|
|
icon_state = "ltube"
|
|
base_state = "ltube"
|
|
item_state = "c_tube"
|
|
g_amt = 100
|
|
brightness = 8
|
|
|
|
/obj/item/weapon/light/tube/large
|
|
w_class = 2
|
|
name = "large light tube"
|
|
brightness = 15
|
|
|
|
/obj/item/weapon/light/bulb
|
|
name = "light bulb"
|
|
desc = "A replacement light bulb."
|
|
icon_state = "lbulb"
|
|
base_state = "lbulb"
|
|
item_state = "contvapour"
|
|
g_amt = 100
|
|
brightness = 5
|
|
|
|
/obj/item/weapon/light/throw_impact(atom/hit_atom)
|
|
..()
|
|
shatter()
|
|
|
|
/obj/item/weapon/light/bulb/fire
|
|
name = "fire bulb"
|
|
desc = "A replacement fire bulb."
|
|
icon_state = "fbulb"
|
|
base_state = "fbulb"
|
|
item_state = "egg4"
|
|
g_amt = 100
|
|
brightness = 5
|
|
|
|
// update the icon state and description of the light
|
|
|
|
/obj/item/weapon/light/proc/update()
|
|
switch(status)
|
|
if(LIGHT_OK)
|
|
icon_state = base_state
|
|
desc = "A replacement [name]."
|
|
if(LIGHT_BURNED)
|
|
icon_state = "[base_state]-burned"
|
|
desc = "A burnt-out [name]."
|
|
if(LIGHT_BROKEN)
|
|
icon_state = "[base_state]-broken"
|
|
desc = "A broken [name]."
|
|
|
|
|
|
/obj/item/weapon/light/New()
|
|
..()
|
|
switch(name)
|
|
if("light tube")
|
|
brightness = rand(6,9)
|
|
if("light bulb")
|
|
brightness = rand(4,6)
|
|
update()
|
|
|
|
|
|
// attack bulb/tube with object
|
|
// if a syringe, can inject plasma to make it explode
|
|
/obj/item/weapon/light/attackby(var/obj/item/I, var/mob/user)
|
|
..()
|
|
if(istype(I, /obj/item/weapon/reagent_containers/syringe))
|
|
var/obj/item/weapon/reagent_containers/syringe/S = I
|
|
|
|
user << "You inject the solution into the [src]."
|
|
|
|
if(S.reagents.has_reagent("plasma", 5))
|
|
|
|
rigged = 1
|
|
|
|
S.reagents.clear_reagents()
|
|
else
|
|
..()
|
|
return
|
|
|
|
// called after an attack with a light item
|
|
// shatter light, unless it was an attempt to put it in a light socket
|
|
// now only shatter if the intent was harm
|
|
|
|
/obj/item/weapon/light/afterattack(atom/target, mob/user)
|
|
if(istype(target, /obj/machinery/light))
|
|
return
|
|
if(user.a_intent != "hurt")
|
|
return
|
|
|
|
shatter()
|
|
|
|
/obj/item/weapon/light/proc/shatter()
|
|
if(status == LIGHT_OK || status == LIGHT_BURNED)
|
|
src.visible_message("\red [name] shatters.","\red You hear a small glass object shatter.")
|
|
status = LIGHT_BROKEN
|
|
force = 5
|
|
playsound(src.loc, 'Glasshit.ogg', 75, 1)
|
|
update()
|
|
|
|
|
|
|
|
// a box of replacement light items
|
|
|
|
/obj/item/weapon/storage/lightbox
|
|
name = "replacement bulbs"
|
|
icon = 'icons/obj/storage.dmi'
|
|
icon_state = "light"
|
|
desc = "This box is shaped on the inside so that only light tubes and bulbs fit."
|
|
item_state = "syringe_kit"
|
|
foldable = /obj/item/stack/sheet/cardboard //BubbleWrap
|
|
storage_slots=21
|
|
can_hold = list("/obj/item/weapon/light/tube", "/obj/item/weapon/light/bulb")
|
|
max_combined_w_class = 21
|
|
|
|
/obj/item/weapon/storage/lightbox/bulbs/New()
|
|
..()
|
|
for(var/i = 0; i < 21; i++)
|
|
new /obj/item/weapon/light/bulb(src)
|
|
|
|
/obj/item/weapon/storage/lightbox/tubes
|
|
name = "replacement tubes"
|
|
icon_state = "lighttube"
|
|
|
|
/obj/item/weapon/storage/lightbox/tubes/New()
|
|
..()
|
|
for(var/i = 0; i < 21; i++)
|
|
new /obj/item/weapon/light/tube(src)
|
|
|
|
/obj/item/weapon/storage/lightbox/mixed
|
|
name = "replacement lights"
|
|
icon_state = "lightmixed"
|
|
|
|
/obj/item/weapon/storage/lightbox/mixed/New()
|
|
..()
|
|
for(var/i = 0; i < 14; i++)
|
|
new /obj/item/weapon/light/tube(src)
|
|
for(var/i = 0; i < 7; i++)
|
|
new /obj/item/weapon/light/bulb(src)
|