[MIRROR] Fix skill related runtimes in mindless mobs. (#965)

* Fix skill related runtimes in mindless mobs. (#53691)

Fixes related to mindless mobs using skills

* Fix skill related runtimes in mindless mobs.

Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
This commit is contained in:
SkyratBot
2020-09-24 20:33:19 +02:00
committed by GitHub
co-authored by Timberpoes
parent bb7f23fa99
commit 18f4fb5029
10 changed files with 103 additions and 67 deletions
+5 -5
View File
@@ -820,7 +820,7 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
closeToolTip(usr)
/// Called when a mob tries to use the item as a tool.Handles most checks.
/// Called when a mob tries to use the item as a tool. Handles most checks.
/obj/item/proc/use_tool(atom/target, mob/living/user, delay, amount=0, volume=0, datum/callback/extra_checks)
// No delay means there is no start message, and no reason to call tool_start_check before use_tool.
// Run the start check here so we wouldn't have to call it manually.
@@ -830,11 +830,11 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
var/skill_modifier = 1
if(tool_behaviour == TOOL_MINING && ishuman(user))
var/mob/living/carbon/human/H = user
skill_modifier = H.mind.get_skill_modifier(/datum/skill/mining, SKILL_SPEED_MODIFIER)
if(user.mind)
skill_modifier = user.mind.get_skill_modifier(/datum/skill/mining, SKILL_SPEED_MODIFIER)
if(H.mind.get_skill_level(/datum/skill/mining) >= SKILL_LEVEL_JOURNEYMAN && prob(H.mind.get_skill_modifier(/datum/skill/mining, SKILL_PROBS_MODIFIER))) // we check if the skill level is greater than Journeyman and then we check for the probality for that specific level.
mineral_scan_pulse(get_turf(H), SKILL_LEVEL_JOURNEYMAN - 2) //SKILL_LEVEL_JOURNEYMAN = 3 So to get range of 1+ we have to subtract 2 from it,.
if(user.mind.get_skill_level(/datum/skill/mining) >= SKILL_LEVEL_JOURNEYMAN && prob(user.mind.get_skill_modifier(/datum/skill/mining, SKILL_PROBS_MODIFIER))) // we check if the skill level is greater than Journeyman and then we check for the probality for that specific level.
mineral_scan_pulse(get_turf(user), SKILL_LEVEL_JOURNEYMAN - 2) //SKILL_LEVEL_JOURNEYMAN = 3 So to get range of 1+ we have to subtract 2 from it,.
delay *= toolspeed * skill_modifier
+22 -11
View File
@@ -97,8 +97,17 @@
new /obj/effect/particle_effect/foam(loc)
return (TOXLOSS)
/**
* Decrease the number of uses the bar of soap has.
*
* The higher the cleaning skill, the less likely the soap will lose a use.
* Arguments
* * user - The mob that is using the soap to clean.
*/
/obj/item/soap/proc/decreaseUses(mob/user)
var/skillcheck = user.mind.get_skill_modifier(/datum/skill/cleaning, SKILL_SPEED_MODIFIER)
var/skillcheck = 1
if(user?.mind)
skillcheck = user.mind.get_skill_modifier(/datum/skill/cleaning, SKILL_SPEED_MODIFIER)
if(prob(skillcheck*100)) //higher level = more uses assuming RNG is nice
uses--
if(uses <= 0)
@@ -109,7 +118,9 @@
. = ..()
if(!proximity || !check_allowed_items(target))
return
var/clean_speedies = cleanspeed * min(user.mind.get_skill_modifier(/datum/skill/cleaning, SKILL_SPEED_MODIFIER)+0.1,1) //less scaling for soapies
var/clean_speedies = 1 * cleanspeed
if(user.mind)
clean_speedies = cleanspeed * min(user.mind.get_skill_modifier(/datum/skill/cleaning, SKILL_SPEED_MODIFIER)+0.1,1) //less scaling for soapies
//I couldn't feasibly fix the overlay bugs caused by cleaning items we are wearing.
//So this is a workaround. This also makes more sense from an IC standpoint. ~Carn
if(user.client && ((target in user.client.screen) && !user.is_holding(target)))
@@ -119,17 +130,17 @@
if(do_after(user, clean_speedies, target = target))
to_chat(user, "<span class='notice'>You scrub \the [target.name] out.</span>")
var/obj/effect/decal/cleanable/cleanies = target
user?.mind.adjust_experience(/datum/skill/cleaning, max(round(cleanies.beauty/CLEAN_SKILL_BEAUTY_ADJUSTMENT),0)) //again, intentional that this does NOT round but mops do.
user.mind?.adjust_experience(/datum/skill/cleaning, max(round(cleanies.beauty/CLEAN_SKILL_BEAUTY_ADJUSTMENT),0)) //again, intentional that this does NOT round but mops do.
qdel(target)
decreaseUses(user)
else if(ishuman(target) && user.zone_selected == BODY_ZONE_PRECISE_MOUTH)
var/mob/living/carbon/human/H = user
var/mob/living/carbon/human/human_user = user
user.visible_message("<span class='warning'>\the [user] washes \the [target]'s mouth out with [src.name]!</span>", "<span class='notice'>You wash \the [target]'s mouth out with [src.name]!</span>") //washes mouth out with soap sounds better than 'the soap' here if(user.zone_selected == "mouth")
if(H.lip_style)
user?.mind.adjust_experience(/datum/skill/cleaning, CLEAN_SKILL_GENERIC_WASH_XP)
H.lip_style = null //removes lipstick
H.update_body()
if(human_user.lip_style)
user.mind?.adjust_experience(/datum/skill/cleaning, CLEAN_SKILL_GENERIC_WASH_XP)
human_user.lip_style = null //removes lipstick
human_user.update_body()
decreaseUses(user)
return
else if(istype(target, /obj/structure/window))
@@ -138,7 +149,7 @@
to_chat(user, "<span class='notice'>You clean \the [target.name].</span>")
target.remove_atom_colour(WASHABLE_COLOUR_PRIORITY)
target.set_opacity(initial(target.opacity))
user?.mind.adjust_experience(/datum/skill/cleaning, CLEAN_SKILL_GENERIC_WASH_XP)
user.mind?.adjust_experience(/datum/skill/cleaning, CLEAN_SKILL_GENERIC_WASH_XP)
decreaseUses(user)
else
user.visible_message("<span class='notice'>[user] begins to clean \the [target.name] with [src]...</span>", "<span class='notice'>You begin to clean \the [target.name] with [src]...</span>")
@@ -146,10 +157,10 @@
to_chat(user, "<span class='notice'>You clean \the [target.name].</span>")
if(user && isturf(target))
for(var/obj/effect/decal/cleanable/cleanable_decal in target)
user.mind.adjust_experience(/datum/skill/cleaning, round(cleanable_decal.beauty / CLEAN_SKILL_BEAUTY_ADJUSTMENT))
user.mind?.adjust_experience(/datum/skill/cleaning, round(cleanable_decal.beauty / CLEAN_SKILL_BEAUTY_ADJUSTMENT))
target.wash(CLEAN_SCRUB)
target.remove_atom_colour(WASHABLE_COLOUR_PRIORITY)
user?.mind.adjust_experience(/datum/skill/cleaning, CLEAN_SKILL_GENERIC_WASH_XP)
user.mind?.adjust_experience(/datum/skill/cleaning, CLEAN_SKILL_GENERIC_WASH_XP)
decreaseUses(user)
return
+23 -22
View File
@@ -363,28 +363,29 @@ GLOBAL_LIST_EMPTY(PDAs)
dat += "<i>Thank you for choosing ExperTrak® brand software! ExperTrak® inc. is proud to be a NanoTrasen employee expertise and effectiveness department subsidary!</i>"
dat += "<br><br>This software is designed to track and monitor your skill development as a NanoTrasen employee. Your job performance across different fields has been quantified and categorized below.<br>"
var/datum/mind/targetmind = user.mind
for (var/type in GLOB.skill_types)
var/datum/skill/S = GetSkillRef(type)
var/lvl_num = targetmind.get_skill_level(type)
var/lvl_name = uppertext(targetmind.get_skill_level_name(type))
var/exp = targetmind.get_skill_exp(type)
var/xp_prog_to_level = targetmind.exp_needed_to_level_up(type)
var/xp_req_to_level = 0
if (xp_prog_to_level)//is it even possible to level up?
xp_req_to_level = SKILL_EXP_LIST[lvl_num+1] - SKILL_EXP_LIST[lvl_num]
dat += "<HR><b>[S.name]</b>"
dat += "<br><i>[S.desc]</i>"
dat += "<ul><li>EMPLOYEE SKILL LEVEL: <b>[lvl_name]</b>"
if (exp && xp_req_to_level)
var/progress_percent = (xp_req_to_level-xp_prog_to_level)/xp_req_to_level
var/overall_percent = exp / SKILL_EXP_LIST[length(SKILL_EXP_LIST)]
dat += "<br>PROGRESS TO NEXT SKILL LEVEL:"
dat += "<br>" + num2loadingbar(progress_percent) + "([progress_percent*100])%"
dat += "<br>OVERALL DEVELOPMENT PROGRESS:"
dat += "<br>" + num2loadingbar(overall_percent) + "([overall_percent*100])%"
if (lvl_num >= length(SKILL_EXP_LIST) && !(type in targetmind.skills_rewarded))
dat += "<br><a href='byond://?src=[REF(src)];choice=SkillReward;skill=[type]'>Contact the Professional [S.title] Association</a>"
dat += "</li></ul>"
if(targetmind)
for (var/type in GLOB.skill_types)
var/datum/skill/S = GetSkillRef(type)
var/lvl_num = targetmind.get_skill_level(type)
var/lvl_name = uppertext(targetmind.get_skill_level_name(type))
var/exp = targetmind.get_skill_exp(type)
var/xp_prog_to_level = targetmind.exp_needed_to_level_up(type)
var/xp_req_to_level = 0
if (xp_prog_to_level)//is it even possible to level up?
xp_req_to_level = SKILL_EXP_LIST[lvl_num+1] - SKILL_EXP_LIST[lvl_num]
dat += "<HR><b>[S.name]</b>"
dat += "<br><i>[S.desc]</i>"
dat += "<ul><li>EMPLOYEE SKILL LEVEL: <b>[lvl_name]</b>"
if (exp && xp_req_to_level)
var/progress_percent = (xp_req_to_level-xp_prog_to_level)/xp_req_to_level
var/overall_percent = exp / SKILL_EXP_LIST[length(SKILL_EXP_LIST)]
dat += "<br>PROGRESS TO NEXT SKILL LEVEL:"
dat += "<br>" + num2loadingbar(progress_percent) + "([progress_percent*100])%"
dat += "<br>OVERALL DEVELOPMENT PROGRESS:"
dat += "<br>" + num2loadingbar(overall_percent) + "([overall_percent*100])%"
if (lvl_num >= length(SKILL_EXP_LIST) && !(type in targetmind.skills_rewarded))
dat += "<br><a href='byond://?src=[REF(src)];choice=SkillReward;skill=[type]'>Contact the Professional [S.title] Association</a>"
dat += "</li></ul>"
if(21)
dat += "<h4>[PDAIMG(mail)] SpaceMessenger V3.9.6</h4>"
dat += "<a href='byond://?src=[REF(src)];choice=Clear'>[PDAIMG(blank)]Clear Messages</a>"
+10 -3
View File
@@ -26,8 +26,13 @@
/obj/item/mop/proc/clean(turf/A, mob/living/cleaner)
if(reagents.has_reagent(/datum/reagent/water, 1) || reagents.has_reagent(/datum/reagent/water/holywater, 1) || reagents.has_reagent(/datum/reagent/consumable/ethanol/vodka, 1) || reagents.has_reagent(/datum/reagent/space_cleaner, 1))
for(var/obj/effect/decal/cleanable/cleanable_decal in A)
cleaner?.mind.adjust_experience(/datum/skill/cleaning, max(round(cleanable_decal.beauty / CLEAN_SKILL_BEAUTY_ADJUSTMENT, 1), 0)) //it is intentional that the mop rounds xp but soap does not, USE THE SACRED TOOL
// If there's a cleaner with a mind, let's gain some experience!
if(cleaner?.mind)
var/total_experience_gain = 0
for(var/obj/effect/decal/cleanable/cleanable_decal in A)
//it is intentional that the mop rounds xp but soap does not, USE THE SACRED TOOL
total_experience_gain += max(round(cleanable_decal.beauty / CLEAN_SKILL_BEAUTY_ADJUSTMENT, 1), 0)
cleaner.mind.adjust_experience(/datum/skill/cleaning, total_experience_gain)
A.wash(CLEAN_SCRUB)
reagents.expose(A, TOUCH, 10) //Needed for proper floor wetting.
@@ -53,7 +58,9 @@
if(T)
user.visible_message("<span class='notice'>[user] begins to clean \the [T] with [src].</span>", "<span class='notice'>You begin to clean \the [T] with [src]...</span>")
var/clean_speedies = user.mind.get_skill_modifier(/datum/skill/cleaning, SKILL_SPEED_MODIFIER)
var/clean_speedies = 1
if(user.mind)
clean_speedies = user.mind.get_skill_modifier(/datum/skill/cleaning, SKILL_SPEED_MODIFIER)
if(do_after(user, mopspeed*clean_speedies, target = T))
to_chat(user, "<span class='notice'>You finish mopping.</span>")
clean(T, user)