Cluster bomb script

ArmA editing, missions, modeling, textures, terrains

Moderators: Snake Man, Lone Wolf

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04, 11:01:01 PM
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-04-01, 01:24:03 PM

Do you think 5 bomblet groups of 40 bomblets, with each group being separated by a .3 sleep would work?

Code for the bottom half of the script - might be rough....

Code: Select all

code removed, see next post
Check the edits...
Sic Semper tyrannosauro.

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04, 11:01:01 PM
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-04-03, 02:28:33 AM

Sorry, SM, I know you don't like double posts, but I feel bad about the code in the last post. I was in a hurry, and didn't proof it before I posted it.

This should be better.

Code: Select all

       _numbomblets = 40;
       _factor = 1;
       // plane altitude modifier
       _altMod = (_planeAlt - 50) / 5;
       
	for [{_b = 1}, {_b <= 5}, {_b = _b + 1}] do
		{
		for [{_g = 1}, {_g <= _numbomblets}, {_g = _g + 1}] do
			{
	          // Position the bomblet
	          _rndOffset = (random 180) - 90;
	          _dir = _bDir + _rndOffset;

	          if ((_dir > 360) || (_dir < 0)) then
	          {
	             _dir = abs (abs (_dir) - 360);
	          };

	          _dist = (random 20) + _altMod;
	          _newposx = (_bpos select 0) + sin (_dir) * _dist;
	          _newposy = (_bpos select 1) + cos (_dir) * _dist;

	          // Create the bomblet
	          _bomblet = _bt createVehicleLocal [_newposx, _newposy, _height];

	          if (VTE_debug) then
	          {
	             player sideChat format["%1 bomblet created at %2.",_bomblet, getPos _bomblet];
	          };
	          // Randomise the z velocity
	          _nvz = _bvz * ((60 + random 80) / 100);

	          // Re-speed the bomb
	          _factor = 2 * _b;
            _bomblet setVelocity [_bvx * _factor, _bvy * _factor, _nvz];

			};
		  //stutter preventing sleep
		sleep .3;
		// advance  the spot to help elongate the dispersion
		 _dist = 10;		// tweakable
		 _newposx = (_bpos select 0) + sin (_bDir) * _dist;
		 _newposy = (_bpos select 1) + cos (_bDir) * _dist;
		 _bpos = [_newposx, _newposy, 0];
		};
    }
   else
   {
      hint "You must be above 50m to drop this ordnance.";
   };
What I changed from what you posted last:
- changed the loop to more what I'm used to - the "for/next" style loop
- replaced the main loop with 2 loops
-- the "big" loop repeats 5 times
-- the small loop creates 40 bomblets - this is less than the 50 that didn't seem to cause any problems
- the pause (now, correctly) happens for .3 second AFTER the creation of each group of 40 bomblets
- after each bomblet creation loop, the bomb position is advanced 10m (that can be tweaked)
-- this should create a longer, more oval dispersion, more realistic
- total of 200 bomblets

The loops also allowed some variability to the vectors so that the ones towards the end have more random "forward" velocity than the ones at the beginning. My thought is that this will create some overlap between the groups, but the ones at the end may have more stragglers. I'm not sure this is the best implementation, though, so there is still some tweaking that may need to be done.
Sic Semper tyrannosauro.

Snake Man
Commander-In-Chief
Posts: 8556
Joined: 2000-07-31, 10:01:01 PM
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC

Re: Cluster bomb script

Post by Snake Man » 2009-04-03, 02:43:59 AM

Hey thanks for the latest update, I'll give it a go "tomorrow" night as I'm just wrapping my full days of editing (dead tired). But sounds really good if we can phase out the 220 bomblets now within reasonable time period (2-3sec max?) to get that massive effect.

Feedback after testing :)
PMC since 1984

Editing knowledge, visit PMC Editing Wiki
Addon manuals, visit PMC addons/mods online manuals
View our videos in PMC Youtube channel.

PMC Tactical forum Advanced Search is power.

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04, 11:01:01 PM
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-04-08, 04:24:29 PM

Hey SnakeMan,

I was looking through the biki and had a couple ideas for changing the velocity and number of the bomblets.

Changed to 6 loops of 37 bomblets for a total of 222. Also, changed the new x/y vector velocity formula to make the directions independently random.

Code for bottom half of the script.

Code: Select all

       _numbomblets = 37;
       _factor = 1;
       // plane altitude modifier
       _altMod = (_planeAlt - 50) / 5;

