Skip to content

Commit

Permalink
Merge pull request #1919 from tigercat2000/funlittletgthings
Browse files Browse the repository at this point in the history
Progress bars
  • Loading branch information
Fox-McCloud committed Sep 1, 2015
2 parents 2fd18a2 + 7f4ac72 commit 9695509
Show file tree
Hide file tree
Showing 139 changed files with 452 additions and 458 deletions.
4 changes: 2 additions & 2 deletions code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
var/obj/item/weapon/weldingtool/WT = W
if (WT.remove_fuel(0,user))
user << "<span class='notice'>Now welding the vent.</span>"
if(do_after(user, 20))
if(do_after(user, 20, target = src))
if(!src || !WT.isOn()) return
playsound(get_turf(src), 'sound/items/Welder2.ogg', 50, 1)
if(!welded)
Expand Down Expand Up @@ -302,7 +302,7 @@
return 1
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/binary_devices/pump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Thus, the two variables affect pump operation are set in New():
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/binary_devices/volume_pump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Thus, the two variables affect pump operation are set in New():
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/omni_devices/omni_base.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
return 1
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
if(do_after(user, 40))
if(do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/portables_connector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/trinary_devices/filter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Filter types:
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/trinary_devices/mixer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/tvalve.dm
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/unary/heat_exchanger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
return 1
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/unary/outlet_injector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
return 1
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/unary/thermal_plate.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
return 1
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
4 changes: 2 additions & 2 deletions code/ATMOSPHERICS/components/unary/vent_pump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
var/obj/item/weapon/weldingtool/WT = W
if (WT.remove_fuel(0,user))
user << "<span class='notice'>Now welding the vent.</span>"
if(do_after(user, 20))
if(do_after(user, 20, target = src))
if(!src || !WT.isOn()) return
playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)
if(!welded)
Expand Down Expand Up @@ -411,7 +411,7 @@
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
4 changes: 2 additions & 2 deletions code/ATMOSPHERICS/components/unary/vent_scrubber.dm
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
var/obj/item/weapon/weldingtool/WT = W
if (WT.remove_fuel(0,user))
user << "<span class='notice'>Now welding the scrubber.</span>"
if(do_after(user, 20))
if(do_after(user, 20, target = src))
if(!src || !WT.isOn()) return
playsound(get_turf(src), 'sound/items/Welder2.ogg', 50, 1)
if(!welded)
Expand Down Expand Up @@ -403,7 +403,7 @@
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/components/valve.dm
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
4 changes: 2 additions & 2 deletions code/ATMOSPHERICS/pipes/pipe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
if (istype(W, /obj/item/device/pipe_freezer))
if(!src.frozen) // If the pipe is not already frozen
user << "<span class='alert'>You begin to freeze the [src].</span>"
if (do_after(user, 60))
if (do_after(user, 60, target = src))
user.visible_message( \
"[user] freezes \the [src].", \
"<span class='notice'>You finished freezing \the [src].</span>", \
Expand Down Expand Up @@ -107,7 +107,7 @@
return 1
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/ATMOSPHERICS/pipes/vent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
return 1
playsound(T, 'sound/items/Ratchet.ogg', 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
if (do_after(user, 40))
if (do_after(user, 40, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
Expand Down
102 changes: 79 additions & 23 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ Turf and target are seperate in case you want to teleport some distance from a t
return M
if(M < 0)
return -M

/proc/get_mob_by_ckey(key)
if(!key)
return
Expand Down Expand Up @@ -779,45 +779,101 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl

else return get_step(ref, base_dir)

/proc/do_mob(var/mob/user , var/mob/target, var/time = 30) //This is quite an ugly solution but i refuse to use the old request system.
if(!user || !target) return 0
/proc/do_mob(var/mob/user , var/mob/target, var/time = 30, numticks = 5, var/stealth = 0) //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/user_loc = user.loc
var/target_loc = target.loc
var/holding = user.get_active_hand()
sleep(time)
if(!user || !target) return 0
if ( user.loc == user_loc && target.loc == target_loc && user.get_active_hand() == holding && !( user.stat ) && ( !user.stunned && !user.weakened && !user.paralysis && !user.lying ) )
return 1
else
return 0
var/timefraction = round(time/numticks)
var/image/progbar
for(var/i = 1 to numticks)
if(user.client)
progbar = make_progress_bar(i, numticks, target)
user.client.images |= progbar
sleep(timefraction)
if(!user || !target)
if(user && user.client)
user.client.images -= progbar
return 0
if ( user.loc != user_loc || target.loc != target_loc || user.get_active_hand() != holding || user.stat || user.stunned || user.weakened || user.paralysis || user.lying)
if(user && user.client)
user.client.images -= progbar
return 0
if(user && user.client)
user.client.images -= progbar
if(user && user.client)
user.client.images -= progbar
return 1

/proc/make_progress_bar(var/current_number, var/goal_number, var/atom/target)
if(current_number && goal_number && target)
var/image/progbar
progbar = image("icon" = 'icons/effects/doafter_icon.dmi', "loc" = target, "icon_state" = "prog_bar_0")
progbar.icon_state = "prog_bar_[round(((current_number / goal_number) * 100), 10)]"
progbar.pixel_y = 32
return progbar

/proc/do_after(var/mob/user as mob, delay as num, var/numticks = 5, var/needhand = 1)
if(!user || isnull(user))
/proc/do_after(mob/user, delay, numticks = 5, needhand = 1, atom/target = null)
if(!user)
return 0

if(numticks == 0)
return 0

var/atom/Tloc = null
if(target)
Tloc = target.loc

var/delayfraction = round(delay/numticks)
var/original_loc = user.loc
var/atom/Uloc = user.loc
var/holding = user.get_active_hand()

for(var/i = 0, i<numticks, i++)
var/holdingnull = 1 //User is not holding anything
if(holding)
holdingnull = 0 //User is holding a tool of some kind
var/image/progbar
for (var/i = 1 to numticks)
if(user.client)
progbar = make_progress_bar(i, numticks, target)
user.client.images |= progbar
sleep(delayfraction)


if(!user || user.stat || user.weakened || user.stunned || (user.loc != original_loc))
return 0
if(needhand && !(user.get_active_hand() == holding)) //Sometimes you don't want the user to have to keep their active hand
if(!user || user.stat || user.weakened || user.stunned || !(user.loc == Uloc))
if(user && user.client)
user.client.images -= progbar
return 0

if(Tloc && (!target || Tloc != target.loc)) //Tloc not set when we don't want to track target
if(user && user.client)
user.client.images -= progbar
return 0 // Target no longer exists or has moved

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 insert some item/tool into the construction
if(!holdingnull)
if(!holding)
if(user && user.client)
user.client.images -= progbar
return 0
if(user.get_active_hand() != holding)
if(user && user.client)
user.client.images -= progbar
return 0
if(user && user.client)
user.client.images -= progbar
if(user && user.client)
user.client.images -= progbar
if(user && user.client)
user.client.images -= progbar
return 1

//Takes: Anything that could possibly have variables and a varname to check.
//Returns: 1 if found, 0 if not.
/proc/hasvar(var/datum/A, var/varname)
if(A.vars.Find(lowertext(varname))) return 1
else return 0

//Returns: all the areas in the world
/proc/return_areas()
var/list/area/areas = list()
Expand All @@ -827,8 +883,8 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl

//Returns: all the areas in the world, sorted.
/proc/return_sorted_areas()
return sortAtom(return_areas())
return sortAtom(return_areas())

//Takes: Area type as text string or as typepath OR an instance of the area.
//Returns: A list of all areas of that type in the world.
/proc/get_areas(var/areatype)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/spells/conjure.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
targets -= T
playsound(get_turf(src), 'sound/items/welder.ogg', 50, 1)

if(do_after(usr,delay))
if(do_after(usr,delay, target = usr))
for(var/i=0,i<summon_amt,i++)
if(!targets.len)
break
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/cult/ritual.dm
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ var/engwords = list("travel", "blood", "join", "hell", "destroy", "technology",
V.show_message("\red [user] slices open a finger and begins to chant and paint symbols on the floor.", 3, "\red You hear chanting.", 2)
user << "\red You slice open one of your fingers and begin drawing a rune on the floor whilst chanting the ritual that binds your life essence with the dark arcane energies flowing through the surrounding world."
user.take_overall_damage((rand(9)+1)/10) // 0.1 to 1.0 damage
if(do_after(user, 50))
if(do_after(user, 50, target = user))
if(usr.get_active_hand() != src)
return
var/mob/living/carbon/human/H = user
Expand Down
10 changes: 5 additions & 5 deletions code/game/gamemodes/nuclear/nuclearbomb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ var/bomb_set

user.visible_message("[user] starts cutting loose the anchoring bolt covers on [src].", "You start cutting loose the anchoring bolt covers with [O]...")

if(do_after(user,40))
if(do_after(user,40, target = src))
if(!src || !user || !WT.remove_fuel(5, user)) return
user.visible_message("[user] cuts through the bolt covers on [src].", "You cut through the bolt cover.")
removal_stage = 1
Expand All @@ -105,7 +105,7 @@ var/bomb_set
if(istype(O,/obj/item/weapon/crowbar))
user.visible_message("[user] starts forcing open the bolt covers on [src].", "You start forcing open the anchoring bolt covers with [O]...")

if(do_after(user,15))
if(do_after(user,15, target = src))
if(!src || !user) return
user.visible_message("[user] forces open the bolt covers on [src].", "You force open the bolt covers.")
removal_stage = 2
Expand All @@ -122,7 +122,7 @@ var/bomb_set

user.visible_message("[user] starts cutting apart the anchoring system sealant on [src].", "You start cutting apart the anchoring system's sealant with [O]...")

if(do_after(user,40))
if(do_after(user,40, target = src))
if(!src || !user || !WT.remove_fuel(5, user)) return
user.visible_message("[user] cuts apart the anchoring system sealant on [src].", "You cut apart the anchoring system's sealant.")
removal_stage = 3
Expand All @@ -133,7 +133,7 @@ var/bomb_set

user.visible_message("[user] begins unwrenching the anchoring bolts on [src].", "You begin unwrenching the anchoring bolts...")

if(do_after(user,50))
if(do_after(user,50, target = src))
if(!src || !user) return
user.visible_message("[user] unwrenches the anchoring bolts on [src].", "You unwrench the anchoring bolts.")
removal_stage = 4
Expand All @@ -144,7 +144,7 @@ var/bomb_set

user.visible_message("[user] begins lifting [src] off of the anchors.", "You begin lifting the device off the anchors...")

if(do_after(user,80))
if(do_after(user,80, target = src))
if(!src || !user) return
user.visible_message("[user] crowbars [src] off of the anchors. It can now be moved.", "You jam the crowbar under the nuclear device and lift it off its anchors. You can now move it!")
anchored = 0
Expand Down

0 comments on commit 9695509

Please sign in to comment.