Jump to content
Heeeere's johnny!

[SCRIPT] Automated Doors 2.5 - doors open and close automatically

Recommended Posts

Hi Lauren,

 

well, unfortunately there's no differentiation between doors and bar gates in terms of the distance at which they open. Of course, such differentiation would be senseful as your question suggests, but the fact that I'm answering your question a week later might show how much time I can spend at the moment on scripting.

 

EDIT:

I've created a quick fix which is a bit of an overhead for just one class, but it gives you the possibility to add custom trigger area sizes to each class name (in the debug version of the script at least). Land_BarGate_F thus have a radius of 6 meters to open and close. I'm confident, there can be a better solution, but it works and has no impact on the script's performance. I'll publish it tomorrow hopefully.

 

Best wishes,

Johnny

Share this post


Link to post
Share on other sites

Looks like the last patch broke doors (name change?) getting      \A3\Structures_F\scripts\Door_close.sqf     NOT Found

Share this post


Link to post
Share on other sites

First of all, the script in that directory is called "fn_DoorClose.sqf".

 

Secondly, Automated Doors is not using that script. Instead, it opens and closes doors using the animate command.

 

But even if the door names changed (which they didn't as far as my testing revealed), the only way you would recognize it would be that Automated Doors would not work, because executing the animate command with a wrong door name does not produce any errors.

 

So I am assuming the error you describe comes from somewhere else, probably an addon. I suggest you disable all your addons and re-enable them step by step to pin down the one which produces the error. Be aware that if this is a message which pops up in the center of the screen, you may have to restart ArmA 3 everytime again, because such messages only occur once with the first incident of that kind.

Share this post


Link to post
Share on other sites

Automated Doors v2.4

 

news_download_a3_3.png

Download v2.4 from Armaholic

Changelog:

v2.4
- renamed #define DOOR_RADIUS to DOOR_RADIUS_SMALL
- added #define DOOR_RADIUS_LARGE (6 meters)
- using DOOR_RADIUS_LARGE on very wide fences/doors including "Land_BarGate_F"
- door radius can be individually set for each building class (default is DOOR_RADIUS_SMALL)


 
Hey guyz,
 
I could actually find some spare time for a small update due to the recent request by (see here). You can now set custom trigger area sizes for each building class. (The easiest way is doing this in the "automatedDoors_debug.sqf".)
 
Wide fences and bar gates will now have a default trigger area of 6 meters (mostly affects Chernarus buildings). Of course, for every other building, the trigger area size will stay as it was before.
 
I hope, you find this useful.
 
Have a nice Play!
Johnny

Share this post


Link to post
Share on other sites

Another good update once again, good work!

Share this post


Link to post
Share on other sites
Guest

Good job on this, and grats on the release :)

 

I would like to throw out an option that the author might desire to consider - an option to close all doors on mission start.

 

I know, this is really completely the reverse of what is intended with this addon, but, afaik, there really is no way to effectively close all doors on mission start on A2 maps, and unless one attempts to dig up all the door names - something I, like probably many, gave up even trying to get into.

 

Just thought I'd throw this out there in case maybe the supporting code is basically already there to allow such an option to easily be put in, if not, then not.

Share this post


Link to post
Share on other sites

Looks like the last patch broke doors (name change?) getting      \A3\Structures_F\scripts\Door_close.sqf     NOT Found

Yes the error was in the UPSMon scripts. Bis changes the name used by that addon

 

Re; open all doors as mentioned previous post, there is a module that will open or close all doors (also shutters) inside a trigger linked to it. Works on both default maps, not tried it on other (A2) maps.

Share this post


Link to post
Share on other sites
Guest

Thanks for that :)

 

I spent quite a bit of time searching the forums for an answer to closing all doors on A2 maps some time ago, someone posted that they tried the module mentioned and it did not work for the A2 maps, but I'll give it a shot to be sure later on when I get some time this evening.

 

/Edit

 

At least on my end, the open/close door module does not work on buildings on both Chenarus and Utes. I did make sure I was doing it right by testing the module with a trigger attached to it on Altis, and all doors open and close when forced by the module with the trigger attached.

Share this post


Link to post
Share on other sites

Good job on this, and grats on the release :)

 

I would like to throw out an option that the author might desire to consider - an option to close all doors on mission start.

Well, I think I understand the situation why you'd like to have this option. I'm just not sure wether such an option really belongs into this script, because all doors on the map are closed by default and if they aren't, I'd be very certain it's because of an addon.

 

I know, this is really completely the reverse of what is intended with this addon, but, afaik, there really is no way to effectively close all doors on mission start on A2 maps, and unless one attempts to dig up all the door names - something I, like probably many, gave up even trying to get into.

 

