Jump to content

Recommended Posts

Hello everyone.. I was trying to test something since I got down by A.A vehicles and units all the time when I'm in the chopper, so... I was thiking about 2 things..
1 -  I was trying to make a "script" that if a locked-on missile is fired, then it loses its target immediately after CM is launched. But I can't get it work...
can anyone tell me what is wrong with this code?

vehicle player addEventHandler ["IncomingMissile", {
"cmImmunity = 0"; }];
];

 

2 - since I didn't get the first one to work I manage to do this script below. I learned that when you CM in the exact moment a missile is fired, you can avoid them. but this code doesnt work either..

this addEventHandler ["IncomingMissile", {params ["_target", "_ammo", "_vehicle", "_instigator"];[_target, "240Rnd_CMFlareMagazine"] call BIS_fnc_fire;}]];

 

 

I know there are briliants minds here.. and I hope you guys could help me.

 

Thanks in advance.

Share this post


Link to post
Share on other sites

Welcome on forum.
The first code has no sense.
Remove the last ] (no need to double it).
then ,theEH will fire. Just code hint str _target  for checking it.

So, the last point is the BIS_fnc_fire. Always read BIKI. 2nd parameter is a muzzle, not a magazine. So, here you need to use something like "SmokeLauncher" for a Marshall or "CMFlareLauncher" for a Blackfoot.
Finding the right weapon/muzzle can be difficult. Two methods:


1 - use weaponsTurret command. Usually commander is at turret [0,0], so ((_target weaponsTurret [0,0]) #0) should return the launcher for vehicle without MG on commander seat, use #1 if any MG ;

you can check that on console watch lines with a named (or player) vehicle.

2 - or, open the config viewer on the vehicle class: right click on vehicle in editor: find in config viewer.
Then, in left column double click to this path: configfile >> "CfgVehicles" >> "B_APC_Wheeled_01_cannon_F" >> "Turrets" >> "MainTurret" >> "Turrets" >> "CommanderOptics" >> "weapons" (example for the Marshal)

  • Like 3

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

Welcome on forum.
The first code has no sense.
Remove the last ] (no need to double it).
then ,theEH will fire. Just code hint str _target  for checking it.

So, the last point is the BIS_fnc_fire. Always read BIKI. 2nd parameter is a muzzle, not a magazine. So, here you need to use something like "SmokeLauncher" for a Marshall or "CMFlareLauncher" for a Blackfoot.
Finding the right weapon/muzzle can be difficult. Two methods:


