clifdenhill 1 Posted January 27, 2014 MaybeYes - won't be for a while but definitely something is on it's way. Cool can't wait to see how it turns out. Share this post Link to post Share on other sites
zapat 56 Posted January 27, 2014 (edited) I've just thrown up a quick test of my idea and I am happy with the results. Default buildingposes seem to be enough for me. Display is powered by BLACK RAIN's GetTactical engine. Houses get populated when you see the lines out of the windows. Not all windows, but most of them are covered by default building positions. So I decided not to include DA's script. Building positions return both covered, windowed and empty windows, but the script check if there is a free los. (los check is what I described above: Startingpoint must be under roof, endpoint (5 meters away) must not be under roof and must have free los. Checked in HouseDir and 90 degree turns) Unit placement: _unit setPos _x; _unit setUnitPos "UP"; doStop _unit; _unit setDir _wd; //wd is the direction of the line out of the window. _pos = [getPos _unit, _wd, 50, 1] call fn_relativePos; _unit doWatch _pos; They stay in position, they stay in direction, they detect enemy (placed behind camera) and they follow enemy by sight (so they turn when you enter). Full script for reference only. This won't run as is, but contains my logic. Note: It is just a quick mashup. _no = nearestObject [getPos player,"building"]; _dir = getDir _no; _bposes = [_no,-1,true] call fn_buildingPos; //own script to get all buildingposes. There is a BIS one I guess if (count _bposes == 0) exitWith {}; { //head pos of a crouched unit _samplePosASL = ATLtoASL[_x select 0, _x select 1, (_x select 2) + 1.5]; //check the 4 main dirs for "_d" from _dir to (_dir + 270) step 90 do { _dst = 5; _counterPosASL = [(_samplePosASL select 0) + sin _d * _dst,(_samplePosASL select 1) + cos _d * _dst,_samplePosASL select 2]; _counterPosHASL = [_counterPosASL select 0, _counterPosASL select 1, (_counterPosASL select 2) + 20]; _window = true; //counterpos mustn't be under roof _liw = lineIntersectsWith [_counterPosHASL, _counterPosASL]; if (count _liw > 0 &&{(_liw select 0) isKindOf "House"}) then {_window = false}; //counterpos must have free los if(_window) then { _liw = lineIntersectsWith [_samplePosASL, _counterPosASL]; if (count _liw > 0 &&{(_liw select 0) isKindOf "House"}) then {_window = false}; }; //this is a window: place unit if (_window) then { _wd = ([_samplePosASL,_counterPosASL] call BIS_fnc_dirTo); _grp = createGroup east; _unit = _grp createUnit ["O_Soldier_F", _x, [], 0,"FORM"]; //can be in the same group, this was just easy now //these are all seem important _unit setPos _x; _unit setUnitPos "UP"; doStop _unit; _unit setDir _wd; _pos = [getPos _unit, _wd, 50, 1] call fn_relativePos; //own relativepos script. BIS' can be used. _unit doWatch _pos; }; }; } foreach _bposes; Edited July 6, 2014 by zapat Share this post Link to post Share on other sites
sttosin 67 Posted January 28, 2014 I've just thrown up a quick test of my idea and I am happy with the results. Default buildingposes seem to be enough for me. Display is powered by PILGRIM engine. Houses get populated when you see the lines out of the windows. Not all windows, but most of them are covered by default building positions. So I decided not to include DA's script. Building positions return both covered, windowed and empty windows, but the script check if there is a free los. (los check is what I described above: Startingpoint must be under roof, endpoint (5 meters away) must not be under roof and must have free los. Checked in HouseDir and 90 degree turns) Unit placement: _unit setPos _x; _unit setUnitPos "UP"; doStop _unit; _unit setDir _wd; //wd is the direction of the line out of the window. _pos = [getPos _unit, _wd, 50, 1] call fn_relativePos; _unit doWatch _pos; They stay in position, they stay in direction, they detect enemy (placed behind camera) and they follow enemy by sight (so they turn when you enter). Full script for reference only. This won't run as is, but contains my logic. Note: It is just a quick mashup. _no = nearestObject [getPos player,"building"]; _dir = getDir _no; _bposes = [_no,-1,true] call fn_buildingPos; //own script to get all buildingposes. There is a BIS one I guess if (count _bposes == 0) exitWith {}; { //head pos of a crouched unit _samplePosASL = ATLtoASL[_x select 0, _x select 1, (_x select 2) + 1.5]; //check the 4 main dirs for "_d" from _dir to (_dir + 270) step 90 do { _dst = 5; _counterPosASL = [(_samplePosASL select 0) + sin _d * _dst,(_samplePosASL select 1) + cos _d * _dst,_samplePosASL select 2]; _counterPosHASL = [_counterPosASL select 0, _counterPosASL select 1, (_counterPosASL select 2) + 20]; _window = true; //counterpos mustn't be under roof _liw = lineIntersectsWith [_counterPosHASL, _counterPosASL]; if (count _liw > 0 &&{(_liw select 0) isKindOf "House"}) then {_window = false}; //counterpos must have free los if(_window) then { _liw = lineIntersectsWith [_samplePosASL, _counterPosASL]; if (count _liw > 0 &&{(_liw select 0) isKindOf "House"}) then {_window = false}; }; //this is a window: place unit if (_window) then { _wd = ([_samplePosASL,_counterPosASL] call BIS_fnc_dirTo); _grp = createGroup east; _unit = _grp createUnit ["O_Soldier_F", _x, [], 0,"FORM"]; //can be in the same group, this was just easy now //these are all seem important _unit setPos _x; _unit setUnitPos "UP"; doStop _unit; _unit setDir _wd; _pos = [getPos _unit, _wd, 50, 1] call fn_relativePos; //own relativepos script. BIS' can be used. _unit doWatch _pos; }; }; } foreach _bposes; But we want more, we want more. Share this post Link to post Share on other sites
sttosin 67 Posted January 28, 2014 Most excited for this thread atm. Share this post Link to post Share on other sites
Tankbuster 1746 Posted January 28, 2014 Houses get populated when you see the lines out of the windows. Not all windows, but most of them are covered by default building positions. So I decided not to include DA's script. Building positions return both covered, windowed and empty windows, but the script check if there is a free los. (los check is what I described above: Startingpoint must be under roof, endpoint (5 meters away) must not be under roof and must have free los. Checked in HouseDir and 90 degree turns) I think you might have made real my original plan. :) If I understand you right, you are doing the following? For each building pos, you start looking away from the building centre, and then in a known arc, start ray tracing to see if anything intersects with view. If it doesn't assume it's a window? Share this post Link to post Share on other sites
zapat 56 Posted January 28, 2014 For each buildingpos I shoot 4 rays (4 since buildings are rectangular) one in building direction, and then 3 more in 90 degree steps. (no need for building centre: that is a weak point because it is not centre, but something the creator of the building thought to be a "centre"). If there is one, where startingpoint is inside and endpoint is outside, and there is no wall/closed window (that is part of the building) in between that is a window. Windows are free los (line of sight) openings in walls, aren't they? :) These are the shown rays. Units for once seem to do what they were told, so there is no need for extra threads (FSMs) watching them. :) Since we know the direction of the tracing ray, we know what direction is outside they just need to watch it. Share this post Link to post Share on other sites
zapat 56 Posted January 28, 2014 https://drive.google.com/file/d/0BxjqGzmtx1GBaGJwNFgwRzFJODA/edit?usp=sharing There you go, play around with it... I added "quality" for the positions. Red (worst) - yellow - blue - green (best) arrows indicate it. Based on los distance. The lines are the los checks. See the description in the function. If anyone has a better idea to the quality, share it, since this one is not that good. Not bad either, but stupid in some cases. Share this post Link to post Share on other sites
Tankbuster 1746 Posted January 28, 2014 Oh cool. I will have a look. I hope that between us, we can come up with a fairly lightweight, well featured script that might make a nice module. Share this post Link to post Share on other sites
mikey74 178 Posted February 1, 2014 Have you tried your unit doWatch position;? This seems to be working for me on my Garrison script so far. Hope that helps. :) Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 1, 2014 yes, doWatch is working much better than setdir. The only problem is that dowatch takes a location or object whereas setdir takes a compass direction. It is possible to convert between the two using already existing BI functions so it's not a massive problem. Share this post Link to post Share on other sites
mikey74 178 Posted February 1, 2014 Sorry, You guys already figured that out. I just read through whole thread. lol I just seen the comment about SetDir, and posted. doofy me. lol Nice script you have here. :) Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 2, 2014 It cool. The biki is as much help as a chocolate teapot, so the more often it gets said in here, the more likely searches are to turn up the fix. Share this post Link to post Share on other sites
sttosin 67 Posted February 2, 2014 Mikey, the script demo from Zapat is freaking awesome. Check it out. Using bcombat with it causes the units to leave their positions though. Share this post Link to post Share on other sites
mikey74 178 Posted February 2, 2014 Yeh it is! I was looking at the video. Its very cool. You could try a force speed 0 in it for certain missions or situations. This may work. I did this but the problem is Sometimes you want them to break and engage. So you have to work out a routine to figure out the conditions that call for them leaving the window position to engage enemy from another position. Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 5, 2014 (edited) https://drive.google.com/file/d/0BxjqGzmtx1GBaGJwNFgwRzFJODA/edit?usp=sharingThere you go, play around with it... I added "quality" for the positions. Red (worst) - yellow - blue - green (best) arrows indicate it. Based on los distance. The lines are the los checks. See the description in the function. If anyone has a better idea to the quality, share it, since this one is not that good. Not bad either, but stupid in some cases. Brilliant. And much easier on the CPU than my version. Thank you for this excellent work. It gets slightly confused by the long balcony on the barracks building. Although it is outside, there's a short roof section overhead, so the script thinks it's inside, and produces sub optimal results, but this is a tiny niggle. Overall, this is just fantastic. http://puu.sh/6Lh9S.jpg (342 kB) Edited February 5, 2014 by Tankbuster Share this post Link to post Share on other sites
zapat 56 Posted February 5, 2014 Glad you like it. It gets slightly confused by the long balcony on the barracks building. Hahaha, this is why I love Arma. It always (an I do mean always) has some little inconsistency that f**ks any of your algorithms over. Although it might be the algorithm's fault. :) Anyhow, it could be "curve-fitted" ( I mean changed for this situation) in exchange for some CPU cycles: not only a vertical, but four more - slightly banked - checks are necessary to check if you are in a building. Of course it won't work on one of the next DLC's hut... :D But hey, guys on a balcony are not that bad: they must be smoking. Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 6, 2014 Hahaha, this is why I love Arma. It always (an I do mean always) has some little inconsistency that f**ks any of your algorithms over. Although it might be the algorithm's fault. :)Anyhow, it could be "curve-fitted" ( I mean changed for this situation) in exchange for some CPU cycles: not only a vertical, but four more - slightly banked - checks are necessary to check if you are in a building. Of course it won't work on one of the next DLC's hut... :D But hey, guys on a balcony are not that bad: they must be smoking. I considered doing a series of non vertical checks to improve the am 'I outdoors?' tests, but I thought the same thing you did. If there was a covered balcony there would be people on it. It's only on this one building that it gets confused. Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 7, 2014 (edited) Zapat, I'm integrating this into my mission now. One question; the getWindowPos function, what exactly is it returning? I see it's returning a multidimension array, but what is the select 0 of each sub array? Is it (for example, not real game numbers) [[0,180,1], [1,270,1],[2,90,2]] or [[[2000,2000,4],180,1], [[2010,2000,4]]] Is the select 0 of each position an actual xyz position or is it a serial number? If it is a serial, does it correspond to buildingPos? edit... answering my own question; it returns real xyz positions. Edited February 7, 2014 by Tankbuster Share this post Link to post Share on other sites
zapat 56 Posted February 7, 2014 0: position (real buildingPos) 1: lookout direction (hopefully 0-360) 2: quality of lookout Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 7, 2014 I've made a few adjustments to make it work within my mission, but here's a very brief look at what I'm got going on now. Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 18, 2014 Just a quick update to say that I've managed to make a public release of my mission featuring this script which I've adapted slightly. http://forums.bistudio.com/showthread.php?173316-GITS-Domination While testing, the window facing AI proved to be very hard to defeat. They engaged through the windows of the buildings over and over again, surprising us in every street. This has really changed the way we play the game. Until now, it was rare to find enemy in buildings, you only ever look outside for them. Now, every building is a potential threat. I've had to learn how to use grenades, both UGL and hand thrown now for room clearance! I'd like to thank everyone who has helped and contributed in this thread. Share this post Link to post Share on other sites
zapat 56 Posted February 18, 2014 This sound freaking amazing! I've never tried it live myself.... Share this post Link to post Share on other sites
Tankbuster 1746 Posted February 18, 2014 It really is a game changer. I know that phrase is bandied about too easily around here, but in this case, it requires a complete rethink of how we play the game in urban environments. Share this post Link to post Share on other sites
froggyluv 2136 Posted January 25, 2015 Don't wanna disturb the dead but this looks like a dream come true- AI that autonomously use windows! Any chance for a SP version or script as I never really play mp anymore? Share this post Link to post Share on other sites
Tankbuster 1746 Posted January 25, 2015 It should work in SP just as well. Share this post Link to post Share on other sites