Jump to content
Sign in to follow this  

Recommended Posts

Hi I'm trying to find a script I can use to allow AI placed artillery to fire at an assigned target with parameters such as fire delay, disable auto-aim, move etc,. The script needs to work with the Iron Front artillery pieces. So far I have found and slightly modified a script by fatty that does what I want. The problem is the shells land some 700 meters short of the assigned Eden targets. I've moved the artillery targets further back and even changed the height of the targets.  I also tried changing the targets from the invisible helipad to an invisible car and even tried game logics. The AI fired shells seem to land at the same short distance. The tested artillery piece I used is both the 10.5cm and Flak 36 guns. I'm at a loss to try and debug the issue. I also tried increasing the skill of the AI gunner and no dice. I even tried going into one of the guns myself while using the artillery computer and I couldn't even get the shells to land near the target area.

Does anyone have any ideas on how to get reasonably accurate gun fire that works with the Iron Front artillery?

 

Share this post


Link to post
Share on other sites
params ["_arty", "_pos"];
_arty setVehicleAmmo 1;
private _amount = _arty ammo (currentWeapon _arty);
private _shotsFired = floor (random _amount);
if (_shotsFired < 3) then {
	_shotsFired = 3;
};
private _ammo = (getArtilleryAmmo [_arty] select 0);
private _smokePos = [_pos select 0, _pos select 1, ((_pos select 2) + 10)];
private _redSmoke = createVehicle ["SmokeShellRed", _smokePos, [], 10, "NONE"];
_arty commandArtilleryFire [_pos, _ammo, _shotsFired];

This is the code I use to call arty in (it also creates a red smoke grenade on the position it's going to fire), you can probably tweak it a bit. 

  • Like 4

Share this post


Link to post
Share on other sites

Thanks Stan. I'm trying to make sense of this code snippet but my scripting knowledge isn't that great. I don't understand what line 5-6 does. I believe I understand the rest of the code. Line 9 is setting up a position with 10 meters added to the Z coordinate? Line 10 - I don't understand this part [], 10, "NONE"] Position offset on the Y axis by 10 meters?

 

I'm not understanding how the artillery unit is getting its target information from. You said this was a radio call? How could I tweak this so the AI fires at a set position and most accurately?

 

 

Share this post


Link to post
Share on other sites

This script takes 2 parameters, _arty, the actual artillery vehicle and _pos, the position it's meant to fire at.

private _shotsFired = floor (random _amount);
if (_shotsFired < 3) then {
	_shotsFired = 3;
};

This part determines how many shots will be fired.  It's going to be a random number between the maximum amount of shells the arty has and 3.  The if statement is this lower limit of 3.

22 hours ago, stanhope said:

private _smokePos = [_pos select 0, _pos select 1, ((_pos select 2) + 10)];

private _redSmoke = createVehicle ["SmokeShellRed", _smokePos, [], 10, "NONE"];

These 2 lines create a smoke grenade 10 meters above the position the arty will be firing at (this is done by the first line) and in a radius of 10 meters around this position.  Check the syntax out here: https://community.bistudio.com/wiki/createVehicle

2 hours ago, crp19851 said:

You said this was a radio call?

Not a radio call no, a function call.  You can either make this a proper function or put this code into a variable and call it that way.  In case you don't know how to do that:

In initserver.sqf put the following:

artyCode = {
  params ["_arty", "_pos"];
  _arty setVehicleAmmo 1;
  private _amount = _arty ammo (currentWeapon _arty);
  private _shotsFired = floor (random _amount);
  if (_shotsFired < 3) then {
      _shotsFired = 3;
  };
  private _ammo = (getArtilleryAmmo [_arty] select 0);
  private _smokePos = [_pos select 0, _pos select 1, ((_pos select 2) + 10)];
  private _redSmoke = createVehicle ["SmokeShellRed", _smokePos, [], 10, "NONE"];
  _arty commandArtilleryFire [_pos, _ammo, _shotsFired];
};

And whenever you want to target a given position with a given arty piece use:

[_arty, _pos] spawn artyCode

Be sure to either replace _arty and _pos with the right variables or to define them wherever you call it from.

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  

×