-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
observer.dm
1078 lines (880 loc) · 34.9 KB
/
observer.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
GLOBAL_LIST_EMPTY(ghost_images_default) //this is a list of the default (non-accessorized, non-dir) images of the ghosts themselves
GLOBAL_LIST_EMPTY(ghost_images_simple) //this is a list of all ghost images as the simple white ghost
GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
/mob/dead/observer
name = "ghost"
desc = "It's a g-g-g-g-ghooooost!" //jinkies!
icon = 'icons/mob/mob.dmi'
icon_state = "ghost"
plane = GHOST_PLANE
stat = DEAD
density = FALSE
see_invisible = SEE_INVISIBLE_OBSERVER
invisibility = INVISIBILITY_OBSERVER
hud_type = /datum/hud/ghost
movement_type = GROUND | FLYING
light_system = MOVABLE_LIGHT
light_range = 1
light_power = 2
light_on = FALSE
shift_to_open_context_menu = FALSE
lighting_cutoff = LIGHTING_CUTOFF_MEDIUM
pass_flags = PASSFLOOR
var/can_reenter_corpse
var/bootime = 0
var/started_as_observer //This variable is set to 1 when you enter the game as an observer.
//If you died in the game and are a ghsot - this will remain as null.
//Note that this is not a reliable way to determine if admins started as observers, since they change mobs a lot.
var/atom/movable/following = null
var/fun_verbs = FALSE
var/image/ghostimage_default = null //this mobs ghost image without accessories and dirs
var/image/ghostimage_simple = null //this mob with the simple white ghost sprite
var/ghostvision = TRUE //is the ghost able to see things humans can't?
var/mob/observetarget = null //The target mob that the ghost is observing. Used as a reference in logout()
var/ghost_hud_enabled = TRUE //did this ghost disable the on-screen HUD?
var/data_huds_on = FALSE //Are data HUDs currently enabled?
var/scanmode = 0
var/list/datahuds = list(DATA_HUD_SECURITY_ADVANCED, DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC_ADVANCED) //list of data HUDs shown to ghosts.
var/ghost_orbit = GHOST_ORBIT_CIRCLE
//These variables store hair data if the ghost originates from a species with head and/or facial hair.
var/hair_style
var/hair_color
var/mutable_appearance/hair_overlay
var/facial_hair_style
var/facial_hair_color
var/mutable_appearance/facial_hair_overlay
var/updatedir = 1 //Do we have to update our dir as the ghost moves around?
var/lastsetting = null //Stores the last setting that ghost_others was set to, for a little more efficiency when we update ghost images. Null means no update is necessary
//We store copies of the ghost display preferences locally so they can be referred to even if no client is connected.
//If there's a bug with changing your ghost settings, it's probably related to this.
var/ghost_accs = GHOST_ACCS_DEFAULT_OPTION
var/ghost_others = GHOST_OTHERS_DEFAULT_OPTION
// Used for displaying in ghost chat, without changing the actual name
// of the mob
var/deadchat_name
var/datum/orbit_menu/orbit_ui
var/datum/jump_menu/jump_ui
var/datum/spawners_menu/spawners_menu
///Action to quickly unobserve someone
var/datum/action/innate/unobserve/unobserve_button
// Current Viewrange
var/view = 0
/mob/dead/observer/Initialize(mapload)
set_invisibility(GLOB.observer_default_invisibility)
add_verb(src, list(
/mob/dead/observer/proc/dead_tele,
/mob/dead/observer/proc/open_spawners_menu,
/mob/dead/observer/proc/tray_view,
/mob/dead/observer/proc/possess_mouse_verb))
if(icon_state in GLOB.ghost_forms_with_directions_list)
ghostimage_default = image(src.icon,src,src.icon_state + "_nodir")
else
ghostimage_default = image(src.icon,src,src.icon_state)
ghostimage_default.override = TRUE
GLOB.ghost_images_default |= ghostimage_default
ghostimage_simple = image(src.icon,src,"ghost_nodir")
ghostimage_simple.override = TRUE
GLOB.ghost_images_simple |= ghostimage_simple
updateallghostimages()
var/turf/T
var/mob/body = loc
if(ismob(body))
T = get_turf(body) //Where is the body located?
gender = body.gender
if(body.mind && body.mind.name)
name = body.mind.name
else
if(body.real_name)
name = body.real_name
else
name = random_unique_name(gender)
mind = body.mind //we don't transfer the mind but we keep a reference to it.
set_suicide(body.suiciding) // Transfer whether they committed suicide.
if(ishuman(body))
var/mob/living/carbon/human/body_human = body
if(HAIR in body_human.dna.species.species_traits)
hair_style = body_human.hair_style
hair_color = brighten_color(body_human.hair_color)
if(FACEHAIR in body_human.dna.species.species_traits)
facial_hair_style = body_human.facial_hair_style
facial_hair_color = brighten_color(body_human.facial_hair_color)
update_appearance()
if(!T || is_secret_level(T.z))
var/list/turfs = get_area_turfs(/area/shuttle/arrival)
if(turfs.len)
T = pick(turfs)
else
T = SSmapping.get_station_center()
abstract_move(T)
if(!name) //To prevent nameless ghosts
name = random_unique_name(gender)
real_name = name
if(!fun_verbs)
remove_verb(src, /mob/dead/observer/verb/boo)
remove_verb(src, /mob/dead/observer/verb/possess)
animate(src, pixel_y = 2, time = 1 SECONDS, loop = -1)
add_to_dead_mob_list()
for(var/v in GLOB.active_alternate_appearances)
if(!v)
continue
var/datum/atom_hud/alternate_appearance/AA = v
AA.onNewMob(src)
. = ..()
grant_all_languages()
show_data_huds()
data_huds_on = 1
/mob/dead/observer/get_photo_description(obj/item/camera/camera)
if(!invisibility || camera.see_ghosts)
return "You can also see a g-g-g-g-ghooooost!"
/mob/dead/observer/narsie_act()
var/old_color = color
color = "#960000"
animate(src, color = old_color, time = 1 SECONDS, flags = ANIMATION_PARALLEL)
addtimer(CALLBACK(src, /atom/proc/update_atom_colour), 10)
/mob/dead/observer/ratvar_act()
var/old_color = color
color = "#FAE48C"
animate(src, color = old_color, time = 1 SECONDS, flags = ANIMATION_PARALLEL)
addtimer(CALLBACK(src, /atom/proc/update_atom_colour), 10)
/mob/dead/observer/Destroy()
if(data_huds_on)
remove_data_huds()
// Update our old body's medhud since we're abandoning it
if(isliving(mind?.current))
mind.current.med_hud_set_status()
GLOB.ghost_images_default -= ghostimage_default
QDEL_NULL(ghostimage_default)
GLOB.ghost_images_simple -= ghostimage_simple
QDEL_NULL(ghostimage_simple)
updateallghostimages()
QDEL_NULL(orbit_ui)
QDEL_NULL(jump_ui)
QDEL_NULL(spawners_menu)
return ..()
/*
* This proc will update the icon of the ghost itself, with hair overlays, as well as the ghost image.
* Please call update_icon(icon_state) from now on when you want to update the icon_state of the ghost,
* or you might end up with hair on a sprite that's not supposed to get it.
* Hair will always update its dir, so if your sprite has no dirs the haircut will go all over the place.
* |- Ricotez
*/
/mob/dead/observer/update_icon(updates=ALL, new_form)
. = ..()
if(client) //We update our preferences in case they changed right before update_icon was called.
ghost_accs = client.prefs.read_preference(/datum/preference/choiced/ghost_accessories)
ghost_others = client.prefs.read_preference(/datum/preference/choiced/ghost_others)
if(hair_overlay)
cut_overlay(hair_overlay)
hair_overlay = null
if(facial_hair_overlay)
cut_overlay(facial_hair_overlay)
facial_hair_overlay = null
if(new_form)
icon_state = new_form
if(icon_state in GLOB.ghost_forms_with_directions_list)
ghostimage_default.icon_state = new_form + "_nodir" //if this icon has dirs, the default ghostimage must use its nodir version or clients with the preference set to default sprites only will see the dirs
else
ghostimage_default.icon_state = new_form
if((ghost_accs == GHOST_ACCS_DIR || ghost_accs == GHOST_ACCS_FULL) && (icon_state in GLOB.ghost_forms_with_directions_list)) //if this icon has dirs AND the client wants to show them, we make sure we update the dir on movement
updatedir = 1
else
updatedir = 0 //stop updating the dir in case we want to show accessories with dirs on a ghost sprite without dirs
setDir(2 )//reset the dir to its default so the sprites all properly align up
if(ghost_accs == GHOST_ACCS_FULL && (icon_state in GLOB.ghost_forms_with_accessories_list)) //check if this form supports accessories and if the client wants to show them
var/datum/sprite_accessory/S
if(facial_hair_style)
S = GLOB.facial_hair_styles_list[facial_hair_style]
if(S)
facial_hair_overlay = mutable_appearance(S.icon, "[S.icon_state]", -HAIR_LAYER)
if(facial_hair_color)
facial_hair_overlay.color = facial_hair_color
facial_hair_overlay.alpha = 200
add_overlay(facial_hair_overlay)
if(hair_style)
S = GLOB.hair_styles_list[hair_style]
if(S)
hair_overlay = mutable_appearance(S.icon, "[S.icon_state]", -HAIR_LAYER)
if(hair_color)
hair_overlay.color = hair_color
hair_overlay.alpha = 200
add_overlay(hair_overlay)
/*
* Increase the brightness of a color by calculating the average distance between the R, G and B values,
* and maximum brightness, then adding 30% of that average to R, G and B.
*
* I'll make this proc global and move it to its own file in a future update. |- Ricotez
*/
/mob/proc/brighten_color(input_color)
var/r_val
var/b_val
var/g_val
var/color_format = length(input_color)
if(color_format != length_char(input_color))
return 0
if(color_format == 3)
r_val = hex2num(copytext(input_color, 1, 2)) * 16
g_val = hex2num(copytext(input_color, 2, 3)) * 16
b_val = hex2num(copytext(input_color, 3, 4)) * 16
else if(color_format == 6)
r_val = hex2num(copytext(input_color, 1, 3))
g_val = hex2num(copytext(input_color, 3, 5))
b_val = hex2num(copytext(input_color, 5, 7))
else
return 0 //If the color format is not 3 or 6, you're using an unexpected way to represent a color.
r_val += (255 - r_val) * 0.4
if(r_val > 255)
r_val = 255
g_val += (255 - g_val) * 0.4
if(g_val > 255)
g_val = 255
b_val += (255 - b_val) * 0.4
if(b_val > 255)
b_val = 255
return copytext(rgb(r_val, g_val, b_val), 2)
/*
Transfer_mind is there to check if mob is being deleted/not going to have a body.
Works together with spawning an observer, noted above.
*/
/mob/proc/ghostize(can_reenter_corpse = 1)
if(!key)
return
if(key[1] == "@") // Skip aghosts.
return
if(HAS_TRAIT(src, TRAIT_CORPSELOCKED))
if(can_reenter_corpse) //If you can re-enter the corpse you can't leave when corpselocked
return
if(ishuman(usr)) //following code only applies to those capable of having an ethereal heart, ie humans
var/mob/living/carbon/human/crystal_fella = usr
var/our_heart = crystal_fella.getorganslot(ORGAN_SLOT_HEART)
if(istype(our_heart, /obj/item/organ/heart/ethereal)) //so you got the heart?
var/obj/item/organ/heart/ethereal/ethereal_heart = our_heart
ethereal_heart.stop_crystalization_process(crystal_fella) //stops the crystallization process
if(isgolem(usr))
var/mob/living/carbon/human/H = usr
var/datum/species/golem/golem = H.dna.species
if(golem && golem.owner)
GLOB.servant_golem_users[usr.ckey] = world.time + (golem.ghost_cooldown ? golem.ghost_cooldown : 0)
stop_sound_channel(CHANNEL_HEARTBEAT) //Stop heartbeat sounds because You Are A Ghost Now
if(can_reenter_corpse && client) //yogs start
oobe_client = client //yogs end
var/mob/dead/observer/ghost = new(src) // Transfer safety to observer spawning proc.
SStgui.on_transfer(src, ghost) // Transfer NanoUIs.
ghost.can_reenter_corpse = can_reenter_corpse
ghost.key = key
if(ghost?.client)
ghost.client.init_verbs()
if(ghost?.client?.holder?.fakekey)
ghost.invisibility = INVISIBILITY_MAXIMUM //JUST IN CASE
ghost.alpha = 0 //JUUUUST IN CASE
ghost.name = " "
ghost.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
return ghost
/*
This is the proc mobs get to turn into a ghost. Forked from ghostize due to compatibility issues.
*/
/mob/living/verb/ghost()
set category = "OOC"
set name = "Ghost"
set desc = "Relinquish your life and enter the land of the dead."
if(stat != DEAD)
succumb()
if(stat == DEAD)
ghostize(TRUE)
return TRUE
var/response = tgui_alert(usr, "Are you -sure- you want to ghost?\n(You are alive. If you ghost whilst still alive you may not play again this round! You can't change your mind so choose wisely!!)","Are you sure you want to ghost?",list("Ghost","Stay in body"))
if(response != "Ghost")
return FALSE//didn't want to ghost after-all
ghostize(FALSE) // FALSE parameter is so we can never re-enter our body. U ded.
return TRUE
/mob/camera/verb/ghost()
set category = "OOC"
set name = "Ghost"
set desc = "Relinquish your life and enter the land of the dead."
var/response = tgui_alert(usr, "Are you -sure- you want to ghost?\n(You are alive. If you ghost whilst still alive you may not play again this round! You can't change your mind so choose wisely!!)","Are you sure you want to ghost?",list("Ghost","Stay in body"))
if(response != "Ghost")
return
ghostize(FALSE)
/mob/dead/observer/Move(NewLoc, direct, glide_size_override = 32)
if(updatedir)
setDir(direct)//only update dir if we actually need it, so overlays won't spin on base sprites that don't have directions of their own
if(glide_size_override)
set_glide_size(glide_size_override)
if(NewLoc)
abstract_move(NewLoc)
update_parallax_contents()
else
var/turf/destination = get_turf(src)
if((direct & NORTH) && y < world.maxy)
destination = get_step(destination, NORTH)
else if((direct & SOUTH) && y > 1)
destination = get_step(destination, SOUTH)
if((direct & EAST) && x < world.maxx)
destination = get_step(destination, EAST)
else if((direct & WEST) && x > 1)
destination = get_step(destination, WEST)
abstract_move(destination)//Get out of closets and such as a ghost
/mob/dead/observer/forceMove(atom/destination)
abstract_move(destination) // move like the wind
return TRUE
/mob/dead/observer/verb/reenter_corpse()
set category = "Ghost"
set name = "Re-enter Corpse"
if(!client)
return
if(!mind || QDELETED(mind.current))
to_chat(src, span_warning("You have no body."))
return
if(!can_reenter_corpse)
to_chat(src, span_warning("You cannot re-enter your body."))
return
if(mind.current.key && mind.current.key[1] != "@") //makes sure we don't accidentally kick any clients
to_chat(usr, span_warning("Another consciousness is in your body...It is resisting you."))
return
client.view_size.setDefault(getScreenSize(client.prefs.read_preference(/datum/preference/toggle/widescreen)))//Let's reset so people can't become allseeing gods
SStgui.on_transfer(src, mind.current) // Transfer NanoUIs.
mind.current.key = key
mind.current.oobe_client = null //yogs
mind.current.client.init_verbs()
return TRUE
/mob/dead/observer/verb/stay_dead()
set category = "Ghost"
set name = "Do Not Resuscitate"
if(!client)
return
if(!can_reenter_corpse)
to_chat(usr, span_warning("You're already stuck out of your body!"))
return FALSE
var/response = tgui_alert(usr, "Are you sure you want to prevent (almost) all means of resuscitation? This cannot be undone. ","Are you sure you want to stay dead?",list("DNR","Save Me"))
if(response != "DNR")
return
can_reenter_corpse = FALSE
to_chat(src, "You can no longer be brought back into your body.")
return TRUE
/mob/dead/observer/proc/notify_cloning(message, sound, atom/source, flashwindow = TRUE)
if(flashwindow)
window_flash(client)
if(message)
to_chat(src, span_ghostalert("[message]"))
if(source)
var/atom/movable/screen/alert/A = throw_alert("[REF(source)]_notify_cloning", /atom/movable/screen/alert/notify_cloning)
if(A)
var/ui_style = client?.prefs?.read_preference(/datum/preference/choiced/ui_style)
if(ui_style)
A.icon = ui_style2icon(ui_style)
A.desc = message
var/old_layer = source.layer
var/old_plane = source.plane
source.layer = FLOAT_LAYER
source.plane = FLOAT_PLANE
A.add_overlay(source)
source.layer = old_layer
source.plane = old_plane
to_chat(src, span_ghostalert("<a href=?src=[REF(src)];reenter=1>(Click to re-enter)</a>"))
if(sound)
SEND_SOUND(src, sound(sound))
/mob/dead/observer/proc/dead_tele()
set category = "Ghost"
set name = "Teleport"
set desc= "Ghostly Magic"
if(!jump_ui)
jump_ui = new(src)
jump_ui.ui_interact(src)
/mob/dead/observer/verb/follow()
set category = "Ghost"
set name = "Orbit" // "Haunt"
set desc = "Follow and orbit a mob."
if(!orbit_ui)
orbit_ui = new(src)
orbit_ui.ui_interact(src)
// This is the ghost's follow verb with an argument
/mob/dead/observer/proc/ManualFollow(atom/movable/target)
if (!istype(target) || (is_secret_level(target.z) && !client?.holder))
return
//shitcode override so that if you try to follow the AI, you'll get redirected to the AI eye where they're actually looking
if(isAI(target))
var/mob/living/silicon/ai/ai_target = target
if(ai_target.eyeobj)
target = ai_target.eyeobj
var/icon/I = icon(target.icon,target.icon_state,target.dir)
var/orbitsize = (I.Width()+I.Height())*0.5
orbitsize -= (orbitsize/world.icon_size)*(world.icon_size*0.25)
var/rot_seg
switch(ghost_orbit)
if(GHOST_ORBIT_TRIANGLE)
rot_seg = 3
if(GHOST_ORBIT_SQUARE)
rot_seg = 4
if(GHOST_ORBIT_PENTAGON)
rot_seg = 5
if(GHOST_ORBIT_HEXAGON)
rot_seg = 6
else //Circular
rot_seg = 36 //360/10 bby, smooth enough aproximation of a circle
orbit(target,orbitsize, FALSE, 20, rot_seg)
/mob/dead/observer/orbit()
setDir(2)//reset dir so the right directional sprites show up
return ..()
/mob/dead/observer/stop_orbit(datum/component/orbiter/orbits)
. = ..()
//restart our floating animation after orbit is done.
pixel_y = 0
animate(src, pixel_y = 2, time = 1 SECONDS, loop = -1)
/mob/dead/observer/verb/change_view_range()
set category = "Ghost"
set name = "View Range"
set desc = "Change your view range."
//yogs start -- Divert this verb to the admin variant if this guy has it
if(check_rights(R_ADMIN,FALSE) && hascall(usr.client,"toggle_view_range"))
call(usr.client,"toggle_view_range")()
return
//yogs end
var/max_view = client.prefs.unlock_content ? GHOST_MAX_VIEW_RANGE_MEMBER : GHOST_MAX_VIEW_RANGE_DEFAULT
if(client.view_size.getView() == client.view_size.default)
var/list/views = list()
for(var/i in 7 to max_view)
views |= i
var/new_view = tgui_input_list(usr, "Choose your new view", "Modify view range", views)
if(new_view)
client.rescale_view(new_view, 0, ((max_view*2)+1) - 15)
else
client.view_size.resetToDefault()
/mob/dead/observer/verb/add_view_range(input as num)
set name = "Add View Range"
set hidden = TRUE
var/max_view = client.prefs.unlock_content ? GHOST_MAX_VIEW_RANGE_MEMBER : GHOST_MAX_VIEW_RANGE_DEFAULT
if(input)
client.rescale_view(input, 0, ((max_view*2)+1) - 15)
/mob/dead/observer/verb/boo()
set category = "Ghost"
set name = "Boo!"
set desc= "Scare your crew members because of boredom!"
if(bootime > world.time)
return
var/obj/machinery/light/L = locate(/obj/machinery/light) in view(1, src)
if(L)
L.flicker()
bootime = world.time + 600
return
//Maybe in the future we can add more <i>spooky</i> code here!
return
/mob/dead/observer/memory()
set hidden = TRUE
to_chat(src, span_danger("You are dead! You have no mind to store memory!"))
/mob/dead/observer/add_memory()
set hidden = TRUE
to_chat(src, span_danger("You are dead! You have no mind to store memory!"))
/mob/dead/observer/verb/toggle_ghostsee()
set name = "Toggle Ghost Vision"
set desc = "Toggles your ability to see things only ghosts can see, like other ghosts"
set category = "Ghost"
ghostvision = !(ghostvision)
update_sight()
to_chat(usr, "You [ghostvision ? "now" : "no longer"] have ghost vision.")
/mob/dead/observer/verb/toggle_darkness()
set name = "Toggle Darkness"
set category = "Ghost"
switch(lighting_cutoff)
if (LIGHTING_CUTOFF_VISIBLE)
lighting_cutoff = LIGHTING_CUTOFF_MEDIUM
if (LIGHTING_CUTOFF_MEDIUM)
lighting_cutoff = 50
if (50)
lighting_cutoff = LIGHTING_CUTOFF_FULLBRIGHT
else
lighting_cutoff = LIGHTING_CUTOFF_VISIBLE
update_sight()
/mob/dead/observer/update_sight()
if(client)
ghost_others = client.prefs.read_preference(/datum/preference/choiced/ghost_others) //A quick update just in case this setting was changed right before calling the proc
if (!ghostvision)
set_invis_see(SEE_INVISIBLE_LIVING)
else
set_invis_see(SEE_INVISIBLE_OBSERVER)
updateghostimages()
..()
/proc/updateallghostimages()
listclearnulls(GLOB.ghost_images_default)
listclearnulls(GLOB.ghost_images_simple)
for (var/mob/dead/observer/O in GLOB.player_list)
O.updateghostimages()
/mob/dead/observer/proc/updateghostimages()
if (!client)
return
if(lastsetting)
switch(lastsetting) //checks the setting we last came from, for a little efficiency so we don't try to delete images from the client that it doesn't have anyway
if(GHOST_OTHERS_DEFAULT_SPRITE)
client.images -= GLOB.ghost_images_default
if(GHOST_OTHERS_SIMPLE)
client.images -= GLOB.ghost_images_simple
lastsetting = client.prefs.read_preference(/datum/preference/choiced/ghost_others)
if(!ghostvision)
return
if(lastsetting != GHOST_OTHERS_THEIR_SETTING)
switch(lastsetting)
if(GHOST_OTHERS_DEFAULT_SPRITE)
client.images |= (GLOB.ghost_images_default-ghostimage_default)
if(GHOST_OTHERS_SIMPLE)
client.images |= (GLOB.ghost_images_simple-ghostimage_simple)
/mob/dead/observer/verb/possess()
set category = "Ghost"
set name = "Possess!"
set desc= "Take over the body of a mindless creature!"
var/list/possessible = list()
for(var/mob/living/L in GLOB.alive_mob_list)
if(istype(L,/mob/living/carbon/human/dummy) || !get_turf(L)) //Haha no.
continue
if(!(L in GLOB.player_list) && !L.mind)
possessible += L
var/mob/living/target = tgui_input_list(usr, "Your new life begins today!", "Possess Mob", sortUsernames(possessible))
if(!target)
return 0
if(ismegafauna(target) || (target.status_flags & GODMODE))
to_chat(src, span_warning("This creature is too powerful for you to possess!"))
return 0
if(can_reenter_corpse && mind?.current)
if(tgui_alert(usr, "Your soul is still tied to your former life as [mind.current.name], if you go forward there is no going back to that life. Are you sure you wish to continue?", "Move On", list("Yes", "No")) == "No")
return FALSE
if(target.key)
to_chat(src, span_warning("Someone has taken this body while you were choosing!"))
return 0
target.key = key
target.faction = list("neutral")
return 1
//this is a mob verb instead of atom for performance reasons
//see /mob/verb/examinate() in mob.dm for more info
//overridden here and in /mob/living for different point span classes and sanity checks
/mob/dead/observer/pointed(atom/A as mob|obj|turf in view())
if(!..())
return 0
usr.visible_message(span_deadsay("<b>[src]</b> points to [A]."))
return 1
/mob/dead/observer/verb/view_manifest()
set name = "View Crew Manifest"
set category = "Ghost"
if(!client)
return
if(world.time < client.crew_manifest_delay)
return
client.crew_manifest_delay = world.time + (1 SECONDS)
var/dat = "<HTML><HEAD><meta charset='UTF-8'></HEAD><BODY>"
dat += "<h4>Crew Manifest</h4>"
dat += GLOB.data_core.get_manifest_html()
dat += "</BODY></HTML>"
src << browse(dat, "window=manifest;size=387x420;can_close=1")
//this is called when a ghost is drag clicked to something.
/mob/dead/observer/MouseDrop(atom/over)
if(!usr || !over)
return
if (isobserver(usr) && usr.client.holder && (isliving(over) || iscameramob(over)) )
if (usr.client.holder.cmd_ghost_drag(src,over))
return
return ..()
/mob/dead/observer/Topic(href, href_list)
..()
if(usr == src)
if(href_list["follow"])
var/atom/movable/target = locate(href_list["follow"])
if(istype(target) && (target != src))
ManualFollow(target)
return
if(href_list["x"] && href_list["y"] && href_list["z"])
var/tx = text2num(href_list["x"])
var/ty = text2num(href_list["y"])
var/tz = text2num(href_list["z"])
var/turf/target = locate(tx, ty, tz)
if(istype(target))
forceMove(target)
return
if(href_list["reenter"])
reenter_corpse()
return
//We don't want to update the current var
//But we will still carry a mind.
/mob/dead/observer/mind_initialize()
return
/mob/dead/observer/proc/show_data_huds()
for(var/hudtype in datahuds)
var/datum/atom_hud/H = GLOB.huds[hudtype]
H.show_to(src)
/mob/dead/observer/proc/remove_data_huds()
for(var/hudtype in datahuds)
var/datum/atom_hud/H = GLOB.huds[hudtype]
H.hide_from(src)
/mob/dead/observer/verb/toggle_data_huds()
set name = "Toggle Sec/Med/Diag HUD"
set desc = "Toggles whether you see medical/security/diagnostic HUDs"
set category = "Ghost"
if(data_huds_on) //remove old huds
remove_data_huds()
else
show_data_huds()
data_huds_on = !data_huds_on
to_chat(src, span_notice("Data HUDs [data_huds_on ? "enabled" : "disabled"]."))
/mob/dead/observer/verb/toggle_health_scan()
set name = "Toggle Health Scan"
set desc = "Toggles whether you health-scan living beings on click"
set category = "Ghost"
scanmode ^= SCAN_HEALTH
to_chat(src, span_notice("Health scan [scanmode & SCAN_HEALTH ? "enabled" : "disabled"]."))
/mob/dead/observer/verb/toggle_chemical_scan()
set name = "Toggle Chemical Scan"
set desc = "Toggles whether you chem-scan living beings on click"
set category = "Ghost"
scanmode ^= SCAN_CHEM
to_chat(src, span_notice("Chemical scan [scanmode & SCAN_CHEM ? "enabled" : "disabled"]."))
/mob/dead/observer/verb/toggle_nanite_scan()
set name = "Toggle Nanite Scan"
set desc = "Toggles scanning of nanites"
set category = "Ghost"
scanmode ^= SCAN_NANITE
to_chat(src, span_notice("Nanite scan [scanmode & SCAN_NANITE ? "enabled" : "disabled"]."))
/mob/dead/observer/verb/toggle_wound_scan()
set name = "Toggle Wound Scan"
set desc = "Toggles scanning of wounds"
set category = "Ghost"
scanmode ^= SCAN_WOUND
to_chat(src, span_notice("Wound scan [scanmode & SCAN_WOUND ? "enabled" : "disabled"]."))
/mob/dead/observer/verb/toggle_gas_scan()
set name = "Toggle Gas Scan"
set desc = "Toggles whether you analyze gas contents on click"
set category = "Ghost"
scanmode ^= SCAN_GAS
to_chat(src, span_notice("Gas scan [scanmode & SCAN_GAS ? "enabled" : "disabled"]."))
/mob/dead/observer/verb/restore_ghost_appearance()
set name = "Restore Ghost Character"
set desc = "Sets your deadchat name and ghost appearance to your \
roundstart character."
set category = "Ghost"
set_ghost_appearance()
if(client?.prefs)
var/real_name = client.prefs.read_preference(/datum/preference/name/real_name)
deadchat_name = real_name
if(mind)
mind.name = real_name
name = real_name
/mob/dead/observer/proc/set_ghost_appearance()
if((!client) || (!client.prefs))
return
client.prefs.apply_character_randomization_prefs()
var/species_type = client.prefs.read_preference(/datum/preference/choiced/species)
var/datum/species/species = new species_type
if(HAIR in species.species_traits)
hair_style = client.prefs.read_preference(/datum/preference/choiced/hairstyle)
hair_color = brighten_color(client.prefs.read_preference(/datum/preference/color/hair_color))
if(FACEHAIR in species.species_traits)
facial_hair_style = client.prefs.read_preference(/datum/preference/choiced/facial_hairstyle)
facial_hair_color = brighten_color(client.prefs.read_preference(/datum/preference/color/facial_hair_color))
qdel(species)
update_appearance()
/mob/dead/observer/canUseTopic(atom/movable/M, be_close=FALSE, no_dextery=FALSE, no_tk=FALSE)
return IsAdminGhost(usr)
/mob/dead/observer/is_literate()
return TRUE
/mob/dead/observer/vv_edit_var(var_name, var_value)
. = ..()
switch(var_name)
if("icon")
ghostimage_default.icon = icon
ghostimage_simple.icon = icon
if("icon_state")
ghostimage_default.icon_state = icon_state
ghostimage_simple.icon_state = icon_state
if("fun_verbs")
if(fun_verbs)
add_verb(src, /mob/dead/observer/verb/boo)
add_verb(src, /mob/dead/observer/verb/possess)
else
remove_verb(src, /mob/dead/observer/verb/boo)
remove_verb(src, /mob/dead/observer/verb/possess)
/mob/dead/observer/reset_perspective(atom/A)
unobserve_button?.Remove(src)
if(client)
if(ismob(client.eye) && (client.eye != src))
cleanup_observe()
if(..())
if(hud_used)
client.clear_screen()
hud_used.show_hud(hud_used.hud_version)
/mob/dead/observer/proc/cleanup_observe()
if(isnull(observetarget))
return
var/mob/target = observetarget
observetarget = null
client?.perspective = initial(client.perspective)
set_sight(initial(sight))
if(target)
UnregisterSignal(target, COMSIG_MOVABLE_Z_CHANGED)
hide_other_mob_action_buttons(target)
LAZYREMOVE(target.observers, src)
unobserve_button.Remove(src)
update_action_buttons()
/mob/dead/observer/verb/observe()
set name = "Observe"
set category = "Ghost"
if(!isobserver(usr)) //Make sure they're an observer!
return
reset_perspective(null)
var/list/possible_destinations = getpois()
var/target = null
target = tgui_input_list(usr, "Please, select a player!", "Jump to Mob", possible_destinations)
if(isnull(target))
return
if(!isobserver(usr))
return
// In nullspace, invalid as a POI. provisonary till we get new POI system
if(ismob(target))
var/mob/mob_target = target
if(!mob_target.loc)
return
reset_perspective(null)
var/mob/chosen_target = possible_destinations[target]
do_observe(chosen_target)
/mob/dead/observer/proc/do_observe(mob/mob_eye)
if(isnewplayer(mob_eye))
stack_trace("/mob/dead/new_player: \[[mob_eye]\] is being observed by [key_name(src)]. This should never happen and has been blocked.")
message_admins("[ADMIN_LOOKUPFLW(src)] attempted to observe someone in the lobby: [ADMIN_LOOKUPFLW(mob_eye)]. This should not be possible and has been blocked.")
return
if(!isnull(observetarget))
stack_trace("do_observe called on an observer ([src]) who was already observing something! (observing: [observetarget], new target: [mob_eye])")
message_admins("[ADMIN_LOOKUPFLW(src)] attempted to observe someone while already observing someone, \
this is a bug (and a past exploit) and should be investigated.")
return
//Istype so we filter out points of interest that are not mobs
if(client && mob_eye && istype(mob_eye))
client.set_eye(mob_eye)
client.perspective = EYE_PERSPECTIVE
if(is_secret_level(mob_eye.z) && !client?.holder)
set_sight(null) //we dont want ghosts to see through walls in secret areas
RegisterSignal(mob_eye, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(on_observing_z_changed), TRUE)
if(!unobserve_button)
unobserve_button = new(src)
unobserve_button.Grant(src)
if(mob_eye.hud_used)
client.clear_screen()
LAZYOR(mob_eye.observers, src)
mob_eye.hud_used.show_hud(mob_eye.hud_used.hud_version, src)
observetarget = mob_eye
/mob/dead/observer/proc/on_observing_z_changed(datum/source, turf/old_turf, turf/new_turf)
SIGNAL_HANDLER
if(is_secret_level(new_turf.z) && !client?.holder)
set_sight(null) //we dont want ghosts to see through walls in secret areas
else
set_sight(initial(sight))
/datum/action/innate/unobserve
name = "Stop Observing"
desc = "Stops observing the person."
button_icon = 'icons/mob/mob.dmi'
button_icon_state = "ghost_nodir"
show_to_observers = FALSE
/datum/action/innate/unobserve/Activate()
owner.reset_perspective(null)
/datum/action/innate/unobserve/IsAvailable(feedback = FALSE)
return TRUE
/mob/dead/observer/verb/register_pai_candidate()
set category = "Ghost"
set name = "pAI Setup"
set desc = "Upload a fragment of your personality to the global pAI databanks"
register_pai()
/mob/dead/observer/proc/register_pai()
if(isobserver(src))
SSpai.recruitWindow(src)
else
to_chat(usr, "Can't become a pAI candidate while not dead!")
/mob/dead/observer/CtrlShiftClick(mob/user)
if(isobserver(user) && check_rights(R_SPAWN))
change_mob_type( /mob/living/carbon/human , null, null, TRUE) //always delmob, ghosts shouldn't be left lingering
/mob/dead/observer/examine(mob/user)
. = ..()
if(!invisibility)
. += "It seems extremely obvious."
/mob/dead/observer/proc/set_invisibility(value)
invisibility = value
set_light_on(!value ? TRUE : FALSE)
// Ghosts have no momentum, being massless ectoplasm
/mob/dead/observer/Process_Spacemove(movement_dir)
return 1
/mob/dead/observer/vv_edit_var(var_name, var_value)
. = ..()
if(var_name == NAMEOF(src, invisibility))
set_invisibility(invisibility) // updates light
/proc/set_observer_default_invisibility(amount, message=null)
for(var/mob/dead/observer/G in GLOB.player_list)
G.set_invisibility(amount)
if(message)
to_chat(G, message)
GLOB.observer_default_invisibility = amount
/mob/dead/observer/proc/open_spawners_menu()
set name = "Spawners Menu"
set desc = "See all currently available spawners"
set category = "Ghost"
if(!spawners_menu)
spawners_menu = new(src)
spawners_menu.ui_interact(src)
/mob/dead/observer/proc/tray_view()
set category = "Ghost"
set name = "T-ray view"
set desc = "Toggles a view of sub-floor objects"
var/static/t_ray_view = FALSE
t_ray_view = !t_ray_view
var/list/t_ray_images = list()