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.
// 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.