From e2da2480e4a91ae2ff1e502c7d7f3d80a7519c9c Mon Sep 17 00:00:00 2001 From: nikothedude <59709059+nikothedude@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:49:02 -0400 Subject: [PATCH] Fixes an alexander harddel as well as an alexander exploit (#85147) ## About The Pull Request mighty_shield will probably always harddel since its ref is never cleared. Also, since the for loop never broke, it was theoretically possible to infinitely stack block chance on shields that were not picked by the drink, since it only ever removed blockchance off mighty shield. ## Why It's Good For The Game bugs bad exploits bad ## Changelog :cl: fix: Alexander no longer causes harddels fix: Removed a theoretical infinite block exploit from alexander /:cl: --- .../reagents/drinks/alcohol_reagents.dm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm b/code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm index 38fb764a955..3559d7f69b3 100644 --- a/code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm @@ -1755,28 +1755,32 @@ quality = DRINK_GOOD taste_description = "bitter, creamy cacao" chemical_flags = REAGENT_CAN_BE_SYNTHESIZED - var/obj/item/shield/mighty_shield + var/datum/weakref/mighty_shield /datum/reagent/consumable/ethanol/alexander/on_mob_metabolize(mob/living/drinker) . = ..() if(ishuman(drinker)) var/mob/living/carbon/human/the_human = drinker for(var/obj/item/shield/the_shield in the_human.contents) - mighty_shield = the_shield - mighty_shield.block_chance += 10 + mighty_shield = WEAKREF(the_shield) + the_shield.block_chance += 10 to_chat(the_human, span_notice("[the_shield] appears polished, although you don't recall polishing it.")) + break /datum/reagent/consumable/ethanol/alexander/on_mob_life(mob/living/drinker, seconds_per_tick, times_fired) - if(mighty_shield && !(mighty_shield in drinker.contents)) //If you had a shield and lose it, you lose the reagent as well. Otherwise this is just a normal drink. + var/obj/item/shield/the_shield = mighty_shield?.resolve() + if(the_shield && !(the_shield in drinker.contents)) //If you had a shield and lose it, you lose the reagent as well. Otherwise this is just a normal drink. holder.remove_reagent(type, volume) return return ..() /datum/reagent/consumable/ethanol/alexander/on_mob_end_metabolize(mob/living/drinker) . = ..() - if(mighty_shield) - mighty_shield.block_chance -= 10 - to_chat(drinker,span_notice("You notice [mighty_shield] looks worn again. Weird.")) + var/obj/item/shield/the_shield = mighty_shield?.resolve() + if(the_shield) + the_shield.block_chance -= 10 + to_chat(drinker,span_notice("You notice [the_shield] looks worn again. Weird.")) + mighty_shield = null /datum/reagent/consumable/ethanol/amaretto_alexander name = "Amaretto Alexander"