Cluster bomb script

ArmA editing, missions, modeling, textures, terrains

Moderators: Lone Wolf, Snake Man

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

Cluster bomb script

Post by Snake Man » 2009-03-20 16:01:58

This is our problematic cluster bomb script.

How we run it is that first we execute firedEH.sqf called script whenever jet aircraft fires anything, this script looks like this:

Code: Select all

private [ "_thing", "_tmp" ];

_thing = _this select 1;

if (VTE_debug) then
{
	player sideChat format["firedEH.sqf executed, _thing: %1", _thing];
};

if(_thing == "VTE_CBU52Rail") then
{
	_tmp = _this execVM "\VTE_config\scripts\vehicle\A1\cbu_cluster.sqf";
};
Then comes the cbu_cluster.sqf script:

Code: Select all

/*

	VTE cluster bomb script
	originally from unknown author (possibly Footmunch).

*/
private [
	"_plane","_weapon","_ammoname","_b","_bt","_z","_bpos","_bombvel",
	"_bvx", "_bvy", "_bvz", "_height", "_numbomblets", "_factor",
	"_newposx", "_newposy", "_bomblet", "_ang", "_nvx", "_nvy", "_nvz"
];

// Init our local vars
_plane = _this select 0;
_weapon = _this select 1;
_ammoname = _this select 4;

// Get the cluster bomb object
_b = nearestObject[_plane, _ammoname];

// Decide on proper bomblet type in a MP environment
_bt = ["VTE_CBU25BombletSpoof", "VTE_CBU25Bomblet"] select (local _b);

// Cluster bombs release at 50 metres
_z = (getPos _b) select 2;
waitUntil
{
	_z = (getPos _b) select 2;
	(_z < 50) || !(alive _b);
};

// Get the bomb velocity and position
_bpos = getPos _b;
_bombvel = velocity _b;
_bvx = _bombvel select 0;
_bvy = _bombvel select 1;
_bvz = _bombvel select 2;

// Remove the original bomb
if (local _b) then
{
	deleteVehicle _b;
};

// Bump the zpos upwards
_height = (_bpos select 2);

/*
REALISM vs GAMEPLAY:
How many bomblets are we releasing. realistically its 220 in one bomb case,
but thats too much for game engine to handle with script, or can the script
be tweaked not to cause huge stutter when the bombs impact?

CHANGE:
Added it now for 50, huge difference on technicality of the explosions, however
ingame visual/kill effect changes are almost none...

BUG:
There is bug howere, right now the bombles are created like "north east" from
the impact point, causing very unnatural explosion area. The area should be just
big circle around the disperal of bomblets point, possibly having the bomblets fly
towards the flight path of the aircraft.
*/
_numbomblets = 50;
_factor = 1;

while {_numbomblets > 0} do
{
	// Position the bomblet
	_newposx = (_bpos select 0) + (5 * (_numbomblets / 12));
	_newposy = (_bpos select 1) + (5 * (_numbomblets / 12));

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

	// Spread the bomblets into an arc randomly
	_ang = - 5 + random 10;

	if (_ang < 0) then
	{
		_ang = _ang + 360;
	};

	if (_ang > 360) then
	{
		_ang = _ang - 360;
	};

	_nvx = (_bvx * cos(_ang)) + (_bvy * sin(_ang));
	_nvy = - (_bvx * sin(_ang)) + (_bvy * cos(_ang));

	// Randomise the z velocity
	_nvz = _bvz * ((60 + random 80) / 100);

	// Re-speed the bomb
	_bomblet setVelocity [_nvx * _factor, _nvy * _factor, _nvz];

	// Next please
	_numbomblets = _numbomblets -1;
};
The "VTE_CBU25BombletSpoof" is a spoof ammo that doesn't do any damage or anything, its for MP desync reasons.

Okay so whats the problem? Well that script for starters creates the bomblets into too narrow (small) area, also it unnaturally creates them on sort of like north-east direction and not in a big (long?) round area.

Anyways, if anyone can improve this script to create round explosion area with optimum number of bomblets for kills and performance, it would be much appreciated.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-20 16:25:11

Well, with a quick glance, I think the NE issue is because of this:

Code: Select all

   // Position the bomblet
   _newposx = (_bpos select 0) + (5 * (_numbomblets / 12));
   _newposy = (_bpos select 1) + (5 * (_numbomblets / 12));
The starting position is only going to be the original position + North and + East.

I suggest something like this:

Code: Select all

   // Position the bomblet
   _dir = random 360;
   _dist = random 25;
   _newposx = (_bpos select 0) + sin (_dir) * _dist;
   _newposy = (_bpos select 1) + cos (_dir) * _dist;
That'll get a random direction (0-359), and a random distance up to 25m from the center point. That'll create a big circle with a 25m radius (50m diameter).

I'm thinking that cluster bombs are usually in more of a rectangular shape along the flight path of the bomb? I *think* I can work something like that up. Will the _plane be facing the direction you want the bombs to spread?
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-20 16:43:23

This is really great, you come from long history of Falcon 4 editing so you should have some first hand knowledge about cluster bomb operations :)

Okay.

Yes the _plane should be the vehicle name of the aircraft which fires the weapon, at the moment of firing... well the bomb of course drops down quite bit depending on altitude, but the direction is always the same, right?

Anyways, we should use our (your) knowledge of F4 cluster bombs or bomb falling physics anyway to build the bomblet spreading as real as we can get... but even a simple working, no stutter causing nice round coverage of bomblets would be great.

In any case, I think the whole point of cluster bombs is that "just drop them in the general area of expected enemy troops and the bomb takes care of the rest..." for example FAS.org CBU-87 page says this: The footprint for the CBU-87 is approximatel 200 meters by 400 meters., damn man, that's big area, drop that in your average ArmA 2cm x 2cm terrains and you kill everyone in the mission hehehe (ok bad joking).

