Jump to content
majorexperimental

Restrict AT-wepons at trigger event (alternatively restrict lock-on)

Recommended Posts

In a mission I build there are assault and attack boats coming from the sea attacking a village and to make it a challenging to fight these boats I wish to restrict the use of AT-weapons only under that phase. To achieve that I have already applied a smoke screen (using smoke modules) but the AT-weapons have no problems to get lock-ons trough the smoke. (The absolute coolest thing would be if the smoke screen in itself could stop AT-look-on's but I guess that's not possible.)

A perhaps cooler alternative would be if AT-weapons cant get a lock-on on the boats at all on whole mission.

Thanks in advance for any ideas!




 

Share this post


Link to post
Share on other sites

i dont think that it is possible to change the lock. i would just delete the fired bullets with an fired event handler and would give a message like "blind shell" to the player.

alternatively u could manipulate the rockets flight path in a way that it will not hit.

Share this post


Link to post
Share on other sites

i dont think that it is possible to change the lock. i would just delete the fired bullets with an fired event handler and would give a message like "blind shell" to the player.

alternatively u could manipulate the rockets flight path in a way that it will not hit.

 

Seems like really good ideas! I'm not a coder; can you give me a hint how to do those things you suggest?

Share this post


Link to post
Share on other sites

You could simply remove all the units that have AT weapons from the mission, or replace them with basic rifleman.

Share this post


Link to post
Share on other sites

okay, it will be hard without any scripting knowledge but we can try it.

u need to create a file in ur mission folder and name it delete_rockets.sqf

Its content should be this:

/*
 Description: adds a fired event handler (EH) and checks the fired bullet. if its a rocket/missile it will be deleted.

 Return value: the index of the EH which is needed to remove the EH if not needed anymore
*/

private ["_index"];

_index = player addEventHandler ["Fired",
{
 private ["_rocket", "_air_friction"];

 _rocket = _this select 6;
 _air_friction = getNumber(configFile >> "CfgAmmo" >> (typeOf _rocket) >> "airFriction");

// air friction of self propelled bullets has positiv value (only tested with vanilla)
 if(_air_friction > 0) then
 {
  deleteVehicle _rocket;
 };
}];

_index
In your init.sqf u add this:
if(hasInterface) then
{
 fnc_delete_rockets = compileFinal preprocessFile "delete_rockets.sqf";
};
Now u have the tools what u have to do now is to set up some triggers. I do more scripting than designing missions therefore triggers r not my specialty.

but what u have to do in the trigger which fires when AT-rockets should not be allowed is:

global_eh_index = [] call fnc_delete_rockets;
in the trigger which should fire if the AT rockets shall be allowed again u ve to do this:

player removeEventHandler["Fired", global_eh_index];

Share this post


Link to post
Share on other sites

okay, it will be hard without any scripting knowledge but we can try it.

u need to create a file in ur mission folder and name it delete_rockets.sqf

Its content should be this:

/*
 Description: adds a fired event handler (EH) and checks the fired bullet. if its a rocket/missile it will be deleted.

 Return value: the index of the EH which is needed to remove the EH if not needed anymore
*/

private ["_index"];

_index = player addEventHandler ["Fired",
{
 private ["_rocket", "_air_friction"];

 _rocket = _this select 6;
 _air_friction = getNumber(configFile >> "CfgAmmo" >> (typeOf _rocket) >> "airFriction");

// air friction of self propelled bullets has positiv value (only tested with vanilla)
 if(_air_friction > 0) then
 {
  deleteVehicle _rocket;
 };
}];

_index
In your init.sqf u add this:
if(hasInterface) then
{
 fnc_delete_rockets = compileFinal preprocessFile "delete_rockets.sqf";
};
Now u have the tools what u have to do now is to set up some triggers. I do more scripting than designing missions therefore triggers r not my specialty.

but what u have to do in the trigger which fires when AT-rockets should not be allowed is:

global_eh_index = [] call fnc_delete_rockets;
in the trigger which should fire if the AT rockets shall be allowed again u ve to do this:

player removeEventHandler["Fired", global_eh_index];

 

 

Thanks sarogahtyp! I tested it and think I got all code right but got his error message and no rockets removed. Any idea?

 

'player |#|removeEventhandler["Fired", global_eh_in...'

Error Type Amy, expected Number

 

Share this post


Link to post
Share on other sites

u should show more of what u did and the error from rpt file.

Share this post


Link to post
Share on other sites

Hi

