mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-13 17:14:47 +01:00
Merge pull request #12492 from optimumtact/patch-1
Brings some sanity to do_after and do_mob
This commit is contained in:
+39
-34
@@ -683,23 +683,23 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
var/holding = user.get_active_hand()
|
||||
var/timefraction = round(time/numticks)
|
||||
var/image/progbar
|
||||
var/continue_looping = 1
|
||||
for(var/i = 1 to numticks)
|
||||
if(user.client && progress)
|
||||
progbar = make_progress_bar(i, numticks, target)
|
||||
user.client.images |= progbar
|
||||
assign_progress_bar(user, progbar)
|
||||
sleep(timefraction)
|
||||
if(!user || !target)
|
||||
if(user && user.client)
|
||||
user.client.images -= progbar
|
||||
continue_looping = 0
|
||||
|
||||
if (continue_looping && !uninterruptible && (user.loc != user_loc || target.loc != target_loc || user.get_active_hand() != holding || user.incapacitated() || user.lying ))
|
||||
continue_looping = 0
|
||||
|
||||
cancel_progress_bar(user, progbar)//Clear the way for the next progbar image
|
||||
if(!continue_looping)
|
||||
return 0
|
||||
if (!uninterruptible && (user.loc != user_loc || target.loc != target_loc || user.get_active_hand() != holding || user.incapacitated() || 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
|
||||
|
||||
cancel_progress_bar(user, progbar)
|
||||
return 1
|
||||
|
||||
/proc/make_progress_bar(current_number, goal_number, atom/target)
|
||||
@@ -709,6 +709,14 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
progbar.icon_state = "prog_bar_[round(((current_number / goal_number) * 100), 10)]"
|
||||
progbar.pixel_y = 32
|
||||
return progbar
|
||||
|
||||
/proc/cancel_progress_bar(mob/user, image/progbar)
|
||||
if(user && user.client && progbar)
|
||||
user.client.images -= progbar
|
||||
|
||||
/proc/assign_progress_bar(mob/user, image/progbar)
|
||||
if(user && user.client && progbar)
|
||||
user.client.images |= progbar
|
||||
|
||||
/proc/do_after(mob/user, delay, numticks = 5, needhand = 1, atom/target = null, progress = 1)
|
||||
if(!user)
|
||||
@@ -722,46 +730,43 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
Tloc = target.loc
|
||||
|
||||
var/delayfraction = round(delay/numticks)
|
||||
|
||||
var/atom/Uloc = user.loc
|
||||
|
||||
var/holding = user.get_active_hand()
|
||||
var/holdingnull = 1 //User is not holding anything
|
||||
if(holding)
|
||||
holdingnull = 0 //User is holding a tool of some kind
|
||||
|
||||
var/image/progbar
|
||||
|
||||
var/continue_looping = 1
|
||||
for (var/i = 1 to numticks)
|
||||
if(user.client && progress)
|
||||
progbar = make_progress_bar(i, numticks, target)
|
||||
if(progbar)
|
||||
user.client.images |= progbar
|
||||
assign_progress_bar(user, progbar)
|
||||
|
||||
sleep(delayfraction)
|
||||
if(!user || user.stat || user.weakened || user.stunned || !(user.loc == Uloc))
|
||||
if(user && user.client && progbar)
|
||||
user.client.images -= progbar
|
||||
return 0
|
||||
continue_looping = 0
|
||||
|
||||
if(Tloc && (!target || Tloc != target.loc)) //Tloc not set when we don't want to track target
|
||||
if(user && user.client && progbar)
|
||||
user.client.images -= progbar
|
||||
return 0 // Target no longer exists or has moved
|
||||
if(continue_looping && Tloc && (!target || Tloc != target.loc)) //Tloc not set when we don't want to track target
|
||||
continue_looping = 0
|
||||
|
||||
if(needhand)
|
||||
if(continue_looping && 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 && progbar)
|
||||
user.client.images -= progbar
|
||||
return 0
|
||||
if(user.get_active_hand() != holding)
|
||||
if(user && user.client && progbar)
|
||||
user.client.images -= progbar
|
||||
return 0
|
||||
if(user && user.client && progbar)
|
||||
user.client.images -= progbar
|
||||
if(user && user.client && progbar)
|
||||
user.client.images -= progbar
|
||||
if(user && user.client && progbar)
|
||||
user.client.images -= progbar
|
||||
continue_looping = 0
|
||||
if(continue_looping && user.get_active_hand() != holding)
|
||||
continue_looping = 0
|
||||
|
||||
cancel_progress_bar(user, progbar)//Clear the way for the next progbar image
|
||||
if(!continue_looping)
|
||||
return 0
|
||||
|
||||
cancel_progress_bar(user,progbar)
|
||||
return 1
|
||||
|
||||
//Takes: Anything that could possibly have variables and a varname to check.
|
||||
|
||||
Reference in New Issue
Block a user