Die_In_Fire
Well-known member
In some stages. when player loses a life, it respawns inside walls or over the walls...
how can I prevent this?
how can I prevent this?
This script only works for players who have joined the game however. It doesn't work for players who join later.
int set_coords(void player) {
if ( getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN") ) {
float x,z,a;
int p = getentityproperty(player, "playerindex"); // non puoi ricavarti il player con getentityproperty(getplayerproperty(p, "entity")) poichè non esiste ancora
int t;
x = getglobalvar("p"+(p+1)+"respawn_x");
z = getglobalvar("p"+(p+1)+"respawn_z");
a = getglobalvar("p"+(p+1)+"respawn_a");
if ( x != NULL() && z != NULL() && a != NULL() ) { // se sono nulle allora non è mai stato nel livello il personaggio. Verrà eseguita l'animazione RESPAWN
changeentityproperty(player, "position", x, z, a);
}
}
}
int set_coords_predeath(void player) {
int frames = 2, mem_frames = 150; // 150
int refresh_time = openborvariant("elapsed_time")%frames;
int anim_id = getentityproperty(player, "animationid");
if ( refresh_time == 0 && anim_id != openborconstant("ANI_SPAWN") && anim_id != openborconstant("ANI_RESPAWN") ) {
float x = getentityproperty(player, "x");
float z = getentityproperty(player, "z");
float a = getentityproperty(player, "a");
float base = getentityproperty(player, "base");
int p = getentityproperty(player, "playerindex");
if ( ( anim_id == openborconstant("ANI_IDLE") || anim_id == openborconstant("ANI_RUN") || anim_id == openborconstant("ANI_WALK") || anim_id == openborconstant("ANI_LAND")
|| anim_id == openborconstant("ANI_GET") || anim_id == openborconstant("ANI_BLOCK") || anim_id == openborconstant("ANI_UP") || anim_id == openborconstant("ANI_DOWN")
|| anim_id == openborconstant("ANI_JUMPLAND") )
&& checkhole(x,z) == 0 && (a == base) ) {
setglobalvar("p"+(p+1)+"respawn_x", x);
setglobalvar("p"+(p+1)+"respawn_z", z);
setglobalvar("p"+(p+1)+"respawn_a", a);
}
}
}
#define MAX_ALTITUDE 5000
int check_respawn(void player, float threshold) {
if ( getentityproperty(getglobalvar("last_player_spawned"), "exists") && getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN")
&& getlocalvar("respawn") == NULL() ) { // && getentityproperty(player, "animpos") > 0
void last_player = getglobalvar("last_player_spawned");
int p = getentityproperty(last_player, "playerindex");
float x = getglobalvar("p"+(p+1)+"respawn_x");
float z = getglobalvar("p"+(p+1)+"respawn_z");
float a = getglobalvar("p"+(p+1)+"respawn_a");
int i;
float t_alt = MAX_ALTITUDE;
float x2, z2;
//drawstring( 20,160,0,"Siamo qui!" );
if ( getglobalvar("last_player_spawned") == player ) return; // Questa funzione ha senso rispetto ad altri giocatori e non a se stessi!! Altrimenti usare le p#respawn_X
// Respawniamo un valore threshold di px in avanti/dietro/giù/su rispetto al giocatore già in gara
for ( i = 0; i <= threshold; ++i ) { // <= così può assumere valore 0!
x2 = x-(threshold-i); z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break; // vedi se stai sopra un muro o una piattaforma
x2 = x-(threshold-i); z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x-(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x-(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
} // fine for
changeentityproperty(player, "position", x2, z2, a);
//setglobalvar("last_player_spawned", player); // Impostiamo l'ultimo giocatore spawnato!
// Lo impostiamo tra le animazioni con @cmd...
setlocalvar("respawn", 1);
}
}
int checkplatform(float distx, float distz, float altitude) {
if ( checkplatformbelow(distx,distz,altitude) == checkplatformbelow(0,0,0) ) return NULL();
else return checkplatformbelow(distx,distz,altitude);
}
I can't. I have some levels that have small walls that interact with player and enemies.utunnels said:Make your wall as tall as 1000 will prevent most such situations. The engine will check if the wall is too tall to spawn on, just in case som levels have low walls that allows you to walk on.
spawn1 120 20
name 1spawn
type none
shadow 0
anim idle
@script
void self = getlocalvar("self");
int x = getentityproperty(self,"x"); //Get character's x coordinate
int z = getentityproperty(self,"z"); //Get character's z coordinate
int a = getentityproperty(self,"a"); //Get character's a coordinate
int P1 = getplayerproperty(0, "entity");
changeentityproperty(P1, "position", x, z, a);
killentity(self); //Suicide!
@end_script
loop 1
delay 5
offset 1 1
frame data/chars/misc/empty.gif
name Respawn
type none
offscreenkill 3000
antigravity 100
anim idle
@script
void self = getlocalvar("self");
int x = getentityproperty(self,"x");
int a = getentityproperty(self,"a");
setindexedvar(0, x);
setindexedvar(1, a);
killentity(self);
@end_script
loop 1
delay 5
offset 1 1
frame data/chars/misc/empty.gif
spawn 1spawn #Begin with 1spawn and its coords and at from the very beginning like this one here
coords 20 920 455 #1st par for spawn a char, 2nd par for z max, 3rd par for altitude for moving up when increasing number on entity (to move up) from the very ground (maybe zmax I think)
at 0 #0+20= 20
spawn Empty
coords 4500 920 200
at 0 #4500+0=4500
spawn Ice_Floor
coords 0 920 440
at 0
spawn Ice_Block
coords 424 920 440
at 0 #0+424= 424
spawn Star
health 20
coords 700 920 600
at 0
spawn Star
health 20
coords 900 920 700
at 17
spawn Ice_Floor2
coords 780 920 632 #481+300
at 18 #781+17= 798
spawn Respawn
coords 0 920 460 #Have it respawned with 0 in x coord
at 220 #0+220= 220 #Where you're going to be respawned after getting killed/dying/falling
spawn Respawn
coords 0 920 600
at 500
spawn Ice_Panel
coords 528 920 714 #480+48=528
at 682 # 528+682= 1210 / 682-528=156
spawn Ice_Panel
coords 528 920 714
at 767 #528+767= 1295
spawn Respawn
coords 0 920 700
at 850
spawn Ice_Panel
coords 528 920 714
at 850 #850+528= 1378
anim respawn
@script
void self = getlocalvar("self");
int x = getindexedvar(0); //Get respawn x coordinate
int z = getentityproperty(self,"z"); //Get character's z coordinate
int a = getindexedvar(1); //Get respawn a coordinate
if(x==NULL()){
x = getentityproperty(self, "x");
}
if(a!=NULL()){
if(frame == 1){
changeentityproperty(self, "position", x, z, a);
}
}
@end_script
delay 1
offset 23 66
frame data/chars/jj/stand1.png
frame data/chars/jj/stand1.png
anim spawn
delay 1
offset 23 66
frame data/chars/jj/stand1.png
frame data/chars/jj/stand1.png
Die_In_Fire said:I can't understand your solution white dragon, where to copy the code. I need to create a spawn script with your code?
please can you check if my spawn.c is ok??White Dragon said:1) create spawn.c and write my funcs.
3) Then in spawn.c write in the main:
set_coords_predeath(self);
set_coords(self);
check_respawn(self,15);
int set_coords(void player) {
if ( getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN") ) {
float x,z,a;
int p = getentityproperty(player, "playerindex"); // non puoi ricavarti il player con getentityproperty(getplayerproperty(p, "entity")) poichè non esiste ancora
int t;
x = getglobalvar("p"+(p+1)+"respawn_x");
z = getglobalvar("p"+(p+1)+"respawn_z");
a = getglobalvar("p"+(p+1)+"respawn_a");
if ( x != NULL() && z != NULL() && a != NULL() ) { // se sono nulle allora non è mai stato nel livello il personaggio. Verrà eseguita l'animazione RESPAWN
changeentityproperty(player, "position", x, z, a);
}
}
}
int set_coords_predeath(void player) {
int frames = 2, mem_frames = 150; // 150
int refresh_time = openborvariant("elapsed_time")%frames;
int anim_id = getentityproperty(player, "animationid");
if ( refresh_time == 0 && anim_id != openborconstant("ANI_SPAWN") && anim_id != openborconstant("ANI_RESPAWN") ) {
float x = getentityproperty(player, "x");
float z = getentityproperty(player, "z");
float a = getentityproperty(player, "a");
float base = getentityproperty(player, "base");
int p = getentityproperty(player, "playerindex");
if ( ( anim_id == openborconstant("ANI_IDLE") || anim_id == openborconstant("ANI_RUN") || anim_id == openborconstant("ANI_WALK") || anim_id == openborconstant("ANI_LAND")
|| anim_id == openborconstant("ANI_GET") || anim_id == openborconstant("ANI_BLOCK") || anim_id == openborconstant("ANI_UP") || anim_id == openborconstant("ANI_DOWN")
|| anim_id == openborconstant("ANI_JUMPLAND") )
&& checkhole(x,z) == 0 && (a == base) ) {
setglobalvar("p"+(p+1)+"respawn_x", x);
setglobalvar("p"+(p+1)+"respawn_z", z);
setglobalvar("p"+(p+1)+"respawn_a", a);
}
}
}
#define MAX_ALTITUDE 5000
int check_respawn(void player, float threshold) {
if ( getentityproperty(getglobalvar("last_player_spawned"), "exists") && getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN")
&& getlocalvar("respawn") == NULL() ) { // && getentityproperty(player, "animpos") > 0
void last_player = getglobalvar("last_player_spawned");
int p = getentityproperty(last_player, "playerindex");
float x = getglobalvar("p"+(p+1)+"respawn_x");
float z = getglobalvar("p"+(p+1)+"respawn_z");
float a = getglobalvar("p"+(p+1)+"respawn_a");
int i;
float t_alt = MAX_ALTITUDE;
float x2, z2;
//drawstring( 20,160,0,"Siamo qui!" );
if ( getglobalvar("last_player_spawned") == player ) return; // Questa funzione ha senso rispetto ad altri giocatori e non a se stessi!! Altrimenti usare le p#respawn_X
// Respawniamo un valore threshold di px in avanti/dietro/giù/su rispetto al giocatore già in gara
for ( i = 0; i <= threshold; ++i ) { // <= così può assumere valore 0!
x2 = x-(threshold-i); z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break; // vedi se stai sopra un muro o una piattaforma
x2 = x-(threshold-i); z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x-(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x-(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
} // fine for
changeentityproperty(player, "position", x2, z2, a);
//setglobalvar("last_player_spawned", player); // Impostiamo l'ultimo giocatore spawnato!
// Lo impostiamo tra le animazioni con @cmd...
setlocalvar("respawn", 1);
}
}
int checkplatform(float distx, float distz, float altitude) {
if ( checkplatformbelow(distx,distz,altitude) == checkplatformbelow(0,0,0) ) return NULL();
else return checkplatformbelow(distx,distz,altitude);
}
set_coords_predeath(self);
set_coords(self);
check_respawn(self,15);
but I should declare like this? animationscript script data/scripts/spawn.c <--is correct?2) Then write in chara.txt -> script data/scripts/spawn.c to call the script on script event
4) Write @cmd setglobalvar "last_player_spawned" getlocalvar("self") ABOVE the SECOND frame of your spawn/respawn anim.
anim respawn
loop 0
delay 5
offset 30 81
frame data/chars/billy/02.png
@cmd setglobalvar "last_player_spawned" getlocalvar("self")
frame data/chars/billy/02.png
frame data/chars/billy/02.png
Does anybody else have this problem?The upload folder is full. Please try a smaller file and/or contact an administrator.
#define MAX_ALTITUDE 5000
void main() {
void self = getlocalvar("self");
set_coords_predeath(self);
set_coords(self);
check_respawn(self,15);
}
int set_coords(void player) {
if ( getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN") ) {
float x,z,a;
int p = getentityproperty(player, "playerindex"); // non puoi ricavarti il player con getentityproperty(getplayerproperty(p, "entity")) poichè non esiste ancora
int t;
x = getglobalvar("p"+(p+1)+"respawn_x");
z = getglobalvar("p"+(p+1)+"respawn_z");
a = getglobalvar("p"+(p+1)+"respawn_a");
if ( x != NULL() && z != NULL() && a != NULL() ) { // se sono nulle allora non è mai stato nel livello il personaggio. Verrà eseguita l'animazione RESPAWN
changeentityproperty(player, "position", x, z, a);
}
}
}
int set_coords_predeath(void player) {
int frames = 2, mem_frames = 150; // 150
int refresh_time = openborvariant("elapsed_time")%frames;
int anim_id = getentityproperty(player, "animationid");
if ( refresh_time == 0 && anim_id != openborconstant("ANI_SPAWN") && anim_id != openborconstant("ANI_RESPAWN") ) {
float x = getentityproperty(player, "x");
float z = getentityproperty(player, "z");
float a = getentityproperty(player, "a");
float base = getentityproperty(player, "base");
int p = getentityproperty(player, "playerindex");
if ( ( anim_id == openborconstant("ANI_IDLE") || anim_id == openborconstant("ANI_RUN") || anim_id == openborconstant("ANI_WALK") || anim_id == openborconstant("ANI_LAND")
|| anim_id == openborconstant("ANI_GET") || anim_id == openborconstant("ANI_BLOCK") || anim_id == openborconstant("ANI_UP") || anim_id == openborconstant("ANI_DOWN")
|| anim_id == openborconstant("ANI_JUMPLAND") )
&& checkhole(x,z) == 0 && (a == base) ) {
setglobalvar("p"+(p+1)+"respawn_x", x);
setglobalvar("p"+(p+1)+"respawn_z", z);
setglobalvar("p"+(p+1)+"respawn_a", a);
}
}
}
int check_respawn(void player, float threshold) {
if ( getentityproperty(getglobalvar("last_player_spawned"), "exists") && getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN")
&& getlocalvar("respawn") == NULL() ) { // && getentityproperty(player, "animpos") > 0
void last_player = getglobalvar("last_player_spawned");
int p = getentityproperty(last_player, "playerindex");
float x = getglobalvar("p"+(p+1)+"respawn_x");
float z = getglobalvar("p"+(p+1)+"respawn_z");
float a = getglobalvar("p"+(p+1)+"respawn_a");
int i;
float t_alt = MAX_ALTITUDE;
float x2, z2;
//drawstring( 20,160,0,"Siamo qui!" );
if ( getglobalvar("last_player_spawned") == player ) return; // Questa funzione ha senso rispetto ad altri giocatori e non a se stessi!! Altrimenti usare le p#respawn_X
// Respawniamo un valore threshold di px in avanti/dietro/giù/su rispetto al giocatore già in gara
for ( i = 0; i <= threshold; ++i ) { // <= così può assumere valore 0!
x2 = x-(threshold-i); z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break; // vedi se stai sopra un muro o una piattaforma
x2 = x-(threshold-i); z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z+(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z-(threshold-i);
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x-(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x-(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z;
if ( checkwall(x2,z2) <= 0 && checkplatform(x2,z2,t_alt) == NULL() && checkhole(x2,z2) == 0 ) break;
} // fine for
changeentityproperty(player, "position", x2, z2, a);
//setglobalvar("last_player_spawned", player); // Impostiamo l'ultimo giocatore spawnato!
// Lo impostiamo tra le animazioni con @cmd...
setlocalvar("respawn", 1);
}
}
int checkplatform(float distx, float distz, float altitude) {
if ( checkplatformbelow(distx,distz,altitude) == checkplatformbelow(0,0,0) ) return NULL();
else return checkplatformbelow(distx,distz,altitude);
}
emm... how? :-[Ps. I advice you to clearglobalvar(); at the beginning of a level!!
levelscript @script
void main() {
clearglobalvar();
}
@end_script
Nope. Haven't used. I will try out your script to see how it works.White Dragon said:Mmm.. tell me, have you used my script?
because I check for a hole...
If u use my script you'll respawn at last SAFE position ^__^
@script
void self = getlocalvar("self");
int p = getentityproperty(self, "playerindex");
int animpos = getentityproperty(self, "animpos");
if ( animpos == 1 ) {
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
float a = getentityproperty(self, "a");
setglobalvar("p"+(p+1)+"respawn_x", x);
setglobalvar("p"+(p+1)+"respawn_z", z);
setglobalvar("p"+(p+1)+"respawn_a", a);
setglobalvar("last_player_spawned", self);
}
@end_script
anim SPAWN
@script
void self = getlocalvar("self");
int p = getentityproperty(self, "playerindex");
int animpos = getentityproperty(self, "animpos");
if ( animpos == 1 ) {
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
float a = getentityproperty(self, "a");
setglobalvar("p"+(p+1)+"respawn_x", x);
setglobalvar("p"+(p+1)+"respawn_z", z);
setglobalvar("p"+(p+1)+"respawn_a", a);
setglobalvar("last_player_spawned", self);
}
@end_script
loop 0
bbox 0 0 0 0
jumpframe 0 2.8 0.6
landframe 3
delay 1
offset 28 59
frame data/chars/misc/empty.gif
delay 80
offset 26 84
frame data/chars/don/044.gif
frame data/chars/don/044.gif
Die_In_Fire said:White Dragon, what is the difference using this new updated method?
#define MAX_ALTITUDE 5000
#define MAX_PLAYERS openborvariant("maxplayers")
void main() {
void self = getlocalvar("self");
set_inspawning(self,15); // must be first func!!
set_coords_predeath(self);
set_coords(self);
}
int set_coords(void player, float max_alt) {
if ( getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN") ) {
float x,z,a,base;
int p = getentityproperty(player, "playerindex"); // non puoi ricavarti il player con getentityproperty(getplayerproperty(p, "entity")) poichè non esiste ancora
int t;
x = getglobalvar("p"+(p+1)+"respawn_x");
z = getglobalvar("p"+(p+1)+"respawn_z");
a = getglobalvar("p"+(p+1)+"respawn_a");
base = getglobalvar("p"+(p+1)+"respawn_base");
if ( check_incam_pos(x,z) == 1 ) { // siamo nel riquadro giusto?
if ( x != NULL() && z != NULL() && a != NULL() && a < max_alt ) { // se sono nulle allora non è mai stato nel livello il personaggio. Verrà eseguita l'animazione RESPAWN
//changeentityproperty(player, "subject_to_wall", 0);
//changeentityproperty(player, "subject_to_platform", 0);
changeentityproperty(player, "position", x, z, a);
} else {
void last_player = getglobalvar("last_player_spawned");
int p = getentityproperty(last_player, "playerindex");
int distance = getlocalvar("distance");
int result;
//if ( !getentityproperty(last_player,"exists") || getentityproperty(last_player,"type") != openborconstant("type_player") ) {
last_player = generate_last_player_spawned(player,1);
//}
if (distance == NULL()) distance = 15;
result = check_respawn(player,distance);
if ( result < 1 ) set_latest_safe_coords(player);
setlocalvar("respawn", 1);
}
} else {
void last_player = getglobalvar("last_player_spawned");
int p = getentityproperty(last_player, "playerindex");
int distance = getlocalvar("distance");
int result;
//if ( !getentityproperty(last_player,"exists") || getentityproperty(last_player,"type") != openborconstant("type_player") ) {
last_player = generate_last_player_spawned(player,1);
//}
if (distance == NULL()) distance = 15;
result = check_respawn(player,distance);
if ( result < 1 ) set_latest_safe_coords(player);
setlocalvar("respawn", 1);
} // fine if incam
// ##### IMPORTANTE: Facciamo eseguire questo script per tutta la durata del respawn!! Perchè al primo frame potrebbero accadere errori!!
}
}
void set_latest_safe_coords(void player) {
float xmax = NULL();
int p;
float xp,zp,ap,basep,x,z,a;
int pindex = getentityproperty(player, "playerindex");
for (p = 0; p < MAX_PLAYERS; ++p) {
int max_player = getplayerproperty(p, "entity");
//if ( !getentityproperty(max_player, "exists") ) continue;
xp = getglobalvar("p"+(p+1)+"respawn_x");
zp = getglobalvar("p"+(p+1)+"respawn_z");
ap = getglobalvar("p"+(p+1)+"respawn_a");
basep = getglobalvar("p"+(p+1)+"respawn_base");
if ( xmax == NULL() || xp > xmax ) {
if ( xp != NULL() && zp != NULL() && ap != NULL() && check_incam_pos(xp,zp) == 1 ) {
xmax = xp;
setglobalvar("p"+(pindex+1)+"respawn_x",xp);
setglobalvar("p"+(pindex+1)+"respawn_z",zp);
setglobalvar("p"+(pindex+1)+"respawn_a",ap);
setglobalvar("p"+(pindex+1)+"respawn_base",basep);
}
} // fine if xmax
} // fine for
if ( x != NULL() && z != NULL() && a != NULL() ) {
changeentityproperty(player, "position", x, z, a);
}
}
// if flag on, search last player spawned but not == self
void generate_last_player_spawned(void self, int self_flag) {
int p;
float last_player = NULL();
for (p = 0; p < MAX_PLAYERS; ++p) {
int player = getplayerproperty(p, "entity");
int time = NULL(), last_time = NULL();
if ( !getentityproperty(player, "exists") ) continue;
if ( getglobalvar("p"+(p+1)+"spawning") == 1 ) continue; // sta spawnando ora
if ( self_flag > 1 && self == player ) continue;
time = getglobalvar("p"+(p+1)+"spawn_time");
if ( last_time == NULL() || time > last_time ) {
last_player = player;
last_time = time;
}
} // fine for
setglobalvar("last_player_spawned", last_player);
return last_player;
}
void set_inspawning(void player, int respawn_distance) {
int anim_id = getentityproperty(player, "animationid");
if ( anim_id == openborconstant("ANI_RESPAWN") || anim_id == openborconstant("ANI_SPAWN") ) {
int p = getentityproperty(player, "playerindex");
if ( respawn_distance != getlocalvar("distance") ) setlocalvar("distance", respawn_distance);
if ( getglobalvar("p"+(p+1)+"spawning") != 1 ) setglobalvar("p"+(p+1)+"spawning", 1);
} else {
int p = getentityproperty(player, "playerindex");
if ( getglobalvar("p"+(p+1)+"spawning") == 1 ) {
setglobalvar("last_player_spawned", player);
setglobalvar("p"+(p+1)+"spawn_time", openborvariant("elapsed_time"));
if ( getlocalvar("respawn") != NULL() ) setlocalvar("respawn", NULL());
setglobalvar("p"+(p+1)+"spawning", 0);
}
}
}
int check_incam_pos(float x, float z) {
float scr_posx = openborvariant("xpos");
int hres = openborvariant("hresolution");
float zmin_distance = get_zmin_distance();
float zmax_distance = get_zmax_distance();
float threshold = 5;
if ( x == NULL() || z == NULL() ) return 0;
if ( x < scr_posx+threshold || x > scr_posx+hres-threshold ) return 0;
if ( z < zmin_distance+threshold || z > zmax_distance-threshold ) return 0;
return 1;
}
int set_coords_predeath(void player, float max_alt) {
int frames = 2, mem_frames = (openborvariant("game_speed")/4)*3; // 150
int refresh_time = openborvariant("elapsed_time")%frames;
int anim_id = getentityproperty(player, "animationid");
if ( refresh_time == 0 && anim_id != openborconstant("ANI_SPAWN") && anim_id != openborconstant("ANI_RESPAWN") ) {
float x = getentityproperty(player, "x");
float z = getentityproperty(player, "z");
float a = getentityproperty(player, "a");
float base = getentityproperty(player, "base");
int p = getentityproperty(player, "playerindex");
if ( ( anim_id == openborconstant("ANI_IDLE") || anim_id == openborconstant("ANI_RUN") || anim_id == openborconstant("ANI_WALK") || anim_id == openborconstant("ANI_LAND")
|| anim_id == openborconstant("ANI_GET") || anim_id == openborconstant("ANI_BLOCK") || anim_id == openborconstant("ANI_UP") || anim_id == openborconstant("ANI_DOWN")
|| anim_id == openborconstant("ANI_JUMPLAND") ) && checkhole(x,z) == 0 && (a == base) ) {
//drawstring( 10,200,0,"Storing Coords...");
setglobalvar("p"+(p+1)+"respawn_x", x);
setglobalvar("p"+(p+1)+"respawn_z", z);
setglobalvar("p"+(p+1)+"respawn_a", a);
setglobalvar("p"+(p+1)+"respawn_base", base);
// Memorizziamo l'altitudine così da confrontarla con la prossima al prossimo frame. In caso si deve memorizzare la posizione sopra una piattaforma.
// Infatti se stesse saltando o cadendo l'altitudine non sarebbe mai uguale da un frame all'altro...
//setlocalvar("a_coord", a);
}
}
}
// Sistemiamo il personaggio dopo il respawn ne caso è dentro una platform (lo script può essere eseguito solo ora e non onspawn event)
// 1 ha esito positivo, 0 non esiste l'ultimo player spawned o non è nel quadro, -1 ultimo giocatore spawnato è se stesso, 2 non viene eseguito
int check_respawn(void player, float threshold) {
if ( getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN") && getlocalvar("respawn") == NULL() ) { // && getentityproperty(player, "animpos") > 0
void last_player = getglobalvar("last_player_spawned");
//drawstring( 20,160,0,"Siamo qui!" );
if ( getglobalvar("last_player_spawned") == player ) {
return -1; // Questa funzione ha senso rispetto ad altri giocatori e non a se stessi!! Altrimenti usare le p#respawn_X
}
if ( !getentityproperty(last_player,"exists") || getentityproperty(last_player,"type") != openborconstant("type_player") || last_player == NULL() ) {
return 0;
} else {
int p = getentityproperty(last_player, "playerindex");
float x = getglobalvar("p"+(p+1)+"respawn_x");
float z = getglobalvar("p"+(p+1)+"respawn_z");
float a = getglobalvar("p"+(p+1)+"respawn_a");
float base = getglobalvar("p"+(p+1)+"respawn_base");
int i;
float t_alt = MAX_ALTITUDE;
float x2, z2;
float wall, platform_a;
void platform;
if ( check_incam_pos(x,z) == 0 ) {
return 0;
}
// Respawniamo un valore threshold di px in avanti/dietro/giù/su rispetto al giocatore già in gara
for ( i = 0; i <= threshold; ++i ) { // <= così può assumere valore 0!
x2 = x-(threshold-i); z2 = z+(threshold-i);
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; // vedi se stai sopra un muro o una piattaforma
x2 = x-(threshold-i); z2 = z-(threshold-i);
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z+(threshold-i);
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z-(threshold-i);
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z+(threshold-i);
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z-(threshold-i);
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z+(threshold-i);
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x; z2 = z-(threshold-i);
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x-(threshold-i); z2 = z;
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x-(threshold-i); z2 = z;
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z;
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
x2 = x+(threshold-i); z2 = z;
wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt);
if ( platform != NULL() ) platform_a = getentityproperty(platform, "a");
if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break;
} // fine for
changeentityproperty(player, "position", x2, z2, a);
//setglobalvar("last_player_spawned", player); // Impostiamo l'ultimo giocatore spawnato!
// Lo impostiamo tra le animazioni con @cmd...
setlocalvar("respawn", 1);
return 1;
} // fine if last_player exists
} else {
return 2;
}
}
int checkplatform(float distx, float distz, float altitude) {
if ( checkplatformbelow(distx,distz,altitude) == checkplatformbelow(0,0,0) ) return NULL();
else return checkplatformbelow(distx,distz,altitude);
}
float get_zmin_distance() {
float scr_posy = openborvariant("ypos");
int zmin_threshold = 20;
float zmin_bound = scr_posy+zmin_threshold;
return zmin_bound;
}
float get_zmax_distance() {
float scr_posy = openborvariant("ypos");
int vres = openborvariant("vresolution");
int zmax_threshold = 20;
float zmax_bound = scr_posy+vres+zmax_threshold;
return zmax_bound;
}
levelscript @script
void main() {
clearglobalvar();
}
@end_script
White Dragon said:spawn.c
Code:#define MAX_ALTITUDE 5000 #define MAX_PLAYERS openborvariant("maxplayers") void main() { void self = getlocalvar("self"); set_inspawning(self,15); // must be first func!! set_coords_predeath(self); set_coords(self); } int set_coords(void player, float max_alt) { if ( getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN") ) { float x,z,a,base; int p = getentityproperty(player, "playerindex"); // non puoi ricavarti il player con getentityproperty(getplayerproperty(p, "entity")) poichè non esiste ancora int t; x = getglobalvar("p"+(p+1)+"respawn_x"); z = getglobalvar("p"+(p+1)+"respawn_z"); a = getglobalvar("p"+(p+1)+"respawn_a"); base = getglobalvar("p"+(p+1)+"respawn_base"); if ( check_incam_pos(x,z) == 1 ) { // siamo nel riquadro giusto? if ( x != NULL() && z != NULL() && a != NULL() && a < max_alt ) { // se sono nulle allora non è mai stato nel livello il personaggio. Verrà eseguita l'animazione RESPAWN //changeentityproperty(player, "subject_to_wall", 0); //changeentityproperty(player, "subject_to_platform", 0); changeentityproperty(player, "position", x, z, a); } else { void last_player = getglobalvar("last_player_spawned"); int p = getentityproperty(last_player, "playerindex"); int distance = getlocalvar("distance"); int result; //if ( !getentityproperty(last_player,"exists") || getentityproperty(last_player,"type") != openborconstant("type_player") ) { last_player = generate_last_player_spawned(player,1); //} if (distance == NULL()) distance = 15; result = check_respawn(player,distance); if ( result < 1 ) set_latest_safe_coords(player); setlocalvar("respawn", 1); } } else { void last_player = getglobalvar("last_player_spawned"); int p = getentityproperty(last_player, "playerindex"); int distance = getlocalvar("distance"); int result; //if ( !getentityproperty(last_player,"exists") || getentityproperty(last_player,"type") != openborconstant("type_player") ) { last_player = generate_last_player_spawned(player,1); //} if (distance == NULL()) distance = 15; result = check_respawn(player,distance); if ( result < 1 ) set_latest_safe_coords(player); setlocalvar("respawn", 1); } // fine if incam // ##### IMPORTANTE: Facciamo eseguire questo script per tutta la durata del respawn!! Perchè al primo frame potrebbero accadere errori!! } } void set_latest_safe_coords(void player) { float xmax = NULL(); int p; float xp,zp,ap,basep,x,z,a; int pindex = getentityproperty(player, "playerindex"); for (p = 0; p < MAX_PLAYERS; ++p) { int max_player = getplayerproperty(p, "entity"); //if ( !getentityproperty(max_player, "exists") ) continue; xp = getglobalvar("p"+(p+1)+"respawn_x"); zp = getglobalvar("p"+(p+1)+"respawn_z"); ap = getglobalvar("p"+(p+1)+"respawn_a"); basep = getglobalvar("p"+(p+1)+"respawn_base"); if ( xmax == NULL() || xp > xmax ) { if ( xp != NULL() && zp != NULL() && ap != NULL() && check_incam_pos(xp,zp) == 1 ) { xmax = xp; setglobalvar("p"+(pindex+1)+"respawn_x",xp); setglobalvar("p"+(pindex+1)+"respawn_z",zp); setglobalvar("p"+(pindex+1)+"respawn_a",ap); setglobalvar("p"+(pindex+1)+"respawn_base",basep); } } // fine if xmax } // fine for if ( x != NULL() && z != NULL() && a != NULL() ) { changeentityproperty(player, "position", x, z, a); } } // if flag on, search last player spawned but not == self void generate_last_player_spawned(void self, int self_flag) { int p; float last_player = NULL(); for (p = 0; p < MAX_PLAYERS; ++p) { int player = getplayerproperty(p, "entity"); int time = NULL(), last_time = NULL(); if ( !getentityproperty(player, "exists") ) continue; if ( getglobalvar("p"+(p+1)+"spawning") == 1 ) continue; // sta spawnando ora if ( self_flag > 1 && self == player ) continue; time = getglobalvar("p"+(p+1)+"spawn_time"); if ( last_time == NULL() || time > last_time ) { last_player = player; last_time = time; } } // fine for setglobalvar("last_player_spawned", last_player); return last_player; } void set_inspawning(void player, int respawn_distance) { int anim_id = getentityproperty(player, "animationid"); if ( anim_id == openborconstant("ANI_RESPAWN") || anim_id == openborconstant("ANI_SPAWN") ) { int p = getentityproperty(player, "playerindex"); if ( respawn_distance != getlocalvar("distance") ) setlocalvar("distance", respawn_distance); if ( getglobalvar("p"+(p+1)+"spawning") != 1 ) setglobalvar("p"+(p+1)+"spawning", 1); } else { int p = getentityproperty(player, "playerindex"); if ( getglobalvar("p"+(p+1)+"spawning") == 1 ) { setglobalvar("last_player_spawned", player); setglobalvar("p"+(p+1)+"spawn_time", openborvariant("elapsed_time")); if ( getlocalvar("respawn") != NULL() ) setlocalvar("respawn", NULL()); setglobalvar("p"+(p+1)+"spawning", 0); } } } int check_incam_pos(float x, float z) { float scr_posx = openborvariant("xpos"); int hres = openborvariant("hresolution"); float zmin_distance = get_zmin_distance(); float zmax_distance = get_zmax_distance(); float threshold = 5; if ( x == NULL() || z == NULL() ) return 0; if ( x < scr_posx+threshold || x > scr_posx+hres-threshold ) return 0; if ( z < zmin_distance+threshold || z > zmax_distance-threshold ) return 0; return 1; } int set_coords_predeath(void player, float max_alt) { int frames = 2, mem_frames = (openborvariant("game_speed")/4)*3; // 150 int refresh_time = openborvariant("elapsed_time")%frames; int anim_id = getentityproperty(player, "animationid"); if ( refresh_time == 0 && anim_id != openborconstant("ANI_SPAWN") && anim_id != openborconstant("ANI_RESPAWN") ) { float x = getentityproperty(player, "x"); float z = getentityproperty(player, "z"); float a = getentityproperty(player, "a"); float base = getentityproperty(player, "base"); int p = getentityproperty(player, "playerindex"); if ( ( anim_id == openborconstant("ANI_IDLE") || anim_id == openborconstant("ANI_RUN") || anim_id == openborconstant("ANI_WALK") || anim_id == openborconstant("ANI_LAND") || anim_id == openborconstant("ANI_GET") || anim_id == openborconstant("ANI_BLOCK") || anim_id == openborconstant("ANI_UP") || anim_id == openborconstant("ANI_DOWN") || anim_id == openborconstant("ANI_JUMPLAND") ) && checkhole(x,z) == 0 && (a == base) ) { //drawstring( 10,200,0,"Storing Coords..."); setglobalvar("p"+(p+1)+"respawn_x", x); setglobalvar("p"+(p+1)+"respawn_z", z); setglobalvar("p"+(p+1)+"respawn_a", a); setglobalvar("p"+(p+1)+"respawn_base", base); // Memorizziamo l'altitudine così da confrontarla con la prossima al prossimo frame. In caso si deve memorizzare la posizione sopra una piattaforma. // Infatti se stesse saltando o cadendo l'altitudine non sarebbe mai uguale da un frame all'altro... //setlocalvar("a_coord", a); } } } // Sistemiamo il personaggio dopo il respawn ne caso è dentro una platform (lo script può essere eseguito solo ora e non onspawn event) // 1 ha esito positivo, 0 non esiste l'ultimo player spawned o non è nel quadro, -1 ultimo giocatore spawnato è se stesso, 2 non viene eseguito int check_respawn(void player, float threshold) { if ( getentityproperty(player, "animationid") == openborconstant("ANI_RESPAWN") && getlocalvar("respawn") == NULL() ) { // && getentityproperty(player, "animpos") > 0 void last_player = getglobalvar("last_player_spawned"); //drawstring( 20,160,0,"Siamo qui!" ); if ( getglobalvar("last_player_spawned") == player ) { return -1; // Questa funzione ha senso rispetto ad altri giocatori e non a se stessi!! Altrimenti usare le p#respawn_X } if ( !getentityproperty(last_player,"exists") || getentityproperty(last_player,"type") != openborconstant("type_player") || last_player == NULL() ) { return 0; } else { int p = getentityproperty(last_player, "playerindex"); float x = getglobalvar("p"+(p+1)+"respawn_x"); float z = getglobalvar("p"+(p+1)+"respawn_z"); float a = getglobalvar("p"+(p+1)+"respawn_a"); float base = getglobalvar("p"+(p+1)+"respawn_base"); int i; float t_alt = MAX_ALTITUDE; float x2, z2; float wall, platform_a; void platform; if ( check_incam_pos(x,z) == 0 ) { return 0; } // Respawniamo un valore threshold di px in avanti/dietro/giù/su rispetto al giocatore già in gara for ( i = 0; i <= threshold; ++i ) { // <= così può assumere valore 0! x2 = x-(threshold-i); z2 = z+(threshold-i); wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; // vedi se stai sopra un muro o una piattaforma x2 = x-(threshold-i); z2 = z-(threshold-i); wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x+(threshold-i); z2 = z+(threshold-i); wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x+(threshold-i); z2 = z-(threshold-i); wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x; z2 = z+(threshold-i); wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x; z2 = z-(threshold-i); wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x; z2 = z+(threshold-i); wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x; z2 = z-(threshold-i); wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x-(threshold-i); z2 = z; wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x-(threshold-i); z2 = z; wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x+(threshold-i); z2 = z; wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; x2 = x+(threshold-i); z2 = z; wall = checkwall(x2,z2); platform = checkplatform(x2,z2,t_alt); if ( platform != NULL() ) platform_a = getentityproperty(platform, "a"); if ( (wall <= 0 || (wall > 0 && wall == a)) && (platform == NULL() || (platform != NULL() && platform_a == a)) && checkhole(x2,z2) == 0 ) break; } // fine for changeentityproperty(player, "position", x2, z2, a); //setglobalvar("last_player_spawned", player); // Impostiamo l'ultimo giocatore spawnato! // Lo impostiamo tra le animazioni con @cmd... setlocalvar("respawn", 1); return 1; } // fine if last_player exists } else { return 2; } } int checkplatform(float distx, float distz, float altitude) { if ( checkplatformbelow(distx,distz,altitude) == checkplatformbelow(0,0,0) ) return NULL(); else return checkplatformbelow(distx,distz,altitude); } float get_zmin_distance() { float scr_posy = openborvariant("ypos"); int zmin_threshold = 20; float zmin_bound = scr_posy+zmin_threshold; return zmin_bound; } float get_zmax_distance() { float scr_posy = openborvariant("ypos"); int vres = openborvariant("vresolution"); int zmax_threshold = 20; float zmax_bound = scr_posy+vres+zmax_threshold; return zmax_bound; }
script data/scripts/spawn.c
anim spawn
@script
void self = getlocalvar("self");
int p = getentityproperty(self, "playerindex");
int animpos = getentityproperty(self, "animpos");
if ( animpos == 1 ) {
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
float a = getentityproperty(self, "a");
setglobalvar("p"+(p+1)+"respawn_x", x);
setglobalvar("p"+(p+1)+"respawn_z", z);
setglobalvar("p"+(p+1)+"respawn_a", a);
setglobalvar("last_player_spawned", self);
}
@end_script
loop 0
delay 5
offset 30 81
frame data/chars/billy/empty.png
# @cmd setglobalvar "last_player_spawned" getlocalvar("self")
frame data/chars/billy/02.png
frame data/chars/billy/02.png