Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports Assorted Do_After Chicanary #2207

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ GLOBAL_LIST_EMPTY(species_list)
/proc/do_mob(mob/user , mob/target, time = 3 SECONDS, uninterruptible = FALSE, progress = TRUE, datum/callback/extra_checks = null)
if(!user || !target)
return FALSE

if(target && INTERACTING_WITH(user, target))
to_chat(user, "<span class='warning'>You're already interacting with [target]!</span>")
return

var/user_loc = user.loc

var/drifting = FALSE
Expand All @@ -255,6 +260,8 @@ GLOBAL_LIST_EMPTY(species_list)

var/target_loc = target.loc

LAZYADD(user.do_afters, target)
LAZYADD(target.targeted_by, user)
var/holding = user.get_active_held_item()
var/datum/progressbar/progbar
if (progress)
Expand Down Expand Up @@ -282,7 +289,9 @@ GLOBAL_LIST_EMPTY(species_list)
break
if(!QDELETED(progbar))
progbar.end_progress()

if(!QDELETED(target))
LAZYREMOVE(user.do_afters, target)
LAZYREMOVE(target.targeted_by, user)

//some additional checks as a callback for for do_afters that want to break on losing health or on the mob taking action
/mob/proc/break_do_after_checks(list/checked_health, check_clicks)
Expand All @@ -302,6 +311,11 @@ GLOBAL_LIST_EMPTY(species_list)
/proc/do_after(mob/user, delay, needhand = TRUE, atom/target = null, progress = TRUE, datum/callback/extra_checks = null)
if(!user)
return FALSE

if(target && INTERACTING_WITH(user, target))
to_chat(user, "<span class='warning'>You're already interacting with [target]!</span>")
return

var/atom/Tloc = null
if(target && !isturf(target))
Tloc = target.loc
Expand Down Expand Up @@ -388,6 +402,14 @@ GLOBAL_LIST_EMPTY(species_list)
targets = list(targets)
if(!length(targets))
return FALSE

for(var/i in targets)
var/mob/living/target = i
if(INTERACTING_WITH(user, target))
to_chat(user, "<span class='warning'>You're already interacting with [target]!</span>")
return


var/user_loc = user.loc

var/drifting = FALSE
Expand All @@ -397,6 +419,8 @@ GLOBAL_LIST_EMPTY(species_list)
var/list/originalloc = list()
for(var/atom/target in targets)
originalloc[target] = target.loc
LAZYADD(user.do_afters, target)
LAZYADD(target.targeted_by, user)

var/holding = user.get_active_held_item()
var/datum/progressbar/progbar
Expand Down Expand Up @@ -428,6 +452,12 @@ GLOBAL_LIST_EMPTY(species_list)
if(!QDELETED(progbar))
progbar.end_progress()

for(var/thing in targets)
var/atom/target = thing
if(!QDELETED(target))
LAZYREMOVE(user.do_afters, target)
LAZYREMOVE(target.targeted_by, user)

/proc/is_species(A, species_datum)
. = FALSE
if(ishuman(A))
Expand Down
146 changes: 74 additions & 72 deletions code/game/objects/items/stacks/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,38 @@
///Sound/Sounds to play when this is applied
var/apply_sounds

/obj/item/stack/medical/attack(mob/living/M, mob/user)
/obj/item/stack/medical/attack(mob/living/target, mob/user)
. = ..()
try_heal(M, user)
try_heal(target, user)


/obj/item/stack/medical/proc/try_heal(mob/living/M, mob/user, silent = FALSE)
if(!M.can_inject(user, TRUE))
/obj/item/stack/medical/proc/try_heal(mob/living/target, mob/user, silent = FALSE)
if(!target.can_inject(user, TRUE))
return
if(M == user)
if(target == user)
playsound(src, islist(apply_sounds) ? pick(apply_sounds) : apply_sounds, 25)
if(!do_mob(user, target, self_delay, extra_checks=CALLBACK(target, /mob/living/proc/can_inject, user, TRUE)))
return
if(!silent)
user.visible_message("<span class='notice'>[user] starts to apply \the [src] on [user.p_them()]self...</span>", "<span class='notice'>You begin applying \the [src] on yourself...</span>")
if(!do_mob(user, M, self_delay, extra_checks=CALLBACK(M, /mob/living/proc/can_inject, user, TRUE)))
return

