Dreepa 10 Posted July 2, 2013 Hi, I am looking for a way to create a trigger that fires when the player is looking at an area. Currently I use OPFOR and have the trigger fire when they are detected. However, I want to make a recon mission, where the trigger should fire when the player observes a compound, where no troops are at. Share this post Link to post Share on other sites
xxanimusxx 2 Posted July 2, 2013 cursorTarget knowsAbout eyeDirection If you can place a specific object which should trigger the action when the player looks at, use cursorTarget and rejoice. Else you have to do some trig calculations using the vector returned by eyeDirection and hope to understand shit :D My suggestion: place an object into the area where the player should look at and check the cursorTarget. Share this post Link to post Share on other sites
Silderoy 1 Posted July 3, 2013 (edited) You can also use aimPos command. place a invisable marker in the middle of the compound, and mane it "reconMark". Place a trigger around the compound that needs to be reconed. size to your choice. Name it "reconTrig". Set condition to Bluefor present repeatedly. in the on act, write: null = [thisList, 20] execVM "seenCheck.sqf"; change the 20 to whatever you like, this is how far from the middle of the compound the player can look to complete the task. Create a new file in the mission folder and name it "seenCheck.sqf". Now open it with notepad and write this: _BlueforPlayers = _this select 0; _required = _this select 1; _targetPos = getMarkerPos "reconMark"; { while {_x in (list reconTrig)} do { _reconPos = aimPos _x; _distance = _targetPos distance _reconPos; if (_distance <= _required) then { RECONISDONE = true; }; sleep 1; }; } forEach _BlueforPlayers Now, in your Init.sqf (if you dont have one, create a new one), add this line: RECONISDONE = false; now to your task itself. create a new trigger. in the cond field, write this: RECONISDONE; and in the on act field write anything you want to happend when the compound is looked at. A bit long and complicated but Im pretty sure it will work (not tested though). Edited July 5, 2013 by Silderoy Share this post Link to post Share on other sites
Dreepa 10 Posted July 4, 2013 Thank you, will try this. How do I approach it best, if I want to understand the script? (Like what are variables with _ in front of them or what does "select" do etc.) Thanks again! Share this post Link to post Share on other sites
xxanimusxx 2 Posted July 4, 2013 Well, you're basically asking us to show you how to count on the basis of the chaos theory equations (which, in this analogy, equals Silderoy's code). As there already are great ressources to learn SQF-Scripting, you should indulge yourself into those and make yourself familiar with the BIKI (Bohemia Interactive Wiki) and you'll step for step understand more of the codes you'll see in this forums. I hope my post doesn't appear too offtopic for you, but I also hope you understand that no one has the time nor the patience to explain every little bit of SQF-Scripting where it doesn't belong to :) Share this post Link to post Share on other sites
Dreepa 10 Posted July 4, 2013 I think you misunderstood me. :) Of course I do not want anyone to spend their time here explaining stuff... I was merely asking for an "approach" to learning it. You know, when you see someone playing a chord on the guitar, and you ask him: How do understand the composition of the chord, and what notes make sense in there? And he will reply with: "Alright, you should probably start getting your fingers to do all standard minor and major chords first, then memorize all notes for each tab on each string, and thereafter you should get a book about harmonics and learn which coords fit into which scale. That will get you started for a good foundation." :) Share this post Link to post Share on other sites
xxanimusxx 2 Posted July 4, 2013 Hmm, there is (or rather was) a thread about which programming language could contribute to learn SQF-Scripting which was interesting, because one could read about how others learned SQF-Scripting. It wouldn't hurt to have some knowledge in any programming/scripting language because it helps you to understand the basic structures and the syntax. My approach was straight forward - looking into scripts and trying to decipher that shit :D BIKI was my best friend as I searched for almost every command and slowly began to understand what command did what and I'm still learning ^^ Search for "beginner" in this subforum, it shoud yield some usefull threads or sometimes tutorials. And to answer your questions in Post #4: Variable names prefixed with _ are local to the scope in which they were defined at. Trying to access this variable outside that scope would normally lead to errors. Every sub-scope can access the local variables of their parent-scopes (which doesn't work for spawned functions though :D). Select is used to get the x'th value off of an array. If you want to get the 6'th value of an array _myArray = [1,2,3,4,5,6,7,8]; , you'd use _myArray select 5 . Arrays are zero-indexed, which means indeces are starting at 0. Share this post Link to post Share on other sites
f2k sel 164 Posted July 4, 2013 The script in #4 has a couple of minor errors. in the triggers on act it should be null=[thisList, 20] execVM "seenCheck.sqf"; and in the condition field of the second trigger it should be RECONISDONE; and not RECONDISDONE; Share this post Link to post Share on other sites
Silderoy 1 Posted July 5, 2013 The script in #4 has a couple of minor errors.in the triggers on act it should be null=[thisList, 20] execVM "seenCheck.sqf"; and in the condition field of the second trigger it should be RECONISDONE; and not RECONDISDONE; fixed, thank you. Share this post Link to post Share on other sites