/
cult_structures.dm
168 lines (145 loc) · 5.44 KB
/
cult_structures.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
// Cult buildings!
/obj/structure/destructible/cult
icon = 'icons/obj/antags/cult/structures.dmi'
break_sound = 'sound/hallucinations/veryfar_noise.ogg'
density = TRUE
anchored = TRUE
light_power = 2
debris = list(/obj/item/stack/sheet/runed_metal = 1)
/// Length of the cooldown between uses.
var/use_cooldown_duration = 5 MINUTES
/// If provided, a bonus tip displayed to cultists on examined.
var/cult_examine_tip
/// The cooldown for when items can be dispensed.
COOLDOWN_DECLARE(use_cooldown)
/obj/structure/destructible/cult/examine_status(mob/user)
if(IS_CULTIST(user) || isobserver(user))
return span_cult("It's at <b>[round(atom_integrity * 100 / max_integrity)]%</b> stability.")
return ..()
/obj/structure/destructible/cult/examine(mob/user)
. = ..()
. += span_notice("[src] is [anchored ? "secured to":"unsecured from"] the floor.")
if(IS_CULTIST(user) || isobserver(user))
if(cult_examine_tip)
. += span_cult(cult_examine_tip)
if(!COOLDOWN_FINISHED(src, use_cooldown_duration))
. += span_cult_italic("The magic in [src] is too weak, it will be ready to use again in <b>[DisplayTimeText(COOLDOWN_TIMELEFT(src, use_cooldown_duration))]</b>.")
/obj/structure/destructible/cult/set_anchored(anchorvalue)
. = ..()
if(isnull(.))
return
update_appearance(UPDATE_ICON)
/obj/structure/destructible/cult/update_icon_state()
icon_state = "[initial(icon_state)][anchored ? "" : "_off"]"
return ..()
/*
* Proc for use with the concealing spell. Hides the building (makes it invisible).
*/
/obj/structure/destructible/cult/proc/conceal()
set_density(FALSE)
visible_message(span_danger("[src] fades away."))
SetInvisibility(INVISIBILITY_OBSERVER, id=type)
alpha = 100
set_light_power(0)
set_light_range(0)
update_light()
/*
* Proc for use with the concealing spell. Reveals the building (makes it visible).
*/
/obj/structure/destructible/cult/proc/reveal()
set_density(initial(density))
RemoveInvisibility(type)
visible_message(span_danger("[src] suddenly appears!"))
alpha = initial(alpha)
set_light_range(initial(light_range))
set_light_power(initial(light_power))
update_light()
// Cult buildings that dispense items to cultists.
/obj/structure/destructible/cult/item_dispenser
/// An associated list of options this structure can make. See setup_options() for format.
var/list/options
/obj/structure/destructible/cult/item_dispenser/Initialize(mapload)
. = ..()
setup_options()
/obj/structure/destructible/cult/item_dispenser/attack_hand(mob/living/user, list/modifiers)
. = ..()
if(.)
return
if(!isliving(user) || !IS_CULTIST(user))
to_chat(user, span_warning("You're pretty sure you know exactly what this is used for and you can't seem to touch it."))
return
if(!anchored)
to_chat(user, span_cult_italic("You need to anchor [src] to the floor first."))
return
if(!COOLDOWN_FINISHED(src, use_cooldown))
to_chat(user, span_cult_italic("The magic in [src] is too weak, it will be ready to use again in <b>[DisplayTimeText(COOLDOWN_TIMELEFT(src, use_cooldown))]</b>."))
return
var/list/spawned_items = get_items_to_spawn(user)
if(!length(spawned_items))
return
if(QDELETED(src) || !anchored || !Adjacent(user) || !check_menu(user) || !COOLDOWN_FINISHED(src, use_cooldown))
return
COOLDOWN_START(src, use_cooldown, use_cooldown_duration)
for(var/item_to_make in spawned_items)
var/obj/item/made_item = new item_to_make(get_turf(src))
succcess_message(user, made_item)
/*
* Set up and populate our list of options.
* Overriden by subtypes.
*
* The list of options is a associated list of format:
* item_name = list(
* preview = image(),
* output = list(paths),
* )
*/
/obj/structure/destructible/cult/item_dispenser/proc/setup_options()
return
/*
* Get all items that this cult building will spawn when interacted with.
* Opens a radial menu for the user and shows them the list of options, which they can choose from.
*
* Return a list: A list of typepaths to items that this building will spawn, chosen by the user.
*/
/obj/structure/destructible/cult/item_dispenser/proc/get_items_to_spawn(mob/living/user)
if(!LAZYLEN(options))
CRASH("[type] did not set any options via setup_options!")
var/list/choices = list()
for(var/item in options)
choices[item] = options[item][PREVIEW_IMAGE]
var/picked_choice = show_radial_menu(
user,
src,
choices,
custom_check = CALLBACK(src, PROC_REF(check_menu), user),
require_near = TRUE,
tooltips = TRUE,
)
if(!picked_choice)
return
return options[picked_choice][OUTPUT_ITEMS]
/*
* Gives feedback to [user] after creating a [spawned_item].
* Override for unique feedback messages on item spawn.
*/
/obj/structure/destructible/cult/item_dispenser/proc/succcess_message(mob/living/user, obj/item/spawned_item)
to_chat(user, span_cult_italic("[src] produces a [spawned_item.name]."))
/*
* Simple proc intended for use in callbacks to determine if [user] can continue to use a radial menu.
*
* Returns TRUE if the user is a living mob that is a cultist and is not incapacitated.
*/
/obj/structure/destructible/cult/item_dispenser/proc/check_menu(mob/user)
return isliving(user) && IS_CULTIST(user) && !user.incapacitated()
// Spooky looking door used in gateways. Or something.
/obj/effect/gateway
name = "gateway"
desc = "You're pretty sure that abyss is staring back."
icon = 'icons/obj/antags/cult/structures.dmi'
icon_state = "hole"
density = TRUE
anchored = TRUE
/obj/effect/gateway/singularity_act()
return
/obj/effect/gateway/singularity_pull()
return