forked from Ochre-Valley/Ochre-Valley
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_virtue.dm
More file actions
151 lines (128 loc) · 4.91 KB
/
_virtue.dm
File metadata and controls
151 lines (128 loc) · 4.91 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
GLOBAL_LIST_EMPTY(virtues)
/datum/virtue
/// What the virtue's called.
var/name
/// A brief, in-character description of what the virtue does.
var/desc
/// Description for origins, allowed to be a bit wordy.
var/origin_desc
/// Name for origins - used for the nation's name, not a denonym!
var/origin_name = "Unknown"
/// A list containing any traits we need to add to the mob.
var/list/added_traits = list()
/// An associative list containing any skills we want to adjust. You can also pass list objects into this in the following format: list(SKILL_TYPE, SKILL_INCREASE, SKILL_MAXIMUM) as needed.
var/list/added_skills = list()
/// An associative list containing any items we want to add to our stash.
var/list/added_stashed_items = list()
/// A list containing any extra languages we need to add to the mob.
var/list/added_languages = list()
/// An associative list containing any extra stats we need to add to the mob. NOTE: virtues should GENERALLY NOT add stats unless they impose serious downsides.
var/list/added_stats = list()
/// Whether the virtue uses racial restrictions
var/restricted = FALSE
/// Whether the origin lets you choose a language freely.
var/extra_language = FALSE
/// For use in outfits applying origins.
var/job_origin
/// For use in outfits applying origins.
var/datum/virtue/last_origin
/// A list of races restricted.
var/list/races = list()
/// The cost of the virtue to apply in TRIUMPH points, if any.
var/triumph_cost = 0
/// A custom addendum that explains what the virtue does outside of the traits / skill adjustments.
var/custom_text
//if a virtue hits the soft cap we give them a 1 skill point boost
var/softcap = FALSE
/// Whether a virtue should show up in regular selection
var/unlisted = FALSE
/datum/virtue/New()
. = ..()
if (triumph_cost)
desc += "<b>Costs [triumph_cost] TRIUMPH.</b>"
/datum/virtue/proc/apply_to_human(mob/living/carbon/human/recipient)
return
/datum/virtue/proc/handle_traits(mob/living/carbon/human/recipient)
if (!LAZYLEN(added_traits))
return
for(var/trait in added_traits)
ADD_TRAIT(recipient, trait, TRAIT_VIRTUE)
/datum/virtue/proc/handle_skills(mob/living/carbon/human/recipient)
if (!recipient?.mind || !LAZYLEN(added_skills))
return
for (var/entry in added_skills)
var/datum/skill/S
var/inc
var/max = null
if (islist(entry))
S = entry[1]
inc = entry[2]
max = entry[3]
else
S = entry
inc = added_skills[entry]
if (!S || !inc)
continue
var/current = recipient.get_skill_level(S)
var/increase_amount = 0
var/virtue_limit = 6
if (max)
virtue_limit = min(max, 6)
if (current < virtue_limit)
var/space_left = virtue_limit - current
increase_amount = min(inc, space_left)
if (increase_amount == 0 && softcap && current < 6)
increase_amount = 1
if (increase_amount == 0)
to_chat(recipient, span_notice("My Virtue cannot influence my skill with [lowertext(S.name)] any further."))
else
recipient.adjust_skillrank(S.type, increase_amount, TRUE)
if (increase_amount == 1 && max && current >= max)
to_chat(recipient, span_notice("My Virtue can only minorly influence my skill with [lowertext(S.name)]."))
/datum/virtue/proc/handle_stashed_items(mob/living/carbon/human/recipient)
if (!recipient.mind || !LAZYLEN(added_stashed_items))
return
for(var/stashed_item in added_stashed_items)
recipient.mind?.special_items[stashed_item] = added_stashed_items[stashed_item]
/datum/virtue/proc/handle_added_languages(mob/living/carbon/human/recipient)
if (!LAZYLEN(added_languages))
return
for (var/language in added_languages)
recipient.grant_language(language)
/datum/virtue/proc/handle_stats(mob/living/carbon/human/recipient)
if (!LAZYLEN(added_stats))
return
for (var/stat in added_stats)
var/value = added_stats[stat]
recipient.change_stat(stat, value)
/datum/virtue/proc/check_triumphs(mob/living/carbon/human/recipient)
if (!triumph_cost)
return TRUE
if (!recipient.mind)
return FALSE
// we should check to see if they have triumphs first but i can't be fucked
recipient.adjust_triumphs(-triumph_cost, FALSE)
return TRUE
/proc/apply_virtue(mob/living/carbon/human/recipient, datum/virtue/virtue_type)
if (!virtue_type.check_triumphs(recipient))
return
virtue_type.apply_to_human(recipient)
virtue_type.handle_traits(recipient)
virtue_type.handle_skills(recipient)
virtue_type.handle_stashed_items(recipient)
virtue_type.handle_added_languages(recipient)
virtue_type.handle_stats(recipient)
if(HAS_TRAIT(recipient, TRAIT_RESIDENT))
if(recipient in SStreasury.bank_accounts)
SStreasury.generate_money_account(20, recipient)
else
SStreasury.create_bank_account(recipient, 20)
if(virtue_type.unlisted)
return
if(istype(virtue_type, /datum/virtue/origin))
record_featured_object_stat(FEATURED_STATS_ORIGINS, virtue_type.name)
else
record_featured_object_stat(FEATURED_STATS_VIRTUES, virtue_type.name)
/datum/virtue/none
name = "None"
desc = "Without virtue."