Jump to content
Sign in to follow this  
qevhytpl

How to create an AA rocket that takes down your chopper?

Recommended Posts

I want to create an AA rocket that takes down chopper?

is there a way to create a rocket somewhere (without a visible in-game source like an AA soldier), that hits the player chopper?

Thanks in advance for any help.

QEVHYTPL

Share this post


Link to post
Share on other sites

You're looking for setHit. Just destroy the motor or rotor or whatever part that gives you the desired crash.

Share this post


Link to post
Share on other sites

BIS script launchMissile.sqf:

[b]//[Targetname, [(markerPos "missileStart") select 0, (markerPos "missileStart") select 1, 5], "M_Igla_AA", 500, position someObject] execVM "launchMissile.sqf";[/b]
[color="DarkRed"]
_primaryTarget = _this select 0;	//target for the missile
_missileStart = _this select 1;		//position where the missile will be spawned
_missileType = _this select 2;		//type of the missile
_missileSpeed = _this select 3;		//speed of the missile
_defaultTargetPos = _this select 4;	//default position where unguided missiles will fly [8340.718750,3074.914795,0];[/color]

_perSecondChecks = 25;		//direction checks per second
_getPrimaryTarget = {if (typeName _primaryTarget == typename {}) then {call _primaryTarget} else {_primaryTarget}};		//code can be used for laser dots
_target = call _getPrimaryTarget;

_missile = _missileType createVehicle _missileStart;
_missile setPos _missileStart;

//secondary target used for random trajectory when laser designator is turned off prematurily
_secondaryTarget = "HeliHEmpty" createVehicle _defaultTargetPos;
_secondaryTarget setPos _defaultTargetPos;

_guidedRandomly = FALSE;

//procedure for guiding the missile
_homeMissile = {

//here we switch to secondary target at random position if the laser dot no longer exists
//if the designator is turned on again, the missile will return to it's original target (providing it hadn't flown too far)
private ["_velocityX", "_velocityY", "_velocityZ", "_target"];
_target = _secondaryTarget;
if (!(_guidedRandomly) && _missile distance _target > _missileSpeed * 1.5) then {
	_guidedRandomly = TRUE;
	_target = _secondaryTarget;
	_dispersion = (_missile distance _defaultTargetPos) / 20;
	_dispersionMin = _dispersion / 10;
	_target setPos [(_defaultTargetPos select 0) + _dispersionMin - (_dispersion / 2) + random _dispersion, (_defaultTargetPos select 1) + _dispersionMin - (_dispersion / 2) + random _dispersion, 0];
};
if (!(isNull (call _getPrimaryTarget))) then {_target = call _getPrimaryTarget; _defaultTargetPos = position _target; _guidedRandomly = FALSE};

//altering the direction, pitch and trajectory of the missile
	_travelTime = (_target distance _missile) / _missileSpeed;
	_steps = floor (_travelTime * _perSecondChecks);

	_relDirHor = [_missile, _target] call BIS_fnc_DirTo;
	_missile setDir _relDirHor;

	_relDirVer = asin ((((getPosASL _missile) select 2) - ((getPosASL _target) select 2) + 0.5) / (_target distance _missile));
	_relDirVer = (_relDirVer * -1);
	[_missile, _relDirVer, 0] call BIS_fnc_setPitchBank;

	_velocityX = (((getPosASL _target) select 0) - ((getPosASL _missile) select 0)) / _travelTime;
	_velocityY = (((getPosASL _target) select 1) - ((getPosASL _missile) select 1)) / _travelTime;
	_velocityZ = (((getPosASL _target) select 2) + 0.5 - ((getPosASL _missile) select 2)) / _travelTime;

[_velocityX, _velocityY, _velocityZ]
};

call _homeMissile;

//missile flying
while {(_missile distance _missileStart) <= (_target distance _missileStart)} do {
_velocityForCheck = call _homeMissile;
if ({(typeName _x) == (typeName 0)} count _velocityForCheck == 3) then {_missile setVelocity _velocityForCheck};
sleep (1 / _perSecondChecks)
};

waitUntil {(_missile distance _missileStart) > (_target distance _missileStart) || !(alive _missile)};
if (alive _missile) then {
while {alive _missile} do {
	_missile setPos position _target;
	_missile setDir (direction _target);
	sleep 0.01
}
};

[color="Blue"]// ----- mission-specific!!!
_primaryTarget setHit ["mala vrtule", 1];
// ----- end of mission-specific[/color]

deleteVehicle _secondaryTarget;

Execute it from somewhere with that first bold line

[Targetname, [(markerPos "missileStart") select 0, (markerPos "missileStart") select 1, 5], "M_Igla_AA", 500, position someObject] execVM "launchMissile.sqf";

obviously substituting the object and marker names for your own.

The ----- mission-specific!!! part at the bottom just destroys the target's tail rotor if it is a chopper.

