Jump to content

Recommended Posts

Hi, i need some help. I use the lattest ARMA 3 dev build.

I try : _WAG_POS01 = [getmarkerpos _WAG_MARKER01,[100,250],random 360,0,[1,250],Armored] call SHK_pos;

and : _WAG_POS01 = [getmarkerpos _WAG_MARKER01,[100,250],random 360,0,[1,250],(typeof Armored)] call SHK_pos;

Result : Error Undefined variable in expression: armored

I have the same problem if i use heli and car, APC, MRAP.

Any idea?

try with the name of the armored, use quote for the name

Share this post


Link to post
Share on other sites

The script uses findEmptyPosition to find the empty space. The command takes vehicle type as a string. If you want to have space for a MRAP for example, then find out the vehicle type of it. One type of MRAP is called "O_MRAP_02_F", for example.

Share this post


Link to post
Share on other sites

Before we start: Great job!

But.. :) Any chance to get road positions on the marker variation of this awesome position script?

Also there seems to be a bug when calling the anchor, distance based variation with search for a road.

For example [player,[0,1],random 360,0,[1,100]] call SHK_pos; This goes ok.

But this [player,[0,1],random 360,0,[2,100]] call SHK_pos; leads to issues when the SHK_POS cannot find a road within the given 100 or first given 1 (paramter 2).

Edited by spirit6

Share this post


Link to post
Share on other sites
Any chance to get road positions on the marker variation of this awesome position script?

Probably, when I get enough time/motivation.

Also there seems to be a bug when calling the anchor, distance based variation with search for a road.

For example [player,[0,1],random 360,0,[1,100]] call SHK_pos; This goes ok.

But this [player,[0,1],random 360,0,[2,100]] call SHK_pos; leads to issues when the SHK_POS cannot find a road within the given 100 or first given 1 (paramter 2).

Are you sure the position retrieved with parameter value 1 is actually a road position? Since with value 1, if none found, it will return a random position as a fail safe.

Share this post


Link to post
Share on other sites
Probably, when I get enough time/motivation.

Are you sure the position retrieved with parameter value 1 is actually a road position? Since with value 1, if none found, it will return a random position as a fail safe.

No, i just wanted to help you isolate the issue. The moment the value 2 is used and within the limites of range a road is not found, then the script goes into errors (i have show script errors on in Arma 3). It does however continue as normal.

And yes, time and motivation are closely related ;)

Share this post


Link to post
Share on other sites
Hey.

I created the functionality to produce road waypoints myself (and a few other things i needed). If you like i can share it with you.

http://postimg.org/image/la9psggnn/

That seems very lovely. It would be great if you don't mind sharing it.

Share this post


Link to post
Share on other sites

Changes:

/* Select a random position from an area defined by a marker.

In: [marker,MaxPos,PositionSurface,MinDisPos,debug,blacklist,emptySpace]

Out: position Array

*/

0) Marker (the marker we need position in)

1) MaxPos (Maximum number of positions we need, it auto iterates for you)

2) PositionSurface (0,1,2,3 - Land, any, water, road)

3) MinDisPos (The minimum distance between the found positions in the array)

4) Debug (show me where you make that positions if set to true)

5) blacklist (the blacklist marker name or array of)

6) emptyspace (the thingy that needs the space in the pos)

It will now return an array of positions instead of just one Pos.

The MaxPos iterations are on 10% fail or max 20 fails. So searching 20.000 water positions on land wont drag the server down. (might need work)

If non found the return value will be [].

Yes the code needs more tweaking and be more neat. Its functional but i am still in WIP to get this code fit into my own needs. Nice work on this thing by the way mate.

Anyway, hera ya go. http://speedy.sh/8AcmJ/shk-pos-getposmarker.sqf

Edited by spirit6

Share this post


Link to post
Share on other sites

Hey Shuko, you have any plans of releasing a new version of this? I'm using this in conjunction with your moveObjects script to move players and objectives (objects/markers/etc) to random points on a map. For the most part it works really well, but it'll occasionally pick a bad location and even stick players inside of rocks (often along the shoreline).

Share this post


Link to post
Share on other sites

@Meatball, you could filter the results to check for nearestObjects (unclassed) and filter for anything with ": r_" in the string. (without the quotes).

Share this post


Link to post
Share on other sites

Yeah, I was just thinking it might be easier to throw some sort of 'isFlatEmpty' check in there as well, but it really chokes the process from what I can tell.

Share this post


Link to post
Share on other sites
Hey Shuko, you have any plans of releasing a new version of this? I'm using this in conjunction with your moveObjects script to move players and objectives (objects/markers/etc) to random points on a map. For the most part it works really well, but it'll occasionally pick a bad location and even stick players inside of rocks (often along the shoreline).

Does that happen even with using the 5th parameters?

Share this post


Link to post
Share on other sites

Yes it does. I've tried setting the 5th parameter to a vehicle (big Green transport chopper), or even just a set distance, 200-300 and it will still do it. My guess is that what's happening is the original check is finding a water location, so it's pulling in and then finding the closest location which is the shore.

