-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
_quirk.dm
150 lines (130 loc) · 5.64 KB
/
_quirk.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
//every quirk in this folder should be coded around being applied on spawn
//these are NOT "mob quirks" like GOTTAGOFAST, but exist as a medium to apply them and other different effects
/datum/quirk
var/name = "Test Quirk"
var/desc = "This is a test quirk."
var/value = 0
var/human_only = TRUE
var/gain_text
var/lose_text
var/medical_record_text //This text will appear on medical records for the trait. Not yet implemented
var/mood_quirk = FALSE //if true, this quirk affects mood and is unavailable if moodlets are disabled
var/mob_trait //if applicable, apply and remove this mob trait
var/mob/living/quirk_holder
var/not_init = FALSE // Yogs -- Allows quirks to be instantiated without all the song & dance below happening
var/list/species_blacklist = list()
var/list/job_blacklist = list()
/// The icon to show in the preferences menu.
/// This references a tgui icon, so it can be FontAwesome or a tgfont (with a tg- prefix).
var/icon
/datum/quirk/New(mob/living/quirk_mob, spawn_effects, no_init = FALSE)
..()
if(no_init) // Yogs -- Allows quirks to be instantiated without all the song & dance below happening
not_init = TRUE
return
if(!quirk_mob || (human_only && !ishuman(quirk_mob)) || quirk_mob.has_quirk(type))
qdel(src)
quirk_holder = quirk_mob
SSquirks.quirk_objects += src
to_chat(quirk_holder, gain_text)
quirk_holder.roundstart_quirks += src
if(mob_trait)
ADD_TRAIT(quirk_holder, mob_trait, ROUNDSTART_TRAIT)
START_PROCESSING(SSquirks, src)
add()
if(spawn_effects)
on_spawn()
addtimer(CALLBACK(src, PROC_REF(post_add)), 30)
/datum/quirk/Destroy()
if(not_init) // Yogs -- Allows quirks to be instantiated without all the song & dance below happening
return ..()
STOP_PROCESSING(SSquirks, src)
remove()
if(quirk_holder)
to_chat(quirk_holder, lose_text)
quirk_holder.roundstart_quirks -= src
if(mob_trait)
REMOVE_TRAIT(quirk_holder, mob_trait, ROUNDSTART_TRAIT)
SSquirks.quirk_objects -= src
return ..()
/// Used to transfer quicks from one mob to another
/datum/quirk/proc/transfer_mob(mob/living/to_mob)
quirk_holder.roundstart_quirks -= src
to_mob.roundstart_quirks += src
if(mob_trait)
REMOVE_TRAIT(quirk_holder, mob_trait, ROUNDSTART_TRAIT)
ADD_TRAIT(to_mob, mob_trait, ROUNDSTART_TRAIT)
quirk_holder = to_mob
on_transfer()
/datum/quirk/proc/add() //special "on add" effects
/datum/quirk/proc/on_spawn() //these should only trigger when the character is being created for the first time, i.e. roundstart/latejoin
/datum/quirk/proc/remove() //special "on remove" effects
/datum/quirk/proc/on_process() //process() has some special checks, so this is the actual process
/datum/quirk/proc/post_add() //for text, disclaimers etc. given after you spawn in with the trait
/datum/quirk/proc/on_transfer() //code called when the trait is transferred to a new mob
/datum/quirk/proc/clone_data() //return additional data that should be remembered by cloning
/datum/quirk/proc/on_clone(data) //create the quirk from clone data
/datum/quirk/proc/check_quirk(datum/preferences/prefs) // Yogs -- allows quirks to check the preferences of the user who may acquire it
return FALSE
/datum/quirk/process(delta_time)
if(QDELETED(quirk_holder))
quirk_holder = null
qdel(src)
return
if(quirk_holder.stat == DEAD)
return
on_process(delta_time)
/mob/living/proc/get_trait_string(medical) //helper string. gets a string of all the traits the mob has
var/list/dat = list()
if(!medical)
for(var/V in roundstart_quirks)
var/datum/quirk/T = V
dat += T.name
if(!dat.len)
return "None"
return dat.Join(", ")
else
for(var/V in roundstart_quirks)
var/datum/quirk/T = V
dat += T.medical_record_text
if(!dat.len)
return "None"
return dat.Join("<br>")
/mob/living/proc/cleanse_trait_datums() //removes all trait datums
for(var/V in roundstart_quirks)
var/datum/quirk/T = V
qdel(T)
/mob/living/proc/transfer_trait_datums(mob/living/to_mob)
for(var/V in roundstart_quirks)
var/datum/quirk/T = V
T.transfer_mob(to_mob)
/*
Commented version of Nearsighted to help you add your own traits
Use this as a guideline
/datum/quirk/nearsighted
name = "Nearsighted"
///The trait's name
desc = "You are nearsighted without prescription glasses, but spawn with a pair."
///Short description, shows next to name in the trait panel
value = -1
///If this is above 0, it's a positive trait; if it's not, it's a negative one; if it's 0, it's a neutral
mob_trait = TRAIT_NEARSIGHT
///This define is in __DEFINES/traits.dm and is the actual "trait" that the game tracks
///You'll need to use "HAS_TRAIT_FROM(src, X, sources)" checks around the code to check this; for instance, the Ageusia trait is checked in taste code
///If you need help finding where to put it, the declaration finder on GitHub is the best way to locate it
gain_text = span_danger("Things far away from you start looking blurry.")
lose_text = span_notice("You start seeing faraway things normally again.")
medical_record_text = "Subject has permanent nearsightedness."
///These three are self-explanatory
/datum/quirk/nearsighted/on_spawn()
var/mob/living/carbon/human/H = quirk_holder
var/obj/item/clothing/glasses/regular/glasses = new(get_turf(H))
H.put_in_hands(glasses)
H.equip_to_slot(glasses, ITEM_SLOT_EYES)
H.regenerate_icons()
//This whole proc is called automatically
//It spawns a set of prescription glasses on the user, then attempts to put it into their hands, then attempts to make them equip it.
//This means that if they fail to equip it, they glasses spawn in their hands, and if they fail to be put into the hands, they spawn on the ground
//Hooray for fallbacks!
//If you don't need any special effects like spawning glasses, then you don't need an add()
*/