/
mob.dm
1498 lines (1298 loc) · 45.6 KB
/
mob.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
/**
* Delete a mob
*
* Removes mob from the following global lists
* * GLOB.mob_list
* * GLOB.dead_mob_list
* * GLOB.alive_mob_list
* * GLOB.all_clockwork_mobs
* * GLOB.mob_directory
*
* Unsets the focus var
*
* Clears alerts for this mob
*
* Resets all the observers perspectives to the tile this mob is on
*
* qdels any client colours in place on this mob
*
* Clears any refs to the mob inside its current location
*
* Ghostizes the client attached to this mob
*
* If our mind still exists, clear its current var to prevent harddels
*
* Parent call
*/
/mob/Destroy()//This makes sure that mobs with clients/keys are not just deleted from the game.
remove_from_mob_list()
remove_from_dead_mob_list()
remove_from_alive_mob_list()
focus = null
if(length(progressbars))
stack_trace("[src] destroyed with elements in its progressbars list")
progressbars = null
for (var/alert in alerts)
clear_alert(alert, TRUE)
if(observers && observers.len)
for(var/M in observers)
var/mob/dead/observe = M
observe.reset_perspective(null)
for(var/datum/atom_hud/hud as anything in GLOB.all_huds)
hud.remove_from_hud(src)
hud.remove_hud_from(src, TRUE)
qdel(hud_used)
QDEL_LIST(client_colours)
active_storage = null
unset_machine()
clear_client_in_contents() //Gotta do this here as well as Logout, since client will be null by the time it gets there, cause of that ghostize
ghostize() //False, since we're deleting it currently
if(mind?.current == src) //Let's just be safe yeah? This will occasionally be cleared, but not always. Can't do it with ghostize without changing behavior
mind.set_current(null)
return ..()
/**
* Intialize a mob
*
* Sends global signal COMSIG_GLOB_MOB_CREATED
*
* Adds to global lists
* * GLOB.mob_list
* * GLOB.mob_directory (by tag)
* * GLOB.dead_mob_list - if mob is dead
* * GLOB.alive_mob_list - if the mob is alive
*
* Other stuff:
* * Sets the mob focus to itself
* * Generates huds
* * If there are any global alternate apperances apply them to this mob
* * set a random nutrition level
* * Intialize the movespeed of the mob
*/
/mob/Initialize()
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_MOB_CREATED, src)
add_to_mob_list()
if(stat == DEAD)
add_to_dead_mob_list()
else
add_to_alive_mob_list()
set_focus(src)
prepare_huds()
for(var/v in GLOB.active_alternate_appearances)
if(!v)
continue
var/datum/atom_hud/alternate_appearance/AA = v
AA.onNewMob(src)
set_nutrition(rand(NUTRITION_LEVEL_START_MIN, NUTRITION_LEVEL_START_MAX))
. = ..()
update_config_movespeed()
update_movespeed(TRUE)
become_hearing_sensitive(ORGAN_TRAIT)
/**
* Generate the tag for this mob
*
* This is simply "mob_"+ a global incrementing counter that goes up for every mob
*/
/mob/GenerateTag()
tag = "mob_[next_mob_id++]"
/**
* Prepare the huds for this atom
*
* Goes through hud_possible list and adds the images to the hud_list variable (if not already
* cached)
*/
/atom/proc/prepare_huds()
hud_list = list()
for(var/hud in hud_possible)
var/hint = hud_possible[hud]
switch(hint)
if(HUD_LIST_LIST)
hud_list[hud] = list()
else
var/image/I = image('icons/mob/hud.dmi', src, "")
I.appearance_flags = RESET_COLOR|RESET_TRANSFORM
hud_list[hud] = I
/**
* Some kind of debug verb that gives atmosphere environment details
*/
/mob/proc/Cell()
set category = "Admin"
set hidden = 1
if(!loc)
return 0
var/datum/gas_mixture/environment = loc.return_air()
var/t = "<span class='notice'>Coordinates: [x],[y] \n</span>"
t += "<span class='danger'>Temperature: [environment.return_temperature()] \n</span>"
for(var/id in environment.get_gases())
if(environment.get_moles(id))
t+="<span class='notice'>[GLOB.gas_data.names[id]]: [environment.get_moles(id)] \n</span>"
to_chat(usr, t)
/**
* Return the desc of this mob for a photo
*/
/mob/proc/get_photo_description(obj/item/camera/camera)
return "a ... thing?"
/**
* Show a message to this mob (visual or audible)
*/
/mob/proc/show_message(msg, type, alt_msg, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2)
if(!client)
return
msg = copytext_char(msg, 1, MAX_MESSAGE_LEN)
if(type)
if(type & MSG_VISUAL && is_blind())//Vision related
if(!alt_msg)
return
else
msg = alt_msg
type = alt_type
if(type & MSG_AUDIBLE && !can_hear())//Hearing related
if(!alt_msg)
return
else
msg = alt_msg
type = alt_type
if(type & MSG_VISUAL && is_blind())
return
// voice muffling
if(stat == UNCONSCIOUS || stat == HARD_CRIT)
if(type & MSG_AUDIBLE) //audio
to_chat(src, "<I>... You can almost hear something ...</I>")
return
to_chat(src, msg)
/**
* Generate a visible message from this atom
*
* Show a message to all player mobs who sees this atom
*
* Show a message to the src mob (if the src is a mob)
*
* Use for atoms performing visible actions
*
* message is output to anyone who can see, e.g. "The [src] does something!"
*
* Vars:
* * self_message (optional) is what the src mob sees e.g. "You do something!"
* * blind_message (optional) is what blind people will hear e.g. "You hear something!"
* * vision_distance (optional) define how many tiles away the message can be seen.
* * ignored_mob (optional) doesn't show any message to a given mob if TRUE.
*/
/atom/proc/visible_message(message, self_message, blind_message, vision_distance = DEFAULT_MESSAGE_RANGE, list/ignored_mobs, visible_message_flags = NONE, separation = " ")
var/turf/T = get_turf(src)
if(!T)
return
if(!islist(ignored_mobs))
ignored_mobs = list(ignored_mobs)
var/list/hearers = get_hearers_in_view(vision_distance, src) //caches the hearers and then removes ignored mobs.
hearers -= ignored_mobs
if(self_message)
hearers -= src
for(var/mob/M in hearers)
if(!M.client)
continue
var/msg = message
//This entire if/else chain could be in two lines but isn't for readibilties sake.
if(M.see_invisible < invisibility)//if src is invisible to M
msg = blind_message
else if(T != loc && T != src) //if src is inside something and not a turf.
msg = blind_message
else if(T.lighting_object && T.lighting_object.invisibility <= M.see_invisible && T.is_softly_lit()) //if it is too dark.
msg = blind_message
else if(visible_message_flags & EMOTE_MESSAGE)
var/shown_name = name
if(M.mind?.guestbook && ishuman(src))
var/mob/living/carbon/human/human_source = src
var/known_name = M.mind.guestbook.get_known_name(M, src, human_source.get_face_name())
if(known_name)
shown_name = known_name
msg = "<span class='emote'><b>[shown_name]</b>[separation][message]</span>"
if(!msg)
continue
if(visible_message_flags & EMOTE_MESSAGE && runechat_prefs_check(M, visible_message_flags))
M.create_chat_message(src, raw_message = message, runechat_flags = visible_message_flags)
M.show_message(msg, MSG_VISUAL, blind_message, MSG_AUDIBLE)
///Adds the functionality to self_message.
/mob/visible_message(message, self_message, blind_message, vision_distance = DEFAULT_MESSAGE_RANGE, list/ignored_mobs, visible_message_flags = NONE, separation = " ")
. = ..()
if(self_message)
show_message(self_message, MSG_VISUAL, blind_message, MSG_AUDIBLE)
/**
* Show a message to all mobs in earshot of this atom
*
* Use for objects performing audible actions
*
* vars:
* * message is the message output to anyone who can hear.
* * deaf_message (optional) is what deaf people will see.
* * hearing_distance (optional) is the range, how many tiles away the message can be heard.
*/
/atom/proc/audible_message(message, deaf_message, hearing_distance = DEFAULT_MESSAGE_RANGE, self_message, audible_message_flags = NONE, list/ignored_mobs, separation = " ")
var/list/hearers = get_hearers_in_view(hearing_distance, src)
if(self_message)
hearers -= src
var/raw_msg = message
for(var/mob/M in hearers)
var/msg = raw_msg
//emote handling
if(audible_message_flags & EMOTE_MESSAGE)
var/shown_name = name
if(M.mind?.guestbook && ishuman(src))
var/mob/living/carbon/human/human_source = src
var/known_name = M.mind.guestbook.get_known_name(M, src, human_source.GetVoice())
if(known_name)
shown_name = known_name
msg = "<span class='emote'><b>[shown_name]</b>[separation][message]</span>"
if(runechat_prefs_check(M, audible_message_flags) && M.can_hear())
M.create_chat_message(src, raw_message = raw_msg, runechat_flags = audible_message_flags)
M.show_message(msg, MSG_AUDIBLE, deaf_message, MSG_VISUAL)
/**
* Show a message to all mobs in earshot of this one
*
* This would be for audible actions by the src mob
*
* vars:
* * message is the message output to anyone who can hear.
* * self_message (optional) is what the src mob hears.
* * deaf_message (optional) is what deaf people will see.
* * hearing_distance (optional) is the range, how many tiles away the message can be heard.
*/
/mob/audible_message(message, deaf_message, hearing_distance = DEFAULT_MESSAGE_RANGE, self_message, audible_message_flags = NONE, list/ignored_mobs, separation = " ")
. = ..()
if(self_message)
show_message(self_message, MSG_AUDIBLE, deaf_message, MSG_VISUAL)
///Returns the client runechat visible messages preference according to the message type.
/atom/proc/runechat_prefs_check(mob/target, visible_message_flags = NONE)
if(!target.client?.prefs.chat_on_map || !target.client.prefs.see_chat_non_mob)
return FALSE
if(visible_message_flags & EMOTE_MESSAGE && !target.client.prefs.see_rc_emotes)
return FALSE
return TRUE
/mob/runechat_prefs_check(mob/target, message, visible_message_flags = NONE)
if(!target.client?.prefs.chat_on_map)
return FALSE
if(visible_message_flags & EMOTE_MESSAGE && !target.client.prefs.see_rc_emotes)
return FALSE
return TRUE
///Get the item on the mob in the storage slot identified by the id passed in
/mob/proc/get_item_by_slot(slot_id)
return null
///Is the mob incapacitated
/mob/proc/incapacitated(ignore_restraints = FALSE, ignore_grab = FALSE, check_immobilized = FALSE)
return
/**
* This proc is called whenever someone clicks an inventory ui slot.
*
* Mostly tries to put the item into the slot if possible, or call attack hand
* on the item in the slot if the users active hand is empty
*/
/mob/proc/attack_ui(slot)
var/obj/item/W = get_active_held_item()
if(istype(W))
//IF HELD TRY APPLY TO SLOT
if(equip_to_slot_if_possible(W, slot,0,0,0))
W.apply_outline()
return 1
//IF NO ITEM IS HELD, APPLY TO SLOT
if(!W)
// Activate the item
var/obj/item/I = get_item_by_slot(slot)
if(istype(I))
I.attack_hand(src)
return 0
/**
* Try to equip an item to a slot on the mob
*
* This is a SAFE proc. Use this instead of equip_to_slot()!
*
* set qdel_on_fail to have it delete W if it fails to equip
*
* set disable_warning to disable the 'you are unable to equip that' warning.
*
* unset redraw_mob to prevent the mob icons from being redrawn at the end.
*
* Initial is used to indicate whether or not this is the initial equipment (job datums etc) or just a player doing it
*/
/mob/proc/equip_to_slot_if_possible(obj/item/W, slot, qdel_on_fail = FALSE, disable_warning = FALSE, redraw_mob = TRUE, bypass_equip_delay_self = FALSE, initial = FALSE, swap = FALSE)
if(!istype(W))
return FALSE
if(!W.mob_can_equip(src, null, slot, disable_warning, bypass_equip_delay_self, swap))
if(qdel_on_fail)
qdel(W)
else
if(!disable_warning)
to_chat(src, "<span class='warning'>You are unable to equip that!</span>")
return FALSE
equip_to_slot(W, slot, initial, redraw_mob, swap) //This proc should not ever fail.
return TRUE
/**
* Actually equips an item to a slot (UNSAFE)
*
* This is an UNSAFE proc. It merely handles the actual job of equipping. All the checks on
* whether you can or can't equip need to be done before! Use mob_can_equip() for that task.
*
*In most cases you will want to use equip_to_slot_if_possible()
*/
/mob/proc/equip_to_slot(obj/item/W, slot)
return
/**
* Equip an item to the slot or delete
*
* This is just a commonly used configuration for the equip_to_slot_if_possible() proc, used to
* equip people when the round starts and when events happen and such.
*
* Also bypasses equip delay checks, since the mob isn't actually putting it on.
* Initial is used to indicate whether or not this is the initial equipment (job datums etc) or just a player doing it
*/
/mob/proc/equip_to_slot_or_del(obj/item/W, slot, initial = FALSE)
return equip_to_slot_if_possible(W, slot, TRUE, TRUE, FALSE, TRUE, initial)
/**
* Auto equip the passed in item the appropriate slot based on equipment priority
*
* puts the item "W" into an appropriate slot in a human's inventory
*
* returns 0 if it cannot, 1 if successful
*/
/mob/proc/equip_to_appropriate_slot(obj/item/W, swap=FALSE)
if(!istype(W))
return 0
var/slot_priority = W.slot_equipment_priority
if(!slot_priority)
slot_priority = list( \
ITEM_SLOT_BACK, ITEM_SLOT_ID,\
ITEM_SLOT_ICLOTHING, ITEM_SLOT_OCLOTHING,\
ITEM_SLOT_MASK, ITEM_SLOT_HEAD, ITEM_SLOT_NECK,\
ITEM_SLOT_FEET, ITEM_SLOT_GLOVES,\
ITEM_SLOT_EARS, ITEM_SLOT_EYES,\
ITEM_SLOT_BELT, ITEM_SLOT_SUITSTORE,\
ITEM_SLOT_LPOCKET, ITEM_SLOT_RPOCKET,\
ITEM_SLOT_DEX_STORAGE\
)
for(var/slot in slot_priority)
if(equip_to_slot_if_possible(W, slot, FALSE, TRUE, TRUE, FALSE, FALSE, swap)) //qdel_on_fail = FALSE; disable_warning = TRUE; redraw_mob = TRUE;
return 1
return 0
/**
* Reset the attached clients perspective (viewpoint)
*
* reset_perspective() set eye to common default : mob on turf, loc otherwise
* reset_perspective(thing) set the eye to the thing (if it's equal to current default reset to mob perspective)
*/
/mob/proc/reset_perspective(atom/A)
if(client)
if(A)
if(ismovable(A))
//Set the the thing unless it's us
if(A != src)
client.perspective = EYE_PERSPECTIVE
client.eye = A
else
client.eye = client.mob
client.perspective = MOB_PERSPECTIVE
else if(isturf(A))
//Set to the turf unless it's our current turf
if(A != loc)
client.perspective = EYE_PERSPECTIVE
client.eye = A
else
client.eye = client.mob
client.perspective = MOB_PERSPECTIVE
else
//Do nothing
else
//Reset to common defaults: mob if on turf, otherwise current loc
if(isturf(loc))
client.eye = client.mob
client.perspective = MOB_PERSPECTIVE
else
client.perspective = EYE_PERSPECTIVE
client.eye = loc
return 1
/// Show the mob's inventory to another mob
/mob/proc/show_inv(mob/user)
return
/**
* Examine a mob
*
* mob verbs are faster than object verbs. See
* [this byond forum post](https://secure.byond.com/forum/?post=1326139&page=2#comment8198716)
* for why this isn't atom/verb/examine()
*/
/mob/verb/examinate(atom/examinify as mob|obj|turf in view()) //It used to be oview(12), but I can't really say why
set name = "Examine"
set category = "IC"
DEFAULT_QUEUE_OR_CALL_VERB(VERB_CALLBACK(src, PROC_REF(run_examinate), examinify))
/mob/proc/run_examinate(atom/examinify)
if(isturf(examinify) && !(sight & SEE_TURFS) && !(examinify in view(client ? client.view : world.view, src)))
// shift-click catcher may issue examinate() calls for out-of-sight turfs
return
if(is_blind() && !blind_examine_check(examinify)) //blind people see things differently (through touch)
return
face_atom(examinify)
var/list/result
if(client)
LAZYINITLIST(client.recent_examines)
if(isnull(client.recent_examines[examinify]) || client.recent_examines[examinify] < world.time)
result = examinify.examine(src)
client.recent_examines[examinify] = world.time + EXAMINE_MORE_TIME // set the value to when the examine cooldown ends
RegisterSignal(examinify, COMSIG_PARENT_QDELETING, PROC_REF(clear_from_recent_examines), override=TRUE) // to flush the value if deleted early
addtimer(CALLBACK(src, PROC_REF(clear_from_recent_examines), examinify), EXAMINE_MORE_TIME)
handle_eye_contact(examinify)
else
result = examinify.examine_more(src)
else
result = examinify.examine(src) // if a tree is examined but no client is there to see it, did the tree ever really exist?
if(result.len)
for(var/i in 1 to (length(result) - 1))
result[i] += "\n"
to_chat(src, examine_block("<span class='infoplain'>[result.Join()]</span>"))
SEND_SIGNAL(src, COMSIG_MOB_EXAMINATE, examinify)
/mob/proc/blind_examine_check(atom/examined_thing)
return TRUE //The non-living will always succeed at this check.
/mob/living/blind_examine_check(atom/examined_thing)
//need to be next to something and awake
if(!in_range(examined_thing, src) || incapacitated())
to_chat(src, "<span class='warning'>Something is there, but you can't see it!</span>")
return FALSE
//also neeed an empty hand, and you can only initiate as many examines as you have hands
if(LAZYLEN(do_afters) >= usable_hands || get_active_held_item())
to_chat(src, "<span class='warning'>You don't have a free hand to examine this!</span>")
return FALSE
//can only queue up one examine on something at a time
if(examined_thing in do_afters)
return FALSE
to_chat(src, "<span class='notice'>You start feeling around for something...</span>")
visible_message("<span class='notice'> [name] begins feeling around for \the [examined_thing.name]...</span>")
/// how long it takes for the blind person to find the thing they're examining
var/examine_delay_length = rand(1 SECONDS, 2 SECONDS)
if(client?.recent_examines && client?.recent_examines[examined_thing]) //easier to find things we just touched
examine_delay_length = 0.5 SECONDS
else if(isobj(examined_thing))
examine_delay_length *= 1.5
else if(ismob(examined_thing) && examined_thing != src)
examine_delay_length *= 2
if(examine_delay_length > 0 && !do_after(src, examine_delay_length, target = examined_thing))
to_chat(src, "<span class='notice'>You can't get a good feel for what is there.</span>")
return FALSE
//now we touch the thing we're examining
/// our current intent, so we can go back to it after touching
var/previous_intent = a_intent
a_intent = INTENT_HELP
examined_thing.attack_hand(src)
a_intent = previous_intent
return TRUE
/mob/proc/clear_from_recent_examines(atom/A)
SIGNAL_HANDLER
if(!client)
return
UnregisterSignal(A, COMSIG_PARENT_QDELETING)
LAZYREMOVE(client.recent_examines, A)
/**
* handle_eye_contact() is called when we examine() something. If we examine an alive mob with a mind who has examined us in the last second within 5 tiles, we make eye contact!
*
* Note that if either party has their face obscured, the other won't get the notice about the eye contact
* Also note that examine_more() doesn't proc this or extend the timer, just because it's simpler this way and doesn't lose much.
* The nice part about relying on examining is that we don't bother checking visibility, because we already know they were both visible to each other within the last second, and the one who triggers it is currently seeing them
*/
/mob/proc/handle_eye_contact(mob/living/examined_mob)
return
/mob/living/handle_eye_contact(mob/living/examined_mob)
if(!istype(examined_mob) || src == examined_mob || examined_mob.stat >= UNCONSCIOUS || !client || !examined_mob.client?.recent_examines || !(src in examined_mob.client.recent_examines))
return
if(get_dist(src, examined_mob) > EYE_CONTACT_RANGE)
return
// check to see if their face is blocked or, if not, a signal blocks it
if(examined_mob.is_face_visible() && SEND_SIGNAL(src, COMSIG_MOB_EYECONTACT, examined_mob, TRUE) != COMSIG_BLOCK_EYECONTACT)
var/msg = "<span class='smallnotice'>You make eye contact with [examined_mob].</span>"
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(to_chat), src, msg), 3) // so the examine signal has time to fire and this will print after
if(is_face_visible() && SEND_SIGNAL(examined_mob, COMSIG_MOB_EYECONTACT, src, FALSE) != COMSIG_BLOCK_EYECONTACT)
var/msg = "<span class='smallnotice'>[src] makes eye contact with you.</span>"
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(to_chat), examined_mob, msg), 3)
/**
* Called by using Activate Held Object with an empty hand/limb
*
* Does nothing by default. The intended use is to allow limbs to call their
* own attack_self procs. It is up to the individual mob to override this
* parent and actually use it.
*/
/mob/proc/limb_attack_self()
return
///Can this mob resist (default FALSE)
/mob/proc/can_resist()
return FALSE //overridden in living.dm
///Spin this mob around it's central axis
/mob/proc/spin(spintime, speed)
set waitfor = 0
var/D = dir
if((spintime < 1)||(speed < 1)||!spintime||!speed)
return
while(spintime >= speed)
sleep(speed)
switch(D)
if(NORTH)
D = EAST
if(SOUTH)
D = WEST
if(EAST)
D = SOUTH
if(WEST)
D = NORTH
setDir(D)
spintime -= speed
///Update the pulling hud icon
/mob/proc/update_pull_hud_icon()
hud_used?.pull_icon?.update_appearance()
///Update the resting hud icon
/mob/proc/update_rest_hud_icon()
hud_used?.rest_icon?.update_appearance()
/**
* Verb to activate the object in your held hand
*
* Calls attack self on the item and updates the inventory hud for hands
*/
/mob/verb/mode()
set name = "Activate Held Object"
set category = "Object"
set src = usr
DEFAULT_QUEUE_OR_CALL_VERB(VERB_CALLBACK(src, PROC_REF(execute_mode)))
///proc version to finish /mob/verb/mode() execution. used in case the proc needs to be queued for the tick after its first called
/mob/proc/execute_mode()
if(ismecha(loc))
return
if(incapacitated())
return
var/obj/item/I = get_active_held_item()
if(I)
I.attack_self(src)
update_inv_hands()
return
limb_attack_self()
/mob/verb/do_unique_action()
set name = "Do Unique Action"
set category = "Object"
set src = usr
if(ismecha(loc))
return
if(incapacitated())
return
var/obj/item/I = get_active_held_item()
if(I)
I.unique_action(src)
update_inv_hands()
/**
* Get the notes of this mob
*
* This actually gets the mind datums notes
*/
/mob/verb/memory()
set name = "Notes"
set category = "IC"
set desc = "View your character's notes memory."
if(mind)
mind.show_memory(src)
else
to_chat(src, "You don't have a mind datum for some reason, so you can't look at your notes, if you had any.")
/**
* Add a note to the mind datum
*/
/mob/verb/add_memory(msg as message)
set name = "Add Note"
set category = "IC"
if(mind)
if (world.time < memory_throttle_time)
return
memory_throttle_time = world.time + 5 SECONDS
msg = copytext_char(msg, 1, MAX_MESSAGE_LEN)
msg = sanitize(msg)
mind.store_memory(msg)
else
to_chat(src, "You don't have a mind datum for some reason, so you can't add a note to it.")
///Shows guestbook tgui window
/mob/verb/guestbook()
set name = "Guestbook"
set category = "IC"
set desc = "View your character's Guestbook."
// the reason why there are two observer checks in here is because the mind datum sometimes carries over to ghosts.
// this is something i should probably fix instead of adding a fallback check, but...
if(isobserver(src))
to_chat(src, span_warning("You have to be in the current round to do that!"))
return
if(!mind)
var/fail_message = "You have no mind!"
if(isobserver(src))
fail_message += " You have to be in the current round at some point to have one."
to_chat(src, span_warning(fail_message))
return
mind.guestbook.ui_interact(usr)
/**
* Allows you to respawn, abandoning your current mob
*
* This sends you back to the lobby creating a new dead mob
*
* Only works if flag/norespawn is allowed in config
*/
/mob/verb/abandon_mob()
set name = "Respawn"
set category = "OOC"
if ((stat != DEAD || !(SSticker)) || !isobserver(usr))
to_chat(usr, "<span class='boldnotice'>You must be dead to use this!</span>")
return
var/respawn_timer = CONFIG_GET(number/respawn_timer)
if(!respawn_timer)
return
var/admin_bypass = FALSE
if(client?.holder)
var/poll_client = tgui_alert(usr, "Would you like to use your rank to bypass a potential respawn timer?", "Admin Alert", list("Yes", "No"))
if(poll_client == "Yes")
admin_bypass = TRUE
message_admins("[key_name_admin(usr)] has used admin permissions to bypass respawn restrictions.")
log_game("key_name(usr) used admin permissions to bypass respawn restrictions.")
if (CONFIG_GET(flag/norespawn) && !admin_bypass)
return
var/usrkey = client?.ckey
if(!usrkey)
log_game("[key_name(usr)] AM failed due to disconnect.")
if(GLOB.respawn_timers[usrkey] && !admin_bypass)
var/time_left = GLOB.respawn_timers[usrkey] + respawn_timer - REALTIMEOFDAY
if(time_left > 0)
to_chat(usr, "<span class='boldnotice'>You still have [DisplayTimeText(time_left)] left before you can respawn.</span>")
return
GLOB.respawn_timers -= usrkey
log_game("[key_name(usr)] used abandon mob.")
to_chat(usr, "<span class='boldnotice'>Please roleplay correctly!</span>")
if(!client)
log_game("[key_name(usr)] AM failed due to disconnect.")
return
client.screen.Cut()
client.screen += client.void
if(!client)
log_game("[key_name(usr)] AM failed due to disconnect.")
return
var/mob/dead/new_player/M = new /mob/dead/new_player()
if(!client)
log_game("[key_name(usr)] AM failed due to disconnect.")
qdel(M)
return
M.key = key
// M.Login() //wat
return
/**
* Sometimes helps if the user is stuck in another perspective or camera
*/
/mob/verb/cancel_camera()
set name = "Cancel Camera View"
set category = "OOC"
reset_perspective(null)
unset_machine()
//suppress the .click/dblclick macros so people can't use them to identify the location of items or aimbot
/mob/verb/DisClick(argu = null as anything, sec = "" as text, number1 = 0 as num , number2 = 0 as num)
set name = ".click"
set hidden = TRUE
set category = null
return
/mob/verb/DisDblClick(argu = null as anything, sec = "" as text, number1 = 0 as num , number2 = 0 as num)
set name = ".dblclick"
set hidden = TRUE
set category = null
return
/**
* Topic call back for any mob
*
* * Unset machines if "mach_close" sent
* * refresh the inventory of machines in range if "refresh" sent
* * handles the strip panel equip and unequip as well if "item" sent
*/
/mob/Topic(href, href_list)
var/mob/user = usr
if(href_list["mach_close"])
var/t1 = text("window=[href_list["mach_close"]]")
unset_machine()
src << browse(null, t1)
if(href_list["flavor_more"])
usr << browse(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", name, replacetext(flavor_text, "\n", "<BR>")), text("window=[];size=500x200", name))
onclose(usr, "[name]")
if(user != src)
if(href_list["item"] && user.canUseTopic(src, BE_CLOSE, NO_DEXTERITY))
var/slot = text2num(href_list["item"])
var/hand_index = text2num(href_list["hand_index"])
var/obj/item/what
if(hand_index)
what = get_item_for_held_index(hand_index)
slot = list(slot,hand_index)
else
what = get_item_by_slot(slot)
if(what)
if(!(what.item_flags & ABSTRACT))
user.stripPanelUnequip(what,src,slot)
else
user.stripPanelEquip(what,src,slot)
if(user.machine == src)
if(Adjacent(user))
show_inv(user)
else
user << browse(null,"window=mob[REF(src)]")
// The src mob is trying to strip an item from someone
// Defined in living.dm
/mob/proc/stripPanelUnequip(obj/item/what, mob/who)
return
// The src mob is trying to place an item on someone
// Defined in living.dm
/mob/proc/stripPanelEquip(obj/item/what, mob/who)
return
/**
* Controls if a mouse drop succeeds (return null if it doesnt)
*/
/mob/MouseDrop(mob/M)
. = ..()
if(M != usr)
return
if(usr == src)
return
if(!Adjacent(usr))
return
if(isAI(M))
return
/**
* Handle the result of a click drag onto this mob
*
* For mobs this just shows the inventory
*/
/mob/MouseDrop_T(atom/dropping, atom/user)
. = ..()
if(ismob(dropping) && dropping != user)
var/mob/M = dropping
if(ismob(user))
var/mob/U = user
if(!iscyborg(U) || U.a_intent == INTENT_HARM)
M.show_inv(U)
else
M.show_inv(user)
///Is the mob muzzled (default false)
/mob/proc/is_muzzled()
return 0
/// Adds this list to the output to the stat browser
/mob/proc/get_status_tab_items()
. = list("") //we want to offset unique stuff from standard stuff
SEND_SIGNAL(src, COMSIG_MOB_GET_STATUS_TAB_ITEMS, .)
/// Gets all relevant proc holders for the browser statpenl
/mob/proc/get_proc_holders()
. = list()
if(mind)
. += get_spells_for_statpanel(mind.spell_list)
. += get_spells_for_statpanel(mob_spell_list)
/**
* Convert a list of spells into a displyable list for the statpanel
*
* Shows charge and other important info
*/
/mob/proc/get_spells_for_statpanel(list/spells)
var/list/L = list()
for(var/obj/effect/proc_holder/spell/S in spells)
if(S.can_be_cast_by(src))
switch(S.charge_type)
if("recharge")
L[++L.len] = list("[S.panel]", "[S.charge_counter/10.0]/[S.charge_max/10]", S.name, REF(S))
if("charges")
L[++L.len] = list("[S.panel]", "[S.charge_counter]/[S.charge_max]", S.name, REF(S))
if("holdervar")
L[++L.len] = list("[S.panel]", "[S.holder_var_type] [S.holder_var_amount]", S.name, REF(S))
return L
#define MOB_FACE_DIRECTION_DELAY 1
// facing verbs
/**
* Returns true if a mob can turn to face things
*
* Conditions:
* * client.last_turn > world.time
* * not dead or unconcious
* * not anchored
* * no transform not set
* * we are not restrained
*/
/mob/proc/canface()
if(world.time < client.last_turn)
return FALSE
if(stat >= UNCONSCIOUS)
return FALSE
if(anchored)
return FALSE
if(notransform)
return FALSE
if(HAS_TRAIT(src, TRAIT_RESTRAINED))
return FALSE
return TRUE
///Checks mobility move as well as parent checks
/mob/living/canface()
if(!(mobility_flags & MOBILITY_MOVE))
return FALSE
return ..()
/mob/dead/observer/canface()
return TRUE
///Hidden verb to turn east
/mob/verb/eastface()
set hidden = TRUE
if(!canface())
return FALSE
setDir(EAST)
client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY
return TRUE
///Hidden verb to turn west
/mob/verb/westface()
set hidden = TRUE
if(!canface())
return FALSE
setDir(WEST)
client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY
return TRUE
///Hidden verb to turn north
/mob/verb/northface()
set hidden = TRUE
if(!canface())
return FALSE
setDir(NORTH)
client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY
return TRUE
///Hidden verb to turn south
/mob/verb/southface()
set hidden = TRUE
if(!canface())
return FALSE
setDir(SOUTH)
client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY
return TRUE
///This might need a rename but it should replace the can this mob use things check
/mob/proc/IsAdvancedToolUser()
return FALSE
/mob/proc/swap_hand()
var/obj/item/held_item = get_active_held_item()
if(SEND_SIGNAL(src, COMSIG_MOB_SWAP_HANDS, held_item) & COMPONENT_BLOCK_SWAP)
to_chat(src, "<span class='warning'>Your other hand is too busy holding [held_item].</span>")