lonewolf12 1 Posted June 4, 2013 (edited) Im having trouble writing a script that ensures that my newly created ai go to a waypoint. firstly i have made a spawn script which activates when all enemy ai are dead. _j = i; while {_j > 0} do { "O_Soldier_TL_F" createUnit [getMarkerPos "mark1", eastside]; hint "TESTING!!!!"; _j = _j - 1;}; i = i + 1; then in order to get them to move i add a waypoint in the same script (activates when all ai are dead) way1 = eastside addWaypoint [getMarkerPos "mark2", 5]; way1 setWaypointType "MOVE"; and from research on the internet i have put eastside = group this in the ai units init i spawn in the editor. EDIT trying this now.... _enemy = [getMarkerPos "mark1", EAST, ["O_Soldier_TL_F"] call BIS_fnc_spawnGroup; EDIT /* still would really appreciate any input!!!! */ Edited June 4, 2013 by lonewolf12 Share this post Link to post Share on other sites
samatra 85 Posted June 4, 2013 _group = [getMarkerPos "mark1", EAST, ["O_Soldier_TL_F"]] call BIS_fnc_spawnGroup; _wp = _group addWaypoint [getMarkerPos "mark2", 5]; _wp setWaypointType "MOVE"; how about this? Share this post Link to post Share on other sites
lonewolf12 1 Posted June 4, 2013 thanks for the reply! (if you are the samatra guy who does wasteland, then hello and nice one on the wasteland missions!, check out the arma3 ones now fussion i think they are, pretty good you can capture areas) anyway, i bet it doesnt work but ill try now lol ---------- Post added at 13:28 ---------- Previous post was at 13:23 ---------- nope doesnt work, i read on another forum that it doesnt work if you use "O_soldier....." but it does if you use the config method, i tried both and neither spawned me anything ---------- Post added at 13:31 ---------- Previous post was at 13:28 ---------- basically what i need is for "O_Soldier_TL_F" createUnit [getMarkerPos "mark1", eastside]; to set the soldiers group to eastside, ive already created the group in an existing units init box. and for way1 = eastside addWaypoint [getMarkerPos "mark2", 5]; way1 setWaypointType "MOVE"; to work as it probably should im not sure if the group dissappears when they die? if so can i create a group that is always there? very confusing bohemia ! Share this post Link to post Share on other sites
samatra 85 Posted June 4, 2013 _group = [getMarkerPos "mark1", EAST, ["O_Soldier_TL_F"]] call BIS_fnc_spawnGroup; _wp = _group addWaypoint [getMarkerPos "mark2", 5]; _wp setWaypointType "MOVE"; how about this? Tested this code in editor and it works fine: soldier spawns and walks to mark2. Make sure you have both markers. Share this post Link to post Share on other sites
lonewolf12 1 Posted June 4, 2013 (edited) Tested this code in editor and it works fine: soldier spawns and walks to mark2. Make sure you have both markers. its not working for me....let me have another look ---------- Post added at 15:39 ---------- Previous post was at 15:35 ---------- i have that in a sqf file is that right? the script definetly executes as i put hint at the end to make sure ---------- Post added at 15:40 ---------- Previous post was at 15:39 ---------- ah noway it worked lol ---------- Post added at 15:43 ---------- Previous post was at 15:40 ---------- thanks mate, i just have to incorporate that into my while loop so i can get more and more enemies now........... quick question while ive still got you, can you instead of spawning just one, spawn what ever a variable (i) is set as so far ive got...... _j = i; while {_j > 0} do { _group = [getMarkerPos "mark1", EAST, ["O_Soldier_TL_F"]] call BIS_fnc_spawnGroup; _wp = _group addWaypoint [getMarkerPos "mark2", 5]; _wp setWaypointType "MOVE"; _j = _j - 1;}; i = i + 1; h = i - 1; hint format ["Level %1",h]; seems to work alright (i = 1, set in the init.sqf file) Edited June 4, 2013 by lonewolf12 Share this post Link to post Share on other sites
samatra 85 Posted June 4, 2013 (edited) Yes you can. I would advice to spawn several soldiers in one group instead of single soldier in each group (there is group number limit in the game by the way) Also instead of while you can use for for "_j" from 1 to i do { _group = [getMarkerPos "mark1", EAST, ["O_Soldier_TL_F", "O_Soldier_F", "O_Soldier_F", "O_Soldier_F"]] call BIS_fnc_spawnGroup; _wp = _group addWaypoint [getMarkerPos "mark2", 5]; _wp setWaypointType "MOVE"; }; i = i + 1; hint format ["Level %1", (i - 1)]; This will spawn group of 4 soldiers (1 team leader, 3 riflemans) "i" times. or if you want "i" number of soldiers in one group _units = ["O_Soldier_TL_F"]; for "_j" from 2 to i do {_units = _units + ["O_Soldier_F"];}; // This will add soldiers only when i is >= 2 _group = [getMarkerPos "mark1", EAST, _units] call BIS_fnc_spawnGroup; _wp = _group addWaypoint [getMarkerPos "mark2", 5]; _wp setWaypointType "MOVE"; i = i + 1; hint format ["Level %1", (i - 1)]; This will create group OPFOR group of teamleader and (i - 2) number of soldiers Edited June 4, 2013 by SaMatra Share this post Link to post Share on other sites
lonewolf12 1 Posted June 4, 2013 aah thanks alot, ill try doing it that way later/tomoro right the next problem is......... ive finally fired up my game mode ive being working on all day (most of which was looking for answers on scripting language lol) and it is executing the script every time for each person who is in the multiplayer room! any ideas on this, im sure its a common thing ( i hope) Share this post Link to post Share on other sites
samatra 85 Posted June 5, 2013 wrap your entire script into if(isServer) then { ... your stuff here ... }; Share this post Link to post Share on other sites
lonewolf12 1 Posted June 27, 2013 just gotta drag this thread up again for a quick question... _j = i;while {_j > 0} do { _group = [getMarkerPos "mark1", EAST, ["O_Soldier_TL_F"]] call BIS_fnc_spawnGroup; _wp = _group addWaypoint [getMarkerPos "mark2", 5]; _wp setWaypointType "MOVE"; _j = _j - 1; }; i = i + 1; h = i - 1; hint format["Level %1",h]; is anything wrong with this code? because you see ive gone to rebuild this mission in the beta, and im getting the error " |#|; };" missing "{" thanks for any help...seems strange since i copied what id wrote before and that worked ok... Share this post Link to post Share on other sites
f2k sel 164 Posted June 27, 2013 What you posted if fine, try scrolling down and see if you have an extra }; that has been pushed down a little. Share this post Link to post Share on other sites
lonewolf12 1 Posted June 27, 2013 What you posted if fine, try scrolling down and see if you have an extra }; that has been pushed down a little. thanks for the reply, ill reply to this thread once i figure it out Share this post Link to post Share on other sites
lonewolf12 1 Posted June 28, 2013 this is driving me crazy! i dont know what it is! Share this post Link to post Share on other sites
f2k sel 164 Posted June 28, 2013 Well I copied and pasted what you posted, I had to add i=4; because it wasn't set in your example but that isn't the cause of the error. The only other things you can check :- Check that it is the right file and named correctly, it could be loading an old version if you changed names at some point. I've even edited the same file but in another directory and spent ages trying to work out why I could fix it. Try place in a hint at the beginning and see if it shows. Could the error be in another file, even BIS scripts sometimes have errors. Share this post Link to post Share on other sites
lonewolf12 1 Posted June 28, 2013 yeah the i variable is in the init file. just to ask, did u get the error? thanks ill try looking at all those things. im pretty sure it errors at the _j - 1 bit or whatever it is... anyway ill sort it one day lol Share this post Link to post Share on other sites
WildFire6 10 Posted June 28, 2013 Just a couple tips.... createVehicle for soldiers doesnt work, AI spawn correctly but are devoid of any action, command or anything, basically dummy units. Spawngroup must be used even if for just one soldier. Also if you put the opposite at the top of your script this will work: if (!isServer) exitWith {}; Checks to see if it is the server, if not the entire script exits. Easier than putting everything in an extra bracket. Share this post Link to post Share on other sites
f2k sel 164 Posted June 28, 2013 yeah the i variable is in the init file.just to ask, did u get the error? thanks ill try looking at all those things. im pretty sure it errors at the _j - 1 bit or whatever it is... anyway ill sort it one day lol I don't get any errors if I add an extra bracket I do get an error but not quite what you get. example http://www.sendspace.com/file/7qrjmr Share this post Link to post Share on other sites
Larrow 2822 Posted June 28, 2013 Just a couple tips....createVehicle for soldiers doesnt work, AI spawn correctly but are devoid of any action, command or anything, basically dummy units. Spawngroup must be used even if for just one soldier. Also if you put the opposite at the top of your script this will work: if (!isServer) exitWith {}; Checks to see if it is the server, if not the entire script exits. Easier than putting everything in an extra bracket. Sorry WildFire6 but this is just bad information. createVehicle for soldiers doesnt workNo because you are ment to use createUnit.Spawngroup must be used even if for just one soldier.No you can use createUnit to create a single unit. if (!isServer) exitWith {}; Checks to see if it is the server, if not the entire script exits. You are better using if (isServer) { //your stuff here }; If the machine the script is running on is not a server then it does not do the block of code. exitWith {} This behaviour is undefined and is a miss use of this command. exitWith exits the execution of a loop defined by one of commands do, for, count or forEach. When you use exitWith not inside a loops, the behaviour is undefined - sometimes it may exit the script, sometimes some other scope, but this is not intended and designed behaviour of this command, and it is not guaranteed to work reliably. Share this post Link to post Share on other sites