Home   Help Search Login Register  

Author Topic: Claymore  (Read 3864 times)

0 Members and 1 Guest are viewing this topic.

Offline Turk

  • Members
  • *
Re: Claymore
« Reply #15 on: 28 Sep 2008, 17:15:15 »
Hello,

I've played around with this code Sponner provided to make the required effect/s more customisable from within the game editor by making alterations to the trigger rather then altering the code within the script itself, this will allow me and others to use multiple triggers with variable effects using just the one script.

I've added the ability to the trigger to set the speed of the projectiles, the height at which the projectiles start at, the type of ammo used and whether to add an explosion at the point at which the projectiles start, I also wanted to add a True/False statement within the trigger itself for the explosion effect. So if true then create explosion effect at start of projectiles, or if false then ignore.

This is where I'm stuck, I've looked at other scripts to see how if statements works and although I get the general idea I have no clue how to get the script to recognize that there is, or should be, a true/false statement within the trigger itself.

Here's what I've altered so far, it all works fine except for the True/False bit which I have no idea how to go about it.

Code: [Select]
// Create an appropriate small object in the editor and give it an appropriate facing (azimuth),
// naming it "A-NameHere".
// Add a ANY PRESENT ONCE trigger on the "dangerous" side with an OnAct
//
// e.g. for 200 projectiles fired with 60 degrees horiztonal and 2.4 degrees vertical spread
// at a speed of 320ms using B_762x54_Ball ammo class name starting at a height of 10 meters
// above the object with an explsion effect (At start height of projectiles) "True/False" and
// Ammo class name of explosion effect "M_TOW_AT"
//
// Null = [A-NameHere, 200, 60, 2.4, 320, "B_762x54_Ball", 10, "True", "M_TOW_AT"] execVM "claymore.sqf";

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

_claymore = _this select 0; // Object acting as claymore. The projectiles will shoot out of this.
_projectiles = _this select 1; // Number of projectiles 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 = _this select 4; // Speed of projectile.(e.g 320 ms, the same as subsonic ammo.)
_AmmoType = _this select 5; // Ammo class name.
_height = _this select 6; // Height of projectile from object.
_explosion = _this select 7; //To create an explosion at object TRUE/FALSE.
_explosionType = _this select 8; //Type of ammo class explosion effect.




_height = (((boundingBox _claymore) select 1) select 2)+ _height;
_pos = _claymore modelToWorld [0, 0, _height];
_minDir = (direction _claymore) - (_horSpread / 2);
_claymoreVAngle = asin ((vectorDir _claymore) select 2);



//==================================================
// Only want this part to play if line 22 is (true from the trigger) (_explosion = _this select 7;)
 
 
_bang = "Bomb" createVehicle _pos;
_bang setPos _pos;
_bang1 = _explosionType createVehicle _pos;
sleep 0.1;
deleteVehicle _bang1;
deletevehicle _bang;


//==================================================
// If line 22 is false then skip above code and play from here.



for "_i" from 1 to _projectiles do

{
   
    _shrapnel = _AmmoType 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;
};


Regards,

Turk. 
« Last Edit: 28 Sep 2008, 17:22:55 by Turk »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Claymore
« Reply #16 on: 29 Sep 2008, 01:30:58 »
You don't need to delete something that is going to explode anyway. Not sure at all why you are creating a "bomb", which is a large unexploded round, since it won't automatically explode (though it is the only explosive that explodes on request when you "_bomb setDamage 1" it).
Code: [Select]
_explosionType = _this select 7; // Type of ammo class explosion effect; "" for no explosion effect.

...

if (_explosionType != "") then
{
    _explosionType createVehicle _pos;
};
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Turk

  • Members
  • *
Re: Claymore
« Reply #17 on: 30 Sep 2008, 02:21:14 »
Thanks Spooner that did the trick, I must have tried everything except that :)

The scripts is working perfectly for me now, here's the finished product along with a demo mission to show some of the effects that can be created using this script.

Once again thanks.

Turk.

Code: [Select]
//==================================================================
// FireForEffect. V1.00b
//==================================================================
//
// Thanks to Spooner who practaly wrote this script for me,I just added a few more options
// to the trigger so it can be customsied to create many different effects from within
// the editor.
// ============
// Turk
//=============
// Description:
// This script started out as a Claymore effect, but now with the added customization to
// triggers within the editor you can create many different effects i.e Claymore/Airburst/Splash/
// Artie/Carpetbombing/Smoke/flares etc etc. The script is now called "FireForEffect.sqf"
// as the name is more appropriate... A demo map is included with this script.
//
// Create an appropriate small object in the editor and give it an appropriate facing (azimuth),
// naming it "A-NameHere".
//
// e.g. for 200 projectiles fired with 60 degrees horiztonal and 2.4 degrees vertical spread
// at a speed of 320ms using B_762x54_Ball ammo class name starting at a height of 1 meter
// above the object with an explsion effect "M_TOW_AT". /"" for no explosion effect
//
// Null = [A-NameHere, 200, 60, 2.4, 320, "B_762x54_Ball", 1, "M_TOW_AT"] execVM "FireForEffect.sqf";
//
//==================================================================

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

//==================================================================

