void main() {
void self = getlocalvar("self");
// WALL/PLATFORM-SPLAT
check_hold_platform(self); // (onblockascript??)
check_hold_wall_anim(self);
}
int check_hold_wall_anim(void player) {
int anim_id = getentityproperty(player,"animationid");
if ( anim_id == openborconstant("ANI_FOLLOW45") && getentityproperty(player, "animpos") <= 0 ) {
int p = getentityproperty(player, "playerindex");
int game_speed = openborvariant("game_speed");
float xdir = 1;
// In questo modo il toss durerà tanto quanto dura il frame 0 di FOLLOW45
changeentityproperty(player, "tosstime", getentityproperty(player,"tosstime")+game_speed/10);
changeentityproperty(player, "aiflag", "jumping", 0);
changeentityproperty(player, "aiflag", "running", 0);
changeentityproperty(player, "velocity", 0,0,0);
if ( getentityproperty(player, "direction") == 1 ) xdir *= -1;
if ( playerkeys(p,0,"jump") ) {
//changeentityproperty(player,"tosstime",0);
xdir *= 2;
tossentity(player, 3, xdir, 0);
xdir /= 1.5;
changeentityproperty(player, "aiflag", "running", 1);
setentityvar(player,5,xdir);
//changeentityproperty(player, "aiflag", "jumping", 1);
//performattack(player, openborconstant("ANI_JUMP"), 1);
} else setentityvar(player,5,xdir);
}
}
int check_hold_platform(void player) {
int anim_id = getentityproperty(player,"animationid");
int p = getentityproperty(player, "playerindex");
float x = getentityproperty(player, "x");
float z = getentityproperty(player, "z");
float a = getentityproperty(player, "y");
int dir = getentityproperty(player, "direction");
float t_dist = 3;
if ( anim_id == openborconstant("ANI_JUMP") ) { // && anim_id != openborconstant("ANI_FOLLOW45") && getentityproperty(player, "aiflag", "jumping")
if ( playerkeys(p,0,"moveright") == 8 && playerkeys(p,0,"moveleft") != 4 && dir ) {
void platform = find_platform_in_a(x+t_dist,z+0,a,MAX_ALTITUDE,10,3); // Stabiliamo l'altezza della piattaforma e la quota della stessa
if ( platform != NULL() ) {
changeentityproperty(player, "aiflag", "jumping", 0); // se è a 1 possiamo muoverci
//changeentityproperty(player, "aiflag", "running", 0);
performattack(player, openborconstant("ANI_FOLLOW45"), 1);
//set_hold_wall_anim(player);
}
} else if ( playerkeys(p,0,"moveleft") == 4 && playerkeys(p,0,"moveright") != 8 && !dir ) {
void platform = find_platform_in_a(x-t_dist,z+0,a,MAX_ALTITUDE,10,3); // Stabiliamo l'altezza della piattaforma e la quota della stessa
if ( platform != NULL() ) {
changeentityproperty(player, "aiflag", "jumping", 0); // se è a 1 possiamo muoverci
//changeentityproperty(player, "aiflag", "running", 0);
performattack(player, openborconstant("ANI_FOLLOW45"), 1);
//set_hold_wall_anim(player);
}
}
} // fine se sta saltando
}
// Retrieves platform entity handler if player "y" is about the same height of the platform
void find_platform_in_a(float distx, float distz, float a, float alt_threshold, float shifty, float h_fix) {
void platform = NULL(), platform_up = NULL();
float height = NULL(), altitude = NULL();
//int visit_flag = 0;
if ( h_fix == NULL() ) h_fix = 1;
if ( shifty == NULL() ) shifty = 0;
do {
platform = checkplatform(distx,distz,alt_threshold);
if ( platform == NULL() ) return NULL();
height = getentityproperty(platform, "height");
altitude = getentityproperty(platform, "y");
if ( height == NULL() ) height = 0;
//if ( visit_flag == 0 ) visit_flag = 1;
//if ( visit_flag == 0 ) return NULL(); // se sin da subito non troviamo alcuna piattaforma al di sotto di alt_threshold è inutile proseguire la ricerca
if ( a >= altitude-shifty && a <= altitude+(height/h_fix)+shifty ) {
return platform;
}
if ( altitude > a ) {
platform_up = platform;
alt_threshold = altitude+height-1;
continue;
}
if ( platform == platform_up ) break;
if ( a >= altitude || alt_threshold <= 0 ) break;
--alt_threshold;
} while( checkplatform(distx,distz,alt_threshold) != NULL() );
return NULL();
}
void checkplatform(float distx, float distz, float altitude) {
void platform = checkplatformbelow(distx,distz,altitude);
/*if ( typeof(platform) == openborconstant("VT_DECIMAL") ) return NULL();
else {
if ( platform == checkplatformbelow(0,0,0) ) return NULL();
else return platform;
}*/
if ( typeof(platform) == openborconstant("VT_PTR") ) {
if ( platform != checkplatformbelow(0,0,0) ) return platform;
}
return NULL();
}