Share this post


Link to post
Share on other sites

Thank you very much!

Your suggestion is very useful.

---------- Post added at 04:31 ---------- Previous post was at 04:30 ----------

Thanks a lot

---------- Post added at 04:35 ---------- Previous post was at 04:31 ----------

You're looking for setHit. Just destroy the motor or rotor or whatever part that gives you the desired crash.

Thank you very much!:yay:

---------- Post added at 04:38 ---------- Previous post was at 04:35 ----------

BIS script launchMissile.sqf:

[b]//[Targetname, [(markerPos "missileStart") select 0, (markerPos "missileStart") select 1, 5], "M_Igla_AA", 500, position someObject] execVM "launchMissile.sqf";[/b]
[color="DarkRed"]
_primaryTarget = _this select 0;	//target for the missile
_missileStart = _this select 1;		//position where the missile will be spawned
_missileType = _this select 2;		//type of the missile
_missileSpeed = _this select 3;		//speed of the missile
_defaultTargetPos = _this select 4;	//default position where unguided missiles will fly [8340.718750,3074.914795,0];[/color]
_perSecondChecks = 25;		//direction checks per second
_getPrimaryTarget = {if (typeName _primaryTarget == typename {}) then {call _primaryTarget} else {_primaryTarget}};		//code can be used for laser dots
_target = call _getPrimaryTarget;

_missile = _missileType createVehicle _missileStart;
_missile setPos _missileStart;

//secondary target used for random trajectory when laser designator is turned off prematurily
_secondaryTarget = "HeliHEmpty" createVehicle _defaultTargetPos;
_secondaryTarget setPos _defaultTargetPos;

_guidedRandomly = FALSE;

//procedure for guiding the missile
_homeMissile = {

//here we switch to secondary target at random position if the laser dot no longer exists
//if the designator is turned on again, the missile will return to it's original target (providing it hadn't flown too far)
private ["_velocityX", "_velocityY", "_velocityZ", "_target"];
_target = _secondaryTarget;
if (!(_guidedRandomly) && _missile distance _target > _missileSpeed * 1.5) then {
	_guidedRandomly = TRUE;
	_target = _secondaryTarget;
	_dispersion = (_missile distance _defaultTargetPos) / 20;
	_dispersionMin = _dispersion / 10;
	_target setPos [(_defaultTargetPos select 0) + _dispersionMin - (_dispersion / 2) + random _dispersion, (_defaultTargetPos select 1) + _dispersionMin - (_dispersion / 2) + random _dispersion, 0];
};
if (!(isNull (call _getPrimaryTarget))) then {_target = call _getPrimaryTarget; _defaultTargetPos = position _target; _guidedRandomly = FALSE};

//altering the direction, pitch and trajectory of the missile
	_travelTime = (_target distance _missile) / _missileSpeed;
	_steps = floor (_travelTime * _perSecondChecks);

	_relDirHor = [_missile, _target] call BIS_fnc_DirTo;
	_missile setDir _relDirHor;

	_relDirVer = asin ((((getPosASL _missile) select 2) - ((getPosASL _target) select 2) + 0.5) / (_target distance _missile));
	_relDirVer = (_relDirVer * -1);
	[_missile, _relDirVer, 0] call BIS_fnc_setPitchBank;

	_velocityX = (((getPosASL _target) select 0) - ((getPosASL _missile) select 0)) / _travelTime;
	_velocityY = (((getPosASL _target) select 1) - ((getPosASL _missile) select 1)) / _travelTime;
	_velocityZ = (((getPosASL _target) select 2) + 0.5 - ((getPosASL _missile) select 2)) / _travelTime;

[_velocityX, _velocityY, _velocityZ]
};

call _homeMissile;

//missile flying
while {(_missile distance _missileStart) <= (_target distance _missileStart)} do {
_velocityForCheck = call _homeMissile;
if ({(typeName _x) == (typeName 0)} count _velocityForCheck == 3) then {_missile setVelocity _velocityForCheck};
sleep (1 / _perSecondChecks)
};

waitUntil {(_missile distance _missileStart) > (_target distance _missileStart) || !(alive _missile)};
if (alive _missile) then {
while {alive _missile} do {
	_missile setPos position _target;
	_missile setDir (direction _target);
	sleep 0.01
}
};

[color="Blue"]// ----- mission-specific!!!
_primaryTarget setHit ["mala vrtule", 1];
// ----- end of mission-specific[/color]

deleteVehicle _secondaryTarget;

Execute it from somewhere with that first bold line

[Targetname, [(markerPos "missileStart") select 0, (markerPos "missileStart") select 1, 5], "M_Igla_AA", 500, position someObject] execVM "launchMissile.sqf";

obviously substituting the object and marker names for your own.

The ----- mission-specific!!! part at the bottom just destroys the target's tail rotor if it is a chopper.