_claymore = _this select 0; // Object acting as claymore. The projectiles will shoot out of this.
_projectiles = _this select 1; // Number of projectiles 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 = _this select 4; // Speed of projectile.(e.g 320 ms, the same as subsonic ammo.)
_AmmoType = _this select 5; // Ammo class name.
_height = _this select 6; // Height of projectile from object.
_explosionType = _this select 7; //Type of ammo class explosion.


//==================================================================

_height = (((boundingBox _claymore) select 1) select 2)+ _height;
_pos = _claymore modelToWorld [0, 0, _height];
_minDir = (direction _claymore) - (_horSpread / 2);
_claymoreVAngle = asin ((vectorDir _claymore) select 2);

//==================================================================

 if (_explosionType != "") then
{
_bang = "Bomb" createVehicle _pos;
_bang setPos _pos;
_bang1 = _explosionType createVehicle _pos;
sleep 0.1;
deleteVehicle _bang1;
deletevehicle _bang;
};

//==================================================================


for "_i" from 1 to _projectiles do

{
   
    _shrapnel = _AmmoType 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;
};


Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Claymore
« Reply #18 on: 30 Sep 2008, 02:53:06 »
I'll clarify what I said in my last post:
Code: [Select]
if (_explosionType != "") then
{
    _bang = "Bomb" createVehicle _pos; // Creates an object that does nothing then is deleted after 0.1s.
    _bang setPos _pos; // Moves an object that has no purpose.
    _bang1 = _explosionType createVehicle _pos; // Creates the actual explosive.
    sleep 0.1; // Sleeps for no reason.
    deleteVehicle _bang1; // Don't need to delete an object that has already exploded by now.
    deletevehicle _bang; // Don't need to delete an object that has no effect.
};

Should be just:
Code: [Select]
if (_explosionType != "") then
{
    _explosionType createVehicle _pos;
};

Incidentally, you don't really need to repeat the code in its entirely in the post if you are attaching it anyway.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Turk

  • Members
  • *
Re: Claymore
« Reply #19 on: 30 Sep 2008, 16:05:17 »
I don't get it Spooner! if I use this code...

Code: [Select]
if (_explosionType != "") then
{
    _explosionType createVehicle _pos;
};

Then the object that's created for the explosion just falls to the ground then explodes, or if its missile type ammo then it just shoots off. Using this code...

Code: [Select]
if (_explosionType != "") then
{
_bang = "Bomb" createVehicle _pos;
_bang setPos _pos;
_bang1 = _explosionType createVehicle _pos;
sleep 0.1;
deleteVehicle _bang1;
deletevehicle _bang;
};

The object explodes where I want it to explode, so for an air burst I can have a "G_40mm_HE" or a "M_TOW_AT" explode 10 meters above the ground with 200 projectiles raining down on to its target. The only reason for _explosionType is to vary the effect a little. I did try the "bomb" setdamage 1 approach, but that explosion and sound didn't always suit the desired effect.

Regards,

Turk. 

 

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Claymore
« Reply #20 on: 30 Sep 2008, 19:54:24 »
Sorry, I was a bit off there. In my version, I just want the claymore to go off near the ground (_pos was close enough to the ground that you don't notice the delay of dropping the explosive onto the ground). I thought you were creating the bomb object in order to set it off (but not doing so, so I couldn't understand why you'd made it). I had experimented a great deal with trying to collide objects in order to set off explosives when I was making SPON VBIED, but in the end, as Mandoble explained, setting damage on a bomb object is the only way to predictably get an explosion in the air.

Still, the method you use, by creating a bomb to "trigger" the explosive is a bit random, since sometimes the bomb will be destroyed by the explosive, producing a much larger explosion than intended (well, assuming the explosion you want is smaller than the bomb's explosion). If you have such a large explosion, the true claymore effect gets a bit lost, since unless you have a large number of projectiles, the effective range of the projectiles is not much more than the blast radius of the bomb. Perhaps you could try with a different collision object; one that doesn't explode when the explosive goes off?
« Last Edit: 30 Sep 2008, 20:01:43 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Turk

  • Members
  • *
Re: Claymore
« Reply #21 on: 01 Oct 2008, 04:17:16 »
Hi its me again :)

Never gave it a thought that the "Bomb" itself might go off on the odd occasion, so I needed to find something small enough as not to be noticed, but large enough to collide with the ammo type. In the end I found that the Radio with the modelToWorld command worked 100% of the time, well at least it did for me in testing so i'll settle with that.

So for anyone who's interested and has read this far and would like to use the script with some degree of reliability you should replace part of the code with this...

Code: [Select]
//==================================================================

 if (_explosionType != "") then
{
_bang = "radio" createVehicle _pos;
_bang setPos _pos;
_bang1 = _explosionType createVehicle (_bang modelToWorld [0,0,0]);
sleep 0.1;
deleteVehicle _bang1;
deletevehicle _bang;
};

//==================================================================

Ok Spooner that's it, I promise not to bother you again on this topic, I'm sure by now you're sick and tired of this claymore thing :)

I'm somewhat reluctant to submit this script to the beta testing section in case someone asks an awkward question, I'm sure you've guessed by now my knowledge of scripting is copy/paste and mess.   

Cheers.

Turk.