i think the easiest way to restrict AT Missile=delete missile from EventHandler "Firedman"  by

running loop which will try to detect distance between boat&AT missile and if the distance become smal enough to looks like the missile  has been "Intercepeted",

create a explosion effect&delete the missile.

below is written in the OnPlayerRespawn.sqf . this runs for Mortor or Hozwitter with possibility of 60%,change the "(getmarkerpos "RT")" with your boat's name and ammo's classname and specific distance

(this case,800m)and loop interval and the possibility.you sholud may delete the possibility (random 100<60) to completely restrict the AT Missile(I think Arma's Anti-Tank/Arty is too much over powered,it just ruins the game balance)

 

player addEventHandler ["FiredMan", {
 params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
    if ( (("Sh_82mm_AMOS"==_this select 4)or("Sh_155mm_AMOS"==_this select 4))&&(random 100 < 60) )then
    {
               [_projectile]spawn{params["_projectile"];while{( (getmarkerpos "RT") distance _projectile)>800 }do
     {sleep 0.5;};
    "helicopterexplobig" createvehicle (getpos _Projectile);private _bm="IEDUrbanBig_Remote_Ammo" createvehicle[0,0,0];_bm setpos(getpos _Projectile);_bm setdamage 1;deletevehicle _Projectile;};
    };
}];

 

Second way is actually intercept the missile.write this in the OnPlayerRespawn.sqf

change the classname of ammo'sname/possibility. remove "(random 100 < 50)" to make the fired missile intercepted certainly.

Changing Intercepting missile(Scalpel) or dummy vehicle(Boat_transport) or ProtectionZone will make this wont work correctly.

Changing Scalpel:Wont intercept the fired missile well,Changing dummy vehicle:wont become transparent well,Changing ProtectionZone:it wont be able to looks like "missile has been intercepeted".

 

player addEventHandler ["FiredMan", {
 params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
  if ( (("M_NLAW_AT_F"==_this select 4)or("M_Titan_AT"==_this select 4)or("M_PG_AT"==_this select 4)or("Missile_AGM_02_F"==_this select 4)or("M_Scalpel_AT"==_this select 4)or("M_AT"==_this select 4)) &&(random 100 < 50) )then
  {
     private _teki=missileTarget _projectile;
     private _g1="M_Scalpel_AT" createvehicle [0,0,0];
     private _ang=getdir _unit;
     _g1 setdir (_ang-180);
     _g1 setpos [getpos _teki select 0,getpos _teki select 1,(getpos _teki select 2)+12];
     private _kabe="ProtectionZone_Invisible_F" createvehicle [0,0,0];
     _kabe attachto[_g1,[0,9,0]];
     _kabe setObjectScale random[0.1,0.2,0.3];
     private _caf="CMflare_Chaff_Ammo" createvehicle [0,0,0];
     _caf attachto[_g1,[0,0,0]];
     private _dmy="B_Boat_Transport_01_F" createvehicle [0,0,0];
     _dmy setObjectTextureGlobal [0, ""];
     _dmy setVehicleTIPars [1, 1, 1];
     _dmy attachto[_projectile,[0,5,0]];
     _g1 reveal _dmy;_g1 setMissileTarget _dmy;

      [_projectile,_teki,_dmy,_g1,_kabe]spawn{params["_projectile","_teki","_dmy","_g1","_kabe"];while{alive _projectile}do
      {sleep 0.5;_g1 setMissileTarget _dmy;};
     "helicopterexplobig" createvehicle (getpos _kabe);private _bm="IEDUrbanBig_Remote_Ammo" createvehicle[0,0,0];_bm setpos(getpos _kabe);_bm setdamage 1;deletevehicle _kabe;deletevehicle _dmy;
      };
   }
}];

 

lastly,the way to restricting MLRS.

 

player addEventHandler ["FiredMan", {
     params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
        if( ("R_230mm_HE"==_this select 4)&&(random 100 < 60) )then
        {
          _projectile addEventHandler ["SubmunitionCreated", {
          params ["_projectile", "_submunitionProjectile", "_pos", "_velocity"];
          "helicopterexplobig" createvehicle (getpos _submunitionProjectile);private _bm="IEDUrbanBig_Remote_Ammo" createvehicle[0,0,0];_bm setpos(getpos _submunitionProjectile);_bm setdamage 1;
          deletevehicle _submunitionProjectile;
          }];
        };
}];

 

I dont know if those are grammarly correct,but they are working in my server(I think they are not eating Server's CPU so much)

I hope this helps

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

×