Fired eventhandler aircraft bombing scripts

ArmA editing, missions, modeling, textures, terrains

Moderators: Lone Wolf, Snake Man

Post Reply
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:

Fired eventhandler aircraft bombing scripts

Post by Snake Man » 2007-10-06 00:46:52

This topic is about fixing the VTE napalm scripts, the script that tracks the dropping bomb and then creates some effects when it hits or rather is about to hit. I opened this topic in hope of developing such scripts to their fullest.

Lets start.

First you launch this script from aircrafts class eventHandlers {} like this:

Code: Select all

		class eventhandlers
		{
			fired = "_this exec ""\VTE_Config\scripts\napalm_distribution.sqs"";";
		};
The above code is still with exec the SQS script, which we should change to SQF of course. Then there is the current napalm_distribution.SQF file which we put together (havent tried it ingame yet so dunno if there are some bugs):

Code: Select all

private [
        "_plane","_weapon","_ammoname","_missobj","_zpos",
        "_bombvel","_bvx","_bvy","_bvz","_bpos","_numbomblets","_btype",
        "_factor","_sensor","_result","_height","_newposx","_newposy",
        "_ang","_nvx","_nvy","_nvz"
];
_plane    = _this select 0;
_weapon   = _this select 1;
_ammoname = _this select 4;
 
if (_ammoname != "VTE_MK74") exitWith {};
 
// #MoveMissile
// Get the missile object
_missobj = nearestObject [_plane, _ammoname];
 
// The bomb can impact, and not trigger
// Also, cluster bombs release at 50 metres
_zpos = getPos _missobj select 2;
while {_zpos > 50 && alive _missobj} do
{
        sleep 0.05;
        _zpos = getPos _missobj select 2;
};
if (not alive _missobj) exitWith {};
 
// Get the bomb velocity and position
_bombvel = velocity _missobj;
_bvx = _bombvel select 0;
_bvy = _bombvel select 1;
_bvz = _bombvel select 2;
_bpos = getPos _missobj;
 
// Remove the original bomb
deleteVehicle _missobj;
 
// How many bomblets are we releasing
_numbomblets = 20;
_factor = 1;
_btype="VTE_Bomblet";
if !(local _plane) then {_btype="VTE_Bomblet_Dummy"};
 
// Create an empty object
_sensor = "EmptyDetector" createVehicleLocal [0,0,0];
 
// Place it directly under the plane in the horizontal
_sensor setPos [_bpos select 0, _bpos select 1];
 
// The OFP engine puts the object on the land surface, so we can get the ground height
_result =(getPos _sensor) select 2;
 
// Clean up the sensor
deleteVehicle _sensor;
 
// Bump the zpos upwards
_height = (_bpos select 2);
 
while {_numbomblets > 0} do
{
        // Position the bomblet
        _newposx = (_bpos select 0) + (5 * (_numbomblets / 15));
        _newposy = (_bpos select 1) + (5 * (_numbomblets / 15));
 
        // Create the bomblet
        // this should be createVehicleLocal to reduce the desync!
        _bomblet = _btype createVehicleLocal [_newposx, _newposy, _height];
        // this is additional since v0.4 style script
        [_bomblet] execVM "\VTE_Config\scripts\vehicle\shared\napalm\napalm.sqf";
 
        // Spread the bomblets into an arc randomly
        _ang = - 5 + random 10;
        ?(_ang <0> 360) : _ang = _ang - 360;
        _nvx = (_bvx * cos(_ang)) + (_bvy * sin(_ang));
        _nvy =-(_bvx * sin(_ang)) + (_bvy * cos(_ang));
 
        // Randomise the z velocity
        _nvz = _bvz * ((20 + random 130) / 100);
 
        // Re-speed the bomb
        _bomblet setVelocity [_nvx* _factor, _nvy* _factor, _nvz];
 
        // Next please
        _numbomblets = _numbomblets -1;
        sleep 0.05;
};
And then last script is the napalm.sqs (yeah didn't make this to sqf yet):

Code: Select all

_bomb = _this select 0;
?!(alive _bomb): exit;

#napalm
?!(alive _bomb): goto "create";
_x = getpos _bomb select 0;
_y = getpos _bomb select 1;
_z = getpos _bomb select 2;
~0.01
?(alive _bomb): goto "napalm";

#create
; make this createVehicleLocal so dont have desync
_smoke = "VTE_Napalm_Smoke" createVehicleLocal [_x,_y,_z];
exit;
So any script gurus out there who want to help us tweak the scripts to maximum performance in MP, all suggestions are very welcome. I will update this first post while we do progress with this script, also I want to add other bombing effect scripts like daisy cutter huge smoke cloud effect script in here.
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."

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests