Warning: include(/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php): failed to open stream: No such file or directory in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Warning: include(): Failed opening '/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Notice: Undefined index: OFPEC in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152
    Home   Help Login Register  

Author Topic: Claymore  (Read 6981 times)

0 Members and 1 Guest are viewing this topic.

Offline Goullou

  • Members
  • *
Claymore
« on: 21 Nov 2007, 06:58:05 »
Hi all,

I'm working on different things to similulate traps, tripwires by script.
To make the final explosion i use to create ammo projectiles found here on the viki http://community.bistudio.com/wiki/ArmA:_Weapons.

In order to simulate a claymore mine i'm trying to create a round of 700 bullets from the position of the mine.
I have a loop somewhere in my script which do that:
Quote
while {_n<700} do
   {
   _shrpnl = "B_9x19_Ball" createvehicle [position _visualobject select 0,position _visualobject select 1,0.30+(random 1)];//This to make a random height
   _shrpnl setDir (((direction _visualobject)-30)+(round random 60));//this to make a random projection in a 60° angle
   _n=_n+1;
   //sleep 0.005;
   };
This makes all the bullets going verticaly to the ground. Then i've tried to apply a vectordir to each bullet but nothing happened.
I loose my hair trying to handle those bullets. I need help !!
Si vis pacem, para bellum.

Offline Loyalguard

  • Former Staff
  • ****
Re: Claymore
« Reply #1 on: 21 Nov 2007, 10:48:44 »
I am far from having any substantive knowledge on the topic but I believe you need to use the setVelocity command in lieu of or in addition to setDir.  I am not sure how to implement it in your script though.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Claymore
« Reply #2 on: 21 Nov 2007, 12:16:51 »
You are quite right about setVelocity, since script created objects always start being stationary. Although just a stylistic thing, I've converted the loop to use for since that is more elegant in this situation:
Code: (untested, but should be fine) [Select]
_speed = 1200; // 1200 ms.
for "_n" from 1 to 700 do
{
    _shrpnl = "B_9x19_Ball" createvehicle [position _visualobject select 0,position _visualobject select 1,0.30+(random 1)];//This to make a random height
    _dir = (((direction _visualobject)-30)+(round random 60));//this to make a random projection in a 60° angle
    _shrpnl setDir _dir;
    _shrpnl setVelocity [(sin _dir) * _speed, (cos _dir) * _speed, 0];
};

I'm pretty sure that 700 projectiles at 1200ms is overkill in the game, even if it is realistic (based on what Wikipedia lies tells us), and would be laggy on a low-end machine. This is due to both the use of lots of createVehicles and that every projectile would be tracked until it hit something. I think you could get away with a lot less fragments, since a one or two bullets will kill anybody; you don't need to shred them!
« Last Edit: 21 Nov 2007, 12:36:37 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Claymore
« Reply #3 on: 21 Nov 2007, 15:27:27 »
You need to change setDir by SetVectorDir and use also the Z component to create a reliable projection of the bullets. You may use a 60 degree horizontal arc and a 30 degree vertical arc. So, if you are just quite close to the Claymore when it detonates, you will have only your legs damaged, if not, you may suffer also direct hits in the head.

Offline Goullou

  • Members
  • *
Re: Claymore
« Reply #4 on: 22 Nov 2007, 10:33:01 »
Thanks a lot Spooner, it's works.  :good:

I'll stay with a simulation using only 200 bullets because more makes lag. I've changed the random horizontal projection to fixed distribution degree/degree. The only think i kept randomly is the height. I reduced the speed of the bullets because fast bullets are noisy and the total sound makes lag too. Anyway for the player there's no visual difference. Otherwise the original shrapnels are steel balls and not so efficient beyond 100m. Using M9 bullets at 1200m/s makes it always lethal beyond 500m.

You need to change setDir by SetVectorDir and use also the Z component to create a reliable projection of the bullets. You may use a 60 degree horizontal arc and a 30 degree vertical arc. So, if you are just quite close to the Claymore when it detonates, you will have only your legs damaged, if not, you may suffer also direct hits in the head.

Good idea but I don't really know how to set a right value to SetVectorDir and as i told above there's no visual difference for the player for that too.

You said "if you are just quite close to the Claymore...", in reality this mine is a true shit. When the mine explode you have 700 balls leaving forward in an angle of 60°, you have something around 350gr of C4 localy exploding and you have the rest of the bottom support and feeth (800gr) flying away backward. If you think you can survive "just quite close" of it ... :D

In my script i create a handgrenade to simultate the local explosion so if someone stays close he die.

Thanks to all for you help !

