From d6797056f2d9a4e0cab4e9a1eb087cd3d30412d5 Mon Sep 17 00:00:00 2001 From: PsiOmegaDelta Date: Fri, 26 Feb 2016 11:46:39 +0100 Subject: [PATCH] Adds progress bars to tasks that take time --- code/__defines/appearance.dm | 3 + code/_helpers/mobs.dm | 112 ++++++++++++++++++++++++++++++----- code/_helpers/unsorted.dm | 41 ------------- code/datums/progressbar.dm | 43 ++++++++++++++ icons/effects/progessbar.dmi | Bin 0 -> 571 bytes polaris.dme | 2 + 6 files changed, 146 insertions(+), 55 deletions(-) create mode 100644 code/__defines/appearance.dm create mode 100644 code/datums/progressbar.dm create mode 100644 icons/effects/progessbar.dmi diff --git a/code/__defines/appearance.dm b/code/__defines/appearance.dm new file mode 100644 index 0000000000..faa97e8f06 --- /dev/null +++ b/code/__defines/appearance.dm @@ -0,0 +1,3 @@ +// Consider these images/atoms as part of the UI/HUD +#define APPEARANCE_UI_IGNORE_ALPHA RESET_COLOR|RESET_TRANSFORM|NO_CLIENT_COLOR|RESET_ALPHA +#define APPEARANCE_UI RESET_COLOR|RESET_TRANSFORM|NO_CLIENT_COLOR diff --git a/code/_helpers/mobs.dm b/code/_helpers/mobs.dm index 9213765bbc..a12340dae6 100644 --- a/code/_helpers/mobs.dm +++ b/code/_helpers/mobs.dm @@ -30,13 +30,10 @@ proc/random_hair_style(gender, species = "Human") var/list/valid_hairstyles = list() for(var/hairstyle in hair_styles_list) var/datum/sprite_accessory/S = hair_styles_list[hairstyle] - - if(gender != NEUTER && gender != PLURAL) - if(gender == MALE && S.gender == FEMALE) - continue - if(gender == FEMALE && S.gender == MALE) - continue - + if(gender == MALE && S.gender == FEMALE) + continue + if(gender == FEMALE && S.gender == MALE) + continue if( !(species in S.species_allowed)) continue valid_hairstyles[hairstyle] = hair_styles_list[hairstyle] @@ -52,13 +49,10 @@ proc/random_facial_hair_style(gender, species = "Human") var/list/valid_facialhairstyles = list() for(var/facialhairstyle in facial_hair_styles_list) var/datum/sprite_accessory/S = facial_hair_styles_list[facialhairstyle] - - if(gender != NEUTER && gender != PLURAL) - if(gender == MALE && S.gender == FEMALE) - continue - if(gender == FEMALE && S.gender == MALE) - continue - + if(gender == MALE && S.gender == FEMALE) + continue + if(gender == FEMALE && S.gender == MALE) + continue if( !(species in S.species_allowed)) continue @@ -171,3 +165,93 @@ Proc for attack log creation, because really why not return 0 var/mob/living/silicon/robot/R = thing.loc return (thing in R.module.modules) + +/proc/get_exposed_defense_zone(var/atom/movable/target) + var/obj/item/weapon/grab/G = locate() in target + if(G && G.state >= GRAB_NECK) //works because mobs are currently not allowed to upgrade to NECK if they are grabbing two people. + return pick("head", "l_hand", "r_hand", "l_foot", "r_foot", "l_arm", "r_arm", "l_leg", "r_leg") + else + return pick("chest", "groin") + +/proc/do_mob(mob/user , mob/target, time = 30, uninterruptible = 0, progress = 1) + if(!user || !target) + return 0 + var/user_loc = user.loc + var/target_loc = target.loc + + var/holding = user.get_active_hand() + var/datum/progressbar/progbar + if (progress) + progbar = new(user, time, target) + + var/endtime = world.time+time + var/starttime = world.time + . = 1 + while (world.time < endtime) + sleep(1) + if (progress) + progbar.update(world.time - starttime) + if(!user || !target) + . = 0 + break + if(uninterruptible) + continue + + if(!user || user.incapacitated() || user.loc != user_loc) + . = 0 + break + + if(target.loc != target_loc || user.get_active_hand() != holding) + . = 0 + break + if (progbar) + qdel(progbar) + +/proc/do_after(mob/user, delay, atom/target = null, needhand = 1, progress = 1) + if(!user) + return 0 + var/atom/target_loc = null + if(target) + target_loc = target.loc + + var/atom/original_loc = user.loc + + var/holding = user.get_active_hand() + + var/holdingnull = 1 //User's hand started out empty, check for an empty hand + if(holding) + holdingnull = 0 //Users hand started holding something, check to see if it's still holding that + + var/datum/progressbar/progbar + if (progress) + progbar = new(user, delay, target) + + var/endtime = world.time + delay + var/starttime = world.time + . = 1 + while (world.time < endtime) + sleep(1) + if (progress) + progbar.update(world.time - starttime) + + if(!user || user.incapacitated() || user.loc != original_loc) + . = 0 + break + + if(target_loc && (!target || target_loc != target.loc)) + . = 0 + break + + if(needhand) + //This might seem like an odd check, but you can still need a hand even when it's empty + //i.e the hand is used to pull some item/tool out of the construction + if(!holdingnull) + if(!holding) + . = 0 + break + if(user.get_active_hand() != holding) + . = 0 + break + + if (progbar) + qdel(progbar) diff --git a/code/_helpers/unsorted.dm b/code/_helpers/unsorted.dm index 8057d65f96..f9a6583897 100644 --- a/code/_helpers/unsorted.dm +++ b/code/_helpers/unsorted.dm @@ -646,47 +646,6 @@ proc/GaussRandRound(var/sigma,var/roundto) else return get_step(ref, base_dir) -/proc/do_mob(var/mob/user, var/mob/target, var/delay = 30, var/numticks = 5, var/needhand = 1) //This is quite an ugly solution but i refuse to use the old request system. - if(!user || !target) return 0 - if(numticks == 0) return 0 - - var/delayfraction = round(delay/numticks) - var/original_user_loc = user.loc - var/original_target_loc = target.loc - var/holding = user.get_active_hand() - - for(var/i = 0, iu4^P)005u_0{{R3dEt5<0000gP)t-skE-z! z5)>{hG&VIm%m6bYAt(O;Gt6c)|CuuY%rgN0Gc#uYW|{wws`1a*B7Oh>00DGTPE!Ct z=GbNc006LhR9JLGWpiV4X>fFDZ*Bkpc$}5fy$ZrG6b0Zpd5X~P(){#qaFG`2U|*p` z8k-EYk_3HygB?ZiZ0BAs-*P!QJN4&bWZh+;Pve8z?(E3ap`hgD=4jI(1tr$F#m0RI zQAd+v_VC*>UA3QzjFQ>;kd~a1o7bz^^Y>}_|0xGp4!8nv1>j1+m4K@NR{?H`ybW+G zz^wqc2HYBO8^CPcvkuXZ_fHy8H$=bs4s(5=rj>009F@L_t(&f$i3@4T3-z zhT(GqaRXez5o85NkOeGm0+Z{l7{G?slG=`;j2`*H&(hxz%=>h2av>Ke_(A{x0RL=N zn6*cTVrvSI4x61RU%i*EwD;20TZhfT7;$0?nCbzvJU|Oz>F5K52MYgyr!C`i*%!Xk#5F) zm~8On1MSmQy4Ai)x8pwaz9IV%007Kr0sFAAIhEH`H_*OGciOjM&b2o9@_~M!eV6XF z@8xf9$UX!B05fv`^M7oUZ;k7zD}5el`>uC-p!W^k-=XhUegMJ