mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-09 16:12:17 +00:00
Allows do_mob and do_after to be exclusive, to prevent stacking
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#define GODMODE 0x1000
|
||||
#define FAKEDEATH 0x2000 // Replaces stuff like changeling.changeling_fakedeath.
|
||||
#define DISFIGURED 0x4000 // Set but never checked. Remove this sometime and replace occurences with the appropriate organ code
|
||||
#define DOING_TASK 0x8000 // Performing a do_after or do_mob that's exclusive
|
||||
|
||||
// Grab levels.
|
||||
#define GRAB_PASSIVE 1
|
||||
|
||||
@@ -142,9 +142,14 @@ Proc for attack log creation, because really why not
|
||||
else
|
||||
return pick("chest", "groin")
|
||||
|
||||
/proc/do_mob(mob/user , mob/target, time = 30, target_zone = 0, uninterruptible = FALSE, progress = TRUE, ignore_movement = FALSE)
|
||||
/proc/do_mob(mob/user , mob/target, time = 30, target_zone = 0, uninterruptible = FALSE, progress = TRUE, ignore_movement = FALSE, exclusive = FALSE)
|
||||
if(!user || !target)
|
||||
return 0
|
||||
if(!time)
|
||||
return 1 //Done!
|
||||
if(user.status_flags & DOING_TASK)
|
||||
to_chat(user, "<span class='warning'>You're in the middle of doing something else already.</span>")
|
||||
return 0 //Performing an exclusive do_after or do_mob already
|
||||
var/user_loc = user.loc
|
||||
var/target_loc = target.loc
|
||||
|
||||
@@ -155,6 +160,10 @@ Proc for attack log creation, because really why not
|
||||
|
||||
var/endtime = world.time+time
|
||||
var/starttime = world.time
|
||||
|
||||
if(exclusive)
|
||||
user.status_flags |= DOING_TASK
|
||||
|
||||
. = TRUE
|
||||
while (world.time < endtime)
|
||||
stoplag(1)
|
||||
@@ -186,14 +195,20 @@ Proc for attack log creation, because really why not
|
||||
. = FALSE
|
||||
break
|
||||
|
||||
if(exclusive)
|
||||
user.status_flags &= ~DOING_TASK
|
||||
|
||||
if (progbar)
|
||||
qdel(progbar)
|
||||
|
||||
/proc/do_after(mob/user, delay, atom/target = null, needhand = TRUE, progress = TRUE, incapacitation_flags = INCAPACITATION_DEFAULT, ignore_movement = FALSE, max_distance = null)
|
||||
/proc/do_after(mob/user, delay, atom/target = null, needhand = TRUE, progress = TRUE, incapacitation_flags = INCAPACITATION_DEFAULT, ignore_movement = FALSE, max_distance = null, exclusive = FALSE)
|
||||
if(!user)
|
||||
return 0
|
||||
if(!delay)
|
||||
return 1 //Okay. Done.
|
||||
if(user.status_flags & DOING_TASK)
|
||||
to_chat(user, "<span class='warning'>You're in the middle of doing something else already.</span>")
|
||||
return 0 //Performing an exclusive do_after or do_mob already
|
||||
var/atom/target_loc = null
|
||||
if(target)
|
||||
target_loc = target.loc
|
||||
@@ -214,6 +229,10 @@ Proc for attack log creation, because really why not
|
||||
|
||||
var/endtime = world.time + delay
|
||||
var/starttime = world.time
|
||||
|
||||
if(exclusive)
|
||||
user.status_flags |= DOING_TASK
|
||||
|
||||
. = 1
|
||||
while (world.time < endtime)
|
||||
stoplag(1)
|
||||
@@ -250,6 +269,9 @@ Proc for attack log creation, because really why not
|
||||
. = FALSE
|
||||
break
|
||||
|
||||
if(exclusive)
|
||||
user.status_flags &= ~DOING_TASK
|
||||
|
||||
if(progbar)
|
||||
qdel(progbar)
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
continue
|
||||
if(used == amount)
|
||||
break
|
||||
if(!do_mob(user, M, W.damage/3))
|
||||
if(!do_mob(user, M, W.damage/3, exclusive = TRUE))
|
||||
to_chat(user, "<span class='notice'>You must stand still to bandage wounds.</span>")
|
||||
break
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
continue
|
||||
if(used == amount)
|
||||
break
|
||||
if(!do_mob(user, M, W.damage/5))
|
||||
if(!do_mob(user, M, W.damage/5, exclusive = TRUE))
|
||||
to_chat(user, "<span class='notice'>You must stand still to bandage wounds.</span>")
|
||||
break
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
else
|
||||
user.visible_message("<span class='notice'>\The [user] starts salving wounds on [M]'s [affecting.name].</span>", \
|
||||
"<span class='notice'>You start salving the wounds on [M]'s [affecting.name].</span>" )
|
||||
if(!do_mob(user, M, 10))
|
||||
if(!do_mob(user, M, 10, exclusive = TRUE))
|
||||
to_chat(user, "<span class='notice'>You must stand still to salve wounds.</span>")
|
||||
return 1
|
||||
if(affecting.is_salved()) // We do a second check after the delay, in case it was bandaged after the first check.
|
||||
@@ -281,7 +281,7 @@
|
||||
continue
|
||||
//if(used == amount) //VOREStation Edit
|
||||
// break //VOREStation Edit
|
||||
if(!do_mob(user, M, W.damage/5))
|
||||
if(!do_mob(user, M, W.damage/5, exclusive = TRUE))
|
||||
to_chat(user, "<span class='notice'>You must stand still to bandage wounds.</span>")
|
||||
break
|
||||
if(affecting.is_bandaged() && affecting.is_disinfected()) // We do a second check after the delay, in case it was bandaged after the first check.
|
||||
@@ -336,7 +336,7 @@
|
||||
else
|
||||
user.visible_message("<span class='notice'>\The [user] starts salving wounds on [M]'s [affecting.name].</span>", \
|
||||
"<span class='notice'>You start salving the wounds on [M]'s [affecting.name].</span>" )
|
||||
if(!do_mob(user, M, 10))
|
||||
if(!do_mob(user, M, 10, exclusive = TRUE))
|
||||
to_chat(user, "<span class='notice'>You must stand still to salve wounds.</span>")
|
||||
return 1
|
||||
if(affecting.is_salved()) // We do a second check after the delay, in case it was bandaged after the first check.
|
||||
@@ -383,7 +383,7 @@
|
||||
to_chat(user, "<span class='danger'>You can't apply a splint to the arm you're using!</span>")
|
||||
return
|
||||
user.visible_message("<span class='danger'>[user] starts to apply \the [src] to their [limb].</span>", "<span class='danger'>You start to apply \the [src] to your [limb].</span>", "<span class='danger'>You hear something being wrapped.</span>")
|
||||
if(do_after(user, 50, M))
|
||||
if(do_after(user, 50, M, exclusive = TRUE))
|
||||
if(affecting.splinted)
|
||||
to_chat(user, "<span class='danger'>[M]'s [limb] is already splinted!</span>")
|
||||
return
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
if (istype(M,/mob/living/silicon/robot)) //Repairing cyborgs
|
||||
var/mob/living/silicon/robot/R = M
|
||||
if (R.getBruteLoss() || R.getFireLoss())
|
||||
if(do_after(user,7 * toolspeed))
|
||||
if(do_after(user, 7 * toolspeed, exclusive = TRUE))
|
||||
R.adjustBruteLoss(-15)
|
||||
R.adjustFireLoss(-15)
|
||||
R.updatehealth()
|
||||
@@ -51,9 +51,9 @@
|
||||
else if(can_use(1))
|
||||
user.setClickCooldown(user.get_attack_speed(src))
|
||||
if(S.open >= 2)
|
||||
if(do_after(user,5 * toolspeed))
|
||||
if(do_after(user, 5 * toolspeed, exclusive = TRUE))
|
||||
S.heal_damage(restoration_internal, restoration_internal, robo_repair = 1)
|
||||
else if(do_after(user,5 * toolspeed))
|
||||
else if(do_after(user, 5 * toolspeed, exclusive = TRUE))
|
||||
S.heal_damage(restoration_external,restoration_external, robo_repair =1)
|
||||
H.updatehealth()
|
||||
use(1)
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
|
||||
if (recipe.time)
|
||||
to_chat(user, "<span class='notice'>Building [recipe.title] ...</span>")
|
||||
if (!do_after(user, recipe.time))
|
||||
if (!do_after(user, recipe.time, exclusive = TRUE))
|
||||
return
|
||||
|
||||
if (use(required))
|
||||
|
||||
@@ -162,7 +162,7 @@
|
||||
// Not staying still fails you too.
|
||||
if(success)
|
||||
var/calc_duration = rand(S.min_duration, S.max_duration)
|
||||
if(!do_mob(user, M, calc_duration * toolspeed, zone))
|
||||
if(!do_mob(user, M, calc_duration * toolspeed, zone, exclusive = TRUE))
|
||||
success = FALSE
|
||||
to_chat(user, "<span class='warning'>You must remain close to and keep focused on your patient to conduct surgery.</span>")
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 571 B After Width: | Height: | Size: 571 B |
Reference in New Issue
Block a user