ID:272292
 
I need help making it so that when my character is defeated it teleports him to a random hyrule temple turf to stop spawn killing, for example say I spawn in one spot, the next time I die I spawn in another, and a different spot after that. I remember seeing how to do this somewhere but I can't remember where.
if(M.hyruletemple)
M.loc=locate(/turf/Hyruletemple)
What you want to do here is make a list of the spots the player can respawn at, then use pick() to randomly choose one of them and teleport the player there. You can use a for() loop to get the list.
for(var/turf/respawn_marker/R) //for every respawn marker there is in the world
respawn_list += R //add it to the list
Here:

proc/MoveToArea(atom/movable/A,options[])
/***
Args:
A: the atom to be moved
options: possible locations the atom can be moved to
***/


if(!options || !options.len) return
var/location = pick(options)
while(!A.Move(location))
options -= location
location = pick(options)
return location


To move a player, you could do this:

var/area/hyrule_temple = locate("hyrule temple")
var/filter[] = list()
for(var/turf/T in hyrule_temple)
filter += T
MoveToArea(player,filter)


... Or something like that.