reggaeman007jah 31 Posted February 17, 2017 Hello again folks, sorry for the double post tonight. I have another small problem I am trying to overcome (sort of linked to my other thread). I am using the getPos function as an alternative to the modelToWorld function. Using the following script, I can sort of simulate a bombing run: Spoiler // Generates bomb strikes 10 degrees from player position bomb = "Bo_Mk82" createvehicle (player getPos [100,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [110,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [120,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [130,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [140,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [150,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [160,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [170,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [180,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [190,10]); bomb setVelocity [0,0,-30]; sleep 3; bomb = "Bo_Mk82" createvehicle (player getPos [200,10]); bomb setVelocity [0,0,-30]; And it looks like this: So my question. Instead of using the player's position as the anchor for the vehicles, how can I generate an alternative fixed point for the above script to work from? Ideally something like 100m north of player position. So from this new point, all of the above MK82's would be linked to that new coordinate, and not the player's position, if that makes sense. Could someone point me in the right direction here? Thanks everyone.. ++ Edit ++ Previous thread title: Question regarding getPos Share this post Link to post Share on other sites
serena 150 Posted February 18, 2017 getPos object - command returns object position as coordinate array [x, y, z], where z is surface related altitude value (PositionAGLS format). origin getPos [distance, heading] - same as above, but position is relative to origin, with given heading and distance from origin. object modelToWorld [x,y,z] - command return position relative to object model center and heading with given offset. For example: player modelToWorld [ 0,-5, 0]; // position behind player modelToWorld [ 0, 5, 0]; // position in front of player modelToWorld [-5, 0, 0]; // position left from player modelToWorld [ 5, 0, 0]; // position right from player modelToWorld [ 0, 0, 5]; // over player modelToWorld [ 0, 0,-5]; // under 100m North from player position: private _position = player getPos [100, 0]; // 100m distance with azimuth 0 How to replace copy-paste with simple iteration: { private _bomb = "Bo_Mk82" createvehicle (player getPos [_x, 10]); _bomb setVelocity [0, 0, -30]; sleep 3; } forEach [100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]; 1 Share this post Link to post Share on other sites
reggaeman007jah 31 Posted February 18, 2017 Serena ... again.. thank you!! KITD FOHS Share this post Link to post Share on other sites
killzone_kid 1326 Posted February 18, 2017 if you look at command page, you should notice that getPos could be used with position as well, doesnt have to be player. [123,456,0] getPos [100, 10] is valid. You can aslo use getRelPos with player instead of modelToWorld. 2 Share this post Link to post Share on other sites
reggaeman007jah 31 Posted February 18, 2017 KK, serena thank you both, your responses have enabled some progress (and learning) for me. To set out what I am trying to do here.. I want to create (ultimately) a small mod that allows a player to call in a bombing / arty run. To do this, I wanted to have the player to do some in-field calculations, rather than automate this work using mapping markers, GPS etc. This was sort of inspired by an absolutely amazing book (IMHO) called, 'A Rumour of War' by Philip Caputo', covering some of the early years of the conflict. In that, there are some examples of how strikes were 'called in', over the wire. My end-goal is to have a mod that allows all of this to be done just using voice alone.. but I digress. Spoiler // Generates bombing run from a fixed position, with variable number of hits and bearing line from origin position _xPos = 05115; _yPos = 04940; _Azimuth = 180; _gap = 0.3; // above sets time between each hit _ord = "Bo_GBU12_LGB"; // above sets type of ord hint "Ord deployed to impact point _xPos _yPos .. Impact in 2 Seconds"; // need to add values in hint sleep 2; // Adjust the above value to reflect how long you want to wait before the ord hits bomb = _ord createvehicle ([_xPos,_yPos] getPos [0,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [10,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [20,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [30,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [40,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [50,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [60,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [70,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [80,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [90,_Azimuth]); sleep _gap; bomb = _ord createvehicle ([_xPos,_yPos] getPos [100,_Azimuth]); // Bang Choices // "Bo_Mk82" // "Bo_GBU12_LGB" // "R_80mm_HE" // "M_Mo_120mm_AT" // "M_Mo_120mm_AT_LG" // "M_Mo_82mm_AT_LG" // "R_60mm_HE" Firstly, the player should designate a 10-digit grid point (KK, thanks for helping me understand this bit). Next, the player needs to designate the direction / azimuth of the run (here, getPos manages the spacing and direction of the run). Pretty simple, but it does force the user to calculate an accurate 10-digit grid, and accurate azimuth, which is part of the fun. If you have a series of armour on a road, these two values are quite key in order to be successful. Additional potential config: type of ordinance, time in between each strike, time to wait before initial hit, total number of ord to hit, and distance between each hit (and so from that, total distance of run from start to finish). I thought it would be an idea to post this as a potential assist to any other newbie scripter like myself. I can already see so much potential to improve this code (e.g. seeing 10 lines of basically the same script is probably quite hilarious ;) thank you serena for the steer on that), so I'm using this as a way to get better at this stuff. Next objective after tidy-up - learn how to create a GUI, and have the values from that inform the script. TLDR, I'm having fun with it. Cheers RM Share this post Link to post Share on other sites
serena 150 Posted February 19, 2017 If you're going to abuse copy-paste - hair grow on your palms XD private _origin = [05115, 04940]; private _count = 0; while {_count < 10} do { private _bomb = _ord createVehicle (_origin getPos [_count * 10.0, _azimuth]); _count = _count + 1; sleep _gap; }; 1 Share this post Link to post Share on other sites
reggaeman007jah 31 Posted February 19, 2017 KEK! nice one :) ++ edit ++ Still chuckling how much more awesome this is, compared to mine. Thanks again.. Share this post Link to post Share on other sites
mikey74 168 Posted February 20, 2017 On 2/18/2017 at 7:13 PM, reggaeman007jah said: KEK! nice one :) ++ edit ++ Still chuckling how much more awesome this is, compared to mine. Thanks again.. Here is something you may have fun with... Give it a try: _posO = TB1 getPos [300, (getDir TB1)]; _posO = [(_posO select 0),(_posO select 1),(75 + random 175)]; for "_i" from 1 to 200 do { _Ptargt = TB1 getPos [random 100 + random -100, random 360]; _flrObj = createVehicle ["Bo_GBU12_LGB", _posO, [], 0, "FLY"]; _dir = _flrObj getDir _Ptargt; _flrObj SetDir _dir; _speed = 2;// comment "Added speed"; //Next code sets bombs in direction with good amount of velocity to random TB1 pos ie _Ptargt = TB1 getPos [random 100 + random -100, random 360]; _flrObj setVelocity (((ATLToASL _Ptargt) vectorDiff (getPosASL _flrObj)) vectorMultiply _speed); ///Make sure all positions are in ASL format sleep random 1.5; }; TB1 is a target I placed on map. ps: Set _speed to 0.2; you can see them coming in significantly slower then work your way up till your happy. let me explain a bit _posO sets the bomb about 300 meters in front of target. This can be changed from any to random directions. _Ptargt sets random position to bomb around TB1 _dir gets direction from the bomb to the target Then next line sets direction. The next 2 lines set the speed to hit that position. :D hope you like and this helps. :) 1 Share this post Link to post Share on other sites
reggaeman007jah 31 Posted February 20, 2017 Thank you very much Mikey.. i am now in work mode, but will give this a try as soon as i get back home mate :) thanks you ... it looks (from what i can see) as a very nice addition KITD FOHS Share this post Link to post Share on other sites
mikey74 168 Posted February 20, 2017 Now Just tested newer version. It all depends on type of ammo you are throwing there. for instance When I use Artillery shells I can place them 3000 k away and 3000 k in the air. They all hit where I want them... BUT when testing with bombs. no can do. You'll have to keep things at range I previously posted for Bo_GBU12_LGB Here is what I am playing with now: Spoiler for "_i" from 1 to 200 do { _posO = beggerm getPos [6000, (getDir beggerm) + (random 45 + random -45)]; _posO = ATLToASL [(_posO select 0),(_posO select 1),(1500 + random 3000)]; _Ptargt = ATLToASL (beggerm getPos [random 50, random 360]); _flrObj = createVehicle ["Sh_155mm_AMOS", _posO, [], 0, "FLY"]; _flrObj setVectorUp surfaceNormal (getPosASL _flrObj); _dir = _flrObj getDir _Ptargt; _flrObj SetDir _dir; _speed = 1;// comment "Added speed"; _flrObj setVelocity ((_Ptargt vectorDiff (getPosASL _flrObj)) vectorMultiply _speed); ///Make sure all positions are in ASL format _Ptargt (getPosASL beggerm) sleep random 1.5; }; lol sorry had 2 targets I was messing with beggerm is a civilian I used this script to pic off on a bridge. Just with this version if you use a bomb or anything other than artillery you want get desired results fall back to the last post. ;) ok This seems to work pretty good with bombs: Spoiler ///// ammo = "Sh_155mm_AMOS"; Bo_GBU12_LGB Sh_120mm_HE Sh_82mm_AMOS R_230mm_HE Rocket_04_HE_F Bomb_03_F Bomb_04_F Sh_105mm_HEAT_MP Sh_105mm_APFSDS Sh_120mm_HE \\\\\ // WWIIammo = "LIB_PzGr40_APCR" "LIB_Sh_81_HE" "LIB_Sh_82_HE" "LIB_M42A1_M1_HE" for "_i" from 1 to 200 do { _posO = beggerm getPos [50, (getDir beggerm) + (random 45 + random -45)]; _posO = ATLToASL [(_posO select 0),(_posO select 1),(150 + random 150)]; _Ptargt = ATLToASL (beggerm getPos [random 50, random 360]); _flrObj = createVehicle ["Bomb_04_F", _posO, [], 0, "FLY"]; _flrObj setVectorUp surfaceNormal (getPosASL _flrObj); _dir = _flrObj getDir _Ptargt; _flrObj SetDir _dir; _speed = 1;// comment "Added speed"; _flrObj setVelocity ((_Ptargt vectorDiff (getPosASL _flrObj)) vectorMultiply _speed); ///Make sure all positions are in ASL format _Ptargt (getPosASL beggerm) sleep random 1.5; }; If you use bombs and 1st script above make speed 5. Bombs don't move as fast a projectiles. 1 Share this post Link to post Share on other sites