This repository was archived by the owner on May 22, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 459
Expand file tree
/
Copy pathabandoned_crates.dm
More file actions
252 lines (235 loc) · 8.35 KB
/
Copy pathabandoned_crates.dm
File metadata and controls
252 lines (235 loc) · 8.35 KB
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
//Originally coded by ISaidNo, later modified by Kelenius. Ported from Baystation12.
/obj/structure/closet/crate/secure/loot
name = "abandoned crate"
desc = "What could be inside?"
icon_state = "securecrate"
integrity_failure = 0 //no breaking open the crate
tamperproof = 90
var/code = null
var/lastattempt = null
var/attempts = 10
var/codelen = 4
/obj/structure/closet/crate/secure/loot/Initialize(mapload)
. = ..()
var/list/digits = list("1", "2", "3", "4", "5", "6", "7", "8", "9", "0")
code = ""
for(var/i = 0, i < codelen, i++)
var/dig = pick(digits)
code += dig
digits -= dig //there are never matching digits in the answer
/obj/structure/closet/crate/secure/loot/update_overlays()
. = ..()
tamperproof = initial(tamperproof)
if(!locked)
. += "securecrateg"
tamperproof = 0 // set explosion chance to zero, so we dont accidently hit it with a multitool and instantly die
/obj/structure/closet/crate/secure/loot/PopulateContents()
. = ..()
var/loot = rand(1,100) //100 different crates with varying chances of spawning
switch(loot)
if(1 to 5) //5% chance
new /obj/item/reagent_containers/food/drinks/bottle/rum(src)
new /obj/item/reagent_containers/food/snacks/grown/ambrosia/deus(src)
new /obj/item/reagent_containers/food/drinks/bottle/whiskey(src)
new /obj/item/lighter(src)
if(6 to 10)
new /obj/item/bedsheet(src)
new /obj/item/kitchen/knife(src)
new /obj/item/wirecutters(src)
new /obj/item/screwdriver(src)
new /obj/item/weldingtool(src)
new /obj/item/hatchet(src)
new /obj/item/crowbar(src)
if(11 to 15)
new /obj/item/reagent_containers/glass/beaker/bluespace(src)
if(16 to 20)
new /obj/item/stack/ore/diamond(src, 10)
if(21 to 25)
for(var/i in 1 to 5)
new /obj/item/poster/random_contraband(src)
if(26 to 30)
for(var/i in 1 to 3)
new /obj/item/reagent_containers/glass/beaker/noreact(src)
if(31 to 35)
new /obj/item/seeds/firelemon(src)
if(36 to 40)
new /obj/item/melee/baton(src)
if(41 to 45)
new /obj/item/clothing/under/shorts/red(src)
new /obj/item/clothing/under/shorts/blue(src)
if(46 to 50)
new /obj/item/clothing/under/chameleon(src)
for(var/i in 1 to 7)
new /obj/item/clothing/neck/tie/horrible(src)
if(51 to 52) // 2% chance
new /obj/item/melee/classic_baton(src)
if(53 to 54)
new /obj/item/toy/balloon(src)
if(55 to 56)
var/newitem = pick(subtypesof(/obj/item/toy/prize))
new newitem(src)
if(57 to 58)
new /obj/item/toy/syndicateballoon(src)
if(59 to 60)
new /obj/item/borg/upgrade/modkit/aoe/mobs(src)
new /obj/item/clothing/suit/space(src)
new /obj/item/clothing/head/helmet/space(src)
if(61 to 62)
for(var/i in 1 to 5)
new /obj/item/clothing/head/kitty(src)
new /obj/item/clothing/neck/petcollar(src)
if(63 to 64)
for(var/i in 1 to rand(4, 7))
var/newcoin = pickweight(list(
/obj/item/coin/silver = 3,
/obj/item/coin/iron = 3,
/obj/item/coin/gold = 1,
/obj/item/coin/diamond = 1,
/obj/item/coin/plasma = 1,
/obj/item/coin/uranium = 1,
))
new newcoin(src)
if(65 to 66)
new /obj/item/clothing/suit/ianshirt(src)
new /obj/item/clothing/suit/hooded/ian_costume(src)
if(67 to 68)
for(var/i in 1 to rand(4, 7))
var/newitem = pick(subtypesof(/obj/item/stock_parts) - /obj/item/stock_parts/subspace)
new newitem(src)
if(69 to 70)
new /obj/item/stack/ore/bluespace_crystal(src, 5)
if(71 to 72)
new /obj/item/pickaxe/drill(src)
if(73 to 74)
new /obj/item/pickaxe/drill/jackhammer(src)
if(75 to 76)
new /obj/item/pickaxe/diamond(src)
if(77 to 78)
new /obj/item/pickaxe/drill/diamonddrill(src)
if(79 to 80)
new /obj/item/cane(src)
new /obj/item/clothing/head/collectable/tophat(src)
if(81 to 82)
new /obj/item/gun/energy/plasmacutter(src)
if(83 to 84)
new /obj/item/toy/katana(src)
if(85 to 86)
new /obj/item/defibrillator/compact(src)
if(87) //1% chance
new /obj/item/weed_extract(src)
if(88)
new /obj/item/organ/brain(src)
if(89)
new /obj/item/organ/brain/alien(src)
if(90)
new /obj/item/organ/heart(src)
if(91)
new /obj/item/soulstone/anybody(src)
if(92)
new /obj/item/katana(src)
if(93)
new /obj/item/dnainjector/xraymut(src)
if(94)
new /obj/item/storage/backpack/clown(src)
new /obj/item/clothing/under/rank/civilian/clown(src)
new /obj/item/clothing/shoes/clown_shoes(src)
new /obj/item/clothing/mask/gas/clown_hat(src)
new /obj/item/bikehorn(src)
new /obj/item/toy/crayon/rainbow(src)
new /obj/item/reagent_containers/spray/waterflower(src)
if(95)
new /obj/item/clothing/under/rank/civilian/mime(src)
new /obj/item/clothing/shoes/sneakers/black(src)
new /obj/item/clothing/gloves/color/white(src)
new /obj/item/clothing/mask/gas/mime(src)
new /obj/item/clothing/head/beret(src)
new /obj/item/clothing/suit/suspenders(src)
new /obj/item/toy/crayon/mime(src)
new /obj/item/reagent_containers/food/drinks/bottle/bottleofnothing(src)
if(96)
new /obj/item/hand_tele(src)
if(97)
new /obj/item/clothing/mask/balaclava
new /obj/item/gun/ballistic/automatic/pistol(src)
new /obj/item/ammo_box/magazine/m10mm(src)
if(98)
new /obj/item/katana/cursed(src)
if(99)
new /obj/item/storage/belt/champion(src)
new /obj/item/clothing/mask/luchador(src)
if(100)
new /obj/item/clothing/head/bearpelt(src)
//ATTACK HAND IGNORING PARENT RETURN VALUE
/obj/structure/closet/crate/secure/loot/attack_hand(mob/user)
if(!locked)
return ..()
to_chat(user, span_notice("The crate is locked with a Deca-code lock."))
var/input = input(usr, "Enter [codelen] digits. All digits must be unique.", "Deca-Code Lock", "") as text
if(user.canUseTopic(src, BE_CLOSE))
var/list/sanitised = list()
var/sanitycheck = TRUE
var/char = ""
var/length_input = length(input)
for(var/i = 1, i <= length_input, i += length(char)) //put the guess into a list
char = input[i]
sanitised += text2num(char)
for(var/i = 1, i <= length(sanitised) - 1, i++) //compare each digit in the guess to all those following it
for(var/j = i + 1, j <= length(sanitised), j++)
if(sanitised[i] == sanitised[j])
sanitycheck = FALSE //if a digit is repeated, reject the input
if(input == code)
to_chat(user, span_notice("The crate unlocks!"))
locked = FALSE
update_appearance(UPDATE_OVERLAYS)
else if(!input || !sanitycheck || length(sanitised) != codelen)
to_chat(user, span_notice("You leave the crate alone."))
else
to_chat(user, span_warning("A red light flashes."))
lastattempt = input
attempts--
if(!attempts)
boom(user)
/obj/structure/closet/crate/secure/loot/AltClick(mob/living/user)
if(!user.canUseTopic(src, BE_CLOSE))
return
return attack_hand(user) //this helps you not blow up so easily by overriding unlocking which results in an immediate boom.
/obj/structure/closet/crate/secure/loot/multitool_act(mob/living/user, obj/item/tool)
if(!locked)
return ..()
to_chat(user, span_notice("DECA-CODE LOCK REPORT:"))
if(attempts == 1)
to_chat(user, span_warning("* Anti-Tamper Bomb will activate on next failed access attempt."))
else
to_chat(user, span_notice("* Anti-Tamper Bomb will activate after [attempts] failed access attempts."))
if(!isnull(lastattempt))
var/bulls = 0 //right position, right number
var/cows = 0 //wrong position but in the puzzle
var/lastattempt_char = ""
var/length_lastattempt = length(lastattempt)
var/lastattempt_it = 1
var/code_char = ""
var/length_code = length(code)
var/code_it = 1
while(lastattempt_it <= length_lastattempt && code_it <= length_code) // Go through list and count matches
lastattempt_char = lastattempt[lastattempt_it]
code_char = code[code_it]
if(lastattempt_char == code_char)
bulls++
else if(findtext(code, lastattempt_char))
cows++
lastattempt_it += length(lastattempt_char)
code_it += length(code_char)
to_chat(user, span_notice("Last code attempt, [lastattempt], had [bulls] correct digits at correct positions and [cows] correct digits at incorrect positions."))
return TOOL_ACT_TOOLTYPE_SUCCESS
/obj/structure/closet/crate/secure/loot/emag_act(mob/user, obj/item/card/emag/emag_card)
if(!locked)
return FALSE
boom(user) // Did you expect the "anti-tamper system" to not work?
return TRUE
/obj/structure/closet/crate/secure/loot/togglelock(mob/user)
if(locked)
boom(user)
return
return ..()
/obj/structure/closet/crate/secure/loot/deconstruct(disassembled = TRUE)
boom()