Jump to content

Recommended Posts

Hello, everyone. As you can see from my title, I am looking for a script to use in a mission. I need to be able to unlock a door of any building in the editor. I guess there's an option in the attributes of a building that must be changed or I need to put a script in the init field. I didn't find anything useful in Google, but I think it hast to be something with: this addAction. Any suggestions? Thanks in advance. Cheers!

Share this post


Link to post
Share on other sites

Did you already lock all the doors on map? Or just some buildings, in a trigger, or area?

Share this post


Link to post
Share on other sites

I don't know how to lock doors of buildings already on the map. If I place buildings from the editor - that's doable. But I want to know about 1 building, no matter what exactly. The mission I played was like this - all doors were locked, but standing in front of one of them, I was given this option with holding space to pick the lock. There was even some ambient sound of unlocking. I guess it's something like this: this  setVehicleLock "UNLOCKED";

But first off, I guess I must use:  setVehicleLock "LOCKED"; in the init's field of the building and right after a trigger is activated (done by holding space) it should be set to:  setVehicleLock "UNLOCKED"; - which I shall put in trigger's On Activation field. Something like this should do the job, I hope. Any ideas how exactly?

Share this post


Link to post
Share on other sites

OK, let's say you blocked doors of buildings in edito (via the edit terrain object module).

 

Place a trigger on map (anywhere, no area needed, not repeatable)

set it to true (instead of this) in condition field

 

copy/paste this code (tested but not really optimized), in on activation field:

 

