Andy455 11 Posted September 17, 2009 Ok so currently I have tried to make my mission more random by making the location of my main objective start in a different location. I have 6 Game Logic - Locations named 'HPos1' - 'HPos 6' and a Heli pad named 'H'. My current script runs with: [] exec "hrandom.sqf"; In the init.sqf This is the hrandom.sqf: _randomNumber = random 6; if (_randomNumber > 0 && _randomNumber < 1) then { H setPos [getPos HPos1 select 0,getPos HPos1 select 1,0]; if (_randomNumber > 1 && _randomNumber < 2) then { H setPos [getPos HPos2 select 0,getPos HPos2 select 1,0]; if (randomNumber > 2 && _randomNumber < 3) then { H setPos [getPos HPos3 select 0,getPos HPos3 select 1,0]; if (randomNumber > 3 && _randomNumber < 4) then { H setPos [getPos HPos4 select 0,getPos HPos4 select 1,0]; if (randomNumber > 4 && _randomNumber < 5) then { H setPos [getPos HPos5 select 0,getPos HPos5 select 1,0]; if (randomNumber > 5 && _randomNumber < 6) then { H setPos [getPos HPos6 select 0,getPos HPos6 select 1,0]; }; }; }; }; }; }; This currently does not work as it always places the helipad (and marker ive made to show where it is) at HPos6. Can anyone please tell me what I'm doing wrong or if there is an easier way to do this? Thanks in advance Andy Share this post Link to post Share on other sites
kylania 567 Posted September 17, 2009 Far too much work perhaps? At least for units you can group then with markers and it'll randomly spawn at one of the markers or it's placed location. That might work with the 'H'? Share this post Link to post Share on other sites
TRexian 0 Posted September 17, 2009 Couple things jump out at me. - you don't have any close-brackets like }; for your if statements - I've noticed that A2 seems to be more sensitive to the lack of parentheses, so, I suggest something like if ((randomNumber > 5) && (_randomNumber < 6)) then { H setPos [(getPos HPos6) select 0,(getPos HPos6) select 1,0]; }; Share this post Link to post Share on other sites
shuko 59 Posted September 17, 2009 call compile format ["H setPos [(getPos HPos%1 select 0),(getPos HPos%1 select 1),0]",ceil(random 6)]; Share this post Link to post Share on other sites
Andy455 11 Posted September 17, 2009 (edited) Erm kylania I'm not sure which type of marker you are talking about but I just trying grouping 2x empty markers to a unit in a new and blank mission. When I spawned I was at the place I place myself in the editor? Is this one of those annoying things that only work if you play the mission from multiplayer or SP scenarios screen? And to TRexian my parentheses are there they are just at the end, my friend has managed to do it this way and it works for him but I can't talk to him right now. So if you can specify which markers make it spawn in a different place then please tell me :) Edit: shk how would I go about implementing that? Could it just go in any trigger / init such as the init.sqf? Edited September 17, 2009 by Andy455 Ask shk something Share this post Link to post Share on other sites
shuko 59 Posted September 17, 2009 Edit: shk how would I go about implementing that? Could it just go in any trigger / init such as the init.sqf? It replaces your whole script. So, yeah, you can just run it from init.sqf. However, remember to run it on server only if its a MP mission. Share this post Link to post Share on other sites
JDog 11 Posted September 17, 2009 Just a quick somethin to throw in... use execVM for sqf files, not exec. Share this post Link to post Share on other sites
Andy455 11 Posted September 17, 2009 Ok thanks shk it works :-) I just put in call compile format ["H setPos [(getPos HPos%1 select 0),(getPos HPos%1 select 1),0]",ceil(random 6)]; into my init.sqf Share this post Link to post Share on other sites
kylania 567 Posted September 17, 2009 Erm kylania I'm not sure which type of marker you are talking about but I just trying grouping 2x empty markers to a unit in a new and blank mission. When I spawned I was at the place I place myself in the editor? Is this one of those annoying things that only work if you play the mission from multiplayer or SP scenarios screen? Of course it did. As I explained that was one of the possibilities. The marker-grouped object spawns either where you placed it or at the location of one of the marker's it's grouped with. You just want the H to appear at a random spot out of 6 possibilities right? Place your FIVE markers in five of the places you want, place your object in the SIXTH place. Then group (this is sometimes difficult since in Group Mode you can't see the marker, but you can see it's tooltip when you're over it) the markers with the object and PREVIEW MORE THAN ONCE. :) The H will move to one of the markers or remain where it is. No need for long if/than scripts or any scripts at all, though shk's solution is pretty elegant too. :) Share this post Link to post Share on other sites
Rommel 2 Posted September 18, 2009 _objArr = [HPos1, HPos2, HPos3, HPos4, HPos5, HPos6]; _randomInt = floor(count _objArr); _HPos = getpos (_objArr select _randomInt); _HPos set [2, 0]; H setPos _HPos; Less is more. Call compile formats are messy. Share this post Link to post Share on other sites