Si vis pacem, para bellum.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Claymore
« Reply #5 on: 22 Nov 2007, 12:41:32 »
What Mandoble says makes a lot of sense, once I considered how claymores actually work, rather than just answering your direct question. The claymore blast pattern is +-30 degrees horizontally and 0 to 2.4 degrees vertically, based purely on the statement "The spherical steel balls are projected in a 60 degree fan-shaped pattern that is two meters high (6 ft, 8 in) and 50 meters (165 ft) wide at a range of 50 meters (165 ft)."@Wikipedia). I know you weren't too bothered about the shape, but I thought that there could be situations where this could matter (for example, using vertical angles further diffuses the fragments making it much less deadly at longer ranges. Also, it means that people who are slightly elevated can be hit at the longer ranges). Maths might come in useful for someone else, even if you don't use it, so I thought I'd give it a go.

To correctly simulate the vertical as well as horizontal element of the blast pattern, use something like:
Code: [Select]
_speed = 320; // 320 ms, the same as subsonic ammo.
_pos = [position _visualobject select 0, position _visualobject select 1, 0.1];
_minDir = (direction _visualobject) - 30;
for "_n" from 1 to 200 do
{
    _shrpnl = "B_9x19_Ball" createvehicle _pos;
    _hAngle = _minDir + (random 60); // +-30 degrees from straight ahead
    _vAngle = random 2.4; // 0 to 2.4 degrees up from hoizontal
    _velocity = [(sin _hAngle) * (cos _vAngle) * _speed, (cos _hAngle) * (cos _vAngle) * _speed, (sin _vAngle) * _speed];
    _shrpnl setVectorDir _velocity;
    _shrpnl setVelocity _velocity;
};