0 = [] spawn {
  while {true} do {
    _houses = ((nearestObjects [player, ["house"], 50]) select {isnil {_x getVariable "passedHouse"}});
    if (count _houses > 0) then {
      _house = _houses #0;
      _house setVariable ["passedHouse",true];
      [_house, "Lockpick 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','_select_door'];
            _intersects = ([cursorObject, 'VIEW'] intersect [ASLToATL eyepos player, (screentoworld [0.5,0.5])]);
            _select_door = if (count _intersects > 0) then [{format ['%1_sound_source', (_intersects #0 #0)]},{''}];
            if (_this distance _target < 15) then {
              MGI_select_door = _select_door;
              true
            } else {false};
          };
          true
        ",
        "true",
        {},
        {},
        {
          if (_target animationSourcePhase MGI_select_door == 0) then {
            _target animateSource [MGI_select_door,1]
          } else {
          _target animateSource [MGI_select_door, 0]
          }
        },
        {},
        [],
        5,
        nil,
        false,
        false
      ] call BIS_fnc_holdActionAdd;
    };
    sleep 0.5;
  };
};

 

Should work to unlock/relock the doors.

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites
4 minutes ago, pierremgi said:

OK, let's say you blocked doors of buildings in edito (via the edit terrain object module).

 

Place a trigger on map (anywhere, no area needed, not repeatable)

set it to true (instead of this) in condition field

 

copy/paste this code (tested but not really optimized), in on activation field:

 


0 = [] spawn {
  while {true} do {
    _houses = ((nearestObjects [player, ["house"], 50]) select {isnil {_x getVariable "passedHouse"}});
    if (count _houses > 0) then {
      _house = _houses #0;
      _house setVariable ["passedHouse",true];
      [_house, "Lockpick 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','_select_door'];
            _intersects = ([cursorObject, 'VIEW'] intersect [ASLToATL eyepos player, (screentoworld [0.5,0.5])]);
            _select_door = if (count _intersects > 0) then [{format ['%1_sound_source', (_intersects #0 #0)]},{''}];
            if (_this distance _target < 15) then {
              MGI_select_door = _select_door;
              true
            } else {false};
          };
          true
        ",
        "true",
        {},
        {},
        {
          if (_target animationSourcePhase MGI_select_door == 0) then {
            _target animateSource [MGI_select_door,1]
          } else {
          _target animateSource [MGI_select_door, 0]
          }
        },
        {},
        [],
        5,
        nil,
        false,
        false
      ] call BIS_fnc_holdActionAdd;
    };
    sleep 0.5;
  };
};

 

Should work to unlock/relock the doors.

 

 

OK, thank you a lot, but is it going to give me this option to unlock a specific door of the building using SPACE with the HOLD SPACE action? I hope you know UNDERDOGS campaign and I want to do it the exact same way.

Share this post


Link to post
Share on other sites

You can adapt it for specific door(s) if needed.

- First of all, this script works for any locked building. That mean on don't nee to loop the code if you know which building you're aiming for.

- Second: say you want to act on door 3 only, just ad a condition like here:

 

 0 = [] spawn { while {true} do { _houses = ((nearestObjects [player, ["house"], 50]) select {isnil {_x getVariable "passedHouse"}}); if (count _houses > 0) then { _house = _houses #0; _house setVariable ["passedHouse",true]; [_house, "Lockpick 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','_select_door']; _intersects = ([cursorObject, 'VIEW'] intersect [ASLToATL eyepos player, (screentoworld [0.5,0.5])]); _select_door = if (count _intersects > 0) then [{format ['%1_sound_source', (_intersects #0 #0)]},{''}]; if (_this distance _target < 15 &&  _select_door == 'door_3_sound_source']) then { MGI_select_door = _select_door; true } else {false}; }; true ", "true", {}, {}, { if (_target animationSourcePhase MGI_select_door == 0) then { _target animateSource [MGI_select_door,1] } else { _target animateSource [MGI_select_door, 0] } }, {}, [], 5, nil, false, false ] call BIS_fnc_holdActionAdd; }; sleep 0.5; }; };

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

You can adapt it for specific door(s) if needed.

- First of all, this script works for any locked building. That mean on don't nee to loop the code if you know which building you're aiming for.

- Second: say you want to act on door 3 only, just ad a condition like here:

 

 0 = [] spawn { while {true} do { _houses = ((nearestObjects [player, ["house"], 50]) select {isnil {_x getVariable "passedHouse"}}); if (count _houses > 0) then { _house = _houses #0; _house setVariable ["passedHouse",true]; [_house, "Lockpick 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','_select_door']; _intersects = ([cursorObject, 'VIEW'] intersect [ASLToATL eyepos player, (screentoworld [0.5,0.5])]); _select_door = if (count _intersects > 0) then [{format ['%1_sound_source', (_intersects #0 #0)]},{''}]; if (_this distance _target < 15 &&  _select_door == 'door_3_sound_source']) then { MGI_select_door = _select_door; true } else {false}; }; true ", "true", {}, {}, { if (_target animationSourcePhase MGI_select_door == 0) then { _target animateSource [MGI_select_door,1] } else { _target animateSource [MGI_select_door, 0] } }, {}, [], 5, nil, false, false ] call BIS_fnc_holdActionAdd; }; sleep 0.5; }; };

Thanks a lot, dude, I really appreciate it. I will test it tomorrow after work. And I will share the results. 🙂

Share this post


Link to post
Share on other sites
On 2/3/2019 at 6:40 PM, pierremgi said:

OK, let's say you blocked doors of buildings in edito (via the edit terrain object module).

 

Place a trigger on map (anywhere, no area needed, not repeatable)

set it to true (instead of this) in condition field

 

copy/paste this code (tested but not really optimized), in on activation field:

 


0 = [] spawn {
  while {true} do {
    _houses = ((nearestObjects [player, ["house"], 50]) select {isnil {_x getVariable "passedHouse"}});
    if (count _houses > 0) then {
      _house = _houses #0;
      _house setVariable ["passedHouse",true];
      [_house, "Lockpick 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','_select_door'];
            _intersects = ([cursorObject, 'VIEW'] intersect [ASLToATL eyepos player, (screentoworld [0.5,0.5])]);
            _select_door = if (count _intersects > 0) then [{format ['%1_sound_source', (_intersects #0 #0)]},{''}];
            if (_this distance _target < 15) then {
              MGI_select_door = _select_door;
              true
            } else {false};
          };
          true
        ",
        "true",
        {},
        {},
        {
          if (_target animationSourcePhase MGI_select_door == 0) then {
            _target animateSource [MGI_select_door,1]
          } else {
          _target animateSource [MGI_select_door, 0]
          }
        },
        {},
        [],
        5,
        nil,
        false,
        false
      ] call BIS_fnc_holdActionAdd;
    };
    sleep 0.5;
  };
};

 

Should work to unlock/relock the doors.

 

 

Hey! I know it has been a long time, but the holdaction still remains after unlocking the doors, how can I solve this?

  • Like 1

Share this post


Link to post
Share on other sites
On 3/27/2020 at 2:26 PM, TheRobberPanda said:

Hey! I know it has been a long time, but the holdaction still remains after unlocking the doors, how can I solve this?

I can check my version and see my test mission and if it doesn't, give me a mail or something to share it with you. 🙂

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

×