Jump to content
Sign in to follow this  
sathanas

Tank Script Problem

Recommended Posts

Hi, I would like to ask help with this old topic about "ENHANCED TANK TURRET" script:


http://www.armaholic.com/page.php?id=31416

 

Script works and my tank blows the enemy infantry into thy kingdom come with main cannon using HE rounds,
but for some reason when it meets enemy tank in battlefield at the same time with enemy infantry, one or the other (my tank or enemy tank ) 
won't engage to a another tank. Can it be that AI gets confused which rounds it should use HE or APFSDS when there is infantry and armored targets at the same time, and does anybody have any ideas how this could be fixed? And also looks like when two tanks confront each other ( without any infantry targets) only the other one of tanks attack and second one gets stuck and just waits to be annihilated. I am not very good at scripting, but long time friend of Arma games so is this even correct if I put this "ENHANCED TANK TURRET" script into the init.sqf file or should I put it somewhere else?

  • Like 1

Share this post


Link to post
Share on other sites

No problem with init.sqf or even trigger set to condition: true.

I can't reproduce the problem so far. If some remaining AT ammo, the tank will shift on this ammo if any incoming enemy armored.

l have a two line correction for some big mod adapt (roughly when hmg or canon is undefined). Nothing for your problem but could you confirm me if you're playing with some mods?

This script allows to shift for some anti-infantry ammo IF the nearest enemy is infantry.

This script doesn't decide some priority for targets. This is the work of Arma's engine.

l will test some scenarios again and try to modify some lines if I can.

I'm not at home right now. I can't go deeper in my script right now.

Share this post


Link to post
Share on other sites

To be tested.


 

Spoiler



    {
      _x spawn {
        _tk = _this;
        _tgt = objNull;
        _even = 0;
        _wpnTrt = _tk weaponsTurret [0];
        _cannon = (_wpnTrt select {getText (configfile >> "CfgWeapons" >> _x >> "nameSound") == "cannon"}) select 0;
        _MG = (_wpnTrt select {getText (configfile >> "CfgWeapons" >> _x >> "nameSound") == "mgun"}) select 0;
        if (isNil "_MG") then {_MG = ""};
        if (isnil "_cannon") then {_cannon = ""};
        while {alive gunner _tk} do {
          _even = (_even + 1) mod 2;
          if (!isNull (assignedTarget gunner _tk)) then {
            _tgt = assignedTarget gunner _tk;
            call {
              if (_tgt isKindOf "CAMAnBase" && _MG != "" && _even == 0) exitWith {
                _tk selectWeaponTurret [_MG,[0]];
              };
              _tk selectWeaponTurret [_Cannon,[0]];
            };
            _ammos = magazinesAmmo _tk apply {_x pushBack ((getText (configfile >> "CfgAmmo" >> (getText (configfile >> "CfgMagazines" >> _x select 0 >> "ammo")) >> "aiAmmoUsageFlags")) splitString " + ");_x};
            _ammos = _ammos  select {_x select 1 > 0};
            {
              _type = _x select 0;
              _ammoType = _x select 1;
              if (_tgt isKindOf _type) exitWith {
                if (_cannon != "" && {_even == 1 or !(_tgt isKindOf "CAManBase")}) exitWith {
                  if !(_ammoType in (getText (configfile >> "CfgAmmo" >> (getText (configfile >> "CfgMagazines" >> _tk currentMagazineTurret [0] >> "ammo")) >> "aiAmmoUsageFlags") splitString " + ")) then {
                    for "_i" from 0 to count _ammos -1 do {
                      if (_ammoType in (_ammos  select _i select 2)) exitWith {
                        _tk loadMagazine [[0],_cannon,_ammos select _i select 0]
                      };
                    };
                  };
                };
                if (_MG != "" && {_even == 0 && (_tgt isKindOf "CAManBase")}) exitWith {
                  if !(_ammoType in (getText (configfile >> "CfgAmmo" >> (getText (configfile >> "CfgMagazines" >> _tk currentMagazineTurret [0] >> "ammo")) >> "aiAmmoUsageFlags") splitString " + ")) then {
                    for "_i" from 0 to count _ammos -1 do {
                      if (_ammoType in (_ammos  select _i select 2)) exitWith {
                        _tk loadMagazine [[0],_MG,_ammos select _i select 0]
                      };
                    };
                  };
                };
              };
              true
            } count [["tank","512"],["air","256"],["landVehicle","128"],["CAManBase","64"]];
          };
          uisleep 0.2;
        }
      }
    } forEach (vehicles select {_x isKindOf "tank"})


 

 

Share this post


Link to post
Share on other sites

I have RHS and CUP mods and JSRS-sound mod, nothing much more

 

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  

×