The weapon we are modeling in VTE is the CBU-52, these are the pages for it: Globalsecurity - CBU-52 and FAS.org - CBU-52. But looking at wikipedias list of bombs in vietnam war there is no mention of 52's hehe, HRR. :)

Aaanyways, lets just fix the script, no matter what the bomblets models are :)
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-20 16:52:17

hehe

Would be cool to getting them working in a more realistic way. I don't think it'll be too difficult. Give the 50 number a try and see if the performance is acceptable. You can always adjust that up until there's a performance hit (and work in a random element, too) and adjust the area, too. ;)

Give me a bit and I think I can work up a way to bias the area in a rectangle along the direction of travel. :thumbs: (I think.) ;)

Edit: one note, I notice the script has the "normal" position array of [x,y,z]. However, when dealing with vectors and some other model-related things, the array is [x,z,y]... but since the script is consistent, I don't know if it really makes a big difference. If you see any funky results, it may be worth switching the z and y variables.

Edit2:
Here's a quick change towards making it more rectangular. It replaces the top of the "while" loop. Basically, it uses the starting point as the point closest to the near edge of the rectangle (near to the position of the plane that dropped the bomb). Then it randomly offsets the bomblet to the side of that point, out to 25m. Right now, it would be an arc, centered on that point. I think the key will be to use that factor variable to adjust the x/y (or z, depending on which position format you're used to) velocity to spread the bomblets out along their trajectory.

(May need to hint format the plane direction to make sure it is getting a valid value.)

Codishness:

Code: Select all

_bDir = getDir _plane;
while {_numbomblets > 0} do
{

   // Position the bomblet
   _rndOffset = (random 180) - 90;
   _dir = _bDir + _rndOffset;
   
		if ((_dir > 360) || (_dir < 0)) then
		{
		_dir = abs (abs (_dir) - 360);
		};
   
   _dist = random 25;
   _newposx = (_bpos select 0) + sin (_dir) * _dist;
   _newposy = (_bpos select 1) + cos (_dir) * _dist;
   
   // Create the bomblet
Edit2:

Ok, you might ALSO try this at the bottom where it sets the vectors.

Code: Select all

_factor = random 2;
   // Re-speed the bomb
   _bomblet setVelocity [_nvx * _factor, _nvy * _factor, _nvz];
I *think* that will either slow down or speed up the horizontal speed of the bomblet, making the overall shape more rectangular, in the direction the bomb is traveling. You may need to increase the number of bomblets, though, to get decent coverage.

Will try to check the thread over the weekend.
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-20 18:14:14

Ooh good stuff, thanks. Will try to implement them tonight.

Another thing came to my mind, how about setting the radius of the spread out bomblets relative to the altitude the bomb was dropped. I know that its not realistic that way, go really high and you kill everyone... but at least you could arcade way simulate the burst altitude setting we have in F4. Was it usually like 1500feet or something? Thats damn 457m or did I calculate correctly? Anyways, its high, perhaps the realism values aren't that usable in ArmA world/terrain.

But in anycase, perhaps if we somehow adjust the random radius of the bomblets by the firing altitude, but with some sort of limits like if you drop it on 25m NOE then it just bursts right away (or actually drops to ground) and if you go really high like above 500m (which is high in ArmA world) then it would just cut off at hum dunno in 200m radius or something like this. We would need to find nice balance.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-20 18:26:47

Yeah, I see what you're saying. Once you test this and get it working, we could probably work up a conditional, so that there's a minimum drop height of, say... 50m. Less than that, it doesn't drop, but displays a launch failure warning. (Oh, BTW, we could also probably script a random launch failure.) ;)

Right now, the burst altitude is set at ~50m. That seems about right for ArmA, IMHO.

But, how about something like:
Get altitude of plane (maybe even use ASL?) and subtract 50 (for the minimum).
Divide that number by 5? (Can tweak that.) And increase the radius by that number.

So, drop at 100m, subtract 50 = 50 / 5 = 10. Radius for bomblets would be 35 (diameter 70), which would be a 40% increase?

Drop at 200m, subract 50 = 150 / 5 = 30. Radius = 55, about double the area. That would be a greater area, but fewer likely kills. Kinda like IRL. ;)

I think the big thing at this point is to figure out how many bomblets you can drop without too much of a performance hit. You know - to spread out the hit, it might be worth a quick, random-length delay. Like sleep (random .5) or something.

Edit:

Code: Select all

   // Next please
   _numbomblets = _numbomblets -1;
  sleep (random .5);
};
Might actually be a kinda cool effect to see them ripple like that. Half a second is probably too long of a delay, though, now that I think of it. More like (random .3) or something.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-20 19:29:34

The burst altitude setting seems good to me.

However the time delay... isn't that going into MP unfriendly territory, or can you tweak it so it produces identical behavior on all clients?

Actually I like the idea, even if its like 30sec or so, I mean who knows if this happens in real life too... like most of the bombs explode on impact, but some don't... then the "dust seddles" perhaps vegetation falls/blows by wind or whatever... which causes the unexploded bomblets to go off. Imagine checking out village after cluster bomb strike and then all of the sudden you get few more explosions at random places :)

(actually just today I read from some google hit that they are still today, cleaning out cluster bomblets in Vietnam which didn't detonate on impact).

Anyways I think we are leaping way too far from the original concept of fixing the NE aligning "bombtrail", I don't want to bite more than we (you) can chew :D
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-20 19:43:08

hehe

Agreed (about the chewing part). :)

Plus, to have a delay like that, you'd actually need to spawn individual scripts for each bomblet - which might rapidly get CPU intensive. What that delay is that I did there is an absolute delay on the iterations. First bomblet gets created, delay of up to .5 sec; second gets created, same random delay up to .5 sec; etc. That's why I think it might be too long of a possible delay.

