gc8 970 Posted December 22, 2018 Hi I'm looking for a way to detect enterable buildings. Now i know there are few threads and "solutions" about this but none work perfectly so I'm asking if anyone knows way to do this properly? Here's what I have tried: BIS_fnc_isBuildingEnterable --- Doesn't work because it returns bridges and canal pieces in stratis getNumber (configfile >> "CfgVehicles" >> typeOf _x >> "numberOfDoors") --- Only works on buildings that have doors and excludes buildings that have exits but no doors (_x buildingExit 0) --- Same as BIS_fnc_isBuildingEnterable So that's what I have tried. Any other ideas? :) thx! Share this post Link to post Share on other sites
haleks 8203 Posted December 22, 2018 The best way I found is to check the number of buildingPos. You might need some kind of filtering, since (if I remember right) a couple objects such as those big metal containers have a few buildingPos - I usually check if there's a roof x meters above at least one position. 2 Share this post Link to post Share on other sites
gc8 970 Posted December 22, 2018 @haleks Sounds like that could work but then there's the performance question, hmmm Share this post Link to post Share on other sites
haleks 8203 Posted December 22, 2018 I use this in Ravage mod, and the performance cost is minimal. Still, if you're worrying about that, you could check the vehicles config at mission start to create a ready-to-use list of enterable buildings. ;) I think those buildingPos are present in the configs (now that I think of it, I might just do that for the Ravage mod). Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted December 22, 2018 1 hour ago, gc8 said: @haleks Sounds like that could work but then there's the performance question, hmmm What performance question? Cheers 1 Share this post Link to post Share on other sites
davidoss 550 Posted December 23, 2018 18 hours ago, haleks said: The best way I found is to check the number of buildingPos. You might need some kind of filtering, since (if I remember right) a couple objects such as those big metal containers have a few buildingPos - I usually check if there's a roof x meters above at least one position. I agree. I am doing that like this: private _posASL = []; private _buldingPositions = (_building buildingPos -1) select { _posASL = (AGLToASL _x); _posASL params ["_vx","_vy","_vz"]; (count (lineIntersectsObjs [_posASL, [_vx,_vy,(_vz + 20)]]) > 0) }; By the way, thanks for your ravage mod i am currently looking it around.- very nice scripted mod. 1 1 Share this post Link to post Share on other sites
gc8 970 Posted December 23, 2018 19 hours ago, Grumpy Old Man said: What performance question? Well you know all those lineintersect calls you have to make. if house has 10 positions and there's 50 houses in town your code has to make 500 intersect calls. So I would prefer another way :) Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted December 23, 2018 52 minutes ago, gc8 said: Well you know all those lineintersect calls you have to make. if house has 10 positions and there's 50 houses in town your code has to make 500 intersect calls. So I would prefer another way :) Just check once for every unique house className on the map upon mission start via preInit or postInit. Cheers 2 Share this post Link to post Share on other sites
gc8 970 Posted December 23, 2018 23 minutes ago, Grumpy Old Man said: Just check once for every unique house className on the map upon mission start via preInit or postInit. Cheers Good idea. But how many unique houses there are? Could still be a big check. Is preinit fast way to run scripts? Share this post Link to post Share on other sites
engima 327 Posted December 23, 2018 1 hour ago, gc8 said: Well you know all those lineintersect calls you have to make. if house has 10 positions and there's 50 houses in town your code has to make 500 intersect calls. So I would prefer another way :) Grumpy has the best solution. But I'm curious. How would you solve the problem with lineintersect? Share this post Link to post Share on other sites
gc8 970 Posted December 23, 2018 18 minutes ago, engima said: But I'm curious. How would you solve the problem with lineintersect? line intersect up to see if there's roof. I think this is what we are talking about here :) Share this post Link to post Share on other sites
pierremgi 4736 Posted December 23, 2018 2 hours ago, gc8 said: Well you know all those lineintersect calls you have to make. if house has 10 positions and there's 50 houses in town your code has to make 500 intersect calls. So I would prefer another way :) For loots, I'm using a nearest house script (not nearestBuilding) to spawn on the fly, things for player(s). As it's for loot, I can despawn them after a "deserted" time. Share this post Link to post Share on other sites
engima 327 Posted December 23, 2018 49 minutes ago, gc8 said: line intersect up to see if there's roof. I think this is what we are talking about here :) Of course. Didn't think about that. Well, Grumpy's solution probably have an execution time under a second (I haven't tested though). You need a very special reason to save that time on mission startup. Also note that preInit is unscheduled environment, and runs *a lot* faster than usual scheduled code. Share this post Link to post Share on other sites