#include <acknex.h>
#include <default.c>
#define _id skill1 //use any free skill
#define _id_player 1
#define _id_respawn 2
var nearest = 100000;
ENTITY* nearest_respawn;
action respawn_point()
{
my._id = _id_respawn;
}
function find_nearest_respawn_point()
{
you = ent_next(NULL);
while(you)
{
if(you._id == _id_respawn)
{
if(vec_dist(you.x, player.x)< nearest)
{
nearest = vec_dist(you.x, player.x);
nearest_respawn = you;
}
}
you = ent_next(you);
}
set(nearest_respawn, TRANSLUCENT);
}
action player_func()
{
var search_off = 1;
player = me;
my._id = _id_player;
while(1)
{
if(key_1&&search_off)
{
find_nearest_respawn_point();
search_off = 0;
}
wait(1);
}
}
function main()
{
randomize();
level_load(NULL);
ent_create(SPHERE_MDL, vector(0,0,0), player_func);
ent_create(CUBE_MDL, vector(random(120)-60,random(120)-60,0), respawn_point);
ent_create(CUBE_MDL, vector(random(120)-60,random(120)-60,0), respawn_point);
ent_create(CUBE_MDL, vector(random(120)-60,random(120)-60,0), respawn_point);
ent_create(CUBE_MDL, vector(random(120)-60,random(120)-60,0), respawn_point);
camera.x = -140;
camera.z = 40;
camera.tilt = -12;
}