BUT, once we work out the dispersion, there are some other possibilities. ;) One that immediately comes to mind is a random chance of some unexploded ordinance, pick out a few random points in the dispersion area, spawn a few scripts with those points passed to them, and wait a random amount of time, then do something like a grenade explosion on those points.....

Lotsa options. :D
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-20 19:57:53

Time to model more accurate bomblet then, so we can have the unexploded ordnance.

Goddamn imagine walking around the battlefield and suddenly stumble into unexploded cluster bomb munition :shock:
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-20 20:06:24

hehe

That'd be some hurt!

What was that mine-laying bomb? :D Have an a/c that drops a bomb and based on the parameters, sets up a minefield! :) I think that'd be possible in ArmA. Easy to grab a dozen or so points within an area, set up small triggers - like a radius of 1 or 2. Or hell, maybe even just put the mines there - I don't know which is the bigger performance hit.

But yeah - let's get the munition we already have working correctly, first! 8-)
Sic Semper tyrannosauro.

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-23 12:16:22

Any update? :)

One thing I thought of over the weekend was that the

Code: Select all

_bDir = getDir _plane;
Should really be up at the top where you initialize other variables. Otherwise, if the pilot turns off the bearing of the bombing run right away, the direction won't represent the angle of the bomb anymore.
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-23 12:40:31

Ah sorry, I implemented your stuff in, there is no errors in that regard...

Just to recap and bring you up to speed, here is the latest script I put together from your suggestions:

Code: Select all

/*

	VTE cluster bomb script
	originally from unknown author (possibly Footmunch).

*/
private [
	"_plane","_weapon","_ammoname","_b","_bt","_z","_bpos","_bombvel",
	"_bvx", "_bvy", "_bvz", "_height", "_numbomblets", "_factor",
	"_newposx", "_newposy", "_bomblet", "_ang", "_nvx", "_nvy", "_nvz",
	"_bDir","_rndOffset"
];

// Init our local vars
_plane = _this select 0;
_weapon = _this select 1;
_ammoname = _this select 4;

if (VTE_debug) then
{
	player sideChat format["cbu_cluster.sqf: %1, %2, %3",_weapon,_ammoName,_plane];
	player sideChat "The scripts\weapons\cluster\cbu_cluster.sqf was executed!";
};

// Get the cluster bomb object
_b = nearestObject[_plane, _ammoname];

// Decide on proper bomblet type in a MP environment
_bt = ["VTE_CBU25BombletSpoof", "VTE_CBU25Bomblet"] select (local _b);

// Cluster bombs release at 50 metres
_z = (getPos _b) select 2;
waitUntil
{
	_z = (getPos _b) select 2;
	(_z < 50) || !(alive _b);
};

if (VTE_debug) then
{
	player sideChat format["%1 opened up at %2 altitude!",_bombObj,_zPos];
};

// Get the bomb velocity and position
_bpos = getPos _b;
_bombvel = velocity _b;
_bvx = _bombvel select 0;
_bvy = _bombvel select 1;
_bvz = _bombvel select 2;

// Remove the original bomb
if (local _b) then
{
	deleteVehicle _b;
};

// Bump the zpos upwards
_height = (_bpos select 2);

/*
REALISM vs GAMEPLAY:
How many bomblets are we releasing. realistically its 220 in one bomb case,
but thats too much for game engine to handle with script, or can the script
be tweaked not to cause huge stutter when the bombs impact?

CHANGE:
Added it now for 50, huge difference on technicality of the explosions, however
ingame visual/kill effect changes are almost none...

BUG:
There is bug howere, right now the bombles are created like "north east" from
the impact point, causing very unnatural explosion area. The area should be just
big circle around the disperal of bomblets point, possibly having the bomblets fly
towards the flight path of the aircraft.
*/
_numbomblets = 50;
_factor = 1;

_bDir = getDir _plane;
while {_numbomblets > 0} do
{
/*
	// Position the bomblet
	_newposx = (_bpos select 0) + (5 * (_numbomblets / 12));
	_newposy = (_bpos select 1) + (5 * (_numbomblets / 12));
*/
	// Position the bomblet
	_rndOffset = (random 180) - 90;
	_dir = _bDir + _rndOffset;

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

	_dist = random 200;
	_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. _numBomblets: %3",_bomblet,getPos _bomblet,_numBomblets];
	};

	// Spread the bomblets into an arc randomly
	_ang = - 5 + random 10;

	if (_ang < 0) then
	{
		_ang = _ang + 360;
	};

	if (_ang > 360) then
	{
		_ang = _ang - 360;
	};

	_nvx = (_bvx * cos(_ang)) + (_bvy * sin(_ang));
	_nvy = - (_bvx * sin(_ang)) + (_bvy * cos(_ang));

	// Randomise the z velocity
	_nvz = _bvz * ((60 + random 80) / 100);

	// Re-speed the bomb
	_factor = random 2;
	_bomblet setVelocity [_nvx * _factor, _nvy * _factor, _nvz];

	// Next please
	_numbomblets = _numbomblets -1;
};
I'm very happy with the results on this script, it now works good enough for your average gameplay, everything else beyond this would be a bonus.

So where do we start with the bonus stuff? :)

BTW all the good stuff in this script (before T Rex updates) on top of the original one was made by Killswitch.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-23 13:25:33

hehe

Excellent.

First suggestion is to move that bDir = getDir _plane up to the top with the initialization stuff. That'll take care of a what-if scenario that someone might notice. :)

Second, are you happy with the "locked" number of bomblets at 50? Especially with the Vietnam era stuff, there was a significant number of duds. You could have a minimum of 50, then randomize another 20 or so.

Also, I've been thinking more about how they fire. The vids I've seen, it seems like the almost set off in a ripple - some go off at the trailing edge of the cluster then a WHOLE LOT go off in the middle, then some fire at the trailing edge. Honestly, I haven't thought that one all the way through yet to even have a clue as to how to make that happen. :D But, I think it should be do-able. The thing is, it would basically be for effect. I don't think it would have any gameplay value.

