Jump to content
RizlaUK

Copy Behaviour of Script

Recommended Posts

Hi,

 

A part of the Invade and Annex i'm using on my server has this script below which allows an ammo drop to be parachuted into the AO to the troops on the ground. I wanted to copy the parachute and smoke/chem light aspect of it to ammo boxes and Medivac containers that are sling loaded. As it stands at the moment if we use a sling loaded box/container, the pilot needs to get it down on the deck and if he damages it while under fire it despawns. If we could make it so if the pilots are under heavy fire they can detach the sling loaded item and when it's dropping, the parachute opens and a smoke deploys - that would be spot on.

 

/*
Author:

	Jester [AW]
	
Edited by:
 
	Quiksilver 
 
Note:
 
	Should be fixedd now.
 
______________________________________________________________*/

private ["_heli", "_reloadtime"];

if (!(AW_ammoDropAvail)) exitWith {
	hint "Ammo drop is not currently available"
};
AW_ammoDropAvail = FALSE; publicVariable "AW_ammoDropAvail";

//------------------------------------------------------- CONFIG

_heli = _this select 0;
_chuteType = "B_Parachute_02_F";			//parachute for blufor, for opfor and greenfor replace the 'B' with 'O' or 'G' respectively
_crateType =  "B_supplyCrate_F";			//ammocrate class for blufor, feel free to change to whichever box you desire
_smokeType =  "SmokeShellPurple";  			//smoke shell color you want to use
_lightType =  "Chemlight_blue";  			//chemlightcolor you want used
_reloadtime = 120;  							// time before next ammo drop is available to use, default 600 or 480
_minheight = 39;  							// the height you have to be before you can actually drop the crate

//--------------------------------------------------------- MEAT AND POTATOES

_chute = createVehicle [_chuteType, [100, 100, 200], [], 0, 'FLY'];
_chute setPos [getPosASL _heli select 0, getPosASL _heli select 1, (getPosASL _heli select 2) - 50];
ammoDropCrate = createVehicle [_crateType, position _chute, [], 0, 'NONE']; publicVariable "ammoDropCrate"; 
ammoDropCrate attachTo [_chute, [0, 0, -1.3]];
ammoDropCrate allowdamage false;
_light = createVehicle [_lightType, position _chute, [], 0, 'NONE'];
_light attachTo [_chute, [0, 0, 0]];

//---------------------------------------------------- CLEAR CRATE

clearWeaponCargoGlobal ammoDropCrate;
clearMagazineCargoGlobal ammoDropCrate;

//---------------------------------------------------- CRATE CONTENTS

ammoDropCrate addMagazineCargoGlobal ["5Rnd_127x108_Mag", 10];
ammoDropCrate addMagazineCargoGlobal ["7Rnd_408_Mag", 15];
ammoDropCrate addMagazineCargoGlobal ["30Rnd_556x45_Stanag", 10];
ammoDropCrate addMagazineCargoGlobal ["30Rnd_65x39_caseless_mag_Tracer", 10];
ammoDropCrate addMagazineCargoGlobal ["20Rnd_762x51_Mag", 15];
ammoDropCrate addMagazineCargoGlobal ["200Rnd_65x39_cased_Box_Tracer", 10];
ammoDropCrate addMagazineCargoGlobal ["30Rnd_65x39_caseless_green", 10];
ammoDropCrate addMagazineCargoGlobal ["150Rnd_762x51_Box", 10];
ammoDropCrate addMagazineCargoGlobal ["30Rnd_65x39_caseless_mag", 10];
ammoDropCrate addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", 2];
ammoDropCrate addMagazineCargoGlobal ["MineDetector", 2];  	
ammoDropCrate addMagazineCargoGlobal ["HandGrenade", 6];
ammoDropCrate addMagazineCargoGlobal ["SmokeShell", 10];
ammoDropCrate addMagazineCargoGlobal ["SmokeShellBlue", 2];
ammoDropCrate addMagazineCargoGlobal ["SmokeShellGreen", 2];
ammoDropCrate addMagazineCargoGlobal ["1Rnd_HE_Grenade_shell", 6];
ammoDropCrate addMagazineCargoGlobal ["RPG32_HE_F", 2];
ammoDropCrate addMagazineCargoGlobal ["RPG32_F", 2];
ammoDropCrate addMagazineCargoGlobal ["NLAW_F", 3];
ammoDropCrate addMagazineCargoGlobal ["Titan_AT", 6];
ammoDropCrate addMagazineCargoGlobal ["Titan_AA", 3];

//--------------------------------------------------- BRIEF

pvBroadcast = [WEST,"AirBase"] sideChat "UH-80 Supply Drop has been deployed!"; publicVariable "pvBroadcast";