1 - use weaponsTurret command. Usually commander is at turret [0,0], so ((_target weaponsTurret [0,0]) #0) should return the launcher for vehicle without MG on commander seat, use #1 if any MG ;

you can check that on console watch lines with a named (or player) vehicle.

2 - or, open the config viewer on the vehicle class: right click on vehicle in editor: find in config viewer.
Then, in left column double click to this path: configfile >> "CfgVehicles" >> "B_APC_Wheeled_01_cannon_F" >> "Turrets" >> "MainTurret" >> "Turrets" >> "CommanderOptics" >> "weapons" (example for the Marshal)

First, thank you for the fast responde.. I wasn't expecting that... thank you for welcoming me too.

 

now, as for the code.. what you mean by no sense? does it mean that the code will lead to nowhere as it is? I was trying to make something like IF something happen, then do this. I know i'm newbie with this, but I will look into it later on.

 

About the cmimunnity, do you think it is possible to apply it into the code? 

 

I'm at work right now, I will test some of these tips later.

Share this post


Link to post
Share on other sites

{ } in EH means you need to apply a workable code (from simple {TRUE} to elaborated code with functions and commands).

"cmImmunity = 0" is a non-workable string,... (which could be also the stringyfied code to be compiled then called).

cmImmunity is perhaps one of your own variable... but I doubt. So, where does that come from?

Share this post


Link to post
Share on other sites
4 minutes ago, pierremgi said:

{ } in EH means you need to apply a workable code (from simple {TRUE} to elaborated code with functions and commands).

"cmImmunity = 0" is a non-workable string,... (which could be also the stringyfied code to be compiled then called).

cmImmunity is perhaps one of your own variable... but I doubt. So, where does that come from?

It came from here: https://community.bistudio.com/wiki/Arma_3:_Targeting_config_reference

Share this post


Link to post
Share on other sites

I mean I can't test right now but... what would you say about this then: This code is meant to be the countermeasure fired after incomingmissile EH

 

player addEventhandler ["IncomingMissile",
{
    _target = (_this player);
    _ammo = _magazinesAmmo "TITAN_AA" unit;
    _vehicle = (_this unit); 
    _instigator = (_this unit); 

if (_target = player) then
{
    player fire ["240Rnd_CMFlareMagazine"];
};

}]; 

 

I'd like to point out that i'm still learning hehe.

Share this post


Link to post
Share on other sites

Yep, it's a token in a config reference, so you can't modify it as a simple variable... And there is neither command nor function setting this behavior.

But you can try something:

 

deleting the missile:

this engineOn TRUE; // just for test

this addEventHandler ["IncomingMissile", {params ["_target", "_ammo", "_vehicle", "_instigator"]; [_target, "smokeLauncher"] call BIS_fnc_fire; deleteVehicle (getpos _vehicle nearestObject _ammo) }];

 

Or perhaps more realistic, divert the missile, creating a new target:

this engineOn TRUE; // just for test;
 

this addEventHandler ["IncomingMissile", {
  params ["_target", "_ammo", "_vehicle", "_instigator"];
  [_target, "smokeLauncher"] call BIS_fnc_fire;
  private _newTarget = createVehicle ["laserTargetE",getpos _target vectorAdd [0,0,5],[],0,"can_collide"];
  (getpos _vehicle nearestObject _ammo) setMissileTarget _newTarget;
}];

 

This new target must be:

- inside the targeting cone of the missile. If not... bam!

- of the right (same) side of the target. Here I simplified for creating an "enemy" target to EAST, so a "laserTargetE" (which is BLUFOR).

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites

Oh my god.. I will test this..

 

I just put this out on editor:

 

player addEventhandler ["IncomingMissile", 
 { 
    _target = (_this select 0); 
    _ammo = (_unit ammo "TITAN_AA");
    _vehicle = (_unit); 
    _instigator = (_unit); 

if (_target == unit) then
 { 
player forceWeaponFire ["240Rnd_CMFlareMagazine", "Burst"]}; 
 
}];

 

 

it t didn't give me any error but it wont work either.. 

 

But I will try yours ASAP to see how it goes.

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

Yep, it's a token in a config reference, so you can't modify it as a simple variable... And there is neither command nor function setting this behavior.

But you can try something:

 

deleting the missile:

this engineOn TRUE; // just for test

this addEventHandler ["IncomingMissile", {params ["_target", "_ammo", "_vehicle", "_instigator"]; [_target, "smokeLauncher"] call BIS_fnc_fire; deleteVehicle (getpos _vehicle nearestObject _ammo) }];

 

Or perhaps more realistic, divert the missile, creating a new target:

this engineOn TRUE; // just for test;
 


this addEventHandler ["IncomingMissile", {
  params ["_target", "_ammo", "_vehicle", "_instigator"];
  [_target, "smokeLauncher"] call BIS_fnc_fire;
  private _newTarget = createVehicle ["laserTargetE",getpos _target vectorAdd [0,0,5],[],0,"can_collide"];
  (getpos _vehicle nearestObject _ammo) setMissileTarget _newTarget;
}];

 

This new target must be:

- inside the targeting cone of the missile. If not... bam!

- of the right (same) side of the target. Here I simplified for creating an "enemy" target to EAST, so a "laserTargetE" (which is BLUFOR).

Have fun!

Those codes didn't work... 

 

I managed to do this:

 

player addEventhandler ["IncomingMissile",

params ["_target", "_ammo", "_vehicle", "_instigator"];

 {
   _target = (_this select 0);
   _ammo = (_unit ammo "TITAN_AA");

   _vehicle = (_unit);
   _instigator = (_unit);
 
if (_target == unit) then

  {
   player forceWeaponFire [blackfoot, "CMFlareLauncher"] call BIS_fnc_fire;
 
}]
 

no joy =(

Share this post


Link to post
Share on other sites

The codes I gave you work, but there are examples for Marshall as target (with crew of course because bis_fnc_fire doesn't work if no one can fire) and a red helo like  Kajman or Orca...  able to fire guided rockets or missiles, not too close.

For Titans from Kamish.. some added lines cound help, like:  _target setVehicleTIPars [0,0,0];   for setting low IR signature momentarily.
something like:

Spoiler



this addEventHandler ["IncomingMissile", {  
  params ["_target", "_ammo", "_vehicle"];
  [_target, "smokeLauncher"] call BIS_fnc_fire;
  private _newTarget = createVehicle ["laserTargetE",getpos _target vectorAdd [0,0,5],[],0,"can_collide"];
  private _missile = (getpos _vehicle nearestObject _ammo);
  _target setVehicleTIPars [0,0,0];
  _missile setMissileTarget _newTarget;
  [_missile,_target,_newTarget] spawn {
    params ["_missile","_target","_newTarget"];
    while {!isNull _missile && alive _target} do {
      if (_missile distance _target < 15) then {deleteVehicle _missile};
    };
    deleteVehicle _newTarget;
  };
}];


 

You have to adapt them with the launcher, the sides....

 

And, you have to read the basics before writing any line on your own.
First variables and "magic" variables,
Second syntax for any command or functions,

third, basic coding (in SP).

Share this post


Link to post
Share on other sites
On 8/27/2021 at 10:26 PM, pierremgi said:

The codes I gave you work, but there are examples for Marshall as target (with crew of course because bis_fnc_fire doesn't work if no one can fire) and a red helo like  Kajman or Orca...  able to fire guided rockets or missiles, not too close.

For Titans from Kamish.. some added lines cound help, like:  _target setVehicleTIPars [0,0,0];   for setting low IR signature momentarily.
something like:

  Reveal hidden contents

 



this addEventHandler ["IncomingMissile", {  
  params ["_target", "_ammo", "_vehicle"];
  [_target, "smokeLauncher"] call BIS_fnc_fire;
  private _newTarget = createVehicle ["laserTargetE",getpos _target vectorAdd [0,0,5],[],0,"can_collide"];
  private _missile = (getpos _vehicle nearestObject _ammo);
  _target setVehicleTIPars [0,0,0];
  _missile setMissileTarget _newTarget;
  [_missile,_target,_newTarget] spawn {
    params ["_missile","_target","_newTarget"];
    while {!isNull _missile && alive _target} do {
      if (_missile distance _target < 15) then {deleteVehicle _missile};
    };
    deleteVehicle _newTarget;
  };
}];

 

 

 

 

You have to adapt them with the launcher, the sides....

 

And, you have to read the basics before writing any line on your own.
First variables and "magic" variables,
Second syntax for any command or functions,

third, basic coding (in SP).

 

Well I did read the stuff.. but still I couldn't get the script to work...thanks a lot for your effort in order to help me. 

 

One of the codes did work (the one that delete the missile, but it only worked in SP).

 

Admins can close this thread.

Share this post


Link to post
Share on other sites

Pierre, how are you? I managed to get the first code to work, and its working fine...

 

as you said, to be more realistic it is important to just divert the missile with a new target... about creating a new target...

"this addEventHandler ["IncomingMissile", { params ["_target", "_ammo", "_vehicle", "_instigator"]; [_target, "smokeLauncher"] call BIS_fnc_fire; private _newTarget = createVehicle ["laserTargetE",getpos _target vectorAdd [0,0,5],[],0,"can_collide"]; (getpos _vehicle nearestObject _ammo) setMissileTarget _newTarget; }];"
Can you help me with that too?

 

This new target must be:

- inside the targeting cone of the missile. If not... bam!   --- How can I know the "cone"? 

- of the right (same) side of the target. Here I simplified for creating an "enemy" target to EAST, so a "laserTargetE" (which is BLUFOR). --- How can I set to any side to work? Can we try independent, opfor and blufor in the same code? Can you makeout a script that the missile - when fired - is always to the wrong direction?

Share this post


Link to post
Share on other sites
7 hours ago, PH CWB said:

- inside the targeting cone of the missile. If not... bam!   --- How can I know the "cone"? 

 

Perhaps waiting for v 2.06 and future getSensorTargets ... No other clue on my side.
 

 

7 hours ago, PH CWB said:

- of the right (same) side of the target. Here I simplified for creating an "enemy" target to EAST, so a "laserTargetE" (which is BLUFOR). --- How can I set to any side to work? Can we try independent, opfor and blufor in the same code? Can you makeout a script that the missile - when fired - is always to the wrong direction?

 

["laserTargetE","laserTargetW"] select (side _target getFriend WEST < 0.6)

 

  • Like 1

Share this post


Link to post
Share on other sites
23 hours ago, pierremgi said:

Perhaps waiting for v 2.06 and future getSensorTargets ... No other clue on my side.
 

 

 


["laserTargetE","laserTargetW"] select (side _target getFriend WEST < 0.6)

Pierre, thank you for your time.

I used this code and it works but it still gives me an error:

vehicle player addEventHandler ["IncomingMissile", { 
  params ["_target", "_ammo", "_vehicle", "_instigator"]; 
  [_target, "smokeLauncher"] call BIS_fnc_fire; 
  private _newTarget = createVehicle ["laserTargetE","laserTargetW",getpos _target vectorAdd [0,0,5],[],0,"can_collide"]; 
  (getpos _vehicle nearestObject _ammo) setMissileTarget _newTarget; 
}];

 

Quote

'...] BIS_fnc_fire;
 private _newTarget = |#|createVehicle ["laserTargetE, "laserT...'
Error 6 elements provided, 5 expected.

 

Any clues?

Share this post


Link to post
Share on other sites

createVehicle ["laserTargetE","laserTargetW",getpos _target vectorAdd [0,0,5],[],0,"can_collide"];  ?????

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

createVehicle ["laserTargetE","laserTargetW",getpos _target vectorAdd [0,0,5],[],0,"can_collide"];  ?????

Oh. I get it. 

I removed the laserTargetW... but it wont work.. when I get the two, it work.

But anyway, this works offline, but when my friend plays with me, he shoot and the missile didn't divert..

 

any clue?

Share this post


Link to post
Share on other sites
if (isServer) then {
this addEventHandler ["IncomingMissile", {
    params ["_target", "_ammo", "_vehicle"];
    [_target, "smokeLauncher"] call BIS_fnc_fire;
    private _newTarget = createVehicle [["laserTargetE","laserTargetW"] select (side _target getFriend WEST < 0.6),getpos _target vectorAdd [0,0,5],[],0,"can_collide"];
    private _missile = (getpos _vehicle nearestObject _ammo);
    [_target, [0,0,0]] remoteExec ["setVehicleTIPars",0];
    _missile setMissileTarget _newTarget;
    [_missile,_target,_newTarget] spawn {
        params ["_missile","_target","_newTarget"];
    while {!isNull _missile && alive _target} do {
            if (_missile distance _target < 15) then {deleteVehicle _missile};
        };
        deleteVehicle _newTarget;
    };
}];
};

Place it in any vehicle init field (the vehicles you want to protect). NOT TESTED (no time for that).

  • Like 1

Share this post


Link to post
Share on other sites
On 10/6/2021 at 12:07 AM, pierremgi said:

if (isServer) then {
this addEventHandler ["IncomingMissile", {
    params ["_target", "_ammo", "_vehicle"];
    [_target, "smokeLauncher"] call BIS_fnc_fire;
    private _newTarget = createVehicle [["laserTargetE","laserTargetW"] select (side _target getFriend WEST < 0.6),getpos _target vectorAdd [0,0,5],[],0,"can_collide"];
    private _missile = (getpos _vehicle nearestObject _ammo);
    [_target, [0,0,0]] remoteExec ["setVehicleTIPars",0];
    _missile setMissileTarget _newTarget;
    [_missile,_target,_newTarget] spawn {
        params ["_missile","_target","_newTarget"];
    while {!isNull _missile && alive _target} do {
            if (_missile distance _target < 15) then {deleteVehicle _missile};
        };
        deleteVehicle _newTarget;
    };
}];
};

Place it in any vehicle init field (the vehicles you want to protect). NOT TESTED (no time for that).

 

Hello Pierre, sorry for the delay my friend.. job was crazy hehe..

 

I tested it right now and it works offline like a charm... incredible what you can do with scripts...  but when I open my server to my friend to join, it wont work... 

Share this post


Link to post
Share on other sites

you can test it without if (isServer) then {...};  but I'm not sure that can tweak the EH. incomingMissile in supposed to be GA (global argument) and the code inside is EG (effet global). So? no clue. I can test in MP now.  Perhaps the shooter is too close from the target?

Share this post


Link to post
Share on other sites
On 10/9/2021 at 12:10 PM, pierremgi said:

you can test it without if (isServer) then {...};  but I'm not sure that can tweak the EH. incomingMissile in supposed to be GA (global argument) and the code inside is EG (effet global). So? no clue. I can test in MP now.  Perhaps the shooter is too close from the target?

 

Hey Pierre, how are you? Sorry for the delay.. 

 

I want you to know that it worked perfectly.

 

Thank you so much for your help. You're an amazing person.

 

  • Like 1

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

×