pierremgi 4890 Posted April 26, 2021 Hi all, Here is a script you can run for each player (initPlayerLocal.sqf is just fine!) This script allow to lock / unlock any door of any house. Works fine in Arma3. I added a little workaround for WW2 houses like in CUP core used by IFA3 mod. That probably worth for ant Arma2 houses, not tested. Spoiler Anyway, in this case (WW2 IFA3) I think the script can be resource demanding if players lock many doors (animations run permanently). So test it with these maps There is just one parameter: TRUE means players must have the item "Keys" in their inventory. And no, I will not script for specific keys for due houses! Say it's a pass. FALSE allows players to lock - unlock the doors of the houses without keys. NOTE : you can also manage just some houses (see below) 0 = FALSE spawn { params [["_needKeys",FALSE],"_houses",["_house",objNull]]; while {true} do { if (isNull objectParent player) then { _houses = ((nearestObjects [player, ["house"], 50]) select {isNil {_x getVariable "securedHouse"}}); if (count _houses > 0) then { _house = _houses select 0; _house setVariable ["securedHouse",_needKeys]; [ _house, "Lock-unlock door", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", " call { private _intersects = []; private _intersect = ''; private _door_anim = ''; private _is_door = FALSE; private _dist = 4; { _intersects = ([_target, _x] intersect [ASLToATL eyepos player, (screentoworld [0.5,0.5])]); if (count (_intersects select 0) > 0) exitwith { _intersects } } forEach ['FIRE','GEOM','VIEW']; if (count _intersects > 0) then { _intersect = _intersects select 0 select 0; _dist = _intersects select 0 select 1; _is_door = ('door' in toLowerANSI _intersect); if (_is_door && _dist < 4) then { if ('ww2_' in toLowerANSI typeOf _target) then { _door_anim = format ['%1_anim', _intersect]; } else { _door_anim = format ['%1_rot', _intersect]; }; }; }; if (_this distance _target < 15 && {_door_anim !=''} && {_target animationPhase _door_anim == 0} && {'keys' in magazines _this or !(_target getVariable 'securedHouse')}) then { _target setVariable ['MGIselDoor',[_intersect,_door_anim]]; true } else {false}; }; ", "true", {}, {}, { if (_target getVariable ["MGIselDoor",[]] isnotEqualTo []) then { (_target getVariable "MGIselDoor") params ["_door","_door_anim"]; private _doorState = format ['bis_disabled_%1',_door]; if (_target getVariable [_doorState,0] == 0) then { _target setVariable [_doorState,1,true]; if ("ww2_" in toLowerANSI typeOf _target) then { [_target,_doorState,_door_anim] spawn { params ["_target","_doorState","_door_anim"]; while {alive _target && _target getVariable _doorState == 1} do { _target animate [_door_anim,0,TRUE]; sleep 0.1; }; }; }; } else { _target setVariable [_doorState,0,true]; }; }; }, {}, [], 5, nil, false, false ] call BIS_fnc_holdActionAdd; }; }; sleep 2; }; }; For specific houses, you want to secure (w. or w/o keys): The general parameter determines the need of keys if you want to skip this code for most of the houses except those which are in a trigger area (example trg1), just replace the line: _houses = ((nearestObjects [player, ["house"], 50]) select {isNil {_x getVariable "securedHouse"}}); by: _houses = ((nearestObjects [player, ["house"], 50]) select {isNil {_x getVariable "securedHouse"} && _x inArea trg1 }); Have fun! 4 3 Share this post Link to post Share on other sites
major-stiffy 279 Posted April 26, 2021 Will this keep AI from walking through the door or wall like it is now? 😂 1 Share this post Link to post Share on other sites
johnnyboy 3797 Posted April 27, 2021 Beautiful. Great work Pierre. 1 Share this post Link to post Share on other sites
johnnyboy 3797 Posted April 27, 2021 2 hours ago, major-stiffy said: Will this keep AI from walking through the door or wall like it is now? I wonder if spawning an invisible barrier object to the door position when locked would fix this problem? 1 Share this post Link to post Share on other sites
LSValmont 789 Posted April 29, 2021 Very, very, VERY useful yet hard to come by peace of code. Well done @pierremgi! 👏 Just like wine your contributions have grown sweeter with time. I can see a combination of this and the lockpicking script for the ultimate "thief" simulator. 2 Share this post Link to post Share on other sites
LSValmont 789 Posted April 29, 2021 On 4/26/2021 at 8:17 PM, johnnyboy said: I wonder if spawning an invisible barrier object to the door position when locked would fix this problem? Some of the gurus at the Arma 3 Discord have stated that the issue is related to the way the AI disables its collision temporarily as a way to prevent them from getting stuck on objects. Funny thing is that agent units do not exhibit this behavior and would not disable their collision on demand, therefore almost never going through solid objects. I suggested the devs to remove this "auto disable collision" behavior that regular units have and instead use a system that when a unit is colliding too much too fast (they are obviously stuck) then just kill them (and put their bodies on a visible location like most other games do) or just disable and hide the ai unit and wait until no player can see the location and then use a BIS_fnc_findSafePos + setPos to unstuck them. The current behavior just makes the whole franchise look bad, since it has been a decade long issue that has never been addressed. Even on the newer DayZ:SA it took them ages to fix it. Share this post Link to post Share on other sites
froggyluv 2136 Posted April 29, 2021 10 minutes ago, LSValmont said: I suggested the devs to remove this "auto disable collision" behavior that regular units have and instead use a system that when a unit is colliding too much too fast (they are obviously stuck) then just kill them (and put their bodies on a visible location like most other games do) or just disable and hide the ai unit and wait until no player can see the location and then use a BIS_fnc_findSafePos + setPos to unstuck them. The current behavior just makes the whole franchise look bad, since it has been a decade long issue that has never been addressed. Even on the newer DayZ:SA it took them ages to fix it. Agreed it something worthy of Dev attention yet another Quality of Life issue they just choose to ignore. Kinda like Spec Ops who run around with their Binocs up or Soldiers quickly reverting to Idle animations DURING combat -these should be easily fixable by the Pros yet they ignore and its an utter shame. How about disabling AI Ghosting when any player is within 400m so we never *(rarely see it)? How about no Binocs when enemy is closer than 300m OR there is an obvious immediate firefight taking place? How about no Idle animations if any shot was fired within past 5 minutes and/or again a known enemy is nearby? Shouldnt be that hard to remedy but alls we get is DLC with new units and maps with the same ol problems.. Share this post Link to post Share on other sites
LSValmont 789 Posted April 29, 2021 16 minutes ago, froggyluv said: Agreed it something worthy of Dev attention yet another Quality of Life issue they just choose to ignore. Kinda like Spec Ops who run around with their Binocs up or Soldiers quickly reverting to Idle animations DURING combat -these should be easily fixable by the Pros yet they ignore and its an utter shame. How about disabling AI Ghosting when any player is within 400m so we never *(rarely see it)? How about no Binocs when enemy is closer than 300m OR there is an obvious immediate firefight taking place? How about no Idle animations if any shot was fired within past 5 minutes and/or again a known enemy is nearby? Shouldn't be that hard to remedy but alls we get is DLC with new units and maps with the same ol problems.. I would pay full retail price for any DLC that brings those fixes plus the flying vehicles issues that just make the Arma 3 physics look like a joke. Sadly it seems that the current remaining dev team, thou immensely talented, are only allowed to do minor / under the hud stuff (for mission makers and modders) but nothing truly visible/palpable for the regular player or vanilla users. (You basically need to play with mods in order the experience most of the last patches content updates) There are so many legacy issues still remaining like way that the damagedEH is handled (any part damage on a unit also damages other connected body parts so if you shoot some unit on the chest it will also receive head and legs damage etc, that behavior being TOTALLY unrealistic and was probably just a work around back in the day but a work around that never got patched. Additionally there are plenty UI related issues and MUCH MUCH needed upgrades regarding managing inventories, logistics, duplicated items, inventory bugs etc. but those will probably will never be fixed at this point, even thou we are still getting new CDLC paid content released. 1 Share this post Link to post Share on other sites
froggyluv 2136 Posted April 29, 2021 12 minutes ago, LSValmont said: Sadly it seems that the current remaining dev team, thou immensely talented Yeah no i dont blame the guys coding i blame those that make the decisions to forgo these vital fixes 2 Share this post Link to post Share on other sites
pierremgi 4890 Posted April 29, 2021 You're right! When creating a scenario, I spend more time in workaround than scripting the action. - Binocs : never in AIs inventory for played groups. Added on player when he joins. (I'm not sure an AI sniper with binoc has its shooting distance improved. Anyway crossing a battlefield with binoc on hands is ridiculous); - AIs passing thru walls. Agree! They can pass wall entering the houses, then they are stuck like fishes in a creel! My little workaround is to allow any player in the group to double click on map, on a position within 30 from the (nearest) AI to make it jump on it. That is not too "cheaty", that helps for other ridiculous stuck, like crossing Merderet river (I'm on it right now!). - spawning vehicles... my own function looking for convenient places instead of seeing inflamed tanks bouncing in the air when spawned in urban context; - I can't count all scripted "band-aid" in fact. 2 Share this post Link to post Share on other sites
johnnyboy 3797 Posted April 29, 2021 55 minutes ago, LSValmont said: On 4/26/2021 at 5:17 PM, johnnyboy said: I wonder if spawning an invisible barrier object to the door position when locked would fix this problem? Some of the gurus at the Arma 3 Discord have stated that the issue is related to the way the AI disables its collision temporarily as a way to prevent them from getting stuck on objects. I totally agree about these unfixed crucial bug complaints. But my question still stands on whether invisible barrier object might prevent AI from using a locked door. The reason I think they might work is their AI Pathing will choose not to go to that door. I've used these in the past to keep AI from certain areas and it seemed to work. If the barrier does work, then AI would not attempt the door. But its still not great because the AI would appear to *know* the door was locked, and thus not approach it at all. 1 Share this post Link to post Share on other sites