The unexploded ordinance thing would be pretty workable. It seems to me there would be 2 kinds: 1) the timer is just delayed - it will eventually explode on its own; and 2) it is almost booby-trapped and if something bumps into it, it goes off.

The first one is probably the easiest. Have an unexploded ordinance script, decide what you want the random range to be (up to 5? 10? 20? a percentage of the total number of bomblets?), then send the script the starting position of the bomb. The unexploded ordinance script would then use a timer (random with a minimum of 30 seconds, up to 5 mins? 10 mins?), and the same placement code (without the vectors) as the other script, and when the timer is done, spawn the bomblet, or a grenade or something. I'm not sure if the bomblet needs some height to explode. I could probably get that script done in not much time at all.

The second one is a bit harder, and may take some testing. It would basically be the same, except that instead of the timer, the unexploded ordinance script would create a very small trigger - like a couple meters, I think. It would be triggered by ANY and spawn the bomblet/grenade at that location when activated.

You could even have a mix of the two. First random decides how many unexploded bomblets there will be and starts the loop. Within the loop, an additional random (up to 1) and < .5 could spawn the timed version, and > .5 could spawn the trigger.

Also, looking back at the thread, the height-based dispersion area could be pretty workable, too. The main thing would be finding a "sweet spot" between the height and the area. This is also where some stress-testing of the number of bomblets could be useful. The smaller the area, the more concentrated the bomblets.

What would be your priority for the bonus things? :)

Edit:
Oh - any chance of a screenshot of the dispersion area? :) I just want to make sure there might not be some way to improve it. ;)
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-23 15:36:10

T_Rex wrote:First suggestion is to move that bDir = getDir _plane up to the top with the initialization stuff.
Moved.
Second, are you happy with the "locked" number of bomblets at 50?
It was just a quick trial to drop it down to a number that definitely works, I'm going to experimenting now rising the number back up. Hopefully perhaps 100 bomblets could be created without stutter (in my computer).
1) the timer is just delayed - it will eventually explode on its own; and 2) it is almost booby-trapped and if something bumps into it, it goes off.
In real life terms these would just mean that they didn't explode, then at some point they do for what ever reason, no reason at all or human intervention.

But there is also those cluster bombs which lay down some mines, right?
What would be your priority for the bonus things?
Definitely the coverage area by altitude.
Oh - any chance of a screenshot of the dispersion area?
Sure.

Image

Image

It seems to me that the bombs are created now into wide but not "deep" area, uhm, if now we can only rotate that circle along the axist of the flight path... it looks good :)
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-23 15:59:28

First priority - area coverage. Sir, yes sir! :)

Looking at those pics, yeah, that is a HUGE area. I'll take another look at the link between the random position and the vectors.

This may also be "cheating" but I may take the vectors out completely. The cluster bombs explode so close to the ground that I'm not sure they matter much, especially if I can bias the overall field in the direction of travel anyway.

Will see if I can get something testable for you soon. 8-)
Sic Semper tyrannosauro.

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-23 16:51:09

Ok.

Here's a quick and dirty attempt. First, I think part of the wide range is that the random for the distance was 200. That means an actual diameter of 400, since the bombs could be placed +/- 90 degrees from the "starting" point. :) But, that doesn't explain why it was elongated N/S or perpendicular to the fall line. (I think it is related to the vectors being in a different order than the position arrays, but that'll require some testing.)

Anyway, here's some code to test. It *should* create a very compact area of bombs, but it will be larger, the higher the plane is when it drops.

At 100m, the dispersion area will be a minimum of 20m + a random number up to an additional 20.

My goal is that once you have that area about where you want it, we can re-introduce the vectors to elongate it.

Also, it won't let the a/c drop at less than 50m. ;)

Code: Select all

/*

   VTE cluster bomb script
   originally from Killswitch.

   *****************************************
   TTD
   Dispersion area linked to height
Get altitude of plane (maybe even use ASL?) and subtract 50 (for the minimum).
Divide that number by 5? (Can tweak that.) And increase the radius by that number.

   
*/
private [
   "_plane","_weapon","_ammoname","_b","_bt","_z","_bpos","_bombvel",
   "_bvx", "_bvy", "_bvz", "_height", "_numbomblets", "_factor",
   "_newposx", "_newposy", "_bomblet", "_ang", "_nvx", "_nvy", "_nvz",
   "_bDir","_rndOffset", "_planePos", "_planeAlt", "_altMod"
];

// Init our local vars
_plane = _this select 0;
_weapon = _this select 1;
_ammoname = _this select 4;
_bDir = getDir _plane;
_planePos = getPos _plane;
_planeAlt = _planePos select 2;

if (_planeAlt > 49) then
{

	if (VTE_debug) then
	{
	   player sideChat format["cbu_cluster.sqf: %1, %2, %3",_weapon,_ammoName,_plane];
	   player sideChat "The scripts\weapons\cluster\cbu_cluster.sqf was executed!";
	};

	// Get the cluster bomb object
	_b = nearestObject[_plane, _ammoname];

	// Decide on proper bomblet type in a MP environment
	_bt = ["VTE_CBU25BombletSpoof", "VTE_CBU25Bomblet"] select (local _b);

	// Cluster bombs release at 50 metres
	_z = (getPos _b) select 2;
	waitUntil
	{
	   _z = (getPos _b) select 2;
	   (_z < 50) || !(alive _b);
	};

	if (VTE_debug) then
	{
	   player sideChat format["%1 opened up at %2 altitude!",_b,_z];
	};

	// Get the bomb velocity and position
	_bpos = getPos _b;
	_bombvel = velocity _b;
	_bvx = _bombvel select 0;
	_bvy = _bombvel select 1;
	_bvz = _bombvel select 2;

	// Remove the original bomb
	if (local _b) then
	{
	   deleteVehicle _b;
	};

	// Bump the zpos upwards
	_height = (_bpos select 2);

	/*
	REALISM vs GAMEPLAY:
	How many bomblets are we releasing. realistically its 220 in one bomb case,
	but thats too much for game engine to handle with script, or can the script
	be tweaked not to cause huge stutter when the bombs impact?

	CHANGE:
	Added it now for 50, huge difference on technicality of the explosions, however
	ingame visual/kill effect changes are almost none...

	BUG:
	There is bug howere, right now the bombles are created like "north east" from
	the impact point, causing very unnatural explosion area. The area should be just
	big circle around the disperal of bomblets point, possibly having the bomblets fly
	towards the flight path of the aircraft.
	*/
	_numbomblets = 50;
	_factor = 1;
	// plane altitude modifier
	_altMod = (_planeAlt - 50) / 5;
	
	while {_numbomblets > 0} do
	{
	/*
	   // Position the bomblet
	   _newposx = (_bpos select 0) + (5 * (_numbomblets / 12));
	   _newposy = (_bpos select 1) + (5 * (_numbomblets / 12));
	*/
	   // Position the bomblet
	   _rndOffset = (random 180) - 90;
	   _dir = _bDir + _rndOffset;

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

//	   _dist = random 200; Snakeman version 23 March
		_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. _numBomblets: %3",_bomblet,getPos _bomblet,_numBomblets];
	   };
	/*
	   // Spread the bomblets into an arc randomly
	   _ang = - 5 + random 10;

	   if (_ang < 0) then
	   {
	      _ang = _ang + 360;
	   };

	   if (_ang > 360) then
	   {
	      _ang = _ang - 360;
	   };

	   _nvx = (_bvx * cos(_ang)) + (_bvy * sin(_ang));
	   _nvy = - (_bvx * sin(_ang)) + (_bvy * cos(_ang));


	   // Randomise the z velocity
	   _nvz = _bvz * ((60 + random 80) / 100);

	   // Re-speed the bomb
	   _factor = random 2;
	   _bomblet setVelocity [_nvx * _factor, _nvy * _factor, _nvz];
	*/
	   // Next please
	   _numbomblets = _numbomblets -1;
	};
}
else
{
hint "You must be above 50m to drop this ordnance."
};
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-23 17:31:32