// 6 loops of 37 bombs = 222 bombs
   for [{_b = 1}, {_b <= 6}, {_b = _b + 1}] do
      {
      for [{_g = 1}, {_g <= _numbomblets}, {_g = _g + 1}] do
         {
             // Position the bomblet
             _rndOffset = (random 180) - 90;
             _dir = _bDir + _rndOffset;

             if ((_dir > 360) || (_dir < 0)) then
             {
                _dir = abs (abs (_dir) - 360);
             };

             _dist = (random 20) + _altMod;
             _newposx = (_bpos select 0) + sin (_dir) * _dist;
             _newposy = (_bpos select 1) + cos (_dir) * _dist;

             // Create the bomblet
             _bomblet = _bt createVehicleLocal [_newposx, _newposy, _height];

             if (VTE_debug) then
             {
                player sideChat format["%1 bomblet created at %2.",_bomblet, getPos _bomblet];
             };
             // Randomise the z velocity
             _nvz = _bvz * ((60 + random 80) / 100);

             // Re-speed the bomb
//             _factor = 2 + _b;
			 _fRandX = random 3;
			 _fRandY = random 3;
            _bomblet setVelocity [_bvx * _fRandX, _bvy * _fRandY, _nvz];

         };
        //stutter preventing sleep
      sleep .3;
      // advance  the spot to help elongate the dispersion
       _dist = 10;      // tweakable
       _newposx = (_bpos select 0) + sin (_bDir) * _dist;
       _newposy = (_bpos select 1) + cos (_bDir) * _dist;
       _bpos = [_newposx, _newposy, 0];
      };
    }
   else
   {
      hint "You must be above 50m to drop this ordnance.";
   };
Sic Semper tyrannosauro.

User avatar
Vigilante
Recruit
Posts: 33
Joined: 2008-12-03, 11:41:58 AM
Gaming Interests: Armed Assault (ArmA)
Editing Interests: All, I (try) to edit everything.
Contact:

Re: Cluster bomb script

Post by Vigilante » 2009-04-08, 04:46:36 PM

right, for loops, like i posted some posts ago... how is your performance with those staggered ones?

this is the one which creates flawlessly... only with the explosions it staggers a bit... but thats the problem with explosions in general, even though those submunitions drop like a bombcarpet i.e. in succession, albeit very quick one.

Code: Select all

...
_CBU = _CBU2;
_value = 201;
_done = false;
_i = 0;
_expulPos = (getPosASL _CBU);

		for [{_i = 0}, {_i < _value}, {_i = _i + 1}] do
		{
//		hint format ["%1 \n %2 \n %3 \n %4",_CBU,_i,_subSelectionPos0,_subSelectionPos1];
			_subSelectionPos0 = format ["subm_pos_CEB_%1",_i];

			_sub = "VIG_BLU97_CEB_retarded" createVehicle [0,0,(450 + ((random 200)+(random 200)))];
			_sub setVectorDirAndUp [vectorDir _CBU,vectorUp _CBU];
			_sub setPosASL [((_expulPos select 0)-((random 6)-(random 6))),((_expulPos select 1)-((random 6)-(random 6))),((_expulPos select 2)-((random 6)-(random 6)))];
//			_sub setVelocity (velocity _CBU);
//			_sub setPos (_CBU selectionPosition _subSelectionPos);

//		hint format ["%1 \n %2 \n %3",_CBU,_i,_subSelectionPos0];

			_i = _i + 1;
			_subSelectionPos1 = format ["subm_pos_CEB_%1",_i];

			_sub2 = "VIG_BLU97_CEB_retarded" createVehicle [0,0,(450 + ((random 200)+(random 200)))];
			_sub2 setVectorDirAndUp [vectorDir _CBU,vectorUp _CBU];
			_sub2 setPosASL [((_expulPos select 0)-((random 6)-(random 6))),((_expulPos select 1)-((random 6)-(random 6))),((_expulPos select 2)-((random 6)-(random 6)))];
//			_sub2 setVelocity (velocity _CBU);
//			_sub2 setPos (_CBU selectionPosition _subSelectionPos);

/*
if ((_value > 50) && (!_done)) then 
{
	[ _sub, 165, 15, 2, 100, 100, 1, 1, 0, 0 ] exec "\gig_camera\freecamera.sqs";
	_done = true;
};
*/

_dropscr0 = [_CBU,_sub] spawn VIG_TMD_DropSubmunitions;
_dropscr1 = [_CBU,_sub2] spawn VIG_TMD_DropSubmunitions;


		hint format ["%1 \n %2 \n %3 \n %4",_CBU,_i,_subSelectionPos0,_subSelectionPos1];

		sleep 0.01;
		};
