total 1 Posted August 30, 2013 (edited) This has probably been asked a hundred times before, but still, I can't figure it out. :( What I want is to spawn exactly what I did in the editor (with exact waypoints) with a Trigger. Can anyone help me with putting together an "On act" script for my trigger with the info below? class Item1 { side="EAST"; class Vehicles { items=4; class Item0 { position[]={14066.943,14.228237,17523.59}; id=1; side="EAST"; vehicle="O_soldier_TL_F"; leader=1; rank="SERGEANT"; skill=0.46666664; }; class Item1 { position[]={14071.943,14.34555,17518.59}; id=2; side="EAST"; vehicle="O_soldier_AA_F"; rank="CORPORAL"; skill=0.33333331; }; class Item2 { position[]={14061.943,14.27914,17518.59}; id=3; side="EAST"; vehicle="O_soldier_AA_F"; skill=0.2; }; class Item3 { position[]={14076.943,14.385554,17513.59}; id=4; side="EAST"; vehicle="O_soldier_AAA_F"; skill=0.2; }; }; class Waypoints { items=4; class Item0 { position[]={14230.033,14.379024,17612.076}; combatMode="RED"; speed="NORMAL"; combat="SAFE"; class Effects { }; showWP="NEVER"; }; class Item1 { position[]={14414.781,17.423283,17696.17}; combatMode="RED"; speed="NORMAL"; combat="SAFE"; class Effects { }; showWP="NEVER"; }; class Item2 { position[]={14415.356,17.463614,17690.428}; combatMode="RED"; speed="NORMAL"; combat="SAFE"; class Effects { }; showWP="NEVER"; }; class Item3 { position[]={14079.998,14.377373,17522.246}; type="CYCLE"; class Effects { }; showWP="NEVER"; }; }; Edited September 2, 2013 by Total Share this post Link to post Share on other sites
Desrat 0 Posted August 31, 2013 createGroup, createUnit then addWaypoint, setWaypointBehaviour, setWaypointType, setWaypointSpeed and setWaypointCombatMode respectively Search the wiki for more info on how to use em. Share this post Link to post Share on other sites
total 1 Posted August 31, 2013 Thanks, but could you please help me with this? Share this post Link to post Share on other sites
Zenophon 110 Posted August 31, 2013 It would take a significant amount of time to translate every value of that code into a script. You would then have a script that was very specific and useless in any other mission. I recommend that you use more general functions that can do what you want fairly closely. You may interested in this function for spawning them: http://community.bistudio.com/wiki/BIS_fnc_spawnGroup Using that, you could write this code in the On Act. field of the trigger: 0 = OpforPatrolGroup = [[14070, 17520, 0], East, ["O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AAA_F"], [], [], [0.2, 0.6]] call BIS_fnc_spawnGroup; I highly recommend that you use markers and 'getMarkerPos' to instead of writing out those position arrays. Nevertheless, the above lines will spawn a group at the given position. The skill levels and soldier types are there, but I did not include ranks. Next, you need them to move exactly to the waypoints. You can use a script to give all of those waypoints with their correct properties, but I think it would be easier to use simple loop to order the group to move. You could try this: 0 = [] spawn { private "_patrolGroup"; _patrolGroup = OpforPatrolGroup; { if (({alive _x} count (units _patrolGroup)) > 0) exitWith {}; (leader _patrolGroup) move _x; _patrolGroup setCombatMode "red"; _patrolGroup setSpeedMode "normal"; _patrolGroup setBehaviour "safe"; waitUntil { unitReady (leader _patrolGroup); sleep 2; }; } forEach [[14230, 17612, 0], [14415, 17696, 0], [14415, 17690, 0], [14080, 17522, 0]]; }; This loops keeps the global name as a local variable, in case that global variable changes, and only orders the group to move to the next position when they are done moving. It also sets their behaviour and speed as in your code; this is necessary every time a 'move' command is given. It will also stop executing if all of the group members are dead. Again, I suggest not using those positions directly in the function. You can just combine both code blocks into the trigger field. I have tested this in stable patch 0.76 and it worked perfectly. Share this post Link to post Share on other sites
kylania 568 Posted August 31, 2013 In your on map group leader type: path = group this; pathStart = getPos this; To spawn a new group with the same waypoints: _grp = [pathStart, opfor, ["O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AA_F"]] call BIS_fnc_spawnGroup; _grp copyWaypoints path; Make sure your trigger Condition is: this && isServer Share this post Link to post Share on other sites
Desrat 0 Posted August 31, 2013 Thanks, but could you please help me with this? I just did - try reading about the commands at the site I mentioned and try applying what you see. As with most coding related sites/forums those that at least have a go themselves and show their efforts in the form of some code (even if it's broken, poorly formatted, or generally haphazardly wrote) are more likely to get the help they require, people like to help those that help themselves, those that can't be bothered often become troublesome repeatedly expecting the work to be done for them (in my experience). Basically Im saying that people are not here to do it all for you, but show your willing to give it a go and people here will attempt to steer you in the right direction, I mean I ask for help all the time but I wouldn't dream of doing so before at least attempting something myself.. Good luck with the project. Share this post Link to post Share on other sites
kylania 568 Posted August 31, 2013 I ask for help all the time but I wouldn't dream of doing so before at least attempting something myself.. Possibly poor advice when it comes to skydiving. :) Share this post Link to post Share on other sites
Von Quest 1163 Posted August 31, 2013 Possibly poor advice when it comes to skydiving. FOR SALE: Parachute, Never Opened, Small Stain, Best Offer. Share this post Link to post Share on other sites
Desrat 0 Posted August 31, 2013 Possibly poor advice when it comes to skydiving. :) Probably :) Share this post Link to post Share on other sites
total 1 Posted August 31, 2013 In your on map group leader type: path = group this; pathStart = getPos this; To spawn a new group with the same waypoints: _grp = [pathStart, opfor, ["O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AA_F"]] call BIS_fnc_spawnGroup; _grp copyWaypoints path; Make sure your trigger Condition is: this && isServer When I try to create a trigger I get the following message: Local variables in global space Share this post Link to post Share on other sites
kylania 568 Posted August 31, 2013 get rid of the _ in front of grp in that case :) i was testing that in the debug console and it didn't care, sorry. :) Share this post Link to post Share on other sites
total 1 Posted August 31, 2013 Thanks, it worked. The problem now is that I have both the soldiers I added in the editor and the new ones that spawns with the trigger. I want only those that spawn after the trigger is released. Is it possible to hide the group I added with the editor? :p Share this post Link to post Share on other sites
kylania 568 Posted August 31, 2013 So you want the group to respawn just once when the first, originally placed, units are dead? Share this post Link to post Share on other sites
total 1 Posted August 31, 2013 (edited) What I want is to just use waypoints from the original ai group. The original group is hidden and the new group with ai spawns when the trigger is released, to hopefully save server resources. I want to do this with all AI in my mission. If I create ten new identical groups with new waypoints and new triggers, how to get them to work together? Edited September 1, 2013 by Total Share this post Link to post Share on other sites
delta99 34 Posted September 1, 2013 Delete the units you placed in the editor. You have replaced all that with code so they aren't needed. Share this post Link to post Share on other sites
total 1 Posted September 1, 2013 (edited) If I delete the units, I also delete waypoints. It will probably work if I had used a hide module and link the units to it. I dont know. The new group that spawns with the trigger doesn't receive the waypoints for the original group. Why? ---------- Post added at 08:51 ---------- Previous post was at 07:39 ---------- 1) Is it possible to use cycle and multiple waypoints markers? How? 2) How to use positions instead of markers? Trigger On Act: nul = execVM "SpawnGroup1.sqf"; hint "spawn test"; SpawnGroup1.sqf if (!isServer) exitwith {}; _side = createCenter EAST; _GroupSquad1 = [getMarkerPos "AA_Squad1", _side, ["O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup; _waypoint1 = _GroupSquad1 addWaypoint [getMarkerPos "AA_wp1", 0]; _waypoint1 setWaypointType "MOVE"; _waypoint1 setWaypointStatements ["true", ""]; Edited September 1, 2013 by Total Share this post Link to post Share on other sites
total 1 Posted September 1, 2013 (edited) Or use EOS... If its possible to deactivate the leave zone feature. When I use the helicopters or planes, the AI will spawn and despawn all the time unless I use large markers. I dont want that. If I use EOS, does the AI have realistic waypoints inside the marker or will they just stay around and protect 40m2 in the area they spawned? I'm working on sector control coop mission, so the goal is to only spawn ai with cycled waypoints in each sector, when each sector trigger fires. I dont want the ai to despawn. Does anyone have an answer to my question in the post above? Very grateful for all the answers so far, has helped me a lot! Edited September 1, 2013 by Total Share this post Link to post Share on other sites
Larrow 2821 Posted September 1, 2013 So basically your wanting a caching script e.g You place all your groups and waypoints in the editor. When the map starts all groups and their waypoints are copied in to arrays and the groups are deleted. On the trigger for your sector firing all groups related to this area are respawned and their waypoints added. On leaving the area the groups stayed spawned. Do any of these group need to respawn again? or once theyve spawned and been killed thats it? Is this what your after?? Share this post Link to post Share on other sites
total 1 Posted September 1, 2013 100% Correct! Each group will only spawn once. When they are killed, they are killed to the next restart. Is this possible? Share this post Link to post Share on other sites
Larrow 2821 Posted September 1, 2013 Yes totally possible, just a big chunk of code to do properly. As you have discovered just copying waypoints is not good enough as their references get deleted on the group being deleted. You have to Get the group, save the typeof each soldier. Get the groups waypoints, for each waypoint get all its info Name, position, combat, statements, behaviour blah blah blah, store it all in an array. Delete the soldiers and their group Then when you need them back Create a group. Pass the list of soldier types to spawngroup to spawn them and add them to the group. Then go through the list of waypoints and their settings, create a waypoint add all the settings to it. If your not using default soldiers e.g youve added/removed items/cargo/weapons etc then youll need to save their init aswell to replicate this. Share this post Link to post Share on other sites
total 1 Posted September 1, 2013 Do you have the ability to create a small example with a unit or a group ? Share this post Link to post Share on other sites
mariodu62 5 Posted September 1, 2013 If its possible to deactivate the leave zone feature. When I use the helicopters or planes, the AI will spawn and despawn all the time unless I use large markers. I dont want that. If I use EOS, does the AI have realistic waypoints inside the marker or will they just stay around and protect 40m2 in the area they spawned?I'm working on sector control coop mission, so the goal is to only spawn ai with cycled waypoints in each sector, when each sector trigger fires. I dont want the ai to despawn. Does anyone have an answer to my question in the post above? Very grateful for all the answers so far, has helped me a lot! U can use EOS and modify it as i do... If you don't want the AI spawn with heli you just have to add an condition with the height of the player in detection. If you don't want the ai despawn, you just have to delete the code where it check if no player is in the trigger... Share this post Link to post Share on other sites
total 1 Posted September 1, 2013 (edited) U can use EOS and modify it as i do... If you don't want the AI spawn with heli you just have to add an condition with the height of the player in detection.If you don't want the ai despawn, you just have to delete the code where it check if no player is in the trigger... Thanks, I know. Now I want to learn how to use Arrays and get it to work like Larrow suggested. :) But I don't have a clue where to start, hehe. If someone could use the information from the first post in this thread and make ​​a small example, I would be eternally grateful :) Edited September 1, 2013 by Total Share this post Link to post Share on other sites
delta99 34 Posted September 1, 2013 Maybe I'm missing something but what you wanted was already posted as a solution. You don't need anything defined in the editor. The script provided duplicated what you did in the editor. You said in a previous post that now you are getting duplicate because the editor placed units and the script placed ones defined the same way. Share this post Link to post Share on other sites