Files
Bubberstation/code/modules/admin/smites/puzzgrid.dm
AnturK 4d6a8bc537 515 Compatibility (#71161)
Makes the code compatible with 515.1594+

Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword

And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.

@tgstation/commit-access Since the .proc/stuff is pretty big change.

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2022-11-15 03:50:11 +00:00

119 lines
3.6 KiB
Plaintext

/// Turns the user into a puzzgrid
/datum/smite/puzzgrid
name = "Puzzgrid"
var/timer
var/gib_on_loss
/datum/smite/puzzgrid/configure(client/user)
var/timer = input(user, "How long should other people have to solve the grid? 0 gives infinite time.", "Puzzgrid", 0) as num | null
if (isnull(timer))
return FALSE
var/gib_on_loss = tgui_alert(user, "What should happen to them when they lose?", "Puzzgrid", list("Gib", "New puzzle")) == "Gib"
src.gib_on_loss = gib_on_loss
src.timer = timer == 0 ? null : (timer * 1 SECONDS)
return TRUE
/datum/smite/puzzgrid/effect(client/user, mob/living/target)
. = ..()
var/datum/puzzgrid/puzzgrid = create_random_puzzgrid()
if (isnull(puzzgrid))
to_chat(user, span_warning("Couldn't create a puzzgrid! Maybe the config isn't setup?"))
return
var/obj/structure/puzzgrid_effect/puzzgrid_effect = new(target.loc, target, puzzgrid, timer, gib_on_loss)
target.forceMove(puzzgrid_effect)
puzzgrid_effect.visible_message(span_warning("[target] has suddenly transformed into a fiendishly hard puzzle!"))
playsound(puzzgrid_effect, 'sound/effects/magic.ogg', 70)
/obj/structure/puzzgrid_effect
anchored = TRUE
density = TRUE
resistance_flags = INDESTRUCTIBLE
icon = 'icons/effects/effects.dmi'
icon_state = "shield2"
var/mob/living/victim
var/timer
var/gib_on_loss
/obj/structure/puzzgrid_effect/Initialize(mapload, mob/living/victim, datum/puzzgrid/puzzgrid, timer, gib_on_loss)
. = ..()
if (isnull(victim))
return
src.victim = victim
src.timer = timer
src.gib_on_loss = gib_on_loss
name = "[victim]'s fiendish curse"
ADD_TRAIT(victim, TRAIT_HANDS_BLOCKED, "[type]")
ADD_TRAIT(victim, TRAIT_IMMOBILIZED, "[type]")
add_puzzgrid_component(puzzgrid)
/obj/structure/puzzgrid_effect/Destroy()
QDEL_NULL(victim)
return ..()
/obj/structure/puzzgrid_effect/proc/add_puzzgrid_component(datum/puzzgrid/puzzgrid)
AddComponent( \
/datum/component/puzzgrid, \
puzzgrid = puzzgrid, \
timer = timer, \
on_victory_callback = CALLBACK(src, PROC_REF(on_victory)), \
on_fail_callback = CALLBACK(src, gib_on_loss ? PROC_REF(loss_gib) : PROC_REF(loss_restart)), \
)
/obj/structure/puzzgrid_effect/proc/on_victory()
victim.forceMove(loc)
victim.Paralyze(5 SECONDS)
victim.visible_message(
span_notice("[victim] is unshackled from their fiendish prison!"),
span_notice("You are unshackled from your fiendish prison!"),
)
remove_traits()
victim = null
qdel(src)
/obj/structure/puzzgrid_effect/proc/loss_gib()
victim.forceMove(loc)
victim.visible_message(
span_bolddanger("You were unable to free [victim] from their fiendish prison, leaving them as nothing more than a smattering of mush!"),
span_bolddanger("Your compatriates were unable to free you from your fiendish prison, leaving you as nothing more than a smattering of mush!"),
)
victim.gib()
victim = null
qdel(src)
/obj/structure/puzzgrid_effect/proc/loss_restart()
var/datum/puzzgrid/puzzgrid = create_random_puzzgrid()
if (isnull(puzzgrid))
victim.forceMove(loc)
victim.Paralyze(5 SECONDS)
victim.visible_message(span_bolddanger("Despite completely failing the puzzle, through unbelievable luck, [victim] manages to break out anyway!"))
remove_traits()
qdel(src)
victim = null
return
visible_message(span_danger("The fiendishly hard puzzle shapeshifts into a different, equally as challenging puzzle!"))
// Defer until after the fail proc finishes, since that will qdel the component.
addtimer(CALLBACK(src, PROC_REF(add_puzzgrid_component), puzzgrid), 0)
/obj/structure/puzzgrid_effect/proc/remove_traits()
REMOVE_TRAIT(victim, TRAIT_HANDS_BLOCKED, "[type]")
REMOVE_TRAIT(victim, TRAIT_IMMOBILIZED, "[type]")