Jump to content
TheRobberPanda

How do I script a door to be opened with brute force?

Recommended Posts

As the title says. I want a door to be locked in my mission, but since its a stealth mission I want the player to have to force the door lock instead of opening it with an explosion, for let's say 20 seconds, until it opens. How do I achieve this?

Share this post


Link to post
Share on other sites
18 hours ago, RCA3 said:

Thanks for that! The script works well, but the holdaction isnt removed when I finish the action, any way to solve this? Thanks again!

Share this post


Link to post
Share on other sites
7 minutes ago, beno_83au said:

holdActionAdd returns the action ID, so use that with https://community.bistudio.com/wiki/BIS_fnc_holdActionRemove

Thanks! But I solved it myself, I got lucky when setting one of the values to true and it apparently solved the issue. Thanks anyways!
 

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, "Force door open", "\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.1,0.1])]);
            _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,
        true,
        false
      ] call BIS_fnc_holdActionAdd;
    };
    sleep 0.5;
  };
};

Only thing is that the action is shown from too farm away, if you know how to solve that, that would be fantastic!
EDIT: solved it again!, now I would only need to add sound, how do I do it?

  • Like 1

Share this post


Link to post
Share on other sites

Ahh yes, I remember that from using them a little while ago. Good spot.

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

×