Jump to content
gc8

Making door breach script

Recommended Posts

Hi

I'm working on my explosive door breach script, which I know some existing ones are around but I want to code my own , for my needs.. 

 

What I haven't been able to figure is how to detect if player places claymore on ground? I have used "Fired" EH but currently don't know how to figure if it's claymore and not handgrenade or bullet

player addEventHandler ["Fired", 
{
 params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
}];

 

Another thing I'm trying to figure is how to get the angle of a door? I can get position but not angle.

 

The reason for this is because I want to place the explosive on the door

 

thx for any help!

Share this post


Link to post
Share on other sites

If you get the door angle, tell me. When I did my script I couldn't work that one out so I was on the work-around train. But just copyToClipboard all your params in the EH when it fires and see what comes up for claymores. Good to remember for other Fired EH too.

Share this post


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

But just copyToClipboard all your params in the EH when it fires and see what comes up for claymores. Good to remember for other Fired EH too.

 

Yeah I did study the params but problem is finding what different attributes does the claymore have vs handgrenade. I don't want to do list of "supported" explosives but rather have script to detect that on the fly - mod compatibility in mind

Share this post


Link to post
Share on other sites

Ahhh, initially I went with vanilla explosive charges, regardless of mods. But in later edits I added in an init param to allow for a any modded explosive to be used. Maybe that could help you? It was pretty fiddly though, good luck!

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, gc8 said:

Hi

I'm working on my explosive door breach script, which I know some existing ones are around but I want to code my own , for my needs.. 

 

What I haven't been able to figure is how to detect if player places claymore on ground? I have used "Fired" EH but currently don't know how to figure if it's claymore and not handgrenade or bullet


player addEventHandler ["Fired", 
{
 params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
}];

 

Another thing I'm trying to figure is how to get the angle of a door? I can get position but not angle.

 

The reason for this is because I want to place the explosive on the door

 

thx for any help!

 

 

See if this does what you want.

 

Quote


  _handle = _x addEventHandler["take", { 
    params ["_plyr","","_charge"]; 
    if ( toLowerANSI _charge in ["claymoredirectionalmine_remote_mag"]) then {  
      _charge_to_place = allmines select (count allmines -1);  
      [_plyr,_charge_to_place,_thisEventHandler] spawn { 
       params ["_plyr","_charge","_eh"]; 
        hint "Charge Placed";
      }; 
    }; 
  }] 
} forEach thisList;
 

 

 

I don't know how to get the direction of the door.

 

This wouldn't be perfect, but assuming that the player is facing the door he wants to place the charge on, have you tried,  getDir player,  then rotate 180?

Share this post


Link to post
Share on other sites

@stburr91 Thanks for your thought. I can right now place/move the charge to center of the door but right angle would be nice to make it look better when the charge is on the door

  • Like 1

Share this post


Link to post
Share on other sites
10 minutes ago, gc8 said:

@stburr91 Thanks for your thought. I can right now place/move the charge to center of the door but right angle would be nice to make it look better when the charge is on the door

 

 

Yeah, it seems that I had the same issue with placing the charge in the proper orientation on the door when I was trying it for a mission I was doing.

 

The take eventhandler I posted above should detect the player placing the claymore mine.

 

Let us know when you get your script up, and running. 

  • Like 1

Share this post


Link to post
Share on other sites

Ok I got some kind of solution for the door angle, it's not perfect but in my tests worked on takistan building doors.

 

Here's the code:

 

private _pos = _bldg selectionPosition format ["Door_%1", _doorIndex];
private _posTrigger = _bldg selectionPosition format ["Door_%1_trigger", _doorIndex];
private _posAxis = _bldg selectionPosition format ["Door_%1_axis", _doorIndex];


_doorAngle = _posTrigger getdir _posAxis; // Get door angle but it varies depeding on which side the door handle is


_closestDist = 100000;
_doorFrontPos = [];
{

// Create 2D vector (engine solution for this?)
_distFromDoor = 0.05;
_tryAngle = _doorAngle + _x;
_x = sin _tryAngle * _distFromDoor;
_y = cos _tryAngle * _distFromDoor;

_vec = [_x,_y,0];

_checkPos = _posTrigger vectorAdd _vec;

_checkPos = _bldg modelToWorld _checkPos;
_dist = _checkPos distance2D player;

if(_dist < _closestDist) then
{
_closestDist = _dist;
_doorFrontPos = _checkPos;
};
} foreach [90,-90];


_chargepos = _doorFrontPos;

_projectile setposAtl _chargepos;

 

 

What it does it checks two different angles from the surface of the door to player and selects the closer one. This way player should always place the charge on the right side of the door

 

 

This script could set the projectile (charge) direction properly facing on the door but I don't know how to get the vector math for that

Edited by gc8
more comments
  • Like 1

Share this post


Link to post
Share on other sites
On 3/28/2020 at 7:19 PM, gc8 said:

This script could set the projectile (charge) direction properly facing on the door but I don't know how to get the vector math for that

 

This may help you @gc8:

 

This guy's code absolutely saved me when I made my explosive breaching. He's been quiet for a few years now, but he did offer up the code in one of his replies. There's an Armaholic link in the description. You'll probably want to look at fnc_get_angle.sqf and fnc_intersect_pos3D.sqf.

Share this post


Link to post
Share on other sites

@beno_83au thanks but I still don't understand the math :) get_angle is no problem I use that a lot but the explosive vector direction on the door is what I haven't yet been able to figure out (should probable use setVectorDirandUp)

Share this post


Link to post
Share on other sites

Lol, I didn't try to wrap my head around it either. I used what he had. His maths is far better than mine. Although I was motivated to work it out and re-write it myself, just never got there.

  • Like 1

Share this post


Link to post
Share on other sites

found the math for my question. Now all I need is the list of explosives that can be planted on a door. if anyone knows how to obtain this list please let me know. thx :)

Share this post


Link to post
Share on other sites

Think I've found solution to the bomb list. Checking that "mineTrigger" variable in ammo cfg is "RemoteTrigger" seems to give the correct remote detonated bombs (Tried with vanilla , CUP , unsung & RHS)

Edited by gc8
& unsung
  • Like 1

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

×