mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-15 18:14:22 +01:00
Merge pull request #14084 from MrStonedOne/GOOOOOF
Upgrades do_after and progress bars.
This commit is contained in:
+81
-1
@@ -139,4 +139,84 @@ Proc for attack log creation, because really why not
|
||||
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Has [what_done] [target ? "[target.name][(ismob(target) && target.ckey) ? "([target.ckey])" : ""]" : "NON-EXISTANT SUBJECT"][object ? " with [object]" : " "][addition][newhealthtxt][coordinates]</font>")
|
||||
if(target && ismob(target))
|
||||
target.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been [what_done] by [user ? "[user.name][(ismob(user) && user.ckey) ? "([user.ckey])" : ""]" : "NON-EXISTANT SUBJECT"][object ? " with [object]" : " "][addition][newhealthtxt][coordinates]</font>")
|
||||
log_attack("[user ? "[user.name][(ismob(user) && user.ckey) ? "([user.ckey])" : ""]" : "NON-EXISTANT SUBJECT"] [what_done] [target ? "[target.name][(ismob(target) && target.ckey)? "([target.ckey])" : ""]" : "NON-EXISTANT SUBJECT"][object ? " with [object]" : " "][addition][newhealthtxt][coordinates]")
|
||||
log_attack("[user ? "[user.name][(ismob(user) && user.ckey) ? "([user.ckey])" : ""]" : "NON-EXISTANT SUBJECT"] [what_done] [target ? "[target.name][(ismob(target) && target.ckey)? "([target.ckey])" : ""]" : "NON-EXISTANT SUBJECT"][object ? " with [object]" : " "][addition][newhealthtxt][coordinates]")
|
||||
|
||||
|
||||
|
||||
/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
|
||||
. = 1
|
||||
while (world.time < endtime)
|
||||
if (progress)
|
||||
progbar.update(endtime - world.time)
|
||||
if(!user || !target)
|
||||
. = 0
|
||||
break
|
||||
if(uninterruptible)
|
||||
continue
|
||||
if(user.loc != user_loc || target.loc != target_loc || user.get_active_hand() != holding || user.incapacitated() || user.lying )
|
||||
. = 0
|
||||
break
|
||||
sleep(1)
|
||||
if (progress)
|
||||
qdel(progbar)
|
||||
|
||||
|
||||
/proc/do_after(mob/user, delay, needhand = 1, atom/target = null, progress = 1)
|
||||
if(!user)
|
||||
return 0
|
||||
var/atom/Tloc = null
|
||||
if(target)
|
||||
Tloc = target.loc
|
||||
|
||||
var/atom/Uloc = 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)
|
||||
if (progress)
|
||||
progbar.update(world.time - starttime)
|
||||
|
||||
if(!user || user.stat || user.weakened || user.stunned || user.loc != Uloc)
|
||||
. = 0
|
||||
break
|
||||
|
||||
if(Tloc && (!target || Tloc != 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
|
||||
sleep(1)
|
||||
if (progress)
|
||||
qdel(progbar)
|
||||
|
||||
+2
-104
@@ -666,108 +666,6 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
|
||||
else return get_step(ref, base_dir)
|
||||
|
||||
/proc/do_mob(mob/user , mob/target, time = 30, numticks = 5, uninterruptible = 0, progress = 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/user_loc = user.loc
|
||||
user.last_move = null
|
||||
var/target_loc = target.loc
|
||||
target.last_move = null
|
||||
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)
|
||||
assign_progress_bar(user, progbar)
|
||||
sleep(timefraction)
|
||||
if(!user || !target)
|
||||
continue_looping = 0
|
||||
|
||||
if (continue_looping && !uninterruptible && (user.loc != user_loc || user.last_move != null || target.loc != target_loc || target.last_move != null || 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
|
||||
|
||||
cancel_progress_bar(user, progbar)
|
||||
return 1
|
||||
|
||||
/proc/make_progress_bar(current_number, goal_number, 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/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)
|
||||
return 0
|
||||
|
||||
if(numticks == 0)
|
||||
return 0
|
||||
|
||||
var/atom/Tloc = null
|
||||
if(target)
|
||||
Tloc = target.loc
|
||||
var/atom/movable/AMtarget
|
||||
if(istype(target,/atom/movable))
|
||||
AMtarget = target
|
||||
AMtarget.last_move = null
|
||||
var/delayfraction = round(delay/numticks)
|
||||
|
||||
var/atom/Uloc = user.loc
|
||||
user.last_move = null
|
||||
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)
|
||||
assign_progress_bar(user, progbar)
|
||||
|
||||
sleep(delayfraction)
|
||||
if(!user || user.stat || user.weakened || user.stunned || !(user.loc == Uloc) || (user.last_move != null))
|
||||
continue_looping = 0
|
||||
|
||||
if(continue_looping && Tloc && (!target || Tloc != target.loc || (AMtarget && AMtarget.last_move != null))) //Tloc not set when we don't want to track target
|
||||
continue_looping = 0
|
||||
|
||||
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)
|
||||
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.
|
||||
//Returns: 1 if found, 0 if not.
|
||||
/proc/hasvar(datum/A, varname)
|
||||
@@ -1217,7 +1115,7 @@ B --><-- A
|
||||
transform = shift
|
||||
|
||||
SpinAnimation(rotation_speed, -1, clockwise, rotation_segments)
|
||||
|
||||
|
||||
//we stack the orbits up client side, so we can assign this back to normal server side without it breaking the orbit
|
||||
transform = initial_transform
|
||||
while(orbiting && orbiting == A && A.loc)
|
||||
@@ -1227,7 +1125,7 @@ B --><-- A
|
||||
loc = targetloc
|
||||
lastloc = loc
|
||||
sleep(0.6)
|
||||
|
||||
|
||||
if (orbiting == A) //make sure we haven't started orbiting something else.
|
||||
orbiting = null
|
||||
SpinAnimation(0,0)
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/datum/progressbar
|
||||
var/goal = 1
|
||||
var/image/bar
|
||||
var/shown = 0
|
||||
var/mob/user
|
||||
var/client/client
|
||||
|
||||
/datum/progressbar/New(mob/User, goal_number, atom/target)
|
||||
. = ..()
|
||||
if (!istype(target))
|
||||
EXCEPTION("Invalid target given")
|
||||
if (goal_number)
|
||||
goal = goal_number
|
||||
bar = image('icons/effects/progessbar.dmi', target, "prog_bar_0")
|
||||
bar.pixel_y = 32
|
||||
user = User
|
||||
if (user)
|
||||
client = user.client
|
||||
|
||||
/datum/progressbar/proc/update(progress)
|
||||
//world << "Update [progress] - [goal] - [(progress / goal)] - [((progress / goal) * 100)] - [round(((progress / goal) * 100), 5)]"
|
||||
if (!user || !user.client)
|
||||
shown = 0
|
||||
return
|
||||
if (user.client != client)
|
||||
if (client)
|
||||
client.images -= bar
|
||||
if (user.client)
|
||||
user.client.images += bar
|
||||
|
||||
progress = Clamp(progress, 0, goal)
|
||||
bar.icon_state = "prog_bar_[round(((progress / goal) * 100), 5)]"
|
||||
if (!shown)
|
||||
user.client.images += bar
|
||||
shown = 1
|
||||
|
||||
/datum/progressbar/Destroy()
|
||||
if (client)
|
||||
client.images -= bar
|
||||
qdel(bar)
|
||||
. = ..()
|
||||
@@ -28,7 +28,7 @@
|
||||
halo = image("icon"='icons/effects/effects.dmi',"icon_state" ="electricity","layer" = EFFECTS_LAYER)
|
||||
user.overlays.Add(halo)
|
||||
playsound(get_turf(user), Snd, 50, 0)
|
||||
if(do_mob(user,user,100,uninterruptible=1))
|
||||
if(do_mob(user,user,100,1))
|
||||
if(ready && cast_check(skipcharge=1))
|
||||
choose_targets()
|
||||
else
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
draining = 1
|
||||
essence_drained += rand(15, 20)
|
||||
src << "<span class='revennotice'>You search for the soul of [target].</span>"
|
||||
if(do_after(src, 10, 3, 0, target)) //did they get deleted in that second?
|
||||
if(do_after(src, 10, 0, target)) //did they get deleted in that second?
|
||||
if(target.ckey)
|
||||
src << "<span class='revennotice'>Their soul burns with intelligence.</span>"
|
||||
essence_drained += rand(20, 30)
|
||||
@@ -178,7 +178,7 @@
|
||||
essence_drained += rand(40, 50)
|
||||
else
|
||||
src << "<span class='revennotice'>Their soul is weak and faltering.</span>"
|
||||
if(do_after(src, 20, 6, 0, target)) //did they get deleted NOW?
|
||||
if(do_after(src, 20, 0, target)) //did they get deleted NOW?
|
||||
switch(essence_drained)
|
||||
if(1 to 30)
|
||||
src << "<span class='revennotice'>[target] will not yield much essence. Still, every bit counts.</span>"
|
||||
@@ -188,7 +188,7 @@
|
||||
src << "<span class='revenboldnotice'>Such a feast! [target] will yield much essence to you.</span>"
|
||||
if(90 to INFINITY)
|
||||
src << "<span class='revenbignotice'>Ah, the perfect soul. [target] will yield massive amounts of essence to you.</span>"
|
||||
if(do_after(src, 20, 6, 0, target)) //how about now
|
||||
if(do_after(src, 20, 0, target)) //how about now
|
||||
if(!target.stat)
|
||||
src << "<span class='revenwarning'>They are now powerful enough to fight off your draining.</span>"
|
||||
target << "<span class='boldannounce'>You feel something tugging across your body before subsiding.</span>"
|
||||
@@ -202,7 +202,7 @@
|
||||
stun(46)
|
||||
target.visible_message("<span class='warning'>[target] suddenly rises slightly into the air, their skin turning an ashy gray.</span>")
|
||||
Beam(target,icon_state="drain_life",icon='icons/effects/effects.dmi',time=44)
|
||||
if(do_after(src, 50, 15, 0, target)) //As one cannot prove the existance of ghosts, ghosts cannot prove the existance of the target they were draining.
|
||||
if(do_after(src, 50, 0, target)) //As one cannot prove the existance of ghosts, ghosts cannot prove the existance of the target they were draining.
|
||||
change_essence_amount(essence_drained, 0, target)
|
||||
if(essence_drained <= 90 && target.stat != DEAD)
|
||||
essence_regen_cap += 5
|
||||
|
||||
@@ -818,7 +818,7 @@ About the new airlock wires panel:
|
||||
"<span class='notice'>You begin [welded ? "unwelding":"welding"] the airlock...</span>", \
|
||||
"<span class='italics'>You hear welding.</span>")
|
||||
playsound(loc, 'sound/items/Welder.ogg', 40, 1)
|
||||
if(do_after(user,40/C.toolspeed,5,1, target = src))
|
||||
if(do_after(user,40/C.toolspeed, 1, target = src))
|
||||
if(density && !operating)//Door must be closed to weld.
|
||||
if( !istype(src, /obj/machinery/door/airlock) || !user || !W || !W.isOn() || !user.loc )
|
||||
return
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
else
|
||||
user.visible_message("<span class='warning'>[user] begins to wipe [H]'s lipstick off with \the [src].</span>", \
|
||||
"<span class='notice'>You begin to wipe off [H]'s lipstick...</span>")
|
||||
if(do_after(user, 10, target = H) && do_after(H, 10, 5, 0)) //user needs to keep their active hand, H does not.
|
||||
if(do_after(user, 10, target = H))
|
||||
user.visible_message("[user] wipes [H]'s lipstick off with \the [src].", \
|
||||
"<span class='notice'>You wipe off [H]'s lipstick.</span>")
|
||||
H.lip_style = null
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
return
|
||||
user << "<span class='notice'>You begin cutting \the [src] apart...</span>"
|
||||
playsound(loc, cutting_sound, 40, 1)
|
||||
if(do_after(user,40/W.toolspeed,5,1, target = src))
|
||||
if(do_after(user,40/W.toolspeed,1, target = src))
|
||||
if( !opened || !istype(src, /obj/structure/closet) || !user || !WT || !WT.isOn() || !user.loc )
|
||||
return
|
||||
playsound(loc, cutting_sound, 50, 1)
|
||||
@@ -234,7 +234,7 @@
|
||||
if(WT.remove_fuel(0,user))
|
||||
user << "<span class='notice'>You begin [welded ? "unwelding":"welding"] \the [src]...</span>"
|
||||
playsound(loc, 'sound/items/Welder2.ogg', 40, 1)
|
||||
if(do_after(user,40,5,1, target = src))
|
||||
if(do_after(user,40,1, target = src))
|
||||
if(opened || !istype(src, /obj/structure/closet) || !user || !WT || !WT.isOn() || !user.loc )
|
||||
return
|
||||
playsound(loc, 'sound/items/welder.ogg', 50, 1)
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
if(open)
|
||||
GM.visible_message("<span class='danger'>[user] starts to give [GM] a swirlie!</span>", "<span class='userdanger'>[user] starts to give [GM] a swirlie...</span>")
|
||||
swirlie = GM
|
||||
if(do_after(user, 30, 5, 0, target = src))
|
||||
if(do_after(user, 30, 0, target = src))
|
||||
GM.visible_message("<span class='danger'>[user] gives [GM] a swirlie!</span>", "<span class='userdanger'>[user] gives [GM] a swirlie!</span>", "<span class='italics'>You hear a toilet flushing.</span>")
|
||||
if(iscarbon(GM))
|
||||
var/mob/living/carbon/C = GM
|
||||
|
||||
@@ -388,7 +388,7 @@ var/const/GALOSHES_DONT_HELP = 4
|
||||
last_special = world.time + CLICK_CD_BREAKOUT
|
||||
visible_message("<span class='warning'>[src] attempts to unbuckle themself!</span>", \
|
||||
"<span class='notice'>You attempt to unbuckle yourself... (This will take around one minute and you need to stay still.)</span>")
|
||||
if(do_after(src, 600, needhand = 0, target = src))
|
||||
if(do_after(src, 600, 0, target = src))
|
||||
if(!buckled)
|
||||
return
|
||||
buckled.user_unbuckle_mob(src,src)
|
||||
@@ -431,7 +431,7 @@ var/const/GALOSHES_DONT_HELP = 4
|
||||
if(!cuff_break)
|
||||
visible_message("<span class='warning'>[src] attempts to remove [I]!</span>")
|
||||
src << "<span class='notice'>You attempt to remove [I]... (This will take around [displaytime] minutes and you need to stand still.)</span>"
|
||||
if(do_after(src, breakouttime, 10, 0, target = src))
|
||||
if(do_after(src, breakouttime, 0, target = src))
|
||||
if(I.loc != src || buckled)
|
||||
return
|
||||
visible_message("<span class='danger'>[src] manages to remove [I]!</span>")
|
||||
@@ -457,7 +457,7 @@ var/const/GALOSHES_DONT_HELP = 4
|
||||
breakouttime = 50
|
||||
visible_message("<span class='warning'>[src] is trying to break [I]!</span>")
|
||||
src << "<span class='notice'>You attempt to break [I]... (This will take around 5 seconds and you need to stand still.)</span>"
|
||||
if(do_after(src, breakouttime, needhand = 0, target = src))
|
||||
if(do_after(src, breakouttime, 0, target = src))
|
||||
if(!I.loc || buckled)
|
||||
return
|
||||
visible_message("<span class='danger'>[src] manages to break [I]!</span>")
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
D << "<span class='warning'>You can't seem to find the [pick(faux_gadgets)]! Without it, [src] [pick(faux_problems)].</span>"
|
||||
return
|
||||
D.visible_message("<span class='notice'>[D] begins to reactivate [src].</span>", "<span class='notice'>You begin to reactivate [src]...</span>")
|
||||
if(do_after(user,30,needhand = 1, target = src))
|
||||
if(do_after(user,30, 1, target = src))
|
||||
adjustBruteLoss(-getBruteLoss()) //Heal all brute damage
|
||||
stat = CONSCIOUS
|
||||
icon_state = icon_living
|
||||
@@ -49,7 +49,7 @@
|
||||
if("Cannibalize")
|
||||
if(D.health < D.maxHealth)
|
||||
D.visible_message("<span class='notice'>[D] begins to cannibalize parts from [src].</span>", "<span class='notice'>You begin to cannibalize parts from [src]...</span>")
|
||||
if(do_after(D, 60,5,0, target = src))
|
||||
if(do_after(D, 60, 0, target = src))
|
||||
D.visible_message("<span class='notice'>[D] repairs itself using [src]'s remains!</span>", "<span class='notice'>You repair yourself using [src]'s remains.</span>")
|
||||
D.adjustBruteLoss(-src.maxHealth)
|
||||
new /obj/effect/decal/cleanable/oil/streak(get_turf(src))
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 455 B |
Binary file not shown.
|
After Width: | Height: | Size: 571 B |
@@ -183,6 +183,7 @@
|
||||
#include "code\datums\modules.dm"
|
||||
#include "code\datums\mutations.dm"
|
||||
#include "code\datums\outfit.dm"
|
||||
#include "code\datums\progressbar.dm"
|
||||
#include "code\datums\recipe.dm"
|
||||
#include "code\datums\spell.dm"
|
||||
#include "code\datums\supplypacks.dm"
|
||||
|
||||
Reference in New Issue
Block a user