frag 0 Posted October 16, 2013 Hi guys, I am calling for your creativity here. I am writing a mission in which the player must take a picture of a tower. There are few options available but I would like your feedback since most of you are stronger than I am... How would you script the “camera effectâ€. Here are the basic requirements: 1. Have a special display (like the binocular) 2. Have some kind of camera objective (square in the middle of the screen) 3. Have a take picture functionality that would play a snapping picture sound. 4. I would like to keep this at script level so addons install would not be necessary. 5. Possibility to get the name of the object at which I am pointing at. How would you do this? I know that there is some magician around here. Inspire me … :) Thanks! Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted October 17, 2013 Most Laser Range/Designators have the ability to record images - why not just use the Laserdesignator and cursorTarget with a key combination that plays back a sound file? Share this post Link to post Share on other sites
Tajin 348 Posted October 17, 2013 (edited) Yeh, using a laserdesignator for that would make sense. You could add an action for that to all players and include a condition that defines when the action should be visible. Something like this in your init should do the trick: photoAction = player addAction["Take photo", "foto.sqf", [], 1, true, true, "", "(currentWeapon _this == 'Laserdesignator') && (_this distance tower < 200) && (cursorTarget == tower)"]; // You'll just have to make sure to broadcast the result over the net in your foto.sqf, as actions are only executed locally. Edited October 17, 2013 by Tajin Share this post Link to post Share on other sites
frag 0 Posted October 18, 2013 I finally used the RangeFinder with a script activated by the action menu. Thanks guys. It works great. But I am wondering ... is there any way to link that script to the fire button while using the RangeFinder. I feel that it is incomplete to have to browse to the action menu to "Take Picture". I would like the script to be executed on a key. Possible? Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted October 19, 2013 (edited) But I am wondering ... is there any way to link that script to the fire button while using the RangeFinder. I feel that it is incomplete to have to browse to the action menu to "Take Picture". I would like the script to be executed on a key. Possible? Yep you need to read these: https://community.bistudio.com/wiki/displayAddEventHandler https://community.bistudio.com/wiki/displaySetEventHandler - note code then note - note at bottom. https://community.bistudio.com/wiki/User_Interface_Event_Handlers https://community.bistudio.com/wiki/ListOfKeyCodes example: http://forums.bistudio.com/showthread.php?108289-Helping-a-noob-with-DISPLAYEVENTHANDLER-scripting Edited October 19, 2013 by Mattar_Tharkari Share this post Link to post Share on other sites
frag 0 Posted November 7, 2013 I played around a little bit with it. Let's say I would like to see the hint "Mouse Clicked" ...everytime I click on the left mouse button while playing. How would I call that? I tried: mousedown = (finddisplay 46) displayAddEventHandler ["onMouseButtonClick",{hint "Mouse Clicked"}]; But it seem that event handler is reserved for the dialogs only. Briefly what I want to achieve is the following. When using the RangeFinder, I would like to see the hint "Mouse Clicked", everytime I click the left mouse button. Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted November 8, 2013 This works - you need to remove the "on": mousedown = (finddisplay 46) displayAddEventHandler ["MouseButtonDown","hint 'Mouse Clicked'"]; Not everything in that list works and you don't know till you try e.g. I'm informed that JoystickButton isn't included any longer? Share this post Link to post Share on other sites
frag 0 Posted November 12, 2013 This works - you need to remove the "on": mousedown = (finddisplay 46) displayAddEventHandler ["MouseButtonDown","hint 'Mouse Clicked'"]; Not everything in that list works and you don't know till you try e.g. I'm informed that JoystickButton isn't included any longer? Ok it works! Actually, it does not work if I enter that line in the init.sqf. But I tried setting it up in a trigger (Alpha Radio) and the command works after. Even the one I was using OnMouseButtonClick works, as well as MouseButton down as recommended by Mattar_Tharkari. Thanks for your help Mattar ! One last thing. Someone would know how I could have that hint appearing when the mouse is clicked ... but only if you are currently looking thru the range finder. Reason is simple, I want to implement a script that will work when you click on the mouse, but only while you are looking thru the range finder. Share this post Link to post Share on other sites
oktyabr 12 Posted January 5, 2014 Eager to know this too! I'm working on a mission that will (hopefully) task the players with taking photos of an object before they destroy it. That's a good start! Kind of surprised that this sort of "spy" thing hasn't already had a script or addon made for it. I thought it would be a more popular component of some missions. Share this post Link to post Share on other sites
iceman77 18 Posted January 6, 2014 (edited) Neat idea. Maybe something like this could aid you. Forgive me if it's out of the scope of the intention or already has been suggested. Example Mission init.sqf // Wait until the player is looking through the rangefinder >> Add a mouseButtonDown EH >> Wait until the player stops looking through the rangefinder >> Remove the EH scopename "MAIN"; while {true} do { private "_id"; waitUntil {(currentWeapon player == "Rangefinder") && {cameraView == "GUNNER"}}; _id = (findDisplay 46) displayAddEventHandler ["MouseButtonDown",{_nul = execVM "flash.sqf";}]; waitUntil {!(cameraView == "GUNNER")}; (findDisplay 46) displayRemoveEventHandler ["MouseButtonDown", _id]; if (!isNil "picTaken") then { breakTo "MAIN"; }; }; flash.sqf // Create the white flash ("flash_layer" call BIS_fnc_rscLayer) cutRsc ["ICE_Flash","PLAIN"]; if (cursorTarget == helo1) then { hint "took a picture of the helicopter"; picTaken = 1; }; description.ext class RscTitles { #include "flash.hpp" }; flash.hpp class IceBasePictureHUD { access = 0; type = 0; style = 0x30; idc = -1; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,0.25}; font = "puristaMedium"; sizeEx = 0; lineSpacing = 0; text = ""; fixedWidth = 0; shadow = 0; x = 0; y = 0; w = 0.2; h = 0.15; }; class ICE_Flash { idd = -1; duration = 0.1; // Small duration (for the flash) fadeIn = 0; fadeOut = 0; onLoad = "uiNamespace setVariable ['ICE_Flash_display', _this select 0];"; class Controls { class flash_pic : IceBasePictureHUD { text = "#(argb,8,8,3)color(1,1,1,1)"; idc = -1; x = 0 * safezoneW + safezoneX; y = 0 * safezoneH + safezoneY; w = 1 * safezoneW; h = 1 * safezoneH; }; }; }; NOTE: Alternatively... instead of creating an entire display for the flash, maybe creating and quickly deleting a bright light source would yield better results? ... Edited January 6, 2014 by Iceman77 Share this post Link to post Share on other sites
oktyabr 12 Posted January 6, 2014 Thanks Iceman77! I'll definitely be giving that a try! Share this post Link to post Share on other sites
oktyabr 12 Posted January 6, 2014 That seems to work excellent! I haven't had the opportunity to test it in MP (coop) yet. Any thing you can think of that might mess that up? I DO notice that the flash is initiated every time the mouse is pressed though (while viewing). How hard would it be to check that it was actually looking at the target before running the flash script? I would also almost prefer a camera sound instead of, or with the flash? Further, how do I go about making sure that all my players have this ability or the ability for even one of them to complete the task in the case I am dead? (No respawn!) Sorry... didn't mean to make you do all the scripting for me. :icon_redface: I'm just finding myself quickly running out of free time to finish this mission. Once my time is done I probably won't be able to spend much on it for most of the year. I really hoped someone would have already published such a working script that I could just plugin, rather than spend a bunch of time trying to reinvent the wheel. Your help is MUCH appreciated! Thanks either way, even if you decide not to contribute any further. Share this post Link to post Share on other sites
iceman77 18 Posted January 6, 2014 How hard would it be to check that it was actually looking at the target before running the flash script? I would also almost prefer a camera sound instead of, or with the flash? Further, how do I go about making sure that all my players have this ability or the ability for even one of them to complete the task in the case I am dead? (No respawn!) Hi. Regardless of if a camera is looking at a particular object (in the real world too) doesn't dictate if it flashes or not. In the flash script, the "important" stuff like completing the objective (substituted with a hint instead in the example) is only ran if the cursor target is valid though. ie; taking the picture while looking at helo1. However, obviously in a "stealth" or any other "combat" situation, a bright flash would probably be bad LOL. So... could make the flash toggleable (like a real camera?) instead. Also, a camera sound would be easy to implement. I would go to freesounds.org and search for camera sounds. Just run the sound from the flash.sqf. As far as making it MP compatible, a publicVariable on the picTaken variable should get you started down the right path. I'm not keen on mp scripting though, so maybe someone else can pickup where I left off, and make the script MP compatible. Maybe if I've some time later I'll help you out with the other requests. Kind Regards, Iceman77 Share this post Link to post Share on other sites
oktyabr 12 Posted January 6, 2014 Thanks again Iceman77! Yeah, I know freesound pretty well. Already have a sound I think would work good. http://www.freesound.org/people/ThompsonMan/sounds/166500/ I was thinking maybe instead of a flash it could do like a split second of screen to black, with the camera sound, to simulate the shutter closing during picture taking, thus providing a visual cue that it had been done as well? Share this post Link to post Share on other sites
iceman77 18 Posted January 7, 2014 Change the color text of the picture control used for the flash, to black instead of white, for the shutter effect. Share this post Link to post Share on other sites
oktyabr 12 Posted January 7, 2014 Thanks again! That works well. I know I can manipulate the sound file to adjust ms of silence before the sound actually plays but I'm wondering if there isn't a precision way to delay the flash/shutter in the script to better synchronize it with the sound? The only delay I know is "sleep". Is this the best to use or is there some other scripting magic that might be preferable for this? Or am I better off just trying to tweak the sound file itself? Share this post Link to post Share on other sites
iceman77 18 Posted January 8, 2014 You could try messing with the duration, fadeIn and fadeOut in the flash.hpp to achieve the desired effect. Share this post Link to post Share on other sites
medusacadenza 6 Posted October 7, 2018 Could someone please re-upload the example mission posted by iceman77? Thanks in advance Share this post Link to post Share on other sites
WarhammerZeus 4 Posted January 9, 2019 On 10/7/2018 at 5:46 AM, medusacadenza said: Could someone please re-upload the example mission posted by iceman77? Thanks in advance same Share this post Link to post Share on other sites