Jump to content
ChlckenWlng

Can you break a window of a building with a trigger?

Recommended Posts

So what I want to do is when a player walks into a trigger the window of the building breaks

Share this post


Link to post
Share on other sites

In preview, escape to debug console when you point at the building. In 1 of the 4 watch lines, write getAllHitPointsDamage cursorObject (cursorObject must be the building you point at).

Copy paste in clipboard the result and see all the points (glasses here) you can break.

Read BIKI how to use the setHit command. In debug console, try to break the glass you want by code.

When you are OK with the result, add a trigger on your building, write a condition like: bob inArea thisTrigger or something else working.

in on act field: (nearestTerrainObjects [thisTrigger,["house"],10] #0) setHit [....,1];

fill .... by the string of the glass you want to break.

 

Share this post


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

In preview, escape to debug console when you point at the building. In 1 of the 4 watch lines, write getAllHitPointsDamage cursorObject (cursorObject must be the building you point at).

Copy paste in clipboard the result and see all the points (glasses here) you can break.

Read BIKI how to use the setHit command. In debug console, try to break the glass you want by code.

When you are OK with the result, add a trigger on your building, write a condition like: bob inArea thisTrigger or something else working.

in on act field: (nearestTerrainObjects [thisTrigger,["house"],10] #0) setHit [....,1]; 

fill .... by the string of the glass you want to break.

 

I dont know what I am doing wrong: (nearestTerrainObjects [thisTrigger,["House","Building"],10] #0) setHit ["glass_1", 1, true]; I just cant fix it

Share this post


Link to post
Share on other sites

Is your trigger within 10 m from the center of your building ? (In 3D) If not, enlarge to 15 or 20 m
Verify the nearestTerrainObjects [thisTrigger,["House","Building"],10] returns at least one building. (name the trigger and in console watch line, replace thisTrigger by the trigger's name)

Be sure you apply setHit on an existing "hit selection name" (2st array in getAllHitPointsDamage's array)

  • Like 1
  • Thanks 1

Share this post


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

Is your trigger within 10 m from the center of your building ? (In 3D) If not, enlarge to 15 or 20 m
Verify the nearestTerrainObjects [thisTrigger,["House","Building"],10] returns at least one building. (name the trigger and in console watch line, replace thisTrigger by the trigger's name)

Be sure you apply setHit on an existing "hit selection name" (2st array in getAllHitPointsDamage's array)

okay worked thanks

 

  • Like 2

Share this post


Link to post
Share on other sites
On 12/5/2019 at 5:53 AM, ChlckenWlng said:

okay worked thanks

Glad you solved it.  Please post your final solution so we all benefit.  🙂

Share this post


Link to post
Share on other sites

Heres some code (not mine) that does has player smash windows:

 

[] spawn {_myNearestEnemy = player findNearestEnemy player;
private _window_pos_arr = [];
private _house = nearestObject [player , "House"];
private _hitPoints = "isClass _x" configClasses (configFile >> "CfgVehicles" >> (typeOf _house) >> "HitPoints");
private _brokenwindows = 0;
private _playerweaponpos = [getPosATL player select 0, getPosATL player select 1, (getPosATL player select 2) + 1.2];
private _rifle = primaryWeapon player;
private _pistol = handgunWeapon player;
private _weapon = currentWeapon player;
 
 
{
    private _cfg_entry = _x;
    private _armor = getNumber (_cfg_entry >> "armor");
 if (_weapon == "" || (animationState player == "Acts_Executioner_Forehand" || animationState player == "Acts_Miller_Knockout" || player getVariable ["ACE_isUnconscious", false] || player getVariable ["ace_captives_isHandcuffed", false])) exitWith{};
    if (_armor < 0.5) then {
        private _brokenGlass = (_cfg_entry >> "DestructionEffects") select 0;
        private _selection_name = getText (_brokenGlass >> "position");
        private _model_pos = _house selectionPosition _selection_name;
        private _world_pos = _house modelToWorld _model_pos;
        _window_pos_arr pushBack _world_pos;
  private _playerdist = _playerweaponpos distance _world_pos;
   
  if !(animationState player == "Acts_Executioner_Forehand" || animationState player == "Acts_Miller_Knockout" || player getVariable ["ACE_isUnconscious", false] || player getVariable ["ace_captives_isHandcuffed", false]) then {
   
   if !(_weapon == _rifle || _weapon == _pistol ) exitWith{};
    
    if (stance player == "STAND" && _playerdist < 1.75 && alive player) then {
     private _hitpointname = (configName _cfg_entry);  
     private _anim = "Acts_Executioner_Forehand";
     private _animspeed = 1.7;
     private _recoverspeed = 0.7;
     if (_house getHitPointDamage _hitpointname < 1) then {
      if (_weapon == _rifle) then {
       _anim = "Acts_Miller_Knockout";
       _animspeed = 1;
       _recoverspeed = 1.3;
      };
      player setAnimSpeedCoef 2;
      [player, _anim] remoteExec ["playMove", 0];
      sleep _animspeed;
      [_house,[_hitPointName, 1]] remoteExec["setHitPointDamage",0,true];
      _sound = format ["A3\Sounds_F\arsenal\sfx\bullet_hits\glass_0%1.wss", (floor random 8) + 1];  
      playSound3D [_sound, player, false, getPosASL player, 3, 1, 30];
       
      sleep _recoverspeed;
      player setAnimSpeedCoef 1;
      [player, ""] remoteExec ["switchMove", 0];
      _brokenwindows = 1;
     };
    };
 
     };
   
  ///  
  if (_brokenwindows > 0) exitWith{};
};
 if (_brokenwindows > 0) exitWith{};
} forEach _hitPoints;
_myNearestEnemy  reveal [player, 1.5];
};

Original Code Window Breaker by Axebeard. He's given permission to vandalize, eroticize or do whatever you want with it. The FindNearestenemy./RevealEnemy stuff I added just to get a  reaction from nearby enemies.

  • Like 2

Share this post


Link to post
Share on other sites
On 12/7/2019 at 6:58 AM, froggyluv said:

Heres some code (not mine) that does has player smash windows:

 


[] spawn {_myNearestEnemy = player findNearestEnemy player;
private _window_pos_arr = [];
private _house = nearestObject [player , "House"];
private _hitPoints = "isClass _x" configClasses (configFile >> "CfgVehicles" >> (typeOf _house) >> "HitPoints");
private _brokenwindows = 0;
private _playerweaponpos = [getPosATL player select 0, getPosATL player select 1, (getPosATL player select 2) + 1.2];
private _rifle = primaryWeapon player;
private _pistol = handgunWeapon player;
private _weapon = currentWeapon player;
 
 
{
    private _cfg_entry = _x;
    private _armor = getNumber (_cfg_entry >> "armor");
 if (_weapon == "" || (animationState player == "Acts_Executioner_Forehand" || animationState player == "Acts_Miller_Knockout" || player getVariable ["ACE_isUnconscious", false] || player getVariable ["ace_captives_isHandcuffed", false])) exitWith{};
    if (_armor < 0.5) then {
        private _brokenGlass = (_cfg_entry >> "DestructionEffects") select 0;
        private _selection_name = getText (_brokenGlass >> "position");
        private _model_pos = _house selectionPosition _selection_name;
        private _world_pos = _house modelToWorld _model_pos;
        _window_pos_arr pushBack _world_pos;
  private _playerdist = _playerweaponpos distance _world_pos;
   
  if !(animationState player == "Acts_Executioner_Forehand" || animationState player == "Acts_Miller_Knockout" || player getVariable ["ACE_isUnconscious", false] || player getVariable ["ace_captives_isHandcuffed", false]) then {
   
   if !(_weapon == _rifle || _weapon == _pistol ) exitWith{};
    
    if (stance player == "STAND" && _playerdist < 1.75 && alive player) then {
     private _hitpointname = (configName _cfg_entry);  
     private _anim = "Acts_Executioner_Forehand";
     private _animspeed = 1.7;
     private _recoverspeed = 0.7;
     if (_house getHitPointDamage _hitpointname < 1) then {
      if (_weapon == _rifle) then {
       _anim = "Acts_Miller_Knockout";
       _animspeed = 1;
       _recoverspeed = 1.3;
      };
      player setAnimSpeedCoef 2;
      [player, _anim] remoteExec ["playMove", 0];
      sleep _animspeed;
      [_house,[_hitPointName, 1]] remoteExec["setHitPointDamage",0,true];
      _sound = format ["A3\Sounds_F\arsenal\sfx\bullet_hits\glass_0%1.wss", (floor random 8) + 1];  
      playSound3D [_sound, player, false, getPosASL player, 3, 1, 30];
       
      sleep _recoverspeed;
      player setAnimSpeedCoef 1;
      [player, ""] remoteExec ["switchMove", 0];
      _brokenwindows = 1;
     };
    };
 
     };
   
  ///  
  if (_brokenwindows > 0) exitWith{};
};
 if (_brokenwindows > 0) exitWith{};
} forEach _hitPoints;
_myNearestEnemy  reveal [player, 1.5];
};

Оригинальный Code Window Breaker от Axebeard. Ему дано разрешение вандализировать, эротизировать или делать с ним все, что угодно. Материал FindNearestenemy./RevealEnemy я добавил только для того, чтобы получить реакцию от ближайших врагов.

Как им пользоваться? через действие?

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

×