mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-29 16:10:02 +01:00
<img width="1549" height="857" alt="image" src="https://github.com/user-attachments/assets/3830233d-0635-4942-b2aa-024651e6cffa" /> Limbs make up roughly half of the "Per additional player" processing overhead, while Organs make up most of the other half. Not every organ is an easy candidate for "Event-only processing", but external limbs are significantly easier to do so. So this PR makes it so that External Limbs no longer require Processing unless an event happens that would justify them requiring processing. Which SIGNIFICANTLY reduces the overall additional cost to the Processing subsystem per player that joins the server. Oh and I also made the Appendix and Kidneys not require constant processing. The Appendix will only process if it is hit by an Appendicitis event, and the Kidneys will only process if they are either damaged, or you get poisoned.
411 lines
12 KiB
Plaintext
411 lines
12 KiB
Plaintext
/obj/item/flashlight
|
|
name = "flashlight"
|
|
desc = "A hand-held emergency light."
|
|
icon = 'icons/obj/lighting.dmi'
|
|
icon_state = "flashlight"
|
|
item_state = "flashlight"
|
|
w_class = WEIGHT_CLASS_SMALL
|
|
obj_flags = OBJ_FLAG_CONDUCTABLE
|
|
slot_flags = SLOT_BELT
|
|
contained_sprite = TRUE
|
|
light_color = LIGHT_COLOR_HALOGEN
|
|
light_system = DIRECTIONAL_LIGHT
|
|
light_range = 4
|
|
|
|
matter = list(MATERIAL_PLASTIC = 50, MATERIAL_GLASS = 20)
|
|
|
|
action_button_name = "Toggle Flashlight"
|
|
/// Is the light currently on or off?
|
|
var/on = FALSE
|
|
// Lighting power when on
|
|
var/flashlight_power = 0.8
|
|
/// Sound the light makes when it's switched
|
|
var/toggle_sound = 'sound/machines/switch_flashlight.ogg'
|
|
/// Sound the light makes when it's turned on
|
|
var/activation_sound = 'sound/items/flashlight.ogg'
|
|
var/obj/item/cell/cell
|
|
var/cell_type = /obj/item/cell/device
|
|
var/list/brightness_levels
|
|
var/brightness_level = "high"
|
|
var/power_usage
|
|
/// Does the light use power?
|
|
var/power_use = TRUE
|
|
/// Should the item start with a cell?
|
|
var/starts_with_cell = TRUE
|
|
/// Does the item accept large cells?
|
|
var/accepts_large_cells = FALSE
|
|
/// Is the light always on?
|
|
var/always_on = FALSE
|
|
/// How efficient the flashlight is at producing light compared to baseline
|
|
var/efficiency_modifier = 1.0
|
|
|
|
/obj/item/flashlight/mechanics_hints(mob/user, distance, is_adjacent)
|
|
. += ..()
|
|
if(!always_on)
|
|
. += "Left-click \the [src] in-hand to toggle the light."
|
|
. += "While held, left-click \the [src] with your free hand to remove the power cell."
|
|
|
|
/obj/item/flashlight/feedback_hints(mob/user, distance, is_adjacent)
|
|
. = list()
|
|
. = ..()
|
|
if(power_use && brightness_level)
|
|
. += "\The [src] is set to [brightness_level]."
|
|
if(cell)
|
|
. += "\The [src] has \a [cell] attached. It has [round(cell.percent())]% charge remaining."
|
|
|
|
/obj/item/flashlight/Initialize()
|
|
|
|
if(power_use && cell_type)
|
|
if(starts_with_cell)
|
|
cell = new cell_type(src)
|
|
brightness_levels = list("low" = 2, "medium" = 3, "high" = 4)
|
|
power_usage = ((brightness_levels[brightness_level]/ 100 ) / efficiency_modifier)
|
|
else
|
|
verbs -= /obj/item/flashlight/verb/toggle_brightness
|
|
|
|
if (on)
|
|
if(brightness_level == "low")
|
|
light_range = light_range * 0.5
|
|
else if(brightness_level == "high")
|
|
light_range = light_range * 1.5
|
|
else
|
|
light_range = light_range
|
|
update_icon()
|
|
set_light_on(on)
|
|
|
|
. = ..()
|
|
|
|
/obj/item/flashlight/Destroy()
|
|
STOP_PROCESSING(SSprocessing, src)
|
|
QDEL_NULL(cell)
|
|
return ..()
|
|
|
|
/obj/item/flashlight/dropped(mob/user)
|
|
. = ..()
|
|
if(user?.dir)
|
|
set_dir(user.dir)
|
|
|
|
/obj/item/flashlight/get_cell()
|
|
return cell
|
|
|
|
/obj/item/flashlight/proc/set_brightness(mob/user)
|
|
var/choice = tgui_input_list(user, "Choose a brightness level.", "Flashlight", brightness_levels)
|
|
if(choice)
|
|
set_light_range(brightness_levels[choice])
|
|
power_usage = brightness_levels[choice]
|
|
to_chat(user, SPAN_NOTICE("You set the brightness level on \the [src] to [brightness_level]."))
|
|
update_icon()
|
|
|
|
/obj/item/flashlight/process()
|
|
if(!on || !cell)
|
|
return PROCESS_KILL
|
|
|
|
if(brightness_level && power_usage)
|
|
if(cell.use(power_usage) != power_usage)
|
|
visible_message(
|
|
SPAN_WARNING("\The [src] flickers before shutting out!")
|
|
)
|
|
playsound(src.loc, 'sound/effects/sparks3.ogg', 10, 1, -3)
|
|
toggle()
|
|
return PROCESS_KILL
|
|
|
|
/obj/item/flashlight/update_icon()
|
|
if(always_on)
|
|
return
|
|
|
|
if(on)
|
|
icon_state = "[initial(icon_state)]-on"
|
|
else
|
|
icon_state = "[initial(icon_state)]"
|
|
if (ismob(src.loc)) //for reasons, this makes headlights work.
|
|
var/mob/M = src.loc
|
|
M.update_inv_l_ear()
|
|
M.update_inv_r_ear()
|
|
M.update_inv_head()
|
|
|
|
/obj/item/flashlight/attack_self(mob/user)
|
|
if(always_on)
|
|
to_chat(user, SPAN_NOTICE("You cannot toggle \the [name]."))
|
|
return 0
|
|
|
|
if(power_use)
|
|
if(!cell || !cell.check_charge(1))
|
|
playsound(src.loc, toggle_sound, 60, 1)
|
|
to_chat(user, SPAN_WARNING("You flip the switch on \the [name], but nothing happens!"))
|
|
return 0
|
|
|
|
if(!isturf(user.loc))
|
|
to_chat(user, SPAN_NOTICE("You cannot turn the light on while in this [user.loc].")) //To prevent some lighting anomalies.
|
|
return 0
|
|
|
|
playsound(src.loc, toggle_sound, 60, 1)
|
|
toggle()
|
|
user.update_action_buttons()
|
|
return 1
|
|
|
|
/obj/item/flashlight/attack_hand(mob/user)
|
|
if(user.get_inactive_hand() == src)
|
|
if(cell)
|
|
STOP_PROCESSING(SSprocessing, src)
|
|
cell.update_icon()
|
|
user.put_in_hands(cell)
|
|
cell = null
|
|
to_chat(user, SPAN_NOTICE("You remove the cell from \the [src]."))
|
|
playsound(src, 'sound/machines/click.ogg', 30, 1, 0)
|
|
on = FALSE
|
|
update_icon()
|
|
return
|
|
..()
|
|
else
|
|
return ..()
|
|
|
|
/obj/item/flashlight/attackby(obj/item/attacking_item, mob/user)
|
|
if(power_use)
|
|
if(istype(attacking_item, /obj/item/cell))
|
|
if(istype(attacking_item, /obj/item/cell/device) || accepts_large_cells)
|
|
if(!cell)
|
|
user.drop_item()
|
|
attacking_item.loc = src
|
|
cell = attacking_item
|
|
to_chat(user, SPAN_NOTICE("You install a cell in \the [src]."))
|
|
playsound(src, 'sound/machines/click.ogg', 30, 1, 0)
|
|
update_icon()
|
|
else
|
|
to_chat(user, SPAN_WARNING("\The [src] already has a cell!"))
|
|
else
|
|
to_chat(user, SPAN_WARNING("\The [src] cannot accept that type of cell."))
|
|
|
|
else
|
|
..()
|
|
|
|
/obj/item/flashlight/proc/toggle()
|
|
on = !on
|
|
if(on && activation_sound)
|
|
playsound(src.loc, activation_sound, 75, 1)
|
|
if(on && power_use)
|
|
START_PROCESSING(SSprocessing, src)
|
|
else if (power_use)
|
|
STOP_PROCESSING(SSprocessing, src)
|
|
set_light_on(on)
|
|
update_icon()
|
|
|
|
/obj/item/flashlight/vendor_action(var/obj/structure/machinery/vending/V)
|
|
toggle()
|
|
|
|
/obj/item/flashlight/emp_act(severity)
|
|
. = ..()
|
|
|
|
for(var/obj/O in contents)
|
|
O.emp_act(severity)
|
|
|
|
/obj/item/flashlight/attack(mob/living/target_mob, mob/living/user, target_zone)
|
|
add_fingerprint(user)
|
|
if(on && user.zone_sel.selecting == BP_EYES)
|
|
|
|
if(((user.is_clumsy()) || (user.mutations & DUMB)) && prob(50)) //too dumb to use flashlight properly
|
|
return ..() //just hit them in the head
|
|
|
|
if(light_range < 2)
|
|
to_chat(user, SPAN_WARNING("This light is too dim to see anything with!"))
|
|
return
|
|
|
|
var/mob/living/carbon/human/H = target_mob //mob has protective eyewear
|
|
if(istype(H))
|
|
if(H.get_flash_protection() > FLASH_PROTECTION_NONE)
|
|
to_chat(user, SPAN_WARNING("You're going to need to remove \the [H]'s eye protection first."))
|
|
return
|
|
|
|
var/obj/item/organ/vision
|
|
if(H.species.vision_organ)
|
|
vision = H.internal_organs_by_name[H.species.vision_organ]
|
|
if(!vision)
|
|
to_chat(user, SPAN_WARNING("You can't find any [H.species.vision_organ ? H.species.vision_organ : "eyes"] on [H]!"))
|
|
|
|
user.visible_message(
|
|
SPAN_NOTICE("\The [user] directs [src] to [H]'s eyes."),
|
|
SPAN_NOTICE("You direct [src] to [H]'s eyes.")
|
|
)
|
|
|
|
inspect_vision(vision, user)
|
|
|
|
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) //can be used offensively
|
|
if (!(light_range < 2))
|
|
H.flash_act(length = 1 SECOND)
|
|
else
|
|
return ..()
|
|
|
|
/obj/item/flashlight/AltClick()
|
|
toggle_brightness()
|
|
|
|
/obj/item/flashlight/proc/inspect_vision(obj/item/organ/vision, mob/living/user)
|
|
var/mob/living/carbon/human/H = vision.owner
|
|
|
|
if (H == user) //can't look into your own eyes buster
|
|
return
|
|
|
|
if (!BP_IS_ROBOTIC(vision))
|
|
|
|
if(H.stat == DEAD || H.blinded || H.status_flags & FAKEDEATH) //mob is dead or fully blind
|
|
to_chat(user, SPAN_WARNING("\The [H]'s pupils do not react to the light!"))
|
|
return
|
|
if((H.mutations & XRAY))
|
|
to_chat(user, SPAN_NOTICE("\The [H]'s pupils give an eerie glow!"))
|
|
if(vision.get_damage())
|
|
to_chat(user, SPAN_WARNING("There's visible damage to [H]'s [vision.name]!"))
|
|
else if(H.eye_blurry)
|
|
to_chat(user, SPAN_NOTICE("\The [H]'s pupils react slower than normally."))
|
|
if(H.getBrainLoss() > 15)
|
|
to_chat(user, SPAN_NOTICE("There's visible lag between the left and right pupils' reactions."))
|
|
|
|
var/list/pinpoint = list(/singleton/reagent/oxycomorphine=1,/singleton/reagent/mortaphenyl=5)
|
|
var/list/dilating = list(/singleton/reagent/drugs/mms=5,/singleton/reagent/drugs/mindbreaker=1)
|
|
var/datum/reagents/ingested = H.get_ingested_reagents()
|
|
if(H.reagents.has_any_reagent(pinpoint) || ingested.has_any_reagent(pinpoint))
|
|
to_chat(user, SPAN_NOTICE("\The [H]'s pupils are already pinpoint and cannot narrow any more."))
|
|
else if(H.shock_stage >= 30 || H.reagents.has_any_reagent(dilating) || ingested.has_any_reagent(dilating) || H.breathing.has_any_reagent(dilating))
|
|
to_chat(user, SPAN_NOTICE("\The [H]'s pupils narrow slightly, but are still very dilated."))
|
|
else
|
|
to_chat(user, SPAN_NOTICE("\The [H]'s pupils narrow."))
|
|
|
|
/obj/item/flashlight/verb/toggle_brightness()
|
|
set name = "Toggle Flashlight Brightness"
|
|
set category = "Object.Held"
|
|
set src in usr
|
|
set_brightness(usr)
|
|
|
|
/obj/item/flashlight/empty
|
|
starts_with_cell = FALSE
|
|
|
|
/obj/item/flashlight/on
|
|
on = TRUE
|
|
|
|
/obj/item/flashlight/pen
|
|
name = "penlight"
|
|
desc = "A pen-sized light, used by medical staff."
|
|
icon_state = "penlight"
|
|
item_state = "pen"
|
|
drop_sound = 'sound/items/drop/accessory.ogg'
|
|
pickup_sound = 'sound/items/pickup/accessory.ogg'
|
|
obj_flags = OBJ_FLAG_CONDUCTABLE
|
|
slot_flags = SLOT_EARS
|
|
light_range = 2
|
|
w_class = WEIGHT_CLASS_TINY
|
|
|
|
/obj/item/flashlight/drone
|
|
name = "low-power flashlight"
|
|
desc = "A miniature lamp, that might be used by small robots."
|
|
icon_state = "penlight"
|
|
item_state = ""
|
|
obj_flags = OBJ_FLAG_CONDUCTABLE
|
|
light_range = 2
|
|
efficiency_modifier = 2
|
|
w_class = WEIGHT_CLASS_TINY
|
|
|
|
/obj/item/flashlight/heavy
|
|
name = "heavy duty flashlight"
|
|
desc = "A high-luminosity flashlight, for specialist duties."
|
|
icon_state = "heavyflashlight"
|
|
item_state = "heavyflashlight"
|
|
light_range = 4
|
|
w_class = WEIGHT_CLASS_NORMAL
|
|
matter = list(MATERIAL_PLASTIC = 100, MATERIAL_GLASS = 70)
|
|
|
|
/obj/item/flashlight/heavy/on
|
|
on = TRUE
|
|
|
|
/obj/item/flashlight/maglight
|
|
name = "maglight"
|
|
desc = "A heavy flashlight, designed for security personnel."
|
|
icon_state = "maglight"
|
|
item_state = "maglight"
|
|
force = 9
|
|
light_range = 5
|
|
efficiency_modifier = 0.8
|
|
w_class = WEIGHT_CLASS_NORMAL
|
|
attack_verb = list("slammed", "whacked", "bashed", "thunked", "battered", "bludgeoned", "thrashed")
|
|
matter = list(MATERIAL_ALUMINIUM = 200, MATERIAL_GLASS = 100)
|
|
hitsound = 'sound/weapons/smash.ogg'
|
|
|
|
/obj/item/flashlight/maglight/update_icon()
|
|
..()
|
|
if(on)
|
|
item_state = "maglight-on"
|
|
else
|
|
item_state = "maglight"
|
|
|
|
/obj/item/flashlight/maglight/on
|
|
on = TRUE
|
|
|
|
/obj/item/flashlight/slime
|
|
gender = PLURAL
|
|
name = "glowing slime extract"
|
|
desc = "A glowing ball of what appears to be amber."
|
|
icon = 'icons/mob/npc/slimes.dmi'
|
|
icon_state = "yellow slime extract"
|
|
item_state = "flashlight"
|
|
w_class = WEIGHT_CLASS_TINY
|
|
light_range = 6
|
|
on = TRUE //Bio-luminesence has one setting, on.
|
|
always_on = TRUE
|
|
power_usage = FALSE
|
|
light_color = LIGHT_COLOR_SLIME_LAMP
|
|
light_system = MOVABLE_LIGHT
|
|
|
|
/obj/item/flashlight/headlights
|
|
name = "headlights"
|
|
desc = "Some nifty lamps drawing from internal battery sources to produce a light, though a dim one."
|
|
icon_state = "headlights"
|
|
item_state = "headlights"
|
|
obj_flags = OBJ_FLAG_CONDUCTABLE
|
|
slot_flags = SLOT_HEAD | SLOT_EARS
|
|
light_range = 2
|
|
w_class = WEIGHT_CLASS_TINY
|
|
body_parts_covered = 0
|
|
|
|
/******************************Lantern*******************************/
|
|
|
|
/obj/item/flashlight/lantern
|
|
name = "lantern"
|
|
desc = "A mining lantern. Accepts larger cells than normal flashlights."
|
|
icon_state = "lantern"
|
|
item_state = "lantern"
|
|
attack_verb = list("bludgeoned, bashed, whacked")
|
|
matter = list(MATERIAL_STEEL = 200,MATERIAL_GLASS = 100)
|
|
flashlight_power = 1
|
|
light_range = 4
|
|
cell_type = /obj/item/cell
|
|
accepts_large_cells = TRUE
|
|
light_color = LIGHT_COLOR_FIRE
|
|
light_system = MOVABLE_LIGHT
|
|
|
|
/obj/item/flashlight/lantern/update_icon()
|
|
..()
|
|
if(on)
|
|
item_state = "lantern-on"
|
|
else
|
|
item_state = "lantern"
|
|
|
|
/obj/item/flashlight/lantern/on
|
|
on = TRUE
|
|
|
|
/obj/item/flashlight/lantern/voidtamer
|
|
name = "voidic lantern"
|
|
desc = "A strange lantern mounted on a metallic stick, draped in carphide. When activated, it ignites a gaseous system resembling a nebula."
|
|
icon = 'icons/obj/diona_items.dmi'
|
|
icon_state = "voidtamer_lantern"
|
|
item_state = "voidtamer_lantern"
|
|
flashlight_power = 2 //strong enough to sustain a dionae
|
|
light_range = 5
|
|
light_color = LIGHT_COLOR_BLUE
|
|
efficiency_modifier = 1.5
|
|
|
|
/obj/item/flashlight/lantern/voidtamer/update_icon()
|
|
..()
|
|
if(on)
|
|
item_state = "voidtamer_lantern-on"
|
|
else
|
|
item_state = "voidtamer_lantern"
|
|
|
|
/obj/item/flashlight/lantern/voidtamer/on
|
|
on = TRUE
|