diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 6f31c627f96..2a227db446f 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -193,12 +193,19 @@ A.point() return +// See click_override.dm +/mob/living/MiddleClickOn(var/atom/A) + if(src.middleClickOverride) + middleClickOverride.onClick(A, src) + else + ..() + /mob/living/carbon/MiddleClickOn(var/atom/A) if(!src.stat && src.mind && src.mind.changeling && src.mind.changeling.chosen_sting && (istype(A, /mob/living/carbon)) && (A != src)) next_click = world.time + 5 mind.changeling.chosen_sting.try_to_sting(src, A) else - A.point() + ..() // In case of use break glass /* @@ -242,6 +249,13 @@ A.AltClick(src) return +// See click_override.dm +/mob/living/AltClickOn(var/atom/A) + if(src.middleClickOverride) + middleClickOverride.onClick(A, src) + else + ..() + /mob/living/carbon/AltClickOn(var/atom/A) if(!src.stat && src.mind && src.mind.changeling && src.mind.changeling.chosen_sting && (istype(A, /mob/living/carbon)) && (A != src)) next_click = world.time + 5 diff --git a/code/_onclick/click_override.dm b/code/_onclick/click_override.dm new file mode 100644 index 00000000000..82cc807d91b --- /dev/null +++ b/code/_onclick/click_override.dm @@ -0,0 +1,43 @@ +/* + Click Overrides + + These are overrides for a living mob's middle and alt clicks. + If the mob in question has their middleClickOverride var set to one of these datums, when they middle or alt click the onClick proc for the datum their clickOverride var is + set equal to will be called. + See click.dm 251 and 196. + + If you have any questions, contact me on the Paradise forums. + - DaveTheHeacrab + */ + +/datum/middleClickOverride/ + +/datum/middleClickOverride/proc/onClick(var/atom/A, var/mob/living/user) + user.middleClickOverride = null + return 1 + /* Note, when making a new click override it is ABSOLUTELY VITAL that you set the source's clickOverride to null at some point if you don't want them to be stuck with it forever. + Calling the super will do this for you automatically, but if you want a click override to NOT clear itself after the first click, you must do it at some other point in the code*/ + +/obj/item/weapon/badminBook/ + name = "old book" + desc = "An old, leather bound tome." + icon = 'icons/obj/library.dmi' + icon_state = "book" + var/datum/middleClickOverride/clickBehavior = new /datum/middleClickOverride/badminClicker + +/obj/item/weapon/badminBook/attack_self(mob/living/user as mob) + if(user.middleClickOverride) + user<< "You try to draw power from the [src], but you cannot hold the power at this time!" + return + user.middleClickOverride = clickBehavior + user << "You draw a bit of power from the [src], you can use middle click or alt click to release the power!" + +/datum/middleClickOverride/badminClicker + var/summon_path = /obj/item/weapon/reagent_containers/food/snacks/cookie + +/datum/middleClickOverride/badminClicker/onClick(var/atom/A, var/mob/living/user) + var/atom/movable/newObject = new summon_path + newObject.loc = get_turf(A) + user << "You release the power you had stored up, summoning \a [newObject.name]! " + usr.loc.visible_message("[user] waves \his hand and summons \a [newObject.name]") + ..() \ No newline at end of file diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index a8c76bbd2ec..b67e2ad878e 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -1,5 +1,6 @@ mob/living var/canEnterVentWith = "/obj/item/weapon/implant=0&/obj/item/clothing/mask/facehugger=0&/obj/item/device/radio/borg=0&/obj/machinery/camera=0" + var/datum/middleClickOverride/middleClickOverride = null /mob/living/carbon/Login() ..() diff --git a/paradise.dme b/paradise.dme index 9b0a59df6e8..eae7b2ed798 100644 --- a/paradise.dme +++ b/paradise.dme @@ -72,6 +72,7 @@ #include "code\_onclick\adjacent.dm" #include "code\_onclick\ai.dm" #include "code\_onclick\click.dm" +#include "code\_onclick\click_override.dm" #include "code\_onclick\cyborg.dm" #include "code\_onclick\drag_drop.dm" #include "code\_onclick\item_attack.dm"