Assume we want to change the animation when we're on a platform.
First of all, check to see if we are actually on a platform with the method:
checkplatform (x, z, 5000) (wrapper checkplatform_below ())
It means that we want to know if we are on a platform. x and z are the coordinates of the player and 5000 is the maximum height of a platform to be controlled.
Then we use the method check_platform_alt (x, z, 100) that returns the height of a platform and allows us to understand if that platform is the one that actually are looking for. 100 is the maximum height.
Unfortunately check_platform_alt (x, z, 100) works with the binary search as there is no real function "pointer" that returns the value directly.
In this way we can know if we are walking on a platform with height 40 px:
if (checkplatform (x, z, 5000)! = NULL () && a == check_platform_alt (x, z, 40) && a == 40) {
changeentityproperty (ent, "animation", openborconstant ("ANI_XXXXX"));
}
it's easy!
There is also another function I wrote:
Code:
int checkplatformaround(void player, int distx, int distz, float altitude) {
int i,j;
float x = getentityproperty(player, "x");
float z = getentityproperty(player, "z");
/*
* f: 1,0
* d/f:1,1
* d: 0,1
* d/b:-1,1
* b: -1,0
* u/b:-1,-1
* u:0,-1
* u/f:1,-1
*/
for (i = -1; i < 1+1; ++i) {
for (j = -1; j < 1+1; ++j) {
if ( checkplatform(x+(i*distx),z+(j*distz),altitude) != NULL() ) return checkplatform(x+(i*distx),z+(j*distz),altitude);
else continue;
}
}
return NULL();
}
Ex. checkplatformaround (player, 5, 5, 1000). This will return the handler of the entity of the platform when the platform is 5px to the left or right or up or down against the player!
