Joe98 92 Posted February 10, 2013 I place an ammo box and name it box1 I give it a placement radius of 500 meters. Every time the mission starts it will be placed at random in a circle of 500 meters radius. I place myself and 2 other men on the map. I believe the name of our group is 1-1-A. I place 3 Move waypoints named , One, Two and Three. I want that 3rd waypoint to always be in the same location as the ammo box I found a command named setWaypointPosition. Apparently it is used like this: [_grp, 2] setWaypointPosition [position player, 0] Q1: What does the 2 mean? Q2: In the On Act: field of waypoint 3 I tried: [1-1-A, 2] setWaypointPosition [position box1, 0] it does not work. Any suggestions? I also tried this setWaypointPosition [position box1, 0] Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted February 10, 2013 [group player, 3] setWaypointPosition [position box1, 0]; Wiki isn't crystal clear on that one, its: [group or group reference, waypoint index number] setWaypointPosition [position, placement radius] Share this post Link to post Share on other sites
Joe98 92 Posted February 11, 2013 What is "group player" ? Share this post Link to post Share on other sites
jakkob4682 23 Posted February 11, 2013 group player is the players group; however in the waypoint statements groupThis or group this refers to the group the waypoint belongs too. Per the wiki each group starts out with one waypoint automatically, their starting position, every subsequent waypoint then would [group,placement radius,_index] where index = 0, so for two waypoints it _index would be equal to one, three waypoints _index would be equal to two, etc. Does that help? ---------- Post added at 13:19 ---------- Previous post was at 13:17 ---------- Matt is spot on for his example, then if you wanted to check it you could setWaypointVisible and use a setPos command to teleport to the box Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted February 11, 2013 You have the links to the wiki Joe? http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2 http://community.bistudio.com/wiki/group group and player are explaned there? Share this post Link to post Share on other sites
jakkob4682 23 Posted February 11, 2013 yeah 1-1-A is not the name of the group that is the group identity iirc; Share this post Link to post Share on other sites
Joe98 92 Posted February 12, 2013 You have the links to the wiki Joe?group and player are explaned there? Yes I do thank you, except that it makes no sense: _playerGrp = group player So I try: [_playerGrp, 3] setWaypointPosition [position box1, 0] Error message "Local Variable in global space" It seems it does not like the underscore at the start. Share this post Link to post Share on other sites
tryteyker 28 Posted February 12, 2013 You cannot initialize local variables in a trigger or in the ingame editor. Share this post Link to post Share on other sites
Joe98 92 Posted February 13, 2013 (edited) I have now worked out how to name the group. Looking at map and Units I can see the n group name. I have now tried [Alpha, 0] setWaypointPosition [position box1, 0] [Alpha, 1] setWaypointPosition [position box1, 0] [Alpha, 2] setWaypointPosition [position box1, 0] [Alpha, 3] setWaypointPosition [position box1, 0] [Alpha, 4] setWaypointPosition [position box1, 0] .....and none of them work. There must be a way to position a waypoint over an object, where the object starts a mission in a different place each mission. Edited February 13, 2013 by Joe98 Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted February 13, 2013 Where do you get Alpha from? How do you name the group and where? You must post your whole code here or we can't see the mistakes. Share this post Link to post Share on other sites
tryteyker 28 Posted February 13, 2013 What you need to understand is that all names of a group, like Alpha, 1-1-A, are not useable in a script. You need to use the squad leader init to name the group, like this: groupName = group this; Share this post Link to post Share on other sites
Joe98 92 Posted February 15, 2013 all names of a group, like Alpha, 1-1-A, are not useable in a script. You need to use the squad leader init to name the group, like this: groupName = group this; OK, in the init of the squad leader (me) I wrote groupName = group this; So, I presume the name of the group is "group". Is that correct? Instead of "group" as the name of my group, I also tried various other words and all failed. So, what is the name of the group now? (I have no script). Share this post Link to post Share on other sites
tryteyker 28 Posted February 15, 2013 No. For example, if I use razor = group this; The name of the group is razor. This is just a global variable you assign to the group, and the variable name is always on the left, so razor. Just change razor with whatever groupname you want. Share this post Link to post Share on other sites
Joe98 92 Posted February 16, 2013 In the init box of the player I have now typed razor = group this; So, the name of the group is razor In the Biki, set waypoint position reads as [_grp, 2] setWaypointPosition [position player, 0] I change it to read (Note there is now only 1 waypoint so the index number is either 1 or 2 – not sure) TEST1: [razor, 1] setWaypointPosition [position box1, 0] TEST2: [razor, 2] setWaypointPosition [position box1, 0] Neither of them work. Any ideas? Share this post Link to post Share on other sites
ceeeb 147 Posted February 16, 2013 (edited) [razor, 1] setWaypointPosition [position box1, 0] This code works, if everything else is set up correctly. [razor, 1] is the first waypoint placed in the mission editor, but actually the group's second waypoint - arrays are zero indexed and all groups have waypoint zero (eg, [razor, 0]) automatically created at the groups initial position. It looks like you are lacking some of the fundamentals of scripting, such as how to declare a variable. Can I suggest you find and read through some scripting tutorials and examples? Edited February 16, 2013 by ceeeb Share this post Link to post Share on other sites
becubed 24 Posted February 16, 2013 Joe, you need to add the waypoint to the group not just set it's position. I think that command is is you want to move an existing waypoint, I've never used it. Try this. Stuff in < > you will need to change //--- set the group of a unit _Grp1 = group (<Unit Name>); //--- add a waypoint - these become a list of waypoints associated with that group //--- this adds a waypoint into position 0 of the list any existing ones are moved along _Grp1WP = _Grp1 addWaypoint [<location>,0]; //--- _Grp1WP is now a variable that points to the last added WP so it can be used to set the way point properties _Grp1WP setWaypointSpeed "LIMITED"; _Grp1WP setWaypointFormation "COLUMN"; _Grp1WP setWaypointBehaviour "SAFE"; _Grp1wP setWaypointCombatMode "YELLOW"; _Grp1wP setWaypointTimeout [5,10,20]; //--- To add another just repeat the above _Grp1WP = _Grp1 addWaypoint [<location2>,0]; //--- Set it to be a cycle so they walk between the two _Grp1WP setWaypointType "CYCLE"; I've just clipped this out of a longer script that I wrote so it should be fine but there may be a problem. Hope it helps Scott Share this post Link to post Share on other sites
Joe98 92 Posted February 16, 2013 This code works, if everything else is set up correctly. In terms of everything, well that is everything. The group is named. In the On Act field of the waypoint is the command. Everything is covered. Share this post Link to post Share on other sites
jakkob4682 23 Posted February 16, 2013 MoveWP = { _grp = _this select 0; _pos = _this select 1; _newWP = _grp addWaypoint [_pos,0,1]; _newWP setWaypointStatements ["true","whatever you want to happen when waypoint is complete"]; _newWP setWaypointType "MOVE"; sleep .01; _newWP setWPPos getPos _pos; } then on another line use a condition check to initiate the MoveWP function where _grp is the group name and _pos is the position you want to move the WP to. //while {condition} or waitUntil{condition} or if(condition) then {} followed with [razor,box] call MoveWP Share this post Link to post Share on other sites
Joe98 92 Posted February 16, 2013 I found the solution: Place 1 waypoint on the map Place a box on the map. Object named box1 starts at random in a different location every time the mission starts. I have been trying to move waypoint 1 over the top of box1 I thought that whilst walking towards waypoint 1 that waypoint 1 is now active. So I typed the command in the On Act: cell in waypoint 1 Instead the command only takes effect after the waypoint is complete. So, in waypoint 1, I type: [razor, 1] setWaypointPosition [position box1, 0] After completing waypoint 1, this gives a second waypoint over the box! Success! BTW I found I can move a trigger over the box too! The trigger will be used to end the mission. . Share this post Link to post Share on other sites
jakkob4682 23 Posted February 16, 2013 :) learn by doing Share this post Link to post Share on other sites
Joe98 92 Posted April 4, 2013 This then is the full solution in case anybody is looking for it: To make a waypoint go to a specific object = = = = = = = = = = = = = = = = = = = = = = = Place a box on the map and name it box1. Set the radius to 500 meters. Every time the mission starts the box starts at a random place within a radius of 500 meters. TEST1 = = = = = I wish my troops to walk to a waypoint and then walk to the box to finish. I need to give my group a name. In my own int I type razor = groupThis In the “On Act†field of the waypoint I type [razor, 1] setWaypointPosition [position box1, 0] TEST2 = = = = = I wish my troops to walk to 2 waypoints and then walk to the box to finish. I need to give my group a name. In my own int I type razor = groupThis The “On Act†field of waypoint 1 is left blank In the “On Act†field of waypoint 2, I type [razor, 2] setWaypointPosition [position box1, 0] TEST3 = = = = = I wish my troops to walk to 3 waypoints and then walk to the box to finish. I need to give my group a name. In my own int I type razor = groupThis The “On Act†field of waypoint 1 is left blank The “On Act†field of waypoint 2 is left blank In the “On Act†field of waypoint 3, I type [razor, 3] setWaypointPosition [position box1, 0] Further I learnt something else. See the zero in the formula. The waypoint is completed that many meters from the box. I have learnt that zero is not a good number to use here. 5 or 10 are both good numbers but you would need to experiment for your own case. Joe Share this post Link to post Share on other sites