else if(other_delay)
playsound(src, islist(apply_sounds) ? pick(apply_sounds) : apply_sounds, 25)
if(!silent)
user.visible_message("<span class='notice'>[user] starts to apply \the [src] on [M].</span>", "<span class='notice'>You begin applying \the [src] on [M]...</span>")
if(!do_mob(user, M, other_delay, extra_checks=CALLBACK(M, /mob/living/proc/can_inject, user, TRUE)))
if(!do_mob(user, target, other_delay, extra_checks=CALLBACK(target, /mob/living/proc/can_inject, user, TRUE)))
return
if(!silent)
user.visible_message("<span class='notice'>[user] starts to apply \the [src] on [target].</span>", "<span class='notice'>You begin applying \the [src] on [target]...</span>")


if(heal(M, user))
if(heal(target, user))
playsound(src, islist(apply_sounds) ? pick(apply_sounds) : apply_sounds, 25)
user?.mind.adjust_experience(/datum/skill/healing, experience_given)
log_combat(user, M, "healed", src.name)
log_combat(user, target, "healed", src.name)
use(1)
if(repeating && amount > 0)
try_heal(M, user, TRUE)
try_heal(target, user, TRUE)

/obj/item/stack/medical/proc/heal(mob/living/M, mob/user)
/obj/item/stack/medical/proc/heal(mob/living/target, mob/user)
return

/obj/item/stack/medical/proc/heal_carbon(mob/living/carbon/C, mob/user, brute, burn)
Expand Down Expand Up @@ -114,24 +116,24 @@
self_delay = 20
grind_results = list(/datum/reagent/medicine/styptic_powder = 10)

/obj/item/stack/medical/bruise_pack/heal(mob/living/M, mob/user)
if(M.stat == DEAD)
to_chat(user, "<span class='warning'>[M] is dead! You can not help [M.p_them()].</span>")
/obj/item/stack/medical/bruise_pack/heal(mob/living/target, mob/user)
if(target.stat == DEAD)
to_chat(user, "<span class='warning'>[target] is dead! You can not help [target.p_them()].</span>")
return
if(isanimal(M))
var/mob/living/simple_animal/critter = M
if(isanimal(target))
var/mob/living/simple_animal/critter = target
if (!(critter.healable))
to_chat(user, "<span class='warning'>You cannot use \the [src] on [M]!</span>")
to_chat(user, "<span class='warning'>You cannot use \the [src] on [target]!</span>")
return FALSE
else if (critter.health == critter.maxHealth)
to_chat(user, "<span class='notice'>[M] is at full health.</span>")
to_chat(user, "<span class='notice'>[target] is at full health.</span>")
return FALSE
user.visible_message("<span class='green'>[user] applies \the [src] on [M].</span>", "<span class='green'>You apply \the [src] on [M].</span>")
M.heal_bodypart_damage((heal_brute/2))
user.visible_message("<span class='green'>[user] applies \the [src] on [target].</span>", "<span class='green'>You apply \the [src] on [target].</span>")
target.heal_bodypart_damage((heal_brute/2))
return TRUE
if(iscarbon(M))
return heal_carbon(M, user, heal_brute, 0)
to_chat(user, "<span class='warning'>You can't heal [M] with the \the [src]!</span>")
if(iscarbon(target))
return heal_carbon(target, user, heal_brute, 0)
to_chat(user, "<span class='warning'>You can't heal [target] with the \the [src]!</span>")

