mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-26 10:12:17 +00:00
This commit first and foremost ports the -tg- atom pooling system, and removes the old experimental system entirely. Secondly, this PR modifies the qdel system to use a -tg- lookalike "destroy hint" system, which means that individual objects can tell qdel what to do with them beyond taking care of things they need to delete. This ties into the atom pooling system via a new hint define, QDEL_HINT_PUTINPOOL, which will place the atom in the pool instead of deleting it as per standard. Emitter beams are now fully pooled. Qdel now has semi-compatibility with all datum types, however it is not the same as -tg-'s "Queue everything!" system. It simply passes it through the GC immediately and adds it to the "hard del" lists. This means that reagents can be qdel'ed, but there is no purpose as of yet, as it is more or less the same as just deleting them, with the added effect of adding logs of them being deleted to the garbage collector.
269 lines
8.4 KiB
Plaintext
269 lines
8.4 KiB
Plaintext
/obj/item/device/flashlight
|
|
name = "flashlight"
|
|
desc = "A hand-held emergency light."
|
|
icon = 'icons/obj/lighting.dmi'
|
|
icon_state = "flashlight"
|
|
item_state = "flashlight"
|
|
w_class = 2
|
|
flags = CONDUCT
|
|
slot_flags = SLOT_BELT
|
|
m_amt = 50
|
|
g_amt = 20
|
|
action_button_name = "Flashlight"
|
|
var/on = 0
|
|
var/brightness_on = 4 //luminosity when on
|
|
|
|
/obj/item/device/flashlight/initialize()
|
|
..()
|
|
if(on)
|
|
icon_state = "[initial(icon_state)]-on"
|
|
set_light(brightness_on)
|
|
else
|
|
icon_state = initial(icon_state)
|
|
set_light(0)
|
|
|
|
/obj/item/device/flashlight/proc/update_brightness(var/mob/user = null)
|
|
if(on)
|
|
icon_state = "[initial(icon_state)]-on"
|
|
set_light(brightness_on)
|
|
else
|
|
icon_state = initial(icon_state)
|
|
set_light(0)
|
|
|
|
/obj/item/device/flashlight/attack_self(mob/user)
|
|
if(!isturf(user.loc))
|
|
user << "You cannot turn the light on while in this [user.loc]." //To prevent some lighting anomalities.
|
|
return 0
|
|
on = !on
|
|
update_brightness(user)
|
|
return 1
|
|
|
|
|
|
/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(((CLUMSY in user.mutations) || user.getBrainLoss() >= 60) && prob(50)) //too dumb to use flashlight properly
|
|
return ..() //just hit them in the head
|
|
|
|
if(!(istype(user, /mob/living/carbon/human) || ticker) && ticker.mode.name != "monkey") //don't have dexterity
|
|
user << "<span class='notice'>You don't have the dexterity to do this!</span>"
|
|
return
|
|
|
|
var/mob/living/carbon/human/H = M //mob has protective eyewear
|
|
if(istype(M, /mob/living/carbon/human) && ((H.head && H.head.flags & HEADCOVERSEYES) || (H.wear_mask && H.wear_mask.flags & MASKCOVERSEYES) || (H.glasses && H.glasses.flags & GLASSESCOVERSEYES)))
|
|
user << "<span class='notice'>You're going to need to remove that [(H.head && H.head.flags & HEADCOVERSEYES) ? "helmet" : (H.wear_mask && H.wear_mask.flags & MASKCOVERSEYES) ? "mask": "glasses"] first.</span>"
|
|
return
|
|
|
|
if(M == user) //they're using it on themselves
|
|
if(!M.blinded)
|
|
flick("flash", M.flash)
|
|
M.visible_message("<span class='notice'>[M] directs [src] to \his eyes.</span>", \
|
|
"<span class='notice'>You wave the light in front of your eyes! Trippy!</span>")
|
|
else
|
|
M.visible_message("<span class='notice'>[M] directs [src] to \his eyes.</span>", \
|
|
"<span class='notice'>You wave the light in front of your eyes.</span>")
|
|
return
|
|
|
|
user.visible_message("<span class='notice'>[user] directs [src] to [M]'s eyes.</span>", \
|
|
"<span class='notice'>You direct [src] to [M]'s eyes.</span>")
|
|
|
|
if(istype(M, /mob/living/carbon/human)) //robots and aliens are unaffected
|
|
if(M.stat == DEAD || M.sdisabilities & BLIND) //mob is dead or fully blind
|
|
user << "<span class='notice'>[M] pupils does not react to the light!</span>"
|
|
else if(XRAY in M.mutations) //mob has X-RAY vision
|
|
flick("flash", M.flash) //Yes, you can still get flashed wit X-Ray.
|
|
user << "<span class='notice'>[M] pupils give an eerie glow!</span>"
|
|
else //they're okay!
|
|
if(!M.blinded)
|
|
flick("flash", M.flash) //flash the affected mob
|
|
user << "<span class='notice'>[M]'s pupils narrow.</span>"
|
|
else
|
|
return ..()
|
|
|
|
/obj/item/device/flashlight/pen
|
|
name = "penlight"
|
|
desc = "A pen-sized light, used by medical staff."
|
|
icon_state = "penlight"
|
|
item_state = ""
|
|
w_class = 1
|
|
slot_flags = SLOT_BELT | SLOT_EARS
|
|
flags = CONDUCT
|
|
brightness_on = 2
|
|
|
|
/obj/item/device/flashlight/seclite
|
|
name = "seclite"
|
|
desc = "A robust flashlight used by security."
|
|
icon_state = "seclite"
|
|
item_state = "seclite"
|
|
icon_override = 'icons/mob/in-hand/tools.dmi'
|
|
force = 9 // Not as good as a stun baton.
|
|
brightness_on = 5 // A little better than the standard flashlight.
|
|
hitsound = 'sound/weapons/genhit1.ogg'
|
|
|
|
/obj/item/device/flashlight/drone
|
|
name = "low-power flashlight"
|
|
desc = "A miniature lamp, that might be used by small robots."
|
|
icon_state = "penlight"
|
|
item_state = ""
|
|
flags = CONDUCT
|
|
brightness_on = 2
|
|
w_class = 1
|
|
|
|
// the desk lamps are a bit special
|
|
/obj/item/device/flashlight/lamp
|
|
name = "desk lamp"
|
|
desc = "A desk lamp with an adjustable mount."
|
|
icon_state = "lamp"
|
|
item_state = "lamp"
|
|
brightness_on = 5
|
|
w_class = 4
|
|
flags = CONDUCT
|
|
m_amt = 0
|
|
g_amt = 0
|
|
on = 1
|
|
|
|
|
|
// green-shaded desk lamp
|
|
/obj/item/device/flashlight/lamp/green
|
|
desc = "A classic green-shaded desk lamp."
|
|
icon_state = "lampgreen"
|
|
item_state = "lampgreen"
|
|
|
|
|
|
|
|
/obj/item/device/flashlight/lamp/verb/toggle_light()
|
|
set name = "Toggle light"
|
|
set category = "Object"
|
|
set src in oview(1)
|
|
|
|
if(!usr.stat)
|
|
attack_self(usr)
|
|
|
|
//Bananalamp
|
|
obj/item/device/flashlight/lamp/bananalamp
|
|
name = "banana lamp"
|
|
desc = "Only a clown would think to make a ghetto banana-shaped lamp. Even has a goofy pullstring."
|
|
icon_state = "bananalamp"
|
|
item_state = "bananalamp"
|
|
|
|
|
|
// FLARES
|
|
|
|
/obj/item/device/flashlight/flare
|
|
name = "flare"
|
|
desc = "A red Nanotrasen issued flare. There are instructions on the side, it reads 'pull cord, make light'."
|
|
w_class = 2.0
|
|
brightness_on = 8 // Made it brighter (from 7 to 8).
|
|
light_color = "#ff0000" // changed colour to a more brighter red.
|
|
icon_state = "flare"
|
|
item_state = "flare"
|
|
var/fuel = 0
|
|
var/on_damage = 7
|
|
var/produce_heat = 1500
|
|
|
|
/obj/item/device/flashlight/flare/New()
|
|
fuel = rand(800, 1000) // Sorry for changing this so much but I keep under-estimating how long X number of ticks last in seconds.
|
|
..()
|
|
|
|
/obj/item/device/flashlight/flare/process()
|
|
var/turf/pos = get_turf(src)
|
|
if(pos)
|
|
pos.hotspot_expose(produce_heat, 5)
|
|
fuel = max(fuel - 1, 0)
|
|
if(!fuel || !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
|
|
src.force = initial(src.force)
|
|
src.damtype = initial(src.damtype)
|
|
if(ismob(loc))
|
|
var/mob/U = loc
|
|
update_brightness(U)
|
|
else
|
|
update_brightness(null)
|
|
|
|
/obj/item/device/flashlight/flare/attack_self(mob/user)
|
|
|
|
// Usual checks
|
|
if(!fuel)
|
|
user << "<span class='notice'>It's out of fuel.</span>"
|
|
return
|
|
if(on)
|
|
return
|
|
|
|
. = ..()
|
|
// All good, turn it on.
|
|
if(.)
|
|
user.visible_message("<span class='notice'>[user] activates the flare.</span>", "<span class='notice'>You pull the cord on the flare, activating it!</span>")
|
|
src.force = on_damage
|
|
src.damtype = "fire"
|
|
processing_objects += src
|
|
|
|
/obj/item/device/flashlight/slime
|
|
gender = PLURAL
|
|
name = "glowing slime extract"
|
|
desc = "A glowing ball of what appears to be amber."
|
|
icon = 'icons/obj/lighting.dmi'
|
|
icon_state = "floor1" //not a slime extract sprite but... something close enough!
|
|
item_state = "slime"
|
|
w_class = 1
|
|
brightness_on = 6
|
|
light_color = "#FFBF00"
|
|
on = 1 //Bio-luminesence has one setting, on.
|
|
|
|
/obj/item/device/flashlight/slime/New()
|
|
set_light(brightness_on)
|
|
spawn(1) //Might be sloppy, but seems to be necessary to prevent further runtimes and make these work as intended... don't judge me!
|
|
update_brightness()
|
|
icon_state = initial(icon_state)
|
|
|
|
/obj/item/device/flashlight/slime/attack_self(mob/user)
|
|
return //Bio-luminescence does not toggle.
|
|
|
|
/obj/item/device/flashlight/emp
|
|
origin_tech = "magnets=4;syndicate=5"
|
|
|
|
var/emp_max_charges = 4
|
|
var/emp_cur_charges = 4
|
|
var/charge_tick = 0
|
|
|
|
|
|
/obj/item/device/flashlight/emp/New()
|
|
..()
|
|
processing_objects.Add(src)
|
|
|
|
/obj/item/device/flashlight/emp/Destroy()
|
|
processing_objects.Remove(src)
|
|
return ..()
|
|
|
|
/obj/item/device/flashlight/emp/process()
|
|
charge_tick++
|
|
if(charge_tick < 10) return 0
|
|
charge_tick = 0
|
|
emp_cur_charges = min(emp_cur_charges+1, emp_max_charges)
|
|
return 1
|
|
|
|
/obj/item/device/flashlight/emp/attack(mob/living/M as mob, mob/living/user as mob)
|
|
if(on && user.zone_sel.selecting == "eyes") // call original attack proc only if aiming at the eyes
|
|
..()
|
|
return
|
|
|
|
/obj/item/device/flashlight/emp/afterattack(atom/A as mob|obj, mob/user, proximity)
|
|
if(!proximity) return
|
|
if (emp_cur_charges > 0)
|
|
emp_cur_charges -= 1
|
|
A.visible_message("<span class='danger'>[user] blinks \the [src] at \the [A].", \
|
|
"<span class='userdanger'>[user] blinks \the [src] at \the [A].")
|
|
if(ismob(A))
|
|
var/mob/M = A
|
|
add_logs(M, user, "attacked", object="EMP-light")
|
|
user << "\The [src] now has [emp_cur_charges] charge\s."
|
|
A.emp_act(1)
|
|
else
|
|
user << "<span class='warning'>\The [src] needs time to recharge!</span>"
|
|
return |