Files
CHOMPStation2/code/modules/spells/general/area_teleport.dm
CHOMPStation2StaffMirrorBot 91bb52b6d4 [MIRROR] Multiple buckling and wizard spell fixes (#11437)
Co-authored-by: Will <7099514+Willburd@users.noreply.github.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
2025-08-16 05:31:14 +02:00

88 lines
2.1 KiB
Plaintext

/spell/area_teleport
name = "Teleport"
desc = "This spell teleports you to a type of area of your selection."
school = "abjuration"
charge_max = 600
spell_flags = NEEDSCLOTHES
invocation = "SCYAR NILA"
invocation_type = SpI_SHOUT
cooldown_min = 200 //100 deciseconds reduction per rank
smoke_spread = 1
smoke_amt = 5
var/randomise_selection = 0 //if it lets the usr choose the teleport loc or picks it from the list
var/invocation_area = 1 //if the invocation appends the selected area
cast_sound = 'sound/effects/teleport.ogg'
hud_state = "wiz_tele"
/spell/area_teleport/before_cast()
return
/spell/area_teleport/choose_targets(mob/user)
var/A = null
if(!randomise_selection)
A = tgui_input_list(user, "Area to teleport to", "Teleport", GLOB.teleportlocs)
else
A = pick(GLOB.teleportlocs)
var/area/thearea = GLOB.teleportlocs[A]
return list(thearea)
/spell/area_teleport/cast(area/thearea, mob/user)
if(!istype(thearea))
if(istype(thearea, /list))
var/list/area_list = thearea
thearea = area_list[1]
var/list/L = list()
for(var/turf/T in get_area_turfs(thearea.type))
if(!T.density)
var/clear = 1
for(var/obj/O in T)
if(O.density)
clear = 0
break
if(clear)
L+=T
if(!L.len)
to_chat(user, span_warning("The spell matrix was unable to locate a suitable teleport destination for an unknown reason. Sorry."))
return
if(user && user.buckled)
user.buckled.unbuckle_mob( user, TRUE)
var/attempt = null
var/success = 0
while(L.len)
attempt = pick(L)
success = user.Move(attempt)
if(!success)
L.Remove(attempt)
else
break
if(!success)
to_chat(user, span_warning("The spell matrix was unable to locate a suitable teleport destination, because the destination area is entirely obstructed. Sorry."))
user.forceMove(pick(L))
return
/spell/area_teleport/after_cast()
return
/spell/area_teleport/invocation(mob/user, area/chosenarea)
if(!istype(chosenarea))
return //can't have that, can we
if(!invocation_area || !chosenarea)
..()
else
invocation += "[uppertext(chosenarea.name)]"
..()
return