Just a real brief test, it seems that it places the bomblets into the location where the bomb was dropped... I think, because at least it looks like the bomblets hit the ground far far behind aircraft.

And yes indeed its very compact area where they hit, like U shape (upside down).
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-23 20:57:16

Excellent.

Next, I think it should be clear where to paste this at the bottom of the script, and give it a try.

Code: Select all

	/*
	   // Spread the bomblets into an arc randomly
	   _ang = - 5 + random 10;

	   if (_ang < 0) then
	   {
	      _ang = _ang + 360;
	   };

	   if (_ang > 360) then
	   {
	      _ang = _ang - 360;
	   };

	   _nvx = (_bvx * cos(_ang)) + (_bvy * sin(_ang));
	   _nvy = - (_bvx * sin(_ang)) + (_bvy * cos(_ang));

*/
	   // Randomise the z velocity
	   _nvz = _bvz * ((60 + random 80) / 100);

	   // Re-speed the bomb
	   _factor = 1;
// original	   _bomblet setVelocity [_nvx * _factor, _nvy * _factor, _nvz];
	   _bomblet setVelocity [_bvx * _factor, _bvy * _factor, _nvz];
	
	   // Next please
	   _numbomblets = _numbomblets -1;
	};
}
else
{
hint "You must be above 50m to drop this ordnance."
};
I'll probably need a screenshot to tell if it is messing up the vectors. This should move that same U shape up towards where the impact point would be.
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Vigilante » 2009-03-23 22:53:23

IF the bomblets are AmmoClass their lifetime in config must be quite high/long, because if they are expelled at like 500+m it will take quite a while for them to reach anything near ground...

And during the NAM era there where more hardmounted dispensers than many think...
I remember when building Revell model planes as kid, i ALWAYS mounted those dispensers the wrong way, wondering why the pins dont fit, because i mistook them for rocketlaunchers.. ;)
The rockeye kind of cluster'bombs' are quite new compared to a near endless list of other types of hardmounted dispensers:

check out here, theres a LOT of equipment listed...
http://www.designation-systems.net/usmi ... html#_SUU7

can you do some 60s lowtech too? There are NAM videos out there showing those kind of dispensers in lowlevel action.
otherwise nice cbu already! im not complaining :P just wishing....
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: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Re: Cluster bomb script

Post by Snake Man » 2009-03-24 06:25:40

This script is for VTE's "CBU-52" but definitely now I'm hoping this could be generic cluster bomb script, easy to use and MP friendly for any mission. Just add few variables at script start so users can configure it to any weapon/ammo class and configuration.

I believe we had the similar SUU pod configuration for our Skyraider earlier, I remember it dropping small bomblets.

All feedback is very much appreciated, keep it coming :)
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

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

Re: Cluster bomb script

Post by Vigilante » 2009-03-24 11:02:42

hey, those hardmounted dispensers, could be more easily made like reverse mounted 'guns' on the plane with salvo settings to their payload nr. of bomblets. i.e. 1 mag loaded with 150 rounds and proper delay betweeen shots, like so:

Code: Select all


class Weapon...
		initSpeed = 0.1;        // just for fun taking a split second to ignite the propulsion charge
		burst = 150;             // # of shots per 'shot'
		reloadTime = 0.25;    // time between each burst/round being expelled
		magazineReloadTime = 0;   // not necessary for dispensers

class Ammo...

		initSpeed = 75;        // initial speed of ammo
		ammo = "VTE_Clusterbomblet_XY";
		count = 150;
		showToPlayer = 1;

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 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-25 18:47:17

Hey SM-

When you test this, if it looks like the pattern is extended in one axis or another (particularly perpendicular to the line of flight) let me know. I think I know what that problem might be.

