Skip to content

Commit

Permalink
make lamps anchor and switch on and off
Browse files Browse the repository at this point in the history
  • Loading branch information
TobleroneSwordfish committed Feb 13, 2025
1 parent 6e6482e commit b54e735
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
3 changes: 3 additions & 0 deletions code/datums/controllers/artifact_controls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ var/datum/artifact_controller/artifact_controls
var/scramblechance = 10 //probability to have "fake" artifact with altered appearance
var/list/activation_sounds = list()
var/list/instrument_sounds = list()
var/list/lightswitch_sounds = list('sound/misc/lightswitch.ogg')
var/list/fault_types = list("all")
var/list/adjectives = list("strange","unusual","odd","curious","bizarre","weird","abnormal","peculiar")
var/list/nouns_large = list("object","machine","artifact","contraption","structure","edifice")
Expand Down Expand Up @@ -319,6 +320,7 @@ var/datum/artifact_controller/artifact_controls
'sound/musical_instruments/artifact/Artifact_Martian_2.ogg',
'sound/musical_instruments/artifact/Artifact_Martian_3.ogg',
'sound/musical_instruments/artifact/Artifact_Martian_4.ogg')
lightswitch_sounds = list('sound/impact_sounds/Slimy_Splat_1.ogg', 'sound/impact_sounds/Slimy_Hit_4.ogg', 'sound/impact_sounds/Slimy_Hit_3.ogg')
impact_reaction_one = 1
impact_reaction_two = 0
heat_reaction_one = 0.99
Expand Down Expand Up @@ -402,6 +404,7 @@ var/datum/artifact_controller/artifact_controls
'sound/musical_instruments/artifact/Artifact_Wizard_2.ogg',
'sound/musical_instruments/artifact/Artifact_Wizard_3.ogg',
'sound/musical_instruments/artifact/Artifact_Wizard_4.ogg')
lightswitch_sounds = list('sound/effects/mag_forcewall.ogg', 'sound/effects/MagShieldUp.ogg', 'sound/effects/MagShieldDown.ogg')
impact_reaction_one = 8
impact_reaction_two = 6
heat_reaction_one = 0.75
Expand Down
44 changes: 33 additions & 11 deletions code/obj/artifacts/artifact_objects/lamp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,58 @@
activ_text = "begins to emit a steady light!"
deact_text = "goes dark and quiet."
react_xray = list(10,90,90,11,"NONE")
var/sound/switch_sound = null

post_setup()
..()
src.switch_sound = pick(src.artitype.lightswitch_sounds)

effect_activate(var/obj/O)
if (..())
return
var/obj/artifact/lamp/L = O
src.light_on(O)

effect_deactivate(var/obj/O)
if (..())
return
src.light_off(O)

proc/light_on(obj/artifact/lamp/L)
playsound(L, src.switch_sound, 40, TRUE, -10)
if (L.light)
L.light.enable()
var/obj/effect/whackylight/bonus = L.bonus_light
if(bonus)
L.vis_contents += bonus
bonus.active = TRUE
bonus.update_whacky(L,null,0)
bonus.update_whacky(L)
L.anchored = TRUE

effect_deactivate(var/obj/O)
if (..())
return
var/obj/artifact/lamp/L = O
proc/light_off(obj/artifact/lamp/L)
playsound(L, src.switch_sound, 40, TRUE, -10)
if (L.light)
L.light.disable()
var/obj/effect/whackylight/bonus = L.bonus_light
if(bonus)
L.vis_contents -= bonus
bonus.active = FALSE
bonus.update_whacky(L,null,0)
bonus.update_whacky(L)
L.anchored = FALSE

effect_touch(obj/artifact/lamp/L, mob/living/user)
if(..())
return
if (!src.activated)
return
if (L.light.enabled)
src.light_off(L)
else
src.light_on(L)

/obj/effect/whackylight

var/radius
var/active = FALSE
glide_size = INFINITY //no gliding for you!
anchored = TRUE //not really, but we do our own moving thank you very much

New(loc, radius=2, color=null)
Expand All @@ -82,11 +106,9 @@
else
src.color = color
src.appearance_flags |= RESET_TRANSFORM
RegisterSignal(loc, COMSIG_MOVABLE_SET_LOC, PROC_REF(update_whacky))
RegisterSignal(loc, COMSIG_MOVABLE_MOVED, PROC_REF(update_whacky))
update_whacky(loc, null, 0)

proc/update_whacky(var/atom/movable/thing, prev_loc, dir)
proc/update_whacky(var/atom/movable/thing)
src.loc = get_turf(thing)
if(active)
for(var/turf/T in src.vis_contents)
Expand Down

0 comments on commit b54e735

Please sign in to comment.