yeh!I suddenly realized.I am trying! Thanks a lot :bounce3:

Share this post


Link to post
Share on other sites
BIS script launchMissile.sqf:

[b]//[Targetname, [(markerPos "missileStart") select 0, (markerPos "missileStart") select 1, 5], "M_Igla_AA", 500, position someObject] execVM "launchMissile.sqf";[/b]
[color="DarkRed"]
_primaryTarget = _this select 0;	//target for the missile
_missileStart = _this select 1;		//position where the missile will be spawned
_missileType = _this select 2;		//type of the missile
_missileSpeed = _this select 3;		//speed of the missile
_defaultTargetPos = _this select 4;	//default position where unguided missiles will fly [8340.718750,3074.914795,0];[/color]

_perSecondChecks = 25;		//direction checks per second
_getPrimaryTarget = {if (typeName _primaryTarget == typename {}) then {call _primaryTarget} else {_primaryTarget}};		//code can be used for laser dots
_target = call _getPrimaryTarget;

_missile = _missileType createVehicle _missileStart;
_missile setPos _missileStart;

//secondary target used for random trajectory when laser designator is turned off prematurily
_secondaryTarget = "HeliHEmpty" createVehicle _defaultTargetPos;
_secondaryTarget setPos _defaultTargetPos;

_guidedRandomly = FALSE;

//procedure for guiding the missile
_homeMissile = {

//here we switch to secondary target at random position if the laser dot no longer exists
//if the designator is turned on again, the missile will return to it's original target (providing it hadn't flown too far)
private ["_velocityX", "_velocityY", "_velocityZ", "_target"];
_target = _secondaryTarget;
if (!(_guidedRandomly) && _missile distance _target > _missileSpeed * 1.5) then {
	_guidedRandomly = TRUE;
	_target = _secondaryTarget;
	_dispersion = (_missile distance _defaultTargetPos) / 20;
	_dispersionMin = _dispersion / 10;
	_target setPos [(_defaultTargetPos select 0) + _dispersionMin - (_dispersion / 2) + random _dispersion, (_defaultTargetPos select 1) + _dispersionMin - (_dispersion / 2) + random _dispersion, 0];
};
if (!(isNull (call _getPrimaryTarget))) then {_target = call _getPrimaryTarget; _defaultTargetPos = position _target; _guidedRandomly = FALSE};

//altering the direction, pitch and trajectory of the missile
	_travelTime = (_target distance _missile) / _missileSpeed;
	_steps = floor (_travelTime * _perSecondChecks);

	_relDirHor = [_missile, _target] call BIS_fnc_DirTo;
	_missile setDir _relDirHor;

	_relDirVer = asin ((((getPosASL _missile) select 2) - ((getPosASL _target) select 2) + 0.5) / (_target distance _missile));
	_relDirVer = (_relDirVer * -1);
	[_missile, _relDirVer, 0] call BIS_fnc_setPitchBank;

	_velocityX = (((getPosASL _target) select 0) - ((getPosASL _missile) select 0)) / _travelTime;
	_velocityY = (((getPosASL _target) select 1) - ((getPosASL _missile) select 1)) / _travelTime;
	_velocityZ = (((getPosASL _target) select 2) + 0.5 - ((getPosASL _missile) select 2)) / _travelTime;

[_velocityX, _velocityY, _velocityZ]
};

call _homeMissile;

//missile flying
while {(_missile distance _missileStart) <= (_target distance _missileStart)} do {
_velocityForCheck = call _homeMissile;
if ({(typeName _x) == (typeName 0)} count _velocityForCheck == 3) then {_missile setVelocity _velocityForCheck};
sleep (1 / _perSecondChecks)
};

waitUntil {(_missile distance _missileStart) > (_target distance _missileStart) || !(alive _missile)};
if (alive _missile) then {
while {alive _missile} do {
	_missile setPos position _target;
	_missile setDir (direction _target);
	sleep 0.01
}
};

[color="Blue"]// ----- mission-specific!!!
_primaryTarget setHit ["mala vrtule", 1];
// ----- end of mission-specific[/color]

deleteVehicle _secondaryTarget;

Execute it from somewhere with that first bold line

[Targetname, [(markerPos "missileStart") select 0, (markerPos "missileStart") select 1, 5], "M_Igla_AA", 500, position someObject] execVM "launchMissile.sqf";

obviously substituting the object and marker names for your own.

The ----- mission-specific!!! part at the bottom just destroys the target's tail rotor if it is a chopper.

Only call it from the radio or addAction????

I want it to work by setteing an latancy trigger,What could I do ?

Share this post


Link to post
Share on other sites

well you can create a trigger and put execVM "launchmissile.sqf" in the on activation screen, and you can than make a script that checks the altitude and execute that in the condition field

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
Sign in to follow this  

×