forked from ss220-space/Skyrat-tg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_spawner.dm
170 lines (156 loc) · 5.36 KB
/
event_spawner.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
/obj/character_event_spawner
icon = 'modular_nova/modules/cryosleep/icons/cryogenics.dmi'
icon_state = "cryopod"
var/list/species_whitelist
var/list/gender_whitelist
var/list/ckey_whitelist
var/used_outfit = /datum/outfit/centcom/ert/engineer
var/job_name
var/gets_loadout = TRUE
var/access_override
var/headset_override
var/flavor_text = ""
var/list/additional_equipment
var/disappear_after_spawn
var/infinite = TRUE
var/used = FALSE
/obj/character_event_spawner/attack_ghost(mob/user)
TrySpawn(user)
/obj/character_event_spawner/proc/TrySpawn(mob/dead/observer/user)
if(!user || !user.client)
return
if(used)
return
if(ckey_whitelist && !(LOWER_TEXT(user.ckey) in ckey_whitelist))
alert(user, "Sorry, This spawner is not for you!", "", "Ok")
return
if(is_banned_from(user.ckey, BAN_GHOST_ROLE_SPAWNER))
to_chat(user, "Error, you are banned from playing ghost roles!")
return
var/species_string
if(species_whitelist)
species_string = ""
var/first = TRUE
for(var/spec_key in species_whitelist)
if(!first)
species_string += ", "
species_string += "[spec_key]"
first = FALSE
var/gender_string
if(gender_whitelist)
gender_string = ""
var/first = TRUE
for(var/spec_key in gender_whitelist)
if(!first)
gender_string += ", "
gender_string += "[spec_key]"
first = FALSE
var/warning_string = "WARNING: This spawner will use your currently selected character in prefs ([user.client.prefs?.read_preference(/datum/preference/name/real_name)])\nMake sure that the character is not used as a station crew, or would have a good reason to be this role.\nDo you wanna proceed?"
if(species_string)
warning_string += "\nThis role is restricted to those species: [species_string]"
if(gender_string)
warning_string += "\nThis role is restricted to those genders: [gender_string]"
var/action = tgui_alert(user, warning_string, "", list("Yes", "Yes with Alias", "No"))
if(!action || action == "No")
return
var/alias
if(action == "Yes with Alias")
var/msg = reject_bad_name(input(usr, "Set your character's alias for this role", "Alias") as text|null)
if(!msg)
return
alias = msg
if(!user || !user.client)
return
if(species_whitelist && !(user.client.prefs?.read_preference(/datum/preference/choiced/species) in species_whitelist))
alert(user, "Sorry, This spawner is limited to those species: [species_string]. Please switch your character.", "", "Ok")
return
if(gender_whitelist && !(user.client.prefs?.read_preference(/datum/preference/choiced/gender) in gender_whitelist))
alert(user, "Sorry, This spawner is limited to those genders: [gender_string]. Please switch your character.", "", "Ok")
return
if(used)
return
SpawnPerson(user, alias)
/obj/character_event_spawner/proc/SpawnPerson(mob/dead/observer/user, alias)
if(!user || !user.client)
return
message_admins("[ADMIN_LOOKUPFLW(user)] spawned as a [job_name] by using a spawner.")
if(!infinite)
used = TRUE
icon_state = "cryopod-open"
name = "opened cryogenic sleeper"
//Spawn and copify prefs
var/mob/living/carbon/human/H = new(src)
user.client.prefs.safe_transfer_prefs_to(H)
H.dna.update_dna_identity()
if(alias)
H.name = alias
H.real_name = alias
H.forceMove(get_turf(src))
//Pre-job equips so Voxes dont die
H.dna.species.pre_equip_species_outfit(null, H)
if(used_outfit && used_outfit != "Naked")
H.equipOutfit(used_outfit)
//Override headset here
if(headset_override)
var/obj/item/headset_slot = H.get_item_by_slot(ITEM_SLOT_EARS)
if(headset_slot)
qdel(headset_slot)
var/obj/item/new_headset = new headset_override()
if(new_headset)
if(!H.equip_to_slot_if_possible(new_headset, ITEM_SLOT_EARS, disable_warning = TRUE, bypass_equip_delay_self = TRUE))
new_headset.forceMove(get_turf(H))
var/obj/item/back_item
if(H.back && H.back.atom_storage)
back_item = H.back
//Spawn our character a backpack if they dont have any
if(!back_item)
var/obj/item/new_bp = new /obj/item/storage/backpack()
if(H.equip_to_appropriate_slot(new_bp))
back_item = new_bp
else
new_bp.forceMove(get_turf(H))
if(additional_equipment)
for(var/eq_path in additional_equipment)
var/obj/item/equipped = new eq_path()
if(!H.equip_to_appropriate_slot(equipped))
if(back_item)
equipped.forceMove(back_item)
else
equipped.forceMove(get_turf(H))
if(gets_loadout)
for(var/datum/loadout_item/item as anything in loadout_list_to_datums(H?.client?.prefs?.loadout_list))
item.post_equip_item(H.client?.prefs, H)
//Override access of the ID card here
var/obj/item/card/id/ID
if(length(access_override))
var/obj/item/id_slot = H.get_item_by_slot(ITEM_SLOT_ID)
if(!id_slot)
var/obj/item/temp_id = new /obj/item/card/id()
if(!H.equip_to_slot_if_possible(temp_id, ITEM_SLOT_ID, disable_warning = TRUE, bypass_equip_delay_self = TRUE))
qdel(temp_id)
else
id_slot = temp_id
if(id_slot)
ID = id_slot.GetID()
if(ID)
ID.access = access_override
//Override name and job of the ID card here
if(!ID)
var/obj/item/id_slot = H.get_item_by_slot(ITEM_SLOT_ID)
if(id_slot)
ID = id_slot.GetID()
if(ID)
ID.registered_name = H.real_name
ID.assignment = job_name
ID.update_label()
H.regenerate_icons()
//Give control
if(user.mind)
user.mind.transfer_to(H, TRUE)
else
H.ckey = user.ckey
//Greet!
to_chat(H, span_big("You are the [job_name]"))
to_chat(H, span_bold("[flavor_text]"))
if(disappear_after_spawn)
qdel(src)