shuko 45 Posted March 12, 2011 (edited) Just another thing I made for a mission of mine. I wanted to spawn enemies in front of the player group. How to get the right direction and thus position? This script will tracking a group and record it's positions in given interval. You can call the function any time to get the average direction, aka a guesstimate where the group to heading to. As usual, it's a 0.1 version. I'll improve it as bugs and new ideas come up. Starting Tracking Required Parameters: 0 Group/Object Group to track. Optional Parameters: 1 Number Recording interval, delay in seconds between position checks. 2 Number History size, number of newest positions to remember. Starting Examples: nul = dude1 execvm "SHK_intercept.sqf"; nul = grpWest1 execvm "SHK_intercept.sqf"; nul = [dude2,5,20] execvm "SHK_intercept.sqf"; Getting the Direction Function's name is SHK_Intercept_getDir. It takes an object or a group as a parameter and returns a direction between 0 and 360. Required Parameters: 0 Group/Object Group to track. Optional Parameters: 1 Number Position info age when calculating direction. Given number is the Nth newest position to compare the current position. Example: positions are [a,b,c,d,e,f,g], you give 3 as info age. The position to be used for direction calculation is e. Float Range 0-1, which is applied to the size of the history. Example: size is 10 and age is 0.5, the dir will be calculated from the 5th position in the history. Or 0.2, the position would be 9th (2nd newest). 2 Number Sample size. Number of positions between newest and the one determined by info age, which is included in the average calculation as well. Examples: dir = grpWest1 call SHK_Intercept_getDir; dir = [grpWest1,0.3] call SHK_Intercept_getDir; dir = [grpWest1,10,5] call SHK_Intercept_getDir; SHK_intercept.sqf SHK_intercept.rar Example pic 1 Example pic 2 Edited March 12, 2011 by Shuko Share this post Link to post Share on other sites
demonized 16 Posted March 12, 2011 pretty cool, will test this out. Share this post Link to post Share on other sites
Two Dogs 10 Posted March 12, 2011 This has been a long time coming. Thanks! Share this post Link to post Share on other sites
cuel 23 Posted December 22, 2011 How would I get a position, say, 100-200 metres infront of the player using this direction? Share this post Link to post Share on other sites
kylania 546 Posted December 22, 2011 // Get a random position within 100-200m and in a 90 degree arc in front of the player's vehicle/player. _unit = player; _randDir = getDir vehicle _unit - 45; _randDir = _randDir + random(90); _randDist = (random 100) + 100; _spawnPosition = [(getPos vehicle _unit select 0) + (_randDist * sin(_randDir)), (getPos vehicle _unit select 1) + (_randDist * cos(_randDir)), 0]; Share this post Link to post Share on other sites
cuel 23 Posted December 22, 2011 Maths is not my best skill. Thanks alot. Share this post Link to post Share on other sites
KeyCat 126 Posted January 16, 2012 Thanks Shuko! Just discovered your script link in your sig as well, lots of good stuff there. /KC Share this post Link to post Share on other sites