...
a.k.a. PhilippRauch
Check out my Addons Wiki @ http://vigilante-systems.webs.com (WIP but already contains lots of infos)

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04, 11:01:01 PM
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-04-08, 05:02:07 PM

Interesting....

With the i = i+ 1 in the parameters of the loop, you also have it in the body of the loop? Doesn't that effectively halve the number of times it loops?

Edit: ah - I see now, you're doing things in pairs, basically. Got it.
Sic Semper tyrannosauro.

User avatar
Vigilante
Recruit
Posts: 33
Joined: 2008-12-03, 11:41:58 AM
Gaming Interests: Armed Assault (ArmA)
Editing Interests: All, I (try) to edit everything.
Contact:

Re: Cluster bomb script

Post by Vigilante » 2009-05-09, 08:21:19 AM

Hi there... one more thing i came along while doing some ICM for a project... the largest part of stagger seems to stem from sounds!! ... I never thought about that, but while i was creating these ICM Effects (only particles, no ammoclass used!) i realized, when i only let every other bomblet 'explode' with sound, the stagger wont happen, even with 88 of them exploding in about 1sec!
When all played their sounds, it was staggering almost always at some point. Maybe even play just one big sound for all sublets going off.. But then you have the problem of different soundvalues, depending on where you die inside the cluster.. ;) ...
If i would be able to calculate the middle or the area of bomblets hitting i would also be able to place a sound at the middle position or the corners, but right now i am not able to come up with a formula to calculate neither middlePos nor area from impact position of those bomblets. Also using ammoclass itself seems to be some source of staggering since each explosion calls some other stuff from inside the gameengine... i would avoid that by doing FX only visually (local particles) and doing the damage by some other means, be it triggerlist or nearObjects calls or so.
a.k.a. PhilippRauch
Check out my Addons Wiki @ http://vigilante-systems.webs.com (WIP but already contains lots of infos)

Snake Man
Commander-In-Chief
Posts: 8556
Joined: 2000-07-31, 10:01:01 PM
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC

Re: Cluster bomb script

Post by Snake Man » 2009-05-09, 09:15:18 AM

That is really interesting. Maybe we can have ten mute bombs for one sounding dummy in the script, I guess its easy to track how many bomblets we have created and every time 10 has incremented, add one with sound.

You guys think that might work?
PMC since 1984

Editing knowledge, visit PMC Editing Wiki
Addon manuals, visit PMC addons/mods online manuals
View our videos in PMC Youtube channel.

PMC Tactical forum Advanced Search is power.

User avatar
Vigilante
Recruit
Posts: 33
Joined: 2008-12-03, 11:41:58 AM
Gaming Interests: Armed Assault (ArmA)
Editing Interests: All, I (try) to edit everything.
Contact:

Re: Cluster bomb script

Post by Vigilante » 2009-05-09, 09:29:43 AM

Code: Select all

_explosionSound = "VIG_Sounds_Explosion_Small_Muffled";
// here comes the sound effect

if ((count _subMunList) % 2 == 0) then
{
	[_position,_explosionSound,550,3] spawn VIG_TmpSoundSource;
};
Its using every 2nd or so sublet, it works, doing it for every 10th or so would be ok maybe, but then the soundeffect should be adjusted to include the now 'missing' explosion sounds... ie incorporate a couple more explosion sounds into that soundfile via soundeditor. Otherwise it will sound 'holy' aehmm i mean, you will see explosions but hear no sound somehow correlating to it.. the kind of 'rumbling' sound is kinda missing, but could be adjusted with above said to be more enjoyable.
a.k.a. PhilippRauch
Check out my Addons Wiki @ http://vigilante-systems.webs.com (WIP but already contains lots of infos)

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04, 11:01:01 PM
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-05-09, 01:09:56 PM

Yeah, that'd be pretty easy.

Let me know what you want. :)

Edit:
Yeah, use what Vigilante did, and use _g mod 2 (or 3 or whatever number) at the bottom of the _g loop, and use _newpositionx/_newpositiony/0 for the source of the sound and it should be pretty close.
Sic Semper tyrannosauro.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest