Skip to content

Commit 38aedce

Browse files
author
Matt Atlas
committed
the beginning of greatness
1 parent 9b3c12e commit 38aedce

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed
File renamed without changes.

code/__DEFINES/skills.dm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,12 @@
3030
#define SKILL_DIFFICULTY_MODIFIER_EASY 1
3131
#define SKILL_DIFFICULTY_MODIFIER_MEDIUM 2
3232
#define SKILL_DIFFICULTY_MODIFIER_HARD 4
33+
34+
/// Critical success on a difficulty class. Obtained by rolling a nat 20 or +10 over the DC. Used for skills at the moment, will be used for more later.
35+
#define CRITICAL_SUCCESS 2
36+
/// Normal success on a difficulty class. Obtained by rolling equal or higher than the DC. Used for skills at the moment, will be used for more later.
37+
#define SUCCESS 1
38+
/// Normal failure on a difficulty class. Obtained by rolling less than the DC. Used for skills at the moment, will be used for more later.
39+
#define FAILURE 0
40+
/// Critical failure on a difficulty class. Obtained by rolling a nat 1 or -10 under the DC. Used for skills at the moment, will be used for more later.
41+
#define CRITICAL_FAILURE -1

code/modules/mob/skills/skills.dm

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,37 @@
5656
/mob/proc/get_skill_multiplier(skill_type, skill_floor = SKILL_LEVEL_TRAINED, bonus = 0.2, malus = 0.2)
5757
var/modifier = 1
5858
var/skill_level = get_skill_level(skill_type)
59-
if(skill_level >= SKILL_LEVEL_TRAINED)
60-
modifier -= bonus * max(1, skill_level - skill_floor)
59+
if(skill_level > skill_floor)
60+
modifier -= bonus * max(0, skill_level - skill_floor)
6161
else
6262
modifier += malus * max(1, skill_floor - skill_level)
6363
return modifier
64+
65+
/**
66+
* A do_after modified by skill proficiency.
67+
*
68+
* delay = The base delay in seconds the do_after should take if skill level is equal to `skill_floor`.
69+
* target = The do_after target.
70+
* skill_type = The skill used for this do_after. Can be a list or a path.
71+
* skill_floor = The base skill level at which the delay is unaffected.
72+
* bonus/malus = The bonus added or removed for each step of skill difference, see get_skill_multiplier.
73+
* do_flags = The do_flags fed to the do_after.
74+
*/
75+
/mob/proc/do_after_skill(base_delay, atom/target, skill_type, skill_floor = SKILL_LEVEL_TRAINED, bonus = 0.2, malus = 0.2, do_flags)
76+
var/skill_mult
77+
if(islist(skill_type))
78+
for(var/skill in skill_type)
79+
skill_mult = min(skill_mult, get_skill_multiplier(skill, skill_floor, bonus, malus))
80+
else
81+
skill_mult = get_skill_multiplier(skill_type, skill_floor, bonus, malus)
82+
return do_after(src, base_delay * skill_mult, target, do_flags)
83+
84+
/**
85+
* Throws a DC challenge against the difficulty class. For explanation on how criticals work, see code\__DEFINES\skills.dm.
86+
* Remember that you should not check `if(!result)` for a failure. You should do `if(result >= FAILURE)` instead, so as to also check for a crit fail.
87+
*
88+
* difficulty_class = The DC to beat.
89+
* skill_type = The skill used for this check. Can be a list or a path.
90+
*/
91+
/mob/proc/skill_challenge(difficulty_class, skill_type)
92+
var/roll = rand(1, 20)

code/modules/power/singularity/emitter.dm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,12 @@
9898

9999
/obj/machinery/power/emitter/attack_hand(mob/user)
100100
add_fingerprint(user)
101-
if(user.get_skill_level(/singleton/skill/reactor_systems) <= SKILL_LEVEL_FAMILIAR)
102-
to_chat(user, SPAN_WARNING("You have no idea where the switch even is on this thing..."))
103-
return
101+
var/max_engineering_skill = max(user.get_skill_level(/singleton/skill/reactor_systems), user.get_skill_level(/singleton/skill/electrical_engineering))
102+
if(max_engineering_skill <= SKILL_LEVEL_TRAINED)
103+
to_chat(user, SPAN_WARNING("You try to find the switch on \the [src]... How do you even turn this thing on?"))
104+
if(!user.do_after_skill(3 SECONDS, src, list(/singleton/skill/reactor_systems, /singleton/skill/electrical_engineering)))
105+
return
106+
to_chat(user, SPAN_NOTICE("You finally find the switch!"))
104107
activate(user)
105108

106109
/obj/machinery/power/emitter/proc/activate(mob/user)

tgui/public/tgui.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)