:thumbs:
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Vigilante » 2009-03-30 15:16:12

If you like clusterbombs (and WP effects) check out my YouTube Channel at
http://www.youtube.com/user/VigilanteSystems
(the direct link to video is: http://www.youtube.com/watch?v=5WKUbI63 ... annel_page)
ther you can find a short video showing the last video i took of my CBU animations depicting the separation of the skins and corresponding explosion of the linear charges doing the cutting of the skins (the skins are animated NOT scripted!)... no submunitions yet ;)
Its the SUU-6x/B Familiy of dispenser, so quite new... i will do rockeyes and earlier models after i finished the whole TMD (Tactical Munitions Dispenser) stuff... of course then you can include them into VTE, if you like!
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: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Re: Cluster bomb script

Post by Snake Man » 2009-03-30 17:16:14

Sorry guys, I've been very busy with VTE in the past few days and I haven't even implemented the latest script parts from here. I'll have to get up to speed on that ASAP so work can continue on the script.
vigilante wrote:If you like clusterbombs (and WP effects) check out my YouTube Channel
Bit fast paced video, but yeah the opening of the cannister looks good.
i will do rockeyes and earlier models
I'll look forward to it. If you need someone to test them, just ask me and we'll set them up for VTE aircraft.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-30 20:15:57

Here is the latest script I put together:

Code: Select all

/*

   VTE cluster bomb script
   originally from Footmunch / Killswitch.

   *****************************************
   TTD
   Dispersion area linked to height
Get altitude of plane (maybe even use ASL?) and subtract 50 (for the minimum).
Divide that number by 5? (Can tweak that.) And increase the radius by that number.

   
*/
private [
	"_plane","_weapon","_ammoname","_b","_bt","_z","_bpos","_bombvel",
	"_bvx", "_bvy", "_bvz", "_height", "_numbomblets", "_factor",
	"_newposx", "_newposy", "_bomblet", "_ang", "_nvx", "_nvy", "_nvz",
	"_bDir","_rndOffset", "_planePos", "_planeAlt", "_altMod"
];

// Init our local vars
_plane = _this select 0;
_weapon = _this select 1;
_ammoname = _this select 4;
_bDir = getDir _plane;
_planePos = getPos _plane;
_planeAlt = _planePos select 2;

if (_planeAlt > 49) then
{
	if (VTE_debug) then
	{
		player sideChat format["cbu_cluster.sqf: %1, %2, %3",_weapon,_ammoName,_plane];
		player sideChat "The scripts\weapons\cluster\cbu_cluster.sqf was executed!";
	};

	// Get the cluster bomb object
	_b = nearestObject[_plane, _ammoname];

	// Decide on proper bomblet type in a MP environment
	_bt = ["VTE_CBU25BombletSpoof", "VTE_CBU25Bomblet"] select (local _b);

	// Cluster bombs release at 50 metres
	_z = (getPos _b) select 2;
	waitUntil
	{
		_z = (getPos _b) select 2;
		(_z < 50) || !(alive _b);
	};

	if (VTE_debug) then
	{
		player sideChat format["%1 opened up at %2 altitude!",_b,_z];
	};

	// Get the bomb velocity and position
	_bpos = getPos _b;
	_bombvel = velocity _b;
	_bvx = _bombvel select 0;
	_bvy = _bombvel select 1;
	_bvz = _bombvel select 2;

	// Remove the original bomb
	if (local _b) then
	{
		deleteVehicle _b;
	};

	// Bump the zpos upwards
	_height = (_bpos select 2);

	/*
   REALISM vs GAMEPLAY:
   How many bomblets are we releasing. realistically its 220 in one bomb case,
   but thats too much for game engine to handle with script, or can the script
   be tweaked not to cause huge stutter when the bombs impact?

   CHANGE:
   Added it now for 50, huge difference on technicality of the explosions, however
   ingame visual/kill effect changes are almost none...

   BUG:
   There is bug howere, right now the bombles are created like "north east" from
   the impact point, causing very unnatural explosion area. The area should be just
   big circle around the disperal of bomblets point, possibly having the bomblets fly
   towards the flight path of the aircraft.
	*/
	_numbomblets = 50;
	_factor = 1;
	// plane altitude modifier
	_altMod = (_planeAlt - 50) / 5;
   
	while {_numbomblets > 0} 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. _numBomblets: %3",_bomblet,getPos _bomblet,_numBomblets];
		};
		// Randomise the z velocity
		_nvz = _bvz * ((60 + random 80) / 100);

		// Re-speed the bomb
		_factor = 1;
		_bomblet setVelocity [_bvx * _factor, _bvy * _factor, _nvz];
       
		// Next please
		_numbomblets = _numbomblets -1;
	};
}
else
{
	hint "You must be above 50m to drop this ordnance.";
};
Am I doing something wrong as it still creates the bomblets in this "arc" like U upside down shape which looks totally unnatural?
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

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

Re: Cluster bomb script

Post by Vigilante » 2009-03-30 23:09:09

When i do some random i always do it like so :

Code: Select all

_sub setPosASL [((_expulPos select 0)-((random 6)-(random 6))),((_expulPos select 1)-((random 6)-(random 6))),((_expulPos select 2)-((random 6)-(random 6)))];
this will litter the sublets anywhere in +/-6m in all three axes around the dispenser ...

