Paste #50518: Grave Spawn

Date: 2018/11/02 22:29:52 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# +---------------------- 
# | GraveSpawn 
# | 
# | Spawn in the nearest predefined location(s) (Graveyard)! 
# +---------------------- 
# 
# @author ShadyMac 
# @denizen-version 1.0.3-snapshot (BUILD 448-dev)
# @version 1.0
# 
# Usage: /gravespawn
# When a player dies in of the defined worlds
# and one/multiple graveyards exist in this
# world, he will respawn in the nearest one
# to him. 
# +---------------------- 
#
GraveSpawn:
    type: world
    events:
###Die Event
        on player dies:
#Define Player Location
        - define player_location "<player.flag[gravespawn.location] .as_location>"
#Flag Player location when die        
        - flag player "gravespawn.location:<player.location>"
#Keep Inventory       
        - determine passively KEEP_INV
#Keep Level        
        - determine KEEP_LEVEL         
###
###        
###Respawn Event  
###
        on player respawns:
#Define returned Death Location
        - define player_location "<player.flag[gravespawn.location].as_location>"
#Define Location of Graveyards on map
        - define location_list <s@graveyard_list.yaml_key[WORLD_NAME]>    
#Define Respawn Location Chosen       
        - define respawn_location "<def[location_list].sort_by_number[distance_squared[<player.location>]].get[1]>" 
#Sends Respawn Message        
        - narrate "You have respawned in a safe location."
#Determine which Graveyard is closest and send player        
        - determine <def[respawn_location]>           
#     
###Graveyard Coords###
graveyard_list:
    type: yaml data
    WORLD_NAME:
    - l@-1758,59,-1621,QCX1
    - l@-1758,59,1621,QCX1