/
wallets.dm
155 lines (126 loc) · 3.81 KB
/
wallets.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
/obj/item/storage/wallet
name = "wallet"
desc = "It can hold a few small and personal things."
icon = 'icons/obj/wallet.dmi'
icon_state = "wallet-white"
color = COLOR_BROWN_ORANGE
w_class = ITEM_SIZE_SMALL
max_w_class = ITEM_SIZE_SMALL
max_storage_space = ITEM_SIZE_SMALL * 3
slot_flags = SLOT_ID
contents_allowed = list(
/obj/item/spacecash,
/obj/item/card,
/obj/item/clothing/mask/smokable,
/obj/item/lipstick,
/obj/item/haircomb,
/obj/item/mirror,
/obj/item/clothing/accessory/locket,
/obj/item/clothing/head/hairflower,
/obj/item/device/flashlight/pen,
/obj/item/seeds,
/obj/item/material/coin,
/obj/item/dice,
/obj/item/disk,
/obj/item/implant,
/obj/item/flame,
/obj/item/paper,
/obj/item/pen,
/obj/item/photo,
/obj/item/reagent_containers/pill,
/obj/item/device/encryptionkey,
/obj/item/key,
/obj/item/clothing/accessory/badge,
/obj/item/clothing/accessory/medal,
/obj/item/clothing/accessory/armor_tag,
/obj/item/clothing/ring,
/obj/item/passport,
/obj/item/clothing/accessory/pride_pin,
/obj/item/clothing/accessory/pronouns,
/obj/item/storage/chewables/rollable,
/obj/item/storage/fancy/matches/matchbook
)
/// If this wallet contains ID cards, the one that is displayed through its window.
var/obj/item/card/id/front_id
/obj/item/storage/wallet/Destroy()
front_id = null
return ..()
/obj/item/storage/wallet/remove_from_storage(obj/item/item, atom/into)
. = ..(item, into)
if (!. || item != front_id)
return
front_id = null
SetName(initial(name))
update_icon()
/obj/item/storage/wallet/handle_item_insertion(obj/item/item, silent)
. = ..(item, silent)
if (!. || !istype(item, /obj/item/card/id))
return
front_id = item
update_icon()
/obj/item/storage/wallet/on_update_icon()
ClearOverlays()
if (front_id)
var/tiny_state = "id-generic"
var/check_state = "id-[front_id.icon_state]"
if (check_state in icon_states(icon))
tiny_state = check_state
var/image/tiny_image = new/image(icon, icon_state = tiny_state)
tiny_image.appearance_flags = DEFAULT_APPEARANCE_FLAGS | RESET_COLOR
AddOverlays(tiny_image)
/obj/item/storage/wallet/GetIdCard()
return front_id
/obj/item/storage/wallet/GetAccess()
var/obj/item/card/id/id = GetIdCard()
if (id)
id.GetAccess()
return ..()
/obj/item/storage/wallet/AltClick(mob/living/user)
if (user != loc || user.incapacitated() || !ishuman(user))
return ..()
var/obj/item/card/id/id = GetIdCard()
if (istype(id))
remove_from_storage(id, get_turf(user))
user.put_in_hands(id)
return TRUE
return ..()
/obj/item/storage/wallet/random
/// Loose cash types permitted for spawning in random wallets.
var/static/list/cash_types = subtypesof(/obj/item/spacecash/bundle)
/obj/item/storage/wallet/random/Initialize()
. = ..()
if (prob(65))
var/obj/item/spacecash/ewallet/stick = new (src)
stick.worth = floor(grand() * 1200)
else
for (var/i = 1 to rand(1, 2))
var/type = pick(cash_types)
new type (src)
if (prob(33))
new_simple_coin(src)
update_icon()
/obj/item/storage/wallet/poly
name = "polychromic wallet"
desc = "You can recolor it! Fancy! The future is NOW!"
/obj/item/storage/wallet/poly/Initialize()
color = get_random_colour()
return ..()
/obj/item/storage/wallet/poly/verb/change_color()
set name = "Change Wallet Color"
set category = "Object"
set desc = "Change the color of the wallet."
set src in usr
if (usr.incapacitated())
return
var/new_color = input(usr, "Pick a new color", "Wallet Color", color) as null | color
if (!new_color || new_color == color || usr.incapacitated())
return
color = new_color
/obj/item/storage/wallet/poly/emp_act(severity)
icon_state = "wallet-emp"
update_icon()
addtimer(new Callback(src, .proc/resolve_emp_timer), 5 SECONDS)
..()
/obj/item/storage/wallet/poly/proc/resolve_emp_timer()
icon_state = initial(icon_state)
update_icon()