(I also removed the rounding on the "random 60", since it isn't necessary, and took out some repeated calculations to speed up the loop).

I'm not sure that you necessarily have to set the vectorDir, since I don't think ArmA really cares about it for ammo flying at "invisible" speeds (and I'm pretty sure it doesn't update this during flight for normal weapon ammo). Removing the setVectorDir could, therefore, save a little extra bandwidth and CPU, though you might want to experiment with that.

EDIT: Changed the speed of the shrapnel to that of subsonic ammo.
« Last Edit: 25 Sep 2008, 19:34:49 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Goullou

  • Members
  • *
Re: Claymore
« Reply #6 on: 26 Nov 2007, 17:18:46 »
Ok Spooner, that's working as well. May be the loop begins to be heavy for low end CPU. I can't know it, mine is fast.
Now there's another issue which is going to make it more complicated.
When the Claymore is placed standing on a flat area the explosion is correct and all shrapnels fly normaly. When on the side of a hill (anywhere having a ground angle) this makes the mine keep on working horizontaly. The good thing would be to change the axes orientation.
Si vis pacem, para bellum.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Claymore
« Reply #7 on: 26 Nov 2007, 19:31:44 »
The best way to test something if you have a fast PC is to do it with more than you intend to use. Thus, if you can happily run with 1000 fragments, then a lower end PC should cope with 200 (you need to judge this by...guessing ;P). The thing is though, that creating and manipulating lots of global ammo objects could use a lot of bandwidth too, so you need to test it in MP if you intend to use it there as well as SP.

Oops! I hadn't considered slopes, but I go more daft the more I am made to think about maths! To sort this out, all we need to do is work out the angle the claymore is facing and then add the vertical spread onto that:
Code: [Select]
_speed = 320; // 320 ms, the same as subsonic ammo.
_pos = [position _visualobject select 0, position _visualobject select 1, 0.1];
_minDir = (direction _visualobject) - 30;
_claymoreVAngle = asin ((vectorDir _visualobject) select 2);
for "_n" from 1 to 200 do
{
    _shrpnl = "B_9x19_Ball" createvehicle _pos;
    _hAngle = _minDir + (random 60); // +-30 degrees from straight ahead
    _vAngle = _claymoreVAngle + (random 2.4); // 0 to 2.4 degrees up from the direction that the claymore is facing.
    _velocity = [(sin _hAngle) * (cos _vAngle) * _speed, (cos _hAngle) * (cos _vAngle) * _speed, (sin _vAngle) * _speed];
    _shrpnl setVectorDir _velocity;
    _shrpnl setVelocity _velocity;
};
« Last Edit: 25 Sep 2008, 19:34:20 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Turk

  • Members
  • *
Re: Claymore
« Reply #8 on: 25 Sep 2008, 17:45:28 »
Hi,

I like the idea of this script and tried Sponner's code form his last post in this topic in a sqf script called Claymore, but with no results at all, not even any errors!

Not sure if I'm missing something here, I've placed an object in the map (in this case a barrel for testing) and called it visualobject, I've then added a trigger to execute the script but nothing happens, Any idea what I'm doing wrong?

Regards,

Turk. 


Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Claymore
« Reply #9 on: 25 Sep 2008, 19:29:27 »
The code that I gave originally wasn't a full script, so try this:
Code: (claymore.sqf) [Select]
// Create an appropriate small object in the editor and give it an appropriate facing (azimuth),
// naming it "claymore1".
// Add a ANY PRESENT ONCE trigger on the "dangerous" side with an OnAct
// (e.g. for 200 balls fired with 60 degrees horiztonal and 2.4 degrees vertical spread):
//   [claymore1, 200, 60, 2.4] execVM "claymore.sqf";

private ["_claymore", "_height", "_pos", "_minDir", "_claymoreVAngle",
"_shrapnel", "_hAngle", "_vAngle", "_velocity"];

_claymore = _this select 0; // Object acting as claymore. The balls will shoot out of this.
_numBalls = _this select 1; // Number of balls to generate.
_horSpread = _this select 2; // Total angle of spread (_horSpread / 2 on each side of centre).
_vertSpread = _this select 3; // Total angle of spread up from horizontal.

_speed = 320; // 320 ms, the same as subsonic ammo.
_height = (((boundingBox _claymore) select 1) select 2) + 0.1;
_pos = _claymore modelToWorld [0, 0, _height];
_minDir = (direction _claymore) - (_horSpread / 2);
_claymoreVAngle = asin ((vectorDir _claymore) select 2);

for "_i" from 1 to _numBalls do
{
    _shrapnel = "B_9x19_Ball" createVehicle _pos;

    _hAngle = _minDir + (random _horSpread);
    _vAngle = _claymoreVAngle + (random _vertSpread);
    _velocity = [(sin _hAngle) * (cos _vAngle) * _speed, (cos _hAngle) * (cos _vAngle) * _speed, (sin _vAngle) * _speed];

    _shrapnel setVelocity _velocity;
};

EDIT: Pingu has released a full claymore addon if you'd prefer to use that.
« Last Edit: 25 Sep 2008, 19:40:23 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Turk

  • Members
  • *
Re: Claymore
« Reply #10 on: 25 Sep 2008, 20:24:43 »
Hi,

Thanks for that Spooner its works a treat and looks great, I've reduced the the amount of bullets due to a short spike lag, which can be expected at 200, and changed the ammo type to B_762x54_Ball so you see green tracer, plus added explosion code to the script.

Code: [Select]
_bang = "G_40mm_HE" createVehicle _pos;
Again, Thanks for taking the time to do that for me, its much appreciated.

Turk

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Claymore
« Reply #11 on: 25 Sep 2008, 22:07:14 »
Yeah 200 balls is fine on my machine in SP, but probably not on other people's and definitely not on anyone's in MP ;P You could possibly reduce the lag by creating the balls over a few frames (at an altitude of 10,000 m so they don't bother anyone ;P) and then moving them to the explosion position. Probably more fiddling about than you need though, since I'm sure 50 (or even less) would be plenty in most circumstances anyway.

It is nice to put the claymore near a wall and watch all the balls hit in a big rectangle. Good for judging just how big the blast really is. Tracers is another way of making it more obvious; hadn't thought of that!

Ah yes, a little explosion would help make it look and sound a lot better. Not that I've seen a real one...but...
« Last Edit: 25 Sep 2008, 22:13:10 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline USM-CPT.Dyson

  • Members
  • *
Re: Claymore
« Reply #12 on: 26 Sep 2008, 08:22:29 »
Can't wait to try this out! Any suggestions on wagt default object could be used to make it look good? Also what about the tripwire? Can a tiny tiny wire object be created. As well a wire to simulate radio detonation?
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Claymore
« Reply #13 on: 26 Sep 2008, 14:32:49 »
You can't create a wire object (without making your own 3d object, but if you want to go as far as using addons, just use Pingu's claymore!). The best you could probably do would be to create a line of particles, I suppose.  The most appropriate vanilla ArmA object is probably the portable radio (class: "Radio"), based on its size and shape.

Quote from: USM-CPT.Dyson
As well a wire to simulate radio detonation?
You don't need a wire for radio detonation. Were you asking about radio detonation? If so, you'd just need to give the player an action that ran "claymore.sqf", rather than using a trigger. If you were talking about having a wire from the player to the device, then you'd have an action, but only let it work when the player is within a certain distance to the claymore object. Again, the wire could be simulated with a row of particles.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline USM-CPT.Dyson

  • Members
  • *
Re: Claymore
« Reply #14 on: 26 Sep 2008, 18:49:46 »
Yeah I guess it would be pretty hardcore to simulate the Radio detonated claymore. Cause then you have to add an action to cover it up anyway, then make is so it acts like a wire attached to something (would be cool though) :dunno:
« Last Edit: 26 Sep 2008, 19:00:14 by USM-CPT.Dyson »
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/