|
56 | 56 | /mob/proc/get_skill_multiplier(skill_type, skill_floor = SKILL_LEVEL_TRAINED, bonus = 0.2, malus = 0.2) |
57 | 57 | var/modifier = 1 |
58 | 58 | 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) |
61 | 61 | else |
62 | 62 | modifier += malus * max(1, skill_floor - skill_level) |
63 | 63 | 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) |
0 commit comments