Basically what I'm doing is setting up an area of units (objects/players) I want to move and throwing in two small objects (pencils). I run the SHK_pos based off an objects I have at the center of Altis, then move the first pencil there. Then I use your move objects to move everything else based off the two pencils :) Not the cleanest, but it works pretty well. Maybe the pencils are so small the setPos on them doesn't care that the 'position' it found is under a rock and throws it there, then moveObjects throws everything around it.

Here's the actual script that runs. It moves nine different batches of objects to random locations across Altis. Some include just objects, others move triggeers and markers as well.

private ["_startPos","_startPos2","_nukePos","_pickupPos1","_pickupPos2","_pickupPos3","_tmpCheck","_randSide","_opSide","_bluSide"];

// Move Players

_startPos = [randCent,random 12000,[0,359],0,[0,200],300] call SHK_pos;
startObj2 setpos [_startPos select 0,_startPos select 1,0];
[startObj1,startObj2,25] execVM "SHK_pos\SHK_moveObjects.sqf";
startTrig1 setpos [_startPos select 0,_startPos select 1,0];
startTrig3 setpos [_startPos select 0,_startPos select 1,0];

//  Move Nuke Convoy / Material

_tmpCheck = 1;
while {_tmpCheck == 1} do {
_nukePos = [randCent,random 12000,[0,359],0,[1,1500],200] call SHK_pos;
nukeObj2 setpos [_nukePos select 0,_nukePos select 1,0];
[nukeObj1,nukeObj2,25] execVM "SHK_pos\SHK_moveObjects.sqf";
_tmpNukeMark = [nukeObj2,(250+(random 100)),[0,359],0] call SHK_pos;
"nukeMark" setMarkerPos _tmpNukeMark;
if ((startObj2 distance nukeObj2) > 5000) then {_tmpCheck = 0};
};

// Move Depots
_randSide = random 2;
// Pick Random Spots
if (_randSide > 1) then {_opSide = randSide1;_bluSide = randSide2;} else {_opSide = randSide2;_bluSide = randSide1;};
_opDepot1 = [_opSide,random 7000,[0,359],0,[1,1000],200] call SHK_pos;
_opDepot2 = [_opSide,random 7000,[0,359],0,[1,1000],200] call SHK_pos;
while {(_opDepot1 distance _opDepot2) < 5000} do {_opDepot2 = [_opSide,random 7500,[0,359],0,[1,500],200] call SHK_pos;};
_bluDepot1 = [_bluSide,random 7000,[0,359],0,[1,1000],200] call SHK_pos;
_bluDepot2 = [_bluSide,random 7000,[0,359],0,[1,1000],200] call SHK_pos;
while {(_bluDepot1 distance _bluDepot2) < 5000} do {_bluDepot2 = [_bluSide,random 7500,[0,359],0,[1,500],200] call SHK_pos;};
_greenDepot1 = [randCent,random 12000,[0,359],0,[1,1000],200] call SHK_pos;
_greenDepot2 = [randCent,random 12000,[0,359],0,[1,1000],200] call SHK_pos;
while {(_greenDepot1 distance _greenDepot2) < 9000} do {_greenDepot2 = [randCent,random 10000,[0,359],0,[0,500],200] call SHK_pos;};

// Move dummy object 
csatD1_2 setpos [_opDepot1 select 0,_opDepot1 select 1,0];
csatD2_2 setpos [_opDepot2 select 0,_opDepot2 select 1,0];
natoD1_2 setpos [_bluDepot1 select 0,_bluDepot1 select 1,0];
natoD2_2 setpos [_bluDepot2 select 0,_bluDepot2 select 1,0];
aafD1_2 setpos [_greenDepot1 select 0,_greenDepot1 select 1,0];
aafD2_2 setpos [_greenDepot2 select 0,_greenDepot2 select 1,0];

// Move depots to dummy objects
[csatD1_1,csatD1_2,25] execVM "SHK_pos\SHK_moveObjects.sqf";
[csatD2_1,csatD2_2,25] execVM "SHK_pos\SHK_moveObjects.sqf";
[natoD1_1,natoD1_2,25] execVM "SHK_pos\SHK_moveObjects.sqf";
[natoD2_1,natoD2_2,25] execVM "SHK_pos\SHK_moveObjects.sqf";
[aafD1_1,aafD1_2,25] execVM "SHK_pos\SHK_moveObjects.sqf";
[aafD2_1,aafD2_2,25] execVM "SHK_pos\SHK_moveObjects.sqf";

// Move Markers
"csatD1Mark" setMarkerPos getPos csatD1_2;
"csatD2Mark" setMarkerPos getPos csatD2_2;
"natoD1Mark" setMarkerPos getPos natoD1_2;
"natoD2Mark" setMarkerPos getPos natoD2_2;
"aafD1Mark" setMarkerPos getPos aafD1_2;
"aafD2Mark" setMarkerPos getPos aafD2_2;

