Home   Help Search Login Register  

Author Topic: Need help with my sqf ied script  (Read 2809 times)

0 Members and 1 Guest are viewing this topic.

Offline zouloum

  • Members
  • *
Need help with my sqf ied script
« on: 14 Jul 2011, 05:15:36 »
Hi, I have some problems with a sqf script that im making.
The problem, is that when I select the location to be a marker,
nothing happens and when I set the location to be a tank for example,
it blows up even if the ammo type used was "B_30mmA10_AP"

here is a download link http://dl.dropbox.com/u/5921391/MyIED.sqf

and here is the code
Code: [Select]
/* IED Script
   By Zouloum
   V0.1 July 13, 2011


   This script will create an explosion of a
   selected size on any object when called.
   The arguments are [objectName, explosionPower]
   Explosion Power will be 1 of 8 choices:

   Tiny - Will injure the legs of the player if standing.
  It will kill the player if crouching or prone.
   
   VerySmall - Will kill anybody in a 5 meter radius.
               It is as effective as a frag grenade.

   Small - Will disable some unarmored vehicles
           without killing the occupants.

   Medium - Will disable any unarmored and
    damage lightly armored vehicles.

   Large - Will destroy unarmored vehicles, disable
           lightly armored vehicles and damage heavily
           armored vehicles.

   Huge - Will usualy destroy anything.

   
   Insane - Will destroy anything instantly


   Smoke - Doesn't do any damage, just pops big
     amount a smoke.


   Example : nul = [thisMarker, "Insane"] execVM "MyIED.sqf";

   or : nul = [theCar, "Small"] execVM "MyIED.sqf";


*/



_target = _this select 0;
_explosion = _this select 1;

//Coordinates of the IED
_iedPos = GetPos _target;
_iedPosX = _iedPos select 0;
_iedPosY = _iedPos select 1;
_iedPosZ = _iedPos select 2;



//The main part
if(_explosion == "Tiny") then {
_ammoType = "B_30mmA10_AP";
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_target setDamage 1;
};


if(_explosion == "VerySmall") then {
_ammoType = "grenade";
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_target setDamage 1;
};


if(_explosion == "Small") then {
_ammoType = "R_57mm_HE";
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_target setDamage 1;
};


if(_explosion == "Medium") then {
_ammoType = "M_Sidewinder_AA_F35";
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_target setDamage 1;
};


if(_explosion == "Large") then {
_ammoType = "Sh_125_HE";
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_target setDamage 1;
};


if(_explosion == "Huge") then {
_ammoType = "Bo_GBU12_LGB";
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_target setDamage 1;
};


if(_explosion == "Insane") then {
_ammoType = "Bo_GBU12_LGB";
_ammoType createVehicle[_iedPosX + 15, _iedPosY + 15, iedPosZ];
_ammoType createVehicle[_iedPosX + 15, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY + 15, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX - 15, _iedPosY -15, iedPosZ];
_ammoType createVehicle[_iedPosX -15, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY -15, iedPosZ];
_target setDamage 1;
};


if(_explosion == "Smoke") then {
_ammoType = "SmokeLauncherAmmo";
for [{_i = 0},{_i <= 3},{_i = _i+1}] do {
_ammoType createVehicle[_iedPosX + 15, _iedPosY + 15, iedPosZ];
_ammoType createVehicle[_iedPosX + 15, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY + 15, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX - 15, _iedPosY -15, iedPosZ];
_ammoType createVehicle[_iedPosX -15, _iedPosY, iedPosZ];
_ammoType createVehicle[_iedPosX, _iedPosY -15, iedPosZ];
_target setDamage 1;
sleep 30;
};
};

Offline i0n0s

  • Moderator
  • *****
Re: Need help with my sqf ied script
« Reply #1 on: 14 Jul 2011, 06:19:51 »
You should use getMarkerPos for marker.
And take a look at the switch statement.

Offline mr_book.PXS.Pvt

  • Members
  • *
Re: Need help with my sqf ied script
« Reply #2 on: 14 Jul 2011, 08:28:45 »
Hi zouloum,
regarding "it blows up even if the ammo type used was so-and-so": you may want to remove all those "_target setdamage 1"-lines. Because whatever ammo is used, even if it's just smoke, your target will blow up.

And i0n0s is quite right, check http://community.bistudio.com/wiki/switch_do to clean your script up a bit.

For example:
Code: [Select]
_target = _this select 0;
_explosion = _this select 1;

_iedPos = GetPos _target;
_iedPosX = _iedPos select 0;
_iedPosY = _iedPos select 1;
_iedPosZ = _iedPos select 2;

switch (_explosion) do
{
 case "Tiny":
 {
  _ammoType = "B_30mmA10_AP";
  _ammoType createVehicle [_iedPosX, _iedPosY, iedPosZ];
  _ammoType createVehicle [_iedPosX, _iedPosY, iedPosZ];
 };

 case "VerySmall":
 {
  _ammoType = "grenade";
  _ammoType createVehicle [_iedPosX, _iedPosY, iedPosZ];
 };

 default {};
};
Good day,
mr_book