/obj/item/stack/medical/bruise_pack/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] is bludgeoning [user.p_them()]self with [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
Expand All @@ -153,14 +155,14 @@
/obj/item/stack/medical/gauze/twelve
amount = 12

/obj/item/stack/medical/gauze/heal(mob/living/M, mob/user)
if(ishuman(M))
var/mob/living/carbon/human/H = M
/obj/item/stack/medical/gauze/heal(mob/living/target, mob/user)
if(ishuman(target))
var/mob/living/carbon/human/H = target
if(!H.bleedsuppress && H.bleed_rate) //so you can't stack bleed suppression
H.suppress_bloodloss(stop_bleeding)
to_chat(user, "<span class='notice'>You stop the bleeding of [M]!</span>")
to_chat(user, "<span class='notice'>You stop the bleeding of [target]!</span>")
return TRUE
to_chat(user, "<span class='warning'>You can not use \the [src] on [M]!</span>")
to_chat(user, "<span class='warning'>You can not use \the [src] on [target]!</span>")

/obj/item/stack/medical/gauze/attackby(obj/item/I, mob/user, params)
if(I.tool_behaviour == TOOL_WIRECUTTER || I.get_sharpness())
Expand Down Expand Up @@ -205,13 +207,13 @@
self_delay = 20
grind_results = list(/datum/reagent/medicine/silver_sulfadiazine = 10)

/obj/item/stack/medical/ointment/heal(mob/living/M, mob/user)
if(M.stat == DEAD)
to_chat(user, "<span class='warning'>[M] is dead! You can not help [M.p_them()].</span>")
/obj/item/stack/medical/ointment/heal(mob/living/target, mob/user)
if(target.stat == DEAD)
to_chat(user, "<span class='warning'>[target] is dead! You can not help [target.p_them()].</span>")
return
if(iscarbon(M))
return heal_carbon(M, user, 0, heal_burn)
to_chat(user, "<span class='warning'>You can't heal [M] with the \the [src]!</span>")
if(iscarbon(target))
return heal_carbon(target, user, 0, heal_burn)
to_chat(user, "<span class='warning'>You can't heal [target] with the \the [src]!</span>")

/obj/item/stack/medical/ointment/suicide_act(mob/living/user)
user.visible_message("<span class='suicide'>[user] is squeezing \the [src] into [user.p_their()] mouth! [user.p_do(TRUE)]n't [user.p_they()] know that stuff is toxic?</span>")
Expand All @@ -238,26 +240,26 @@
heal_brute = 15
grind_results = list(/datum/reagent/medicine/polypyr = 2)

/obj/item/stack/medical/suture/heal(mob/living/M, mob/user)
/obj/item/stack/medical/suture/heal(mob/living/target, mob/user)
. = ..()
if(M.stat == DEAD)
to_chat(user, "<span class='warning'>[M] is dead! You can not help [M.p_them()].</span>")
if(target.stat == DEAD)
to_chat(user, "<span class='warning'>[target] is dead! You can not help [target.p_them()].</span>")
return
if(iscarbon(M))
return heal_carbon(M, user, heal_brute, 0)
if(isanimal(M))
var/mob/living/simple_animal/critter = M
if(iscarbon(target))
return heal_carbon(target, user, heal_brute, 0)
if(isanimal(target))
var/mob/living/simple_animal/critter = target
if (!(critter.healable))
to_chat(user, "<span class='warning'>You cannot use \the [src] on [M]!</span>")
to_chat(user, "<span class='warning'>You cannot use \the [src] on [target]!</span>")
return FALSE
else if (critter.health == critter.maxHealth)
to_chat(user, "<span class='notice'>[M] is at full health.</span>")
to_chat(user, "<span class='notice'>[target] is at full health.</span>")
return FALSE
user.visible_message("<span class='green'>[user] applies \the [src] on [M].</span>", "<span class='green'>You apply \the [src] on [M].</span>")
M.heal_bodypart_damage(heal_brute)
user.visible_message("<span class='green'>[user] applies \the [src] on [target].</span>", "<span class='green'>You apply \the [src] on [target].</span>")
target.heal_bodypart_damage(heal_brute)
return TRUE

to_chat(user, "<span class='warning'>You can't heal [M] with the \the [src]!</span>")
to_chat(user, "<span class='warning'>You can't heal [target] with the \the [src]!</span>")

/obj/item/stack/medical/mesh
name = "regenerative mesh"
Expand Down Expand Up @@ -286,17 +288,17 @@
else
return ..()

/obj/item/stack/medical/mesh/heal(mob/living/M, mob/user)
/obj/item/stack/medical/mesh/heal(mob/living/target, mob/user)
. = ..()
if(M.stat == DEAD)
to_chat(user, "<span class='warning'>[M] is dead! You can not help [M.p_them()].</span>")
if(target.stat == DEAD)
to_chat(user, "<span class='warning'>[target] is dead! You can not help [target.p_them()].</span>")
return
if(iscarbon(M))
return heal_carbon(M, user, 0, heal_burn)
to_chat(user, "<span class='warning'>You can't heal [M] with the \the [src]!</span>")
if(iscarbon(target))
return heal_carbon(target, user, 0, heal_burn)
to_chat(user, "<span class='warning'>You can't heal [target] with the \the [src]!</span>")


/obj/item/stack/medical/mesh/try_heal(mob/living/M, mob/user, silent = FALSE)
/obj/item/stack/medical/mesh/try_heal(mob/living/target, mob/user, silent = FALSE)
if(!is_open)
to_chat(user, "<span class='warning'>You need to open [src] first.</span>")
return
Expand Down Expand Up @@ -353,26 +355,26 @@
var/heal = 3
grind_results = list(/datum/reagent/consumable/aloejuice = 1)

/obj/item/stack/medical/aloe/heal(mob/living/M, mob/user)
/obj/item/stack/medical/aloe/heal(mob/living/target, mob/user)
. = ..()
if(M.stat == DEAD)
to_chat(user, "<span class='warning'>[M] is dead! You can not help [M.p_them()].</span>")
if(target.stat == DEAD)
to_chat(user, "<span class='warning'>[target] is dead! You can not help [target.p_them()].</span>")
return FALSE
if(iscarbon(M))
return heal_carbon(M, user, heal, heal)
if(isanimal(M))
var/mob/living/simple_animal/critter = M
if(iscarbon(target))
return heal_carbon(target, user, heal, heal)
if(isanimal(target))
var/mob/living/simple_animal/critter = target
if (!(critter.healable))
to_chat(user, "<span class='warning'>You cannot use \the [src] on [M]!</span>")
to_chat(user, "<span class='warning'>You cannot use \the [src] on [target]!</span>")
return FALSE
else if (critter.health == critter.maxHealth)
to_chat(user, "<span class='notice'>[M] is at full health.</span>")
to_chat(user, "<span class='notice'>[target] is at full health.</span>")
return FALSE
user.visible_message("<span class='green'>[user] applies \the [src] on [M].</span>", "<span class='green'>You apply \the [src] on [M].</span>")
M.heal_bodypart_damage(heal, heal)
user.visible_message("<span class='green'>[user] applies \the [src] on [target].</span>", "<span class='green'>You apply \the [src] on [target].</span>")
target.heal_bodypart_damage(heal, heal)
return TRUE

to_chat(user, "<span class='warning'>You can't heal [M] with the \the [src]!</span>")
to_chat(user, "<span class='warning'>You can't heal [target] with the \the [src]!</span>")


/*
Expand All @@ -397,11 +399,11 @@
other_delay = 15
splint_fracture = TRUE

/obj/item/stack/medical/splint/heal(mob/living/M, mob/user)
/obj/item/stack/medical/splint/heal(mob/living/target, mob/user)
. = ..()
if(iscarbon(M))
return heal_carbon(M, user)
to_chat(user, "<span class='warning'>You can't splint [M]'s limb' with the \the [src]!</span>")
if(iscarbon(target))
return heal_carbon(target, user)
to_chat(user, "<span class='warning'>You can't splint [target]'s limb' with the \the [src]!</span>")

/obj/item/stack/medical/splint/ghetto //slightly shittier, but gets the job done
name = "makeshift splints"
Expand Down
10 changes: 0 additions & 10 deletions code/modules/clothing/shoes/_shoes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@
return

if(user == loc && tied != SHOES_TIED) // if they're our own shoes, go tie-wards
if(INTERACTING_WITH(user, our_guy))
to_chat(user, "<span class='warning'>You're already interacting with [src]!</span>")
return
user.visible_message("<span class='notice'>[user] begins [tied ? "unknotting" : "tying"] the laces of [user.p_their()] [src.name].</span>", "<span class='notice'>You begin [tied ? "unknotting" : "tying"] the laces of your [src.name]...</span>")

if(do_after(user, lace_time, needhand=TRUE, target=our_guy, extra_checks=CALLBACK(src, .proc/still_shoed, our_guy)))
Expand All @@ -170,9 +167,6 @@
if(tied == SHOES_KNOTTED)
to_chat(user, "<span class='warning'>The laces on [loc]'s [src.name] are already a hopelessly tangled mess!</span>")
return
if(INTERACTING_WITH(user, our_guy))
to_chat(user, "<span class='warning'>You're already interacting with [src]!</span>")
return

var/mod_time = lace_time
to_chat(user, "<span class='notice'>You quietly set to work [tied ? "untying" : "knotting"] [loc]'s [src.name]...</span>")
Expand Down Expand Up @@ -254,10 +248,6 @@
/obj/item/clothing/shoes/attack_self(mob/user)
. = ..()

if(INTERACTING_WITH(user, src))
to_chat(user, "<span class='warning'>You're already interacting with [src]!</span>")
return

to_chat(user, "<span class='notice'>You begin [tied ? "untying" : "tying"] the laces on [src]...</span>")

if(do_after(user, lace_time, needhand=TRUE, target=src,extra_checks=CALLBACK(src, .proc/still_shoed, user)))
Expand Down
Loading