Just thought I'd throw this out there in case maybe the supporting code is basically already there to allow such an option to easily be put in, if not, then not.

 

The most efficient way I could come up with is this:

fnc_findLast = { //Finds the last occurance of an element in a string or array.
    private ["_hayStackCount", "_hayStackTmpIndex", "_indexLast"];
    params [["_hayStack", [], ["", []]], ["_needle", "", ["", []]]];

    _hayStackCount        = count _hayStack;
    _hayStackTmpIndex     = _hayStack find _needle;
    _indexLast            = -1;

    while {_hayStackTmpIndex > -1} do
    {
        _indexLast        = _indexLast + 1 + _hayStackTmpIndex;
        _hayStackTmp      = _hayStack select [_indexLast + 1, _hayStackCount];
        _hayStackTmpIndex = _hayStackTmp find _needle;
    };

    _indexLast
};

_mapRadius = worldSize / 2;
_mapCenter = [_mapRadius, _mapRadius];
_doorState = 0;

{
    _configAnimationSources = configFile / "CfgVehicles" / (typeOf _x) / "animationSources";

    for "_i" from 0 to (count _configAnimationSources) - 1 do {
        _sourceName = configName (_configAnimationSources select _i);
                
        if (-1 != _sourceName find "Door") then {
            switch true do {
                case (-1 != _sourceName find "A_") : { //slider door
                    _x animate [(_sourceName select [0, [_sourceName, "_"] call fnc_findLast]) + "_move", _doorState];
                };
                case (-1 != _sourceName find "B_") : { //slider door
                    _x animate [(_sourceName select [0, [_sourceName, "_"] call fnc_findLast]) + "_move", _doorState];
                };
                default {
                    _x animate [(_sourceName select [0, [_sourceName, "_"] call fnc_findLast]) + "_rot", _doorState];
                };
            };
        };
    };
} forEach (_mapCenter nearObjects ["House", _mapRadius * 1.2]);

Called on Altis, it only takes a few seconds on my machine. I hope that helps.

Share this post


Link to post
Share on other sites
Guest

Thanks Johnny for that, I spent a good bit of time trying to get this to work on Utes (the map I have issues with some doors that are open by default), and I can't get it to work. I did try to code on Altis just to be sure, and it works fine there.

 

I didn't even realize that you were trying to help out someone else with basically the same issue in a thread I had tracked down while trying to find an answer to this :

 

https://forums.bistudio.com/topic/183955-closing-doors-in-usermade-terrains-possible/?hl=doors

 

I actually tried the same stuff some of the folks there tried as well, along with an older method that worked with OA doors, and does not work at least on Utes (probably not on Chenarus as well).

 

So it looks like the answer never really was found, and probably won't be found - certainly not worth spending hours upon hours trying to get it to work. I would think it probably is some sort of naming issue between door names used by Arma2 and maybe actual folder names as well possibly being different and in Czech maybe too.

 

Really, thanks again, and I think for both myself and anyone elses time, I'm going to let this one go - after already having spent hours on this issue, and a good few others trying as well with no luck, I fear that only more personal time (that is limited these days lol) of folks will be spent in potential significance with no probably no answer found still.

 

 

/Edit

 

I realized I totally forgot to mention that the A2 maps I have been referring to are from the All In Arma Pack, not the original A2 stuff through Arma 2 itself. That probably explains a lot. Sorry about that.

Share this post


Link to post
Share on other sites

Thanks Johnny for that, I spent a good bit of time trying to get this to work on Utes (the map I have issues with some doors that are open by default), and I can't get it to work. I did try to code on Altis just to be sure, and it works fine there.

 

Yeah, well, that code does only work in ArmA 3 because in older ArmA versions, many things (so doors) were called differently, there were no proper namining conventions in the configs and the code, plus ArmA 2 door names do not have underscores (which the fnc_findLast function searches in that particular case).

 

I didn't even realize that you were trying to help out someone else with basically the same issue in a thread I had tracked down while trying to find an answer to this :

 

https://forums.bistudio.com/topic/183955-closing-doors-in-usermade-terrains-possible/?hl=doors

 

Did I? ... (clicking link ... searching post) ... oh, I did! :D

 

I actually tried the same stuff some of the folks there tried as well, along with an older method that worked with OA doors, and does not work at least on Utes (probably not on Chenarus as well).

 

So it looks like the answer never really was found, and probably won't be found - certainly not worth spending hours upon hours trying to get it to work. I would think it probably is some sort of naming issue between door names used by Arma2 and maybe actual folder names as well possibly being different and in Czech maybe too.

 