//--------------------------------------------------- CRATE LANDING

waitUntil {
	position ammoDropCrate select 2 < 2 || isNull _chute
};

detach ammoDropCrate;
ammoDropCrate setPos [position ammoDropCrate select 0, position ammoDropCrate select 1, 0];
ammoDropCrate setVectorUp [0,0,1];
ammoDropCrate enableSimulationGlobal TRUE;
_smoke = _smokeType createVehicle [getPos ammoDropCrate select 0, getPos ammoDropCrate select 1,5];

 

Any help would be great.

 

Regards

 

Rizla

Share this post


Link to post
Share on other sites

If we could make it so if the pilots are under heavy fire they can detach the sling loaded item and when it's dropping, the parachute opens and a smoke deploys

 

Hello,

 

I suppose you could accomplish this with the RopeBreak eventhandler

 

 

Nikander

Share this post


Link to post
Share on other sites

Hello,

I suppose you could accomplish this with the RopeBreak eventhandler

Nikander

I made a script very similar to this a long time ago, using the above EH, however, firstly, I cannot find it atm (figures), secondly, there are multiple ropes attached to the box (4 if I remeber), therefore, the EH will execute 4 times, so you need to be sure to execute your code only once out of those four times or else it will spawn 3 extra parachutes :).

Share this post


Link to post
Share on other sites

your_heli addEventHandler ["RopeBreak", { your code for rope breaking here }];

Share this post


Link to post
Share on other sites

I made a script very similar to this a long time ago, using the above EH, however, firstly, I cannot find it atm (figures), secondly, there are multiple ropes attached to the box (4 if I remeber), therefore, the EH will execute 4 times, so you need to be sure to execute your code only once out of those four times or else it will spawn 3 extra parachutes :).

 

Hi, do you have any suggestions of how to do this? I've got the problem with trying to spawn a parachute on a supply box when it gets detached from the rope, but it is spawning 4 parachutes. I've tried checking if one is attached already and stopping it creating a new one/deleting the new one if there is but it doesn't work. What would be the best way to do this?

Share this post


Link to post
Share on other sites

Hi, do you have any suggestions of how to do this? I've got the problem with trying to spawn a parachute on a supply box when it gets detached from the rope, but it is spawning 4 parachutes. I've tried checking if one is attached already and stopping it creating a new one/deleting the new one if there is but it doesn't work. What would be the best way to do this?

If I remember correctly I used get/setVariable on the object being dropped (_this select 2 within the EH), but I also seem to remember that may not have been a fast enough solution considering the EH fired 4 times nearly at the same time, but like I said I can't find the damned script and don't remember if I found a solution to that or not.

Share this post


Link to post
Share on other sites

you could try to remove the EH with the first fire.

Share this post


Link to post
Share on other sites

you could try to remove the EH with the first fire.

Very true, problem being you have to attach this to the helicopter, so you would need a system to reapply the EH, and just sleeping til you know for certain that all ropes are broken may have unforeseen complications.

Share this post


Link to post
Share on other sites

there is a command to determine whether vehicles are attached by ropes. (ropeattachedto?) 

 

could spawn a thread in the rope break event code to wait until that returns false, and then check a series of conditions to determine whether it should be paradropped (for instance if you're too low altitude probably paradrop not appropriate).

 

Personally these days I just use the sling loading capability instead of the virtual paradrop scipt. Less code/scripts, has a visual feedback component, and requires some planning by the pilots and ground teams.

 

edit:

 

here is some untested example code for how it could look:

_vehicle addEventHandler [
     'RopeBreak',
     {
          params ['_vehicle','_rope','_object'];
          if (serverTime > (_vehicle getVariable ['tag_var_lastparadrop',0])) then {
               comment 'time plus the minimum delay in seconds you want between paradrop actuations from this vehicle';
               _vehicle setVariable ['tag_var_lastparadrop',(serverTime + 600),true];  
               [_vehicle,_rope,_object] spawn {
                    params ['_vehicle','_rope','_object'];
                    _t = time + 3;
                    waitUntil {
                         (isNull (ropeAttachedTo _object)) ||
                         (!alive _vehicle) ||
                         (!alive _object) ||
                         (time > _t)
                         sleep 0.1;
                    };
                    if (time > _t) exitWith {comment 'not all ropes were broken, exit';};
                    if ((!alive _vehicle) || {(!alive _object)}) exitWith {comment 'one of the objects was destroyed, exit';};
                    comment 'All ropes are broken simultaneously and both objects still alive, continue';
                    comment 'spawn a function to control the paradrop itself';
                    [_object] spawn (missionnamespace getvariable ['tag_fnc_paradrop',{}]);
               };
          };
     }
];

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×