this because if you subtract (for example 6)
((_dispenser getPosASL select 2)-((random 6-(random 6))
it might be + 6 or -6 or anything inbetween so with your 180deg could be +180 and -180 and all inbetween ... after you normalized the direction its (should be)then to the left or right a random 180deg each

its late here 0100h and i cant test right now.. tomorrow i will ... did something similiar with my clusters, i made a new video of it too.. they contain 202 submunitions and theres a little stutter (i also used thing class submunitions which run a spawn loop checking their height and then replace them with 105mm shell ;) (havent done my explosions yet))... i will see how that can be fixed or spoofed... does it matter if there is more time between each sublet? i dropped 2 each frame (sleep 0.001 in a for/do loop) ... even with 2 each frame it takes 101 frames for all submunitions to 'appear' ... so it will be around 10secs if i used sleep 0.1 ... damn ... i will try 0.01 then 1 sec should be ok...

i meant like so...

Code: Select all

_rndOffset = (random 180) - (random 180);
_dir = _bDir - _rndOffset;
sometimes i play with the random because its not tHAT random (thanks bis :P ) ...
... like so...

Code: Select all

_rndOffset = ((random 90) - (random 90)) - ((random 90) - (random 90));
_dir = _bDir - _rndOffset;
you could even do 360 instead of 90.. i always play with the values till it looks right ... (sometimes i wish i had another pc, then i would run the script in a loop with execVM and change the values via vnc or putty because execVM loads the file each time new, but it must be inside the missions folder not a pbo .. ... ;) )

why you do this?

Code: Select all

          if ((_dir > 360) || (_dir < 0)) then
          {
             _dir = abs (abs (_dir) - 360);
          };
especially why abs ? ... 233.4433 degree is nice randomness... otherwise you only have like 360 different directions ... and i would also randomize the _dist a bit
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: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Re: Cluster bomb script

Post by Snake Man » 2009-03-31 10:34:26

So how would you replace the abs part of the script?
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

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

Re: Cluster bomb script

Post by Vigilante » 2009-03-31 12:14:35

i would omit it alltogether... i just was asking because i thought you had a certain reason to do it... :)
abs will make out of 365.44333 a 365 which might be just what you want, but if you want more randomness then the more numbers the better :) ... BUT sometimes ArmAengine doesnt like too big numbers behind the point and will give out some endless number not doing much... if that happens then its better to do >> mod 0.01 << with the result before using it in other calculations...

(mod cuts or rounds the numbers behind the point (damn forgot the right english term for it ;) ) )

But i was wondering why you want to do the whole part

Code: Select all

if ((_dir > 360) || (_dir < 0)) then
          {
             _dir = abs (abs (_dir) - 360);
          };
i would rather do it with +/-180 if necessary at all (again i couldnt try your script yet)
like so?

Code: Select all

if ((_dir > 180) && (_dir < 0)) then
       {
             _dir = (_dir - 180) mod 0.01;
        }
else
       {
             _dir = (_dir + 180) mod 0.01;
       };



Im busy right now with animating, but later today or this evening i will try your script in arma ...


but in the beginning i would do all calculations WITHOUT randomness to see the general effect they create, THEN add randomness everywhere... ;)
Last edited by Vigilante on 2009-04-03 12:33:28, edited 1 time in total.
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 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-31 19:47:11

Right.

Since this is testing, there are several areas that can be randomized later.

SnakeMan-
Going back to the script you just posted, it should still be a U shape, but I want to make sure it is placed relatively correctly along the fall line of the plane. Your initial comment was that it seemed to be placed close to the place it was dropped, rather than the place it was supposed to land. Also, since it is a U, that means that the vectors are in the correct order. But, was the U the same size, or was it at least elongated a bit?

To text the next iteration, I suggest just changing the respeed the bomb portion this:

Code: Select all

      // Re-speed the bomb
      _factor = random 2;
      _bomblet setVelocity [_bvx * _factor, _bvy * _factor, _nvz];
And see if that spreads it out any better. Pics would also help. ;)

As for the abs command, I do not believe that it rounds. I haven't tested it, but nothing is mentioned in the OFPEC ComRef about that. It is only supposed to take the absolute value of a number. (That takes the place of the "if > 360 then subtract, or if < 360 add" conditionals.) And sure, the distance is tweakable, depending on the results we get.

I kinda like the double-randomization idea. :D But, since no one is likely to notice the difference, I think it is overkill for something like this. :)

Edit:
Oh, and SM - did the size of the U appear to change based on the drop height?
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-31 20:32:07

These two screenshots show bomblets dropped from 300m and 600m altitudes, which are HIGH in my opinion, most players would fly around 100m average, even lower I think.

Left image 300m, right image 600m.
Image

I guess its quite OK, maybe the bomblets scatter only to a small area at low level (realistic or not) and you really need to fly high alt to get wide area damage. It starts to be like carpet bombing on those alts :)
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-31 20:38:17

Roger.

Are those pics with the _factor = random 2 change?

It looks like the height does make a difference, so that is a good thing. We can tweak the values.

Biggest issue is that it is an "outline" though. We need to fill that in. Several ideas about how to do that. I thought the randomization of the x/y vector would take care of it. If it hasn't, then we can fiddle with slowing down the re-speed vectors and placing the bomblets more where we want them. There is a distinct pattern to the bomblets that should be do-able.

Edit:
Shhhhhhhhheeeyute.

Change the _dist calculation to:

Code: Select all

          _dist = random (20 + _altMod);
Otherwise, as I had it, every bomblet would START the distance of _altMod away. That was one thing preventing the horseshoe from being filled in. Sorry about that. :? :oops:
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-31 21:03:55

Yes the above images were with the latest "_factor = random 2" change.

I added now the latest "_dist = random (20 + _altMod);" and now we get nice and round circle area of bomblets.

However... dunno if its my 50 bomblets, the area, or what... but the cluster bombs now are ... wimpy, I mean you really have to accurately hit the target to get any kills. In the above screenshots you cannot see the 3 squads of enemies down there, but I used team switch to first drop the bombs and then switch into a unit down in the village, but after three or four tries I didn't get killed once... so we need some fear in god for those bomblets :)
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-31 21:12:32

Yeah, I'd bump up the number to 100 or so.... :)
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-31 21:41:32

And now I'm having hard time balancing the number of bomblets and sleep delay for them to go off, lets say 220 bomblets and sleep 0.001 and it takes forever for the bomblets to explode. I'm thinking that perhaps the sleep cycle should come like after each 10th bomblet has gone off or something.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-03-31 22:08:05

