-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
wizard.dm
367 lines (305 loc) · 12.6 KB
/
wizard.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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
/// Global assoc list. [ckey] = [spellbook entry type]
GLOBAL_LIST_EMPTY(wizard_spellbook_purchases_by_key)
/datum/antagonist/wizard
name = "Space Wizard"
roundend_category = "wizards/witches"
antagpanel_category = "Wizard"
job_rank = ROLE_WIZARD
antag_hud_name = "wizard"
antag_moodlet = /datum/mood_event/focused
var/give_objectives = TRUE
var/strip = TRUE //strip before equipping
var/allow_rename = TRUE
var/datum/team/wizard/wiz_team //Only created if wizard summons apprentices
var/move_to_lair = TRUE
var/outfit_type = /datum/outfit/wizard
var/wiz_age = WIZARD_AGE_MIN /* Wizards by nature cannot be too young. */
can_hijack = HIJACK_HIJACKER
show_to_ghosts = TRUE
preview_outfit = /datum/outfit/wizard
/datum/antagonist/wizard/on_gain()
register()
equip_wizard()
if(give_objectives)
create_objectives()
if(move_to_lair)
send_to_lair()
. = ..()
if(allow_rename)
rename_wizard()
/datum/antagonist/wizard/proc/register()
SSticker.mode.wizards |= owner
/datum/antagonist/wizard/proc/unregister()
SSticker.mode.wizards -= src
/datum/antagonist/wizard/create_team(datum/team/wizard/new_team)
if(!new_team)
return
if(!istype(new_team))
stack_trace("Wrong team type passed to [type] initialization.")
wiz_team = new_team
/datum/antagonist/wizard/get_team()
return wiz_team
/datum/team/wizard
name = "wizard team"
var/datum/antagonist/wizard/master_wizard
/datum/antagonist/wizard/proc/create_wiz_team()
wiz_team = new(owner)
wiz_team.name = "[owner.current.real_name] team"
wiz_team.master_wizard = src
/datum/antagonist/wizard/proc/send_to_lair()
if(!owner || !owner.current)
return
if(!GLOB.wizardstart.len)
SSjob.SendToLateJoin(owner.current)
to_chat(owner, "HOT INSERTION, GO GO GO")
owner.current.forceMove(pick(GLOB.wizardstart))
/datum/antagonist/wizard/proc/create_objectives()
switch(rand(1,100))
if(1 to 30)
var/datum/objective/assassinate/kill_objective = new
kill_objective.owner = owner
kill_objective.find_target()
objectives += kill_objective
if (!(locate(/datum/objective/escape) in objectives))
var/datum/objective/escape/escape_objective = new
escape_objective.owner = owner
objectives += escape_objective
if(31 to 60)
var/datum/objective/steal/steal_objective = new
steal_objective.owner = owner
steal_objective.find_target()
objectives += steal_objective
if (!(locate(/datum/objective/escape) in objectives))
var/datum/objective/escape/escape_objective = new
escape_objective.owner = owner
objectives += escape_objective
if(61 to 85)
var/datum/objective/assassinate/kill_objective = new
kill_objective.owner = owner
kill_objective.find_target()
objectives += kill_objective
var/datum/objective/steal/steal_objective = new
steal_objective.owner = owner
steal_objective.find_target()
objectives += steal_objective
if (!(locate(/datum/objective/survive) in objectives))
var/datum/objective/survive/survive_objective = new
survive_objective.owner = owner
objectives += survive_objective
else
if (!(locate(/datum/objective/hijack) in objectives))
var/datum/objective/hijack/hijack_objective = new
hijack_objective.owner = owner
objectives += hijack_objective
/datum/antagonist/wizard/on_removal()
unregister()
// Currently removes all spells regardless of innate or not. Could be improved.
for(var/datum/action/cooldown/spell/spell in owner.current.actions)
if(spell.target == owner)
qdel(spell)
owner.current.actions -= spell
return ..()
/datum/antagonist/wizard/proc/equip_wizard()
if(!owner)
return
var/mob/living/carbon/human/H = owner.current
if(!istype(H))
return
if(strip)
H.delete_equipment()
//Wizards are human by default. Use the mirror if you want something else.
H.set_species(/datum/species/human)
if(H.age < wiz_age)
H.age = wiz_age
H.equipOutfit(outfit_type)
/datum/antagonist/wizard/greet()
to_chat(owner, span_boldannounce("You are the Space Wizard!"))
to_chat(owner, "<B>The Space Wizards Federation has given you the following tasks:</B>")
owner.announce_objectives()
to_chat(owner, "You will find a list of available spells in your spell book. Choose your magic arsenal carefully.")
to_chat(owner, "The spellbook is bound to you, and others cannot use it.")
to_chat(owner, "In your pockets you will find a teleport scroll. Use it as needed.")
to_chat(owner,"<B>Remember:</B> do not forget to prepare your spells.")
/datum/antagonist/wizard/farewell()
to_chat(owner, span_userdanger("You have been brainwashed! You are no longer a wizard!"))
/datum/antagonist/wizard/proc/rename_wizard()
set waitfor = FALSE
var/wizard_name_first = pick(GLOB.wizard_first)
var/wizard_name_second = pick(GLOB.wizard_second)
var/randomname = "[wizard_name_first] [wizard_name_second]"
var/mob/living/wiz_mob = owner.current
var/newname = sanitize_name(reject_bad_text(stripped_input(wiz_mob, "You are the [name]. Would you like to change your name to something else?", "Name change", randomname, MAX_NAME_LEN)))
if (!newname)
newname = randomname
wiz_mob.fully_replace_character_name(wiz_mob.real_name, newname)
/datum/antagonist/wizard/apply_innate_effects(mob/living/mob_override)
var/mob/living/M = mob_override || owner.current
M.faction |= ROLE_WIZARD
add_team_hud(M)
/datum/antagonist/wizard/remove_innate_effects(mob/living/mob_override)
var/mob/living/M = mob_override || owner.current
M.faction -= ROLE_WIZARD
/datum/antagonist/wizard/get_admin_commands()
. = ..()
.["Send to Lair"] = CALLBACK(src, PROC_REF(admin_send_to_lair))
/datum/antagonist/wizard/proc/admin_send_to_lair(mob/admin)
owner.current.forceMove(pick(GLOB.wizardstart))
/datum/antagonist/wizard/apprentice
name = "Wizard Apprentice"
antag_hud_name = "apprentice"
var/datum/mind/master
var/school = APPRENTICE_DESTRUCTION
outfit_type = /datum/outfit/wizard/apprentice
wiz_age = APPRENTICE_AGE_MIN
/datum/antagonist/wizard/apprentice/greet()
to_chat(owner, "<B>You are [master.current.real_name]'s apprentice! You are bound by magic contract to follow [master.p_their()] orders and help [master.p_them()] in accomplishing [master.p_their()] goals.")
owner.announce_objectives()
/datum/antagonist/wizard/apprentice/register()
SSticker.mode.apprentices |= owner
/datum/antagonist/wizard/apprentice/unregister()
SSticker.mode.apprentices -= owner
/datum/antagonist/wizard/apprentice/equip_wizard()
. = ..()
if(!ishuman(owner.current))
return
var/list/spells_to_grant = list()
var/list/items_to_grant = list()
switch(school)
if(APPRENTICE_DESTRUCTION)
spells_to_grant = list(
/datum/action/cooldown/spell/aoe/magic_missile,
/datum/action/cooldown/spell/pointed/projectile/fireball,
)
to_chat(owner, span_bold("Your service has not gone unrewarded, however. \
Studying under [master.current.real_name], you have learned powerful, \
destructive spells. You are able to cast magic missile and fireball."))
if(APPRENTICE_BLUESPACE)
spells_to_grant = list(
/datum/action/cooldown/spell/teleport/area_teleport/wizard,
/datum/action/cooldown/spell/jaunt/ethereal_jaunt,
)
to_chat(owner, span_bold("Your service has not gone unrewarded, however. \
Studying under [master.current.real_name], you have learned reality-bending \
mobility spells. You are able to cast teleport and ethereal jaunt."))
if(APPRENTICE_HEALING)
spells_to_grant = list(
/datum/action/cooldown/spell/charge,
/datum/action/cooldown/spell/forcewall,
)
items_to_grant = list(
/obj/item/gun/magic/staff/healing,
)
to_chat(owner, span_bold("Your service has not gone unrewarded, however. \
Studying under [master.current.real_name], you have learned life-saving \
survival spells. You are able to cast charge and forcewall, and have a staff of healing."))
if(APPRENTICE_ROBELESS)
spells_to_grant = list(
/datum/action/cooldown/spell/aoe/knock,
/datum/action/cooldown/spell/pointed/mind_transfer,
)
to_chat(owner, span_bold("Your service has not gone unrewarded, however. \
Studying under [master.current.real_name], you have learned stealthy, \
robeless spells. You are able to cast knock and mindswap."))
for(var/spell_type in spells_to_grant)
var/datum/action/cooldown/spell/new_spell = new spell_type(owner)
new_spell.Grant(owner.current)
for(var/item_type in items_to_grant)
var/obj/item/new_item = new item_type(owner.current)
owner.current.put_in_hands(new_item)
/datum/antagonist/wizard/apprentice/create_objectives()
var/datum/objective/protect/new_objective = new /datum/objective/protect
new_objective.owner = owner
new_objective.target = master
new_objective.explanation_text = "Protect [master.current.real_name], the wizard."
objectives += new_objective
//Random event wizard
/datum/antagonist/wizard/apprentice/imposter
name = "Wizard Imposter"
allow_rename = FALSE
move_to_lair = FALSE
/datum/antagonist/wizard/apprentice/imposter/greet()
to_chat(owner, "<B>You are an imposter! Trick and confuse the crew to misdirect malice from your handsome original!</B>")
owner.announce_objectives()
/datum/antagonist/wizard/apprentice/imposter/equip_wizard()
var/mob/living/carbon/human/master_mob = master.current
var/mob/living/carbon/human/H = owner.current
if(!istype(master_mob) || !istype(H))
return
if(master_mob.ears)
H.equip_to_slot_or_del(new master_mob.ears.type, ITEM_SLOT_EARS)
if(master_mob.w_uniform)
H.equip_to_slot_or_del(new master_mob.w_uniform.type, ITEM_SLOT_ICLOTHING)
if(master_mob.shoes)
H.equip_to_slot_or_del(new master_mob.shoes.type, ITEM_SLOT_FEET)
if(master_mob.wear_suit)
H.equip_to_slot_or_del(new master_mob.wear_suit.type, ITEM_SLOT_OCLOTHING)
if(master_mob.head)
H.equip_to_slot_or_del(new master_mob.head.type, ITEM_SLOT_HEAD)
if(master_mob.back)
H.equip_to_slot_or_del(new master_mob.back.type, ITEM_SLOT_BACK)
//Operation: Fuck off and scare people
var/datum/action/cooldown/spell/jaunt/ethereal_jaunt/jaunt = new(owner)
jaunt.Grant(H)
var/datum/action/cooldown/spell/teleport/area_teleport/wizard/teleport = new(owner)
teleport.Grant(H)
var/datum/action/cooldown/spell/teleport/radius_turf/blink/blink = new(owner)
blink.Grant(H)
/datum/antagonist/wizard/academy
name = "Academy Teacher"
outfit_type = /datum/outfit/wizard/academy
/datum/antagonist/wizard/academy/equip_wizard()
. = ..()
if(!isliving(owner.current))
return
var/mob/living/living_current = owner.current
var/datum/action/cooldown/spell/jaunt/ethereal_jaunt/jaunt = new(owner)
jaunt.Grant(living_current)
var/datum/action/cooldown/spell/aoe/magic_missile/missile = new(owner)
missile.Grant(living_current)
var/datum/action/cooldown/spell/pointed/projectile/fireball/fireball = new(owner)
fireball.Grant(living_current)
var/obj/item/implant/exile/exiled = new /obj/item/implant/exile(living_current)
exiled.implant(living_current)
/datum/antagonist/wizard/academy/create_objectives()
var/datum/objective/new_objective = new("Protect Wizard Academy from the intruders")
new_objective.owner = owner
objectives += new_objective
//Solo wizard report
/datum/antagonist/wizard/roundend_report()
var/list/parts = list()
parts += printplayer(owner)
var/count = 1
var/wizardwin = 1
for(var/datum/objective/objective in objectives)
if(objective.check_completion())
parts += "<B>Objective #[count]</B>: [objective.explanation_text] [span_greentext("Success!")]"
else
parts += "<B>Objective #[count]</B>: [objective.explanation_text] [span_redtext("Fail.")]"
wizardwin = 0
count++
if(wizardwin)
parts += span_greentext("The wizard was successful!")
SSachievements.unlock_achievement(/datum/achievement/greentext/wizwin, owner.current.client) //wizard wins, give achievement
else
parts += span_redtext("The wizard has failed!")
SSachievements.unlock_achievement(/datum/achievement/redtext/winlost, owner.current.client) //wizard loses, still give achievement lol
var/list/purchases = list()
for(var/list/log as anything in GLOB.wizard_spellbook_purchases_by_key[owner.key])
var/datum/spellbook_entry/bought = log[LOG_SPELL_TYPE]
var/amount = log[LOG_SPELL_AMOUNT]
purchases += "[amount > 1 ? "[amount]x ":""][initial(bought.name)]"
if(length(purchases))
parts += span_bold("[owner.name] used the following spells:")
parts += purchases.Join(", ")
else
parts += span_bold("[owner.name] didn't buy any spells!")
return parts.Join("<br>")
//Wizard with apprentices report
/datum/team/wizard/roundend_report()
var/list/parts = list()
parts += span_header("Wizards/witches of [master_wizard.owner.name] team were:")
parts += master_wizard.roundend_report()
parts += " "
parts += span_header("[master_wizard.owner.name] apprentices were:")
parts += printplayerlist(members - master_wizard.owner)
return "<div class='panel redborder'>[parts.Join("<br>")]</div>"