// Move Pickup Points
_pickupPos1 = [randCent,(2000 + (random 10000)),[0,359],0,[0,200],150] call SHK_pos;
_pickupPos2 = [randCent,(2000 + (random 10000)),[0,359],0,[0,200],150] call SHK_pos;
_pickupPos3 = [randCent,(2000 + (random 10000)),[0,359],0,[0,200],150] call SHK_pos;

pickup1 setpos [_pickupPos1 select 0,_pickupPos1 select 1,0];
pickup2 setpos [_pickupPos2 select 0,_pickupPos2 select 1,0];
pickup3 setpos [_pickupPos3 select 0,_pickupPos3 select 1,0];

"pickupMark1" setMarkerPos getPos pickup1;
"pickupMark2" setMarkerPos getPos pickup2;
"pickupMark3" setMarkerPos getPos pickup3;

pickupTrig1 setpos [_pickupPos1 select 0,_pickupPos1 select 1,0];
pickupTrig2 setpos [_pickupPos2 select 0,_pickupPos2 select 1,0];
pickupTrig3 setpos [_pickupPos3 select 0,_pickupPos3 select 1,0];

Edited by Meatball

Share this post


Link to post
Share on other sites

I was digging into the script a bit more and it seems like shk_pos_fnc_getpos.sqf is the key.

//  In: [position,distance,direction]
// Out: position
private ["_pos","_dst","_dir","_orgX","_orgY","_posX","_posY"];
_pos = _this select 0;
_dst = _this select 1;
_dir = _this select 2;

_orgX = _pos select 0;
_orgY = _pos select 1;
_posX = _orgX + (_dst * sin _dir);
_posY = _orgY + (_dst * cos _dir);

[_posX,_posY,0]

Shouldn't I be able to throw an isFlatEmpty check into that somehow so it'll keep checking till it finds a location that's somewhat flat/empty?

Share this post


Link to post
Share on other sites

Not really, because it's the object mover that moves the stuff? Or is the unit/object inside a rock always the anchor/middle one?

Edit:

If you can bother trying if this works, at all. I didn't test it. Change foreacg at the end of the moveObject.sqf

{
 _xPos = getpos _x;
 _dir = ((_xPos select 0) - (_aPos select 0)) atan2 ((_xPos select 1) - (_aPos select 1));
 _dir = _dir + _dAdj;
 _dst = _aPos distance _xPos;
 if (!isnil "_fDir") then {_x setdir _fDir};

 _xPos = [((_dPos select 0) + (_dst * sin _dir)),
           ((_dPos select 1) + (_dst * cos _dir)),
           0];

 _endPos =+ _xPos;
 _endPos set [2,20];
 for "_i" from 0.25 to 20 step 0.25 do {
   _endPos set [2,_i];
   if (!(lineIntersects [ATLToASL _xPos, ATLToASL _endPos])) exitWith {};
 };

 _x setposATL _endPos;
} foreach _objects;

Edited by Shuko

Share this post


Link to post
Share on other sites
I was digging into the script a bit more and it seems like shk_pos_fnc_getpos.sqf is the key.

//  In: [position,distance,direction]
// Out: position
private ["_pos","_dst","_dir","_orgX","_orgY","_posX","_posY"];
_pos = _this select 0;
_dst = _this select 1;
_dir = _this select 2;

_orgX = _pos select 0;
_orgY = _pos select 1;
_posX = _orgX + (_dst * sin _dir);
_posY = _orgY + (_dst * cos _dir);

[_posX,_posY,0]

Shouldn't I be able to throw an isFlatEmpty check into that somehow so it'll keep checking till it finds a location that's somewhat flat/empty?

I can't remember for sure if it is the isFlatEmpty check that basically doesn't find much as it is probably way too restrictive. So, you'll find almost no suitable locations when there really are some. It is mostly why people use their own methods.

Share this post


Link to post
Share on other sites

I am having an issue with this script, it is not working when I preprocess it in my init.sqf, it is loading, but not linking to the marker I set to the pos variable, I think it may be that I am not putting the pos variable with the parameters and stuff in the right place, my code is on GitHub, it's for ArmA 2, but you posted on the other post that it was the same script, cheers!

Share this post


Link to post
Share on other sites

I basically want to find a random location a minimum distance from any buildings or roads (500m) to place a 200m x 200m marker for helicopter crash locations, etc. Is there an easy way to do this?

Share this post


Link to post
Share on other sites

for buildings you could use BIS_fnc_findSavePosition or so... don't think it considers roads.

forget what i wrote...

greetings Na_Palm

Share this post


Link to post
Share on other sites

Anyone able to get Invade and Annex working on Chernarus, I am stuck, I get the error mapSize param is not defined for 'Chernarus'

Any ideas on how to fix? , am using latest version of this SHK_pos to get some units spawned in but radio towers will not.

Edited by JAndrews1

Share this post


Link to post
Share on other sites

A bug fix was done to a function by Cool=Azroul13. New version is up.

Share this post


Link to post
Share on other sites
Guest

New version frontpaged on the Armaholic homepage.

===================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×