Hmm... I'd say try it without any sleep and see what it does.

Also, maybe try making the _factor to random 10, see what effect that has.
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-03-31 22:32:34

Without sleep its huge stutter as all the bomblets go off at pretty much the same time, yeah there is bit delay but just barely.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

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

Re: Cluster bomb script

Post by Vigilante » 2009-03-31 23:57:12

yeah, guys thats the same problems i face with my CBU... its hard to get any real number of ammoobjects in the needed timeframe in the correct spot without any stutter... unfortunately... and you cant use sleep < 0.001 since 0.001 is one frame ingame. I work atm on some ideas i had to get there, or you can do them in two or three spawn scripts which run at the same time, if youre freaky you even syncronize them :D ... spawn command creates another thread for each script run without interrupting other scripts like call would do ... i ran 202 bomblets with a simple dropscript spawned on each bomblet without troubles ..but beware..
(also try to use frequent = 1 as named property inside the geolod for instancing of the object, maybe this helps something, i didnt recognize bad or good behaviour so i use it, even if it doesnt help and as long as i dont see drawbacks i think it just can help (?) .)

and:
abs is not randomizing anything its rounding a number to a natural/real number i.e. -1 becomes 1 and 4.5 becomes 4.5 and -3.4 becomes 3.4 ... it does (abs -1 = 1).
mod was the old command to round now they have ceil, floor and round but with mod 0.1 or mod 0.01 you can round them to a certain place after the period i.e. (((1 * 4.54545343) mod 0.001) == 4.545) which can help with enormous numbers behind the period which can result in scalar bool error stuff with some divisions or multiplications creating huge afterperiod values.

your clusterbomb look good and for more killing power i would like 'clone' those bomblets, lets say halfway down their drop. like getting their position at _dropheight/2 and then creating there another one, maybe even slightly offset (2m left and 2m back) when the new bombletclone is created at this position the original one is already a few feet away from his new sibling and all can kill happily ever after..
make them bigger inside config, more indirect hit range or so ... or run that script twice with 50 bomblets each with like a second or half inbetween?!
(sorry had to do some gardening today, no test of your scripts yet :oops: )
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 23:01:01
Location: here

Re: Cluster bomb script

Post by T_Rex » 2009-04-01 02:45:40

Hmmm... a group/delay counter wouldn't be hard.

But... I'm thinking of a way that may be more realistic (I think) with the rearward bomblets landing first, and the most forward firing last. Basically, a slightly phased dispersion.

I have to think it all the way through, though. Will try to post more in the next 24 hours.

Do you think you'll be sticking with the 200 number for bomblets? Or at least, in that range?
Sic Semper tyrannosauro.

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

Re: Cluster bomb script

Post by Snake Man » 2009-04-01 06:40:28

Number of bomblets is all about balance... it needs to be devastating weapon which is HIGH PERFORMANCE on ArmA engine. I have absolutely no use for uber cool combat whore photography topic weapon which brings ArmA to its knees and kicks out every player from dedicated server.

Performance first, gameplay second, visuals last :)
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

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

Re: Cluster bomb script

Post by Vigilante » 2009-04-01 07:32:26

i second that snakeman ... and if we can get all of it, even better, but priorities must be set :)

phased dispersion sounds good, three 'bursts' of bomblets, the first behind the _posCBU (seen in direction of flight) second at _posCBU and last in front of that position... they just shouldnt reach ground at the same time... i had no problems spawning my 202 bomblets at 0.001 interval but if they start to hit ground at the same time, it stutters (if i use exploding ones or spawn a explosion at their impactpoint). If i use the non-exploding alone, no problem, if they are not all in one heap (i mean really a heap like in/on one spot), because then arma physics go mad with so many things colliding ;) ...

(BTW i really hope they beefed up physics and particles in ArmA2, too bad they threw away that NVIDIA/Aegis PhysiX which is still in VBS, at least for ropes. Since you can use the physiX with a cheap secondary or event third gfx card in a slower PCIx port now.. anyway... BTT)

The Problem of stuttering seems to be in the particles of the explosions i guess, since even without explosives when i play with particles it starts to go stuttery at some point or it deletes all the particle goodness, also the damage calculations of the explosions seem to make a hit on any machine...

maybe spoofing some part would be good? Like keeping the visual explosions (ie just the particles) and then grouping a bunch of bomblets together calculating the area they are saturating and doing just a triggerlist with setdamage==veryPainfull for all objects inside... who cares about single fragment objects, or explosions, if you are inside of such a cloud of death? (and watching from the outside you wouldnt recognize those anyway).. i mean, you see them raining down on you, next thing you see some clouds and BANG youre dead or wounded...

Dropping simple non-exploding objects and just deleting them with above triggerlist + explosionParticle at their position would do ok i think AND you can take like every second or so object and leave it jumping around to be later collected as UXO (after the whole explosion stuff done, do a search for the uxo bomblets and create a small trigger around each of them with some nice killeffect on it. Also nice to leave some bomblets lying around WITHOUT that killtriggerscript, just with useraction for VC and such to pick them up and then placing a boobytrap magazine in their inventory (like they did very often back then) the cool thing also is that you can make the "Pick up Bomblet" action appear BEFORE you reach an actuall kiltrigger, so its possible that you get blown up when you try to pick up that valuable ordnance...


According to sources there is up to 40% non-exploded ordnance lying around after such an cbu goes off... i know the DoD states otherwise and the CBU manufaturer even more so, but i rather belive in the reports filed by those people putting civillians back together (if at all possible) and those cleaning up that mess afterwards, they report somewhere from 20-40% of each CBU bomblets dont go off and with 60s-70s ordnance in jungle environment its rather the worse number than the lower.
a.k.a. PhilippRauch
Check out my Addons Wiki @ http://vigilante-systems.webs.com (WIP but already contains lots of infos)

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests