Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 4cd2de9

Browse files
Adds Skills (#22683)
* skill issue to do: -chemistry -virology -balance stuff -??? i forgor * this shouldn't be here * more stuff * bit of rebalancing * i hate javascript!!! * more balance * stuff * things * fixed some stuff * hacking * ghost roles * fix * crafting skill requirements * real menu button * cyborg * fixed IPC repair * new skill icons * fix + rebalancing * skill icons 2 * exploit fixed * chem dispenser fix * fix again * clockwork style * genetics * science fix * progress bar indicators * minor refactor + rebalance * dna console fix * exploit fix * progress bar * more like evilscript * remove exploit * fix * why is round ID a string??? * another day, another exploit fixed
1 parent e205931 commit 4cd2de9

File tree

152 files changed

+1400
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+1400
-339
lines changed

code/__DEFINES/flags.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,7 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
250250
#define IGNORE_INCAPACITATED (1<<3)
251251
/// Used to prevent important slowdowns from being abused by drugs like kronkaine
252252
#define IGNORE_SLOWDOWNS (1<<4)
253+
/// Used to keep the skill indicator icon without using the built-in delay modifier
254+
#define IGNORE_SKILL_DELAY (1<<5)
253255

254256
#define IGNORE_ALL (IGNORE_USER_LOC_CHANGE|IGNORE_TARGET_LOC_CHANGE|IGNORE_HELD_ITEM|IGNORE_INCAPACITATED|IGNORE_SLOWDOWNS)

code/__DEFINES/hud.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#define ui_borg_radio "EAST-1:28,SOUTH+1:7"
107107
#define ui_borg_intents "EAST-2:26,SOUTH:5"
108108
#define ui_language_menu "EAST-5:20,SOUTH:21"
109+
#define ui_skill_menu "EAST-5:20,SOUTH:5"
109110
#define ui_move_up "EAST-4:22, SOUTH:21"
110111
#define ui_move_down "EAST-4:22, SOUTH:5"
111112

code/__DEFINES/skills.dm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
/// Medicine and surgery.
3+
#define SKILL_PHYSIOLOGY "physiology"
4+
/// Construction and repair of structures and machinery.
5+
#define SKILL_MECHANICAL "mechanics"
6+
/// Hacking, piloting, and robotic maintenance.
7+
#define SKILL_TECHNICAL "technical"
8+
/// Chemistry, botany, physics, and other sciences.
9+
#define SKILL_SCIENCE "science"
10+
/// Strength, endurance, accuracy.
11+
#define SKILL_FITNESS "fitness"
12+
13+
/// No experience whatsoever.
14+
#define EXP_NONE 0
15+
/// Some experience, but not much.
16+
#define EXP_LOW 1
17+
/// Enough experience to do a decent job.
18+
#define EXP_MID 2
19+
/// Above average skill level.
20+
#define EXP_HIGH 3
21+
/// Exceptionally skilled.
22+
#define EXP_MASTER 4
23+
/// Uniquely gifted. Not obtainable through normal means.
24+
#define EXP_GENIUS 5
25+
26+
/// Experience required to increase your skills by one level. Increases exponentially the higher your level already is.
27+
#define EXPERIENCE_PER_LEVEL 500

code/__DEFINES/tools.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define TOOL_MULTITOOL "multitool"
44
#define TOOL_SCREWDRIVER "screwdriver"
55
#define TOOL_WIRECUTTER "wirecutter"
6+
#define TOOL_WIRING "wiring"
67
#define TOOL_WRENCH "wrench"
78
#define TOOL_WELDER "welder"
89
#define TOOL_ANALYZER "analyzer"

code/__DEFINES/traits/declarations.dm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109
#define TRAIT_IGNOREDAMAGESLOWDOWN "ignoredamageslowdown"
110110
/// Makes the screen go black and white while illuminating all mobs based on their body temperature
111111
#define TRAIT_INFRARED_VISION "infrared_vision"
112+
/// Punches don't stun. Use this instead of setting punchstunchance to zero.
113+
#define TRAIT_NO_PUNCH_STUN "no-punch-stun"
112114

113115
////////////////////////////////////////////////////////////////////////////////////
114116
//-------------------------Species Specific defines-------------------------------//
@@ -441,6 +443,10 @@
441443
#define TRAIT_PRESENT_VISION "present-vision"
442444
#define TRAIT_DISK_VERIFIER "disk-verifier"
443445
#define TRAIT_NOMOBSWAP "no-mob-swap"
446+
/// Can allocate 5 points into one skill instead of the usual 4
447+
#define TRAIT_EXCEPTIONAL_SKILL "exceptional-skill"
448+
/// Acts as an additional skill point for piloting mechs, up to EXP_MASTER.
449+
#define TRAIT_SKILLED_PILOT "skilled-pilot"
444450
/// Can examine IDs to see if they are roundstart.
445451
#define TRAIT_ID_APPRAISER "id_appraiser"
446452
/// Gives us turf, mob and object vision through walls

code/__HELPERS/mobs.dm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ GLOBAL_LIST_EMPTY(species_list)
319319
* given `delay`. Returns `TRUE` on success or `FALSE` on failure.
320320
* Interaction_key is the assoc key under which the do_after is capped, with max_interact_count being the cap. Interaction key will default to target if not set.
321321
*/
322-
/proc/do_after(mob/user, delay, atom/target, timed_action_flags = NONE, progress = TRUE, datum/callback/extra_checks, interaction_key, max_interact_count = 1)
322+
/proc/do_after(mob/user, delay, atom/target, timed_action_flags = NONE, progress = TRUE, datum/callback/extra_checks, interaction_key, max_interact_count = 1, skill_check = null)
323323
if(!user)
324324
return FALSE
325325
if(!isnum(delay))
@@ -335,10 +335,13 @@ GLOBAL_LIST_EMPTY(species_list)
335335

336336
if(!(timed_action_flags & IGNORE_SLOWDOWNS))
337337
delay *= user.action_speed_modifier * user.do_after_coefficent() //yogs: darkspawn
338+
339+
if(skill_check && user.mind && !(timed_action_flags & IGNORE_SKILL_DELAY))
340+
delay *= (12 - user.get_skill(skill_check)) / 10
338341

339342
var/datum/progressbar/progbar
340343
if(progress)
341-
progbar = new(user, delay, target || user, timed_action_flags, extra_checks)
344+
progbar = new(user, delay, target || user, timed_action_flags, extra_checks, skill_check)
342345

343346
SEND_SIGNAL(user, COMSIG_DO_AFTER_BEGAN)
344347

code/_onclick/hud/alert.dm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,16 @@ or shoot a gun to move around via Newton's 3rd Law of Motion."
322322
var/mob/living/carbon/C = mob_viewer
323323
C.take(giver, receiving)
324324

325+
//SKILLS
326+
327+
/atom/movable/screen/alert/skill_up
328+
name = "Allocate Skill Points"
329+
desc = "You have unspent skill points! Click here to allocate them."
330+
331+
/atom/movable/screen/alert/skill_up/Click(location, control, params)
332+
. = ..()
333+
mob_viewer.hud_used?.skill_menu?.ui_interact(mob_viewer)
334+
325335
//ALIENS
326336

327337
/atom/movable/screen/alert/alien_tox

code/_onclick/hud/hud.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
4040
var/atom/movable/screen/rest_icon
4141
var/atom/movable/screen/throw_icon
4242
var/atom/movable/screen/module_store_icon
43+
var/atom/movable/screen/skill_menu/skill_menu
4344

4445
var/list/static_inventory = list() //the screen objects which are static
4546
var/list/toggleable_inventory = list() //the screen objects which can be hidden

code/_onclick/hud/human.dm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
using.screen_loc = UI_BOXAREA
102102
static_inventory += using
103103

104+
skill_menu = new /atom/movable/screen/skill_menu(src)
105+
skill_menu.icon = ui_style
106+
if(!widescreen_layout)
107+
skill_menu.screen_loc = UI_BOXAREA
108+
static_inventory += skill_menu
109+
104110
action_intent = new /atom/movable/screen/combattoggle/flashy(src)
105111
action_intent.icon = ui_style
106112
action_intent.screen_loc = ui_combat_toggle

code/_onclick/hud/screen_objects.dm

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,108 @@
118118
var/datum/language_holder/H = M.get_language_holder()
119119
H.open_language_menu(usr)
120120

121+
/atom/movable/screen/skill_menu
122+
name = "skills menu"
123+
icon = 'icons/mob/screen_midnight.dmi'
124+
icon_state = "skill_menu"
125+
screen_loc = ui_skill_menu
126+
var/list/allocated_skills = list(
127+
SKILL_PHYSIOLOGY = EXP_NONE,
128+
SKILL_MECHANICAL = EXP_NONE,
129+
SKILL_TECHNICAL = EXP_NONE,
130+
SKILL_SCIENCE = EXP_NONE,
131+
SKILL_FITNESS = EXP_NONE,
132+
)
133+
var/allocated_points = EXP_NONE
134+
135+
/atom/movable/screen/skill_menu/Click()
136+
ui_interact(usr)
137+
138+
/atom/movable/screen/skill_menu/ui_interact(mob/user, datum/tgui/ui)
139+
if(!user.mind)
140+
CRASH("[user.type] ([user]) tried to use the skill menu without a mind!")
141+
ui = SStgui.try_update_ui(user, src, ui)
142+
if (!ui)
143+
ui = new(user, src, "SkillMenu", "Allocate Skill Points")
144+
ui.open()
145+
146+
/atom/movable/screen/skill_menu/ui_data(mob/user)
147+
var/list/data = list()
148+
var/list/skill_data = list()
149+
for(var/skill in user.mind.skills)
150+
skill_data.Add(list(list(
151+
"base" = user.get_skill(skill),
152+
"allocated" = allocated_skills[skill],
153+
"exp_progress" = user.mind?.exp_progress[skill],
154+
)))
155+
data["skills"] = skill_data
156+
data["skill_points"] = user.mind.skill_points
157+
data["allocated_points"] = allocated_points
158+
data["exceptional_skill"] = HAS_MIND_TRAIT(user, TRAIT_EXCEPTIONAL_SKILL)
159+
return data
160+
161+
/atom/movable/screen/skill_menu/ui_static_data(mob/user)
162+
var/static/list/data = list(
163+
"exp_per_level" = EXPERIENCE_PER_LEVEL
164+
)
165+
return data
166+
167+
/atom/movable/screen/skill_menu/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
168+
. = ..()
169+
if(.)
170+
return
171+
var/mob/user = usr
172+
if(!user.mind)
173+
CRASH("User ([user]) without a mind attempted to allocate skill points!")
174+
switch(action)
175+
if("confirm")
176+
if(allocated_points > user.mind.skill_points)
177+
stack_trace("[user] attempted to allocate [allocated_points] skill points when they only had [user.mind.skill_points] available!")
178+
message_admins("[key_name_admin(user)] may have attempted an exploit to gain more skill points than intended!")
179+
qdel(allocated_skills)
180+
allocated_skills = list(
181+
SKILL_PHYSIOLOGY = EXP_NONE,
182+
SKILL_MECHANICAL = EXP_NONE,
183+
SKILL_TECHNICAL = EXP_NONE,
184+
SKILL_SCIENCE = EXP_NONE,
185+
SKILL_FITNESS = EXP_NONE,
186+
)
187+
allocated_points = EXP_NONE
188+
return TRUE
189+
for(var/skill in user.mind.skills)
190+
user.adjust_skill(skill, allocated_skills[skill], max_skill = EXP_GENIUS)
191+
allocated_skills[skill] = EXP_NONE
192+
user.mind.skill_points -= allocated_points
193+
allocated_points = EXP_NONE
194+
if(!user.mind.skill_points)
195+
user.clear_alert("skill points")
196+
return TRUE
197+
if("allocate")
198+
if(allocated_points + params["amount"] > user.mind.skill_points)
199+
return TRUE
200+
if(allocated_points + params["amount"] < 0)
201+
return TRUE
202+
if(allocated_skills[params["skill"]] + params["amount"] + user.get_skill(params["skill"]) > (4 + HAS_MIND_TRAIT(user, TRAIT_EXCEPTIONAL_SKILL)))
203+
return TRUE
204+
if(allocated_skills[params["skill"]] + params["amount"] < 0)
205+
return TRUE
206+
allocated_skills[params["skill"]] += params["amount"]
207+
allocated_points += params["amount"]
208+
return TRUE
209+
210+
/atom/movable/screen/skill_menu/ui_status(mob/user)
211+
if(!user.mind)
212+
return UI_CLOSE
213+
return UI_INTERACTIVE
214+
215+
/atom/movable/screen/skill_menu/ui_state(mob/user)
216+
return GLOB.always_state
217+
218+
/atom/movable/screen/skill_menu/ui_assets(mob/user)
219+
return list(
220+
get_asset_datum(/datum/asset/spritesheet/crafting),
221+
)
222+
121223
/atom/movable/screen/ghost/pai
122224
name = "pAI Candidate"
123225
icon = 'icons/mob/screen_midnight.dmi'

0 commit comments

Comments
 (0)