Page 1 of 1

check if position X/Y have a sector

Posted: Sat Feb 01, 2014 7:58 pm
by ibm5155
what I want is a function to check if a given position have a sector or it's off the map

Code: Select all

function bool pos_havesector(fixed X,fixed Y){
 bool out=false;
 if(SOMETHING TO MAKE MAGIC HAPPEN) out=true;
 return out;
}
example situation:

a the map is a cube of 64x64, the position X:0 Y:0 is on the middle of this cube, so if I call pos_havesector(0,0) it would return 1, but if I call pos_havesector(100.0,100.0) it would return 0.


and yes, I tried to make it, this is the best that I did, but it's giving wrong information =/

Code: Select all

function bool pos_havesector(int float_x, int float_y){

    bool out=false;
    int tid=unusedTID(1000,2000);//receive a tid not used ingame
    int floor=GetSectorFloorZ(0,float_x,float_y);
    int ceiling=GetSectorCeilingZ(0,float_x,float_y);
    print(s:"floor:",f:floor,s:" ceiling:",f:ceiling);
    if(floor<ceiling){
        spawn("mapspot",float_x,float_y,floor,tid,0);
        if(thingcount(t_none,tid))out=true;
    }return out;
}