Really, thanks again, and I think for both myself and anyone elses time, I'm going to let this one go - after already having spent hours on this issue, and a good few others trying as well with no luck, I fear that only more personal time (that is limited these days lol) of folks will be spent in potential significance with no probably no answer found still.

 

 

/Edit

 

I realized I totally forgot to mention that the A2 maps I have been referring to are from the All In Arma Pack, not the original A2 stuff through Arma 2 itself. That probably explains a lot. Sorry about that.

No problem. There is (almost) always a solution. The question is whether you're gonna take it or respond with "If that's the solution, I want my problem back." ;)

 

Utes is still an ArmA map, so you can search the config just as you can do in ArmA 3. You may need to know that in Czech, "door" is "dveře" and "gate" is "vrata". Hence, "dvere" and "vrata" are the words used in the configs of Chernarus buildings.

 

I don't know what buildings are on Utes, but all you need to do is a look into the configs of a building to find out what the doors are called there. The bigger problem is that things like "string select [0, 5]" or "string find string" did not exist in ArmA 2, if that's your environment. So adapting the code requires a little more than copy-paste.

Share this post


Link to post
Share on other sites
Guest

Thanks for the info there :)

 

 

Take care, and Merry Christmas!

 

 

/Edit

 

I must say that the script for the Automated Doors function is really a library to give all the door names of the A2 building doors. Found the two buildings in the Debug script version that I've been having issues with on Utes, script already has the door names, and just forced the doors shut in an Init script :


Sleep 2.0;

{
//Player SideChat Format ["%1",TypeOf _x];
if (TypeOf _x == "Land_HouseV_1I4") then {_x animate ["dvere1", 0];_x animate ["dvere2", 0];};
} forEach ([3360,4392,16] nearObjects ["House",20]);

Sleep 1.0;

{
//Player SideChat Format ["%1",TypeOf _x];
if (TypeOf _x == "Land_Mil_ControlTower") then {_x animate ["dvere_spodni_L", 0];_x animate ["dvere_spodni_R", 0];_x animate ["dvere_vrchni", 0];};
} forEach ([3570,3649,18] nearObjects ["House",20]);

I will put in my missions credits your name for the help and for the library of door names that made this possible (because I was not going to pursue digging into the config stuff to find them lol).

 

Great job on the Automated Doors script, that is a pretty significant piece of work.

Share this post


Link to post
Share on other sites

I just noticed this in my .rpt file and pops up constantly with show script errors on. Just started since the 2.4 release. I'm using the script version and I'm on the Altis map. But it seems to still work fine but the gates on altis don't open at 6m. (not confirmed on all gates)

19:06:11 Error in expression <allDoorPositions select _buildingIndex, _allRadius select _buildingIndex] call _>
19:06:11   Error position: <_allRadius select _buildingIndex] call _>
19:06:11   Error Undefined variable in expression: _allradius
19:06:11 automatedDoors.sqf, line 383

Share this post


Link to post
Share on other sites

I just found this line as well!

18:14:29 Performance warning: SimpleSerialization::Write 'scriptHandle_automatedDoors' is using type of ',SCRIPT' which is not optimized by simple serialization, falling back to generic serialization, use generic type or ask for optimizations for these types

Share this post


Link to post
Share on other sites

 

I just noticed this in my .rpt file and pops up constantly with show script errors on. Just started since the 2.4 release. I'm using the script version and I'm on the Altis map. But it seems to still work fine but the gates on altis don't open at 6m. (not confirmed on all gates)

19:06:11 Error in expression <allDoorPositions select _buildingIndex, _allRadius select _buildingIndex] call _>
19:06:11   Error position: <_allRadius select _buildingIndex] call _>
19:06:11   Error Undefined variable in expression: _allradius
19:06:11 automatedDoors.sqf, line 383

 

This error arises, because I simply forgot something in that context, I'm sorry. When I added the different door area sizes, I forgot to add the respective values in the "non-debug" version. The script works though because if the function creating the triggers does not get a value as size parameter, it takes 3 meters as default value.

 

Either way, this problem will be fixed with the next update (coming the next days). Thank you very much for reporting!

 

 

I just found this line as well!

18:14:29 Performance warning: SimpleSerialization::Write 'scriptHandle_automatedDoors' is using type of ',SCRIPT' which is not optimized by simple serialization, falling back to generic serialization, use generic type or ask for optimizations for these types

 

I personally did not get this message yet. But I do not have the knowledge to tell you where this might come from.

 

