mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-19 02:54:41 +01:00
Ports tg's smooth progress bars
This commit is contained in:
@@ -180,4 +180,6 @@
|
||||
#define TURF_DRY 0
|
||||
#define TURF_WET_WATER 1
|
||||
#define TURF_WET_LUBE 2
|
||||
#define TURF_WET_ICE 3
|
||||
#define TURF_WET_ICE 3
|
||||
|
||||
#define APPEARANCE_UI_IGNORE_ALPHA RESET_COLOR|RESET_TRANSFORM|NO_CLIENT_COLOR|RESET_ALPHA
|
||||
@@ -162,3 +162,97 @@ proc/add_logs(mob/target, mob/user, what_done, var/object=null, var/addition=nul
|
||||
if(!admin) return
|
||||
msg_admin_attack("[key_name_admin(user)] [what_done] [key_name_admin(target)][object ? " with [object]" : " "][addition]")
|
||||
|
||||
/proc/do_mob(var/mob/user, var/mob/target, var/time = 30, var/uninterruptible = 0, progress = 1)
|
||||
if(!user || !target)
|
||||
return 0
|
||||
var/user_loc = user.loc
|
||||
|
||||
var/drifting = 0
|
||||
if(!user.Process_Spacemove(0) && user.inertia_dir)
|
||||
drifting = 1
|
||||
|
||||
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(drifting && !user.inertia_dir)
|
||||
drifting = 0
|
||||
user_loc = user.loc
|
||||
|
||||
if((!drifting && user.loc != user_loc) || target.loc != target_loc || user.get_active_hand() != holding || user.incapacitated() || user.lying )
|
||||
. = 0
|
||||
break
|
||||
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/drifting = 0
|
||||
if(!user.Process_Spacemove(0) && user.inertia_dir)
|
||||
drifting = 1
|
||||
|
||||
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(drifting && !user.inertia_dir)
|
||||
drifting = 0
|
||||
Uloc = user.loc
|
||||
|
||||
if(!user || user.stat || user.weakened || user.stunned || (!drifting && 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
|
||||
if (progress)
|
||||
qdel(progbar)
|
||||
@@ -601,95 +601,6 @@ 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, numticks = 5, var/uninterruptible = 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()
|
||||
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 (!uninterruptible && (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(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/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
|
||||
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 == 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)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/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.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
|
||||
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)
|
||||
. = ..()
|
||||
@@ -129,7 +129,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 = target)) //did they get deleted in that second?
|
||||
if(do_after(src, 10, 0, target = 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)
|
||||
@@ -138,7 +138,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 = target)) //did they get deleted NOW?
|
||||
if(do_after(src, 20, 0, target = 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>"
|
||||
@@ -148,7 +148,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 = target)) //how about now
|
||||
if(do_after(src, 20, 0, target = 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>"
|
||||
@@ -162,7 +162,7 @@
|
||||
stun(27)
|
||||
target.visible_message("<span class='warning'>[target] suddenly rises slightly into the air, their skin turning an ashy gray.</span>")
|
||||
target.Beam(src,icon_state="drain_life",icon='icons/effects/effects.dmi',time=26)
|
||||
if(do_after(src, 30, 9, 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, 30, 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)
|
||||
essence_regen_cap += 25
|
||||
|
||||
@@ -82,7 +82,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
|
||||
|
||||
@@ -430,7 +430,9 @@ proc/get_radio_key_from_channel(var/channel)
|
||||
speech_bubble_recipients.Add(M.client)
|
||||
|
||||
spawn(0)
|
||||
flick_overlay(image('icons/mob/talk.dmi', src, "h[speech_bubble_test]",MOB_LAYER+1), speech_bubble_recipients, 30)
|
||||
var/image/I = image('icons/mob/talk.dmi', src, "h[speech_bubble_test]", MOB_LAYER + 1)
|
||||
I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
|
||||
flick_overlay(I, speech_bubble_recipients, 30)
|
||||
|
||||
if(watching.len)
|
||||
var/rendered = "<span class='game say'><span class='name'>[src.name]</span> [not_heard].</span>"
|
||||
@@ -441,4 +443,6 @@ proc/get_radio_key_from_channel(var/channel)
|
||||
return 1
|
||||
|
||||
/mob/living/speech_bubble(var/bubble_state = "",var/bubble_loc = src, var/list/bubble_recipients = list())
|
||||
flick_overlay(image('icons/mob/talk.dmi', bubble_loc, bubble_state,MOB_LAYER+1), bubble_recipients, 30)
|
||||
var/image/I = image('icons/mob/talk.dmi', bubble_loc, bubble_state, MOB_LAYER + 1)
|
||||
I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
|
||||
flick_overlay(, bubble_recipients, 30)
|
||||
@@ -165,7 +165,7 @@
|
||||
|
||||
src.visible_message("<span class='userdanger'>\the [src] starts to eat \the [noms]!</span>","<span class='notice'>You start to eat \the [noms]. (This will take about [ufnomDelay] seconds.)</span>","<span class='userdanger'>You hear gnashing.</span>") //inform everyone what the fucking worm is doing.
|
||||
|
||||
if(do_after(src, nomDelay,5,0, target = noms))
|
||||
if(do_after(src, nomDelay, 0, target = noms))
|
||||
if(noms && Adjacent(noms) && (currentlyEating == noms))//It exists, were next to it, and it's still the thing were eating
|
||||
if(W)
|
||||
W.ChangeTurf(/turf/simulated/floor/plating)
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
else
|
||||
user.visible_message("<span class='warning'>[user] begins to wipe [H]'s face clean with \the [src].</span>", \
|
||||
"<span class='notice'>You begin to wipe off [H]'s face.</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) && do_after(H, 10, 0)) //user needs to keep their active hand, H does not.
|
||||
user.visible_message("<span class='notice'>[user] wipes [H]'s face clean with \the [src].</span>", \
|
||||
"<span class='notice'>You wipe off [H]'s face.</span>")
|
||||
H.lip_style = null
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 913 B |
Binary file not shown.
|
After Width: | Height: | Size: 571 B |
@@ -190,6 +190,7 @@
|
||||
#include "code\datums\mixed.dm"
|
||||
#include "code\datums\modules.dm"
|
||||
#include "code\datums\periodic_news.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