check if position X/Y have a sector

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
ibm5155
Addicted to Zandronum
Posts: 1641
Joined: Tue Jun 05, 2012 9:32 pm
Location: Somewhere, over the rainbow

check if position X/Y have a sector

#1

Post by ibm5155 » Sat Feb 01, 2014 7:58 pm

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;
}
Last edited by ibm5155 on Sat Feb 01, 2014 7:59 pm, edited 1 time in total.
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!

<this post is proof of "Decline">

Post Reply