/
wall_engraver.dm
76 lines (60 loc) · 2.92 KB
/
wall_engraver.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
/// An element that lets you engrave walls when right click is used
/datum/element/wall_engraver
/datum/element/wall_engraver/Attach(datum/target)
. = ..()
if (!isitem(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
RegisterSignal(target, COMSIG_ITEM_PRE_ATTACK_SECONDARY, PROC_REF(on_item_pre_attack_secondary))
/datum/element/wall_engraver/Detach(datum/source)
. = ..()
UnregisterSignal(source, COMSIG_ATOM_EXAMINE)
UnregisterSignal(source, COMSIG_ITEM_PRE_ATTACK_SECONDARY)
///signal called on parent being examined
/datum/element/wall_engraver/proc/on_examine(datum/source, mob/user, list/examine_list)
SIGNAL_HANDLER
examine_list += span_notice("You can engrave some walls with your secondary attack if you can think of something interesting to engrave.")
///signal called on parent being used to right click attack something
/datum/element/wall_engraver/proc/on_item_pre_attack_secondary(datum/source, atom/target, mob/living/user)
SIGNAL_HANDLER
INVOKE_ASYNC(src, PROC_REF(try_chisel), source, target, user)
return COMPONENT_CANCEL_ATTACK_CHAIN
/datum/element/wall_engraver/proc/try_chisel(obj/item/item, turf/closed/wall, mob/living/user)
if(!istype(wall) || !user.mind)
return
if(HAS_TRAIT_FROM(wall, TRAIT_NOT_ENGRAVABLE, INNATE_TRAIT))
user.balloon_alert(user, "wall cannot be engraved!")
return
if(HAS_TRAIT_FROM(wall, TRAIT_NOT_ENGRAVABLE, TRAIT_GENERIC))
user.balloon_alert(user, "wall has already been engraved!")
return
if(!length(user.mind?.memories))
user.balloon_alert(user, "nothing memorable to engrave!")
return
var/datum/memory/memory_to_engrave = user.mind.select_memory("engrave")
if(!memory_to_engrave)
return
if(!user.Adjacent(wall))
return
item.add_fingerprint(user)
playsound(item, item.hitsound, 30, TRUE, -1)
user.do_attack_animation(wall)
user.balloon_alert(user, "engraving wall...")
if(!do_after(user, 5 SECONDS, target = wall))
return
user.balloon_alert(user, "wall engraved")
user.do_attack_animation(wall)
var/do_persistent_save = !(memory_to_engrave.memory_flags & MEMORY_FLAG_NOPERSISTENCE)
var/engraved_story = memory_to_engrave.generate_story(STORY_ENGRAVING, STORY_FLAG_DATED)
if(!engraved_story)
CRASH("Tried to submit a memory with an invalid story [memory_to_engrave]")
wall.AddComponent(/datum/component/engraved, engraved_story, persistent_save = do_persistent_save, story_value = memory_to_engrave.story_value)
memory_to_engrave.memory_flags |= MEMORY_FLAG_ALREADY_USED
//while someone just engraved a story "worth engraving" we should add this to SSpersistence for a possible prison tattoo
if(do_persistent_save)
var/list/tattoo_entry = list()
var/tattoo_story = memory_to_engrave.generate_story(STORY_TATTOO)
if(!tattoo_story)
CRASH("Tried to submit a memory with an invalid story [memory_to_engrave]")
tattoo_entry["story"] = tattoo_story
SSpersistence.prison_tattoos_to_save += list(tattoo_entry)