The global variable "scriptHandle_automatedDoors" exists so people have something definite to terminate the script if needed. But I was already thinking how senseful this really is since they could simply create a handle themselves when using execVM.

Share this post


Link to post
Share on other sites

Automated Doors v2.5

 

news_download_a3_3.png

Download v2.5 from Armaholic

Changelog:

v2.5
- automatedDoors.sqf: changed plain numbers in radius array to defines
- outsourced building arrays to separate files and #include them
- added doorsTakistan.sqf (door positions on Takistan)
- added doorsUtes.sqf (door positions on Utes)
- added doorsZargabad.sqf (door positions on Zargabad)
- fnc_getModelPos optimized, because nearestObject might not always take the building the player is in
- slightly optimized handling of first script parameter ("_objects")
- added DOOR_RADIUS_LARGE to all remaining gates on Altis and Stratis



Happy new year, people!

First off, yes I have friends and family and I have spent Christmas and New Year's Eve with them. But that doesn't mean I can't publish an update on 2 January 2016. ;)

Since the number of building classes grew massively with this update and the file size (especially the number of lines) got off the charts, I decided to outsource the door positions into separate files. As long as you have the "doors..." file needed for your map in the same folder as the "automatedDoors.sqf", everything's fine.

As always, if you have any issues, suggestions or whatsoever, just let me know. :)

Have a nice Play!
Johnny

Share this post


Link to post
Share on other sites

Latest addon version seems to have a problem.  Something about automateddoorsaltisautomateddoors.sqf (or something) when I run it on Altis.

 

Will check some more.

Share this post


Link to post
Share on other sites

Latest addon version seems to have a problem.  Something about automateddoorsaltisautomateddoors.sqf (or something) when I run it on Altis.

 

Will check some more.

 

Thank you for reporting! This is a pathing problem. The script searches for the "doors..." files in the folder of the running mission. I did not find that error, because I tested the addon version in a mission where the required files luckily existed. I'm going to fix this and inform you as soon as I uploaded the fixed script. Sorry for that.

Share this post


Link to post
Share on other sites

I've fixed the error. You may download the fixed version from the usual link (here).

 

Please let me know if it works properly (which it actually should ^_^).

Share this post


Link to post
Share on other sites

I haven't played since your last update but when I tried to load my mission after updating to the 2.5 fixed version (script version) I get this:

17:17:27 Performance warning: SimpleSerialization::Write 'scriptHandle_automatedDoors' is using type of ',SCRIPT' which is not optimized by simple serialization, falling back to generic serialization, use generic type or ask for optimizations for these types
17:17:27 "_fileName = C:\Users\I7-950\Documents\Arma 3 - Other Profiles\CDN_BiggDogg\mpmissions\resist_infected.Altis\myscripts\doorsaltis.sqf"
17:17:27 Invalid path (only relative paths supported): 'C:\Users\I7-950\Documents\Arma 3 - Other Profiles\CDN_BiggDogg\mpmissions\resist_infected.Altis\myscripts\doorsaltis.sqf'
17:17:27 Warning Message: Script C:\Users\I7-950\Documents\Arma 3 - Other Profiles\CDN_BiggDogg\mpmissions\resist_infected.Altis\myscripts\doorsaltis.sqf not found
17:17:27 "automatedDoors: File "C:\Users\I7-950\Documents\Arma 3 - Other Profiles\CDN_BiggDogg\mpmissions\resist_infected.Altis\myscripts\doorsaltis.sqf" does not exist."

this is my exec line:

[["altis"], true] execVM "myscripts\automatedDoors.sqf";

I checked and double checked that both the automatedDoors.sqf and doorsAltis.sqf files are in the myscripts folder. I also tried to move them to the root folder but the result was the same!

 

Any ideas?

 

***EDIT***

 

Should make note that the script failed on a local server but was fine on a dedicated server!

Edited by cdn_biggdogg

Share this post


Link to post
Share on other sites

Hi,

 

yes, I know the reason for that. Your files are fine, no matter where they are. It's in my code and I'm already working on a fix and will provide you with the updated script as soon as I'm done.

 

Thank you very much for bringing this to my attention! I really appreciate your help.

 

Have a nice Play!

Johnny

Share this post


Link to post
Share on other sites

Hey Johnny,

 

Automated Doors addon does not work well with new Tanoa island ... could you have a look please?

  • Like 1

Share this post


Link to post
Share on other sites

Hey Johnny,

 

Automated Doors addon does not work well with new Tanoa island ... could you have a look please?

 

The Tanoa buildings and if you could could you add the MBG buildings.....they are used on the Napf island. Pretty please!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×