Jump to content

Recommended Posts

Hi folks, could someone please help me with this. I had it working last year but now today I tried to create a mission with it & I cant get it to work.

Basically what it does is force an enemy MG gunner to hit a target (a can) when the player walks into a trigger. Ive set the distance the same as last year within the editor but for some reason I cant get it to work. Incase I'm asked, yes I have placed the SQF file in the mission folder. The code has been placed in the trigger that's activated by the player & the enemy have been named MG & MG2.

 

expActiv="0 = [MG, target1,30,100,3] execVM ""shootingInf.sqf""; ;this addeventhandler [""fired"", {(_this select 0) setvehicleammo 1}]; 0 = [MG2, target1,30,100,3,] execVM ""shootingInf.sqf""; ;this addeventhandler [""fired"", {(_this select 0) setvehicleammo 1}];";

 

 

This is the original SQF info:

 

_soldier = _this select 0;
_target = _this select 1;
_min = _this select 2;
_max = _this select 3;
_pause = _this select 4;
_weapon = _this select 5;


/* Customization for infantry - uses soldier, soldier
use: 0 = [soldier, target, min bullets per round, max bullets per round, pause between rounds
example includes shooting from primary weapon
0 = [unit, target,7,10,8] execVM "shootingInf.sqf";

All infantry shooting can be ordered to stop by calling Radio
Alpha (0-0-1).
*/
stoporder = false;
while {!stoporder} do {
_i = Ceil(random _max);
if (_i < _min) then {_i =_min};

while {_i >= 1} do {
_i = _i - 1;
_soldier doTarget _target;
sleep 0.15;
logic action ["useWeapon", _soldier, _soldier, _weapon];
};


sleep _pause;
};

 

Thanks for any help guys.

 

Share this post


Link to post
Share on other sites

are you sure this logic action useweapon stuff works?

 

I would use fire/dofire/fireattarget instead, IMO more reliable

Share this post


Link to post
Share on other sites
12 minutes ago, fn_Quiksilver said:

are you sure this logic action useweapon stuff works?

 

I would use fire/dofire/fireattarget instead, IMO more reliable

I'm not sure mate as I'm not a coder. I was frustrated when I couldn't get the enemy AI to fire at the players squad at proper effective fire distances last year & some kind person had given me this script & back then it worked. I then left arma for a while & now I want to get back into making missions I needed this to work but its now not working & I was hoping that someone with experience would maybe amend it so I could get the AI to fire the weapon as per the script.

Share this post


Link to post
Share on other sites

just brainstorming, i have no idea how to use triggers though, i am focusing on the 'UseWeapon' line

 

try one of these

 

// replace this
logic action ["useWeapon", _soldier, _soldier, _weapon];

// with one of these
_soldier doSuppressiveFire _target;

_soldier fire (currentWeapon _soldier);

_soldier forceWeaponFire [ currentWeapon _soldier,"single"];

 

Share this post


Link to post
Share on other sites
21 minutes ago, fn_Quiksilver said:

just brainstorming, i have no idea how to use triggers though, i am focusing on the 'UseWeapon' line

 

try one of these

 


// replace this
logic action ["useWeapon", _soldier, _soldier, _weapon];

// with one of these
_soldier doSuppressiveFire _target;

_soldier fire (currentWeapon _soldier);

_soldier forceWeaponFire [ currentWeapon _soldier,"single"];

 

Ive tried all three mate & nothing.

Just to confirm what ive done:

created 2 enemy MG's about 1.5ks away on a hill. Named them MG & MG2. Placed the can on the ground & called it target1. Created a trigger to call the .SQF once the player enters it.

It used to work as: player enters trigger, trigger calls script & then both gunners open up at the can.

 

This is whats put in the activation part of the trigger:

 

expActiv="0 = [MG, target1,30,100,3] execVM ""shootingInf.sqf""; ;this addeventhandler [""fired"", {(_this select 0) setvehicleammo 1}]; 0 = [MG2, target1,30,100,3] execVM ""shootingInf.sqf""; ;this addeventhandler [""fired"", {(_this select 0) setvehicleammo 1}];";

Share this post


Link to post
Share on other sites

 

Firing at a can (named cible):

For a sniper, gunner, but single burst (what ever the weapon mode could be!):

in init field of the shooter (adapt for script apart):
 

0 = this spawn {
  while {alive _this} do {
    _this doTarget cible; sleep 2;
    if (_this ammo (currentWeapon _this) == 0) then {_this addMagazine currentMagazine _this};
     _this forceWeaponFire [currentWeapon _this,"manual"];
    sleep 2;
    _this lookAt cible ;
    sleep 2;
  }
};

 

For a MG, use dosuppresiveFire instead:


 

0 = this spawn {
  while {alive _this} do {
    _this doTarget cible; sleep 2;
    if (_this ammo (currentWeapon _this) == 0) then {_this addMagazine currentMagazine _this};
    _this doSuppressiveFire cible;
    sleep 2;
    _this lookAt cible ;
    sleep 2;
  }
};

 

To go one step further:

For an accurate shoot on a target (firing range), it's far more difficult. I succeed with this kind of code, pretty demanding for finding the good value:

Say for a target popup (named cible) at 150 m

 

0 = this spawn {
      while {alive _this} do {
        _this doTarget cible;
        waitUntil {cible animationPhase "Terc" == 0};
        _time = diag_tickTime;
        sleep 2;
        if (_this ammo (currentWeapon _this) == 0) then {_this addMagazine currentMagazine _this};
        if ((_this weaponDirection (currentWeapon _this) vectorCos ((position cible) vectorDiff (eyepos _this))) > 0.991 min (0.975 + (0.00024 *(_this distance cible)))) then {
          _this forceWeaponFire [currentWeapon _this,"single"];
          waitUntil {cible animationPhase "Terc" == 1 or diag_tickTime > _time + 10};
        } else {
          _this lookAt cible
        };
        sleep 3;
      }
    }

 

Change 0.991 by any value <1.  If too close from 1, accuracy is sharp but your unit will never fire. On the other hand, the less value, the more spilled bullets.

Probably better workaround but no idea at this time. Keep on mind, if no sway at all, this could be hard to meet the condition also.

Any improvement greatly appreciated.

  • Like 1

Share this post


Link to post
Share on other sites

The part of the mission I'm trying to create guys is this:

Player is tasked to search a warehouse. As he enters the area  in front, the enemy will fire an LMG into a trigger the player has just walked into & will continue to do so while the player is in there. The area in question wont be hit hard but it gives the player the impression the enemy are trying to fix him be suppressive the trigger area.

 

When I had the code working last yr, I had to give the AI MG team a target to fire at & as I didn't want the player to notice anything I placed a can in the grass & called it target1. As the AI LMG gunner is firing in bursts & as the distance from trigger/can & the enemy FP is about 1.5ks the spread of the burst was effective (a large spread). Now I added another LMG gunner into the team so the effects on the ground for the player were even more dramatic without him himself being killed. The purpose for all this is that the player would feel the pressure of the area being fixed without putting the player in real danger as long as he moved out of the area (trigger).

There was an area between the trigger & the warehouse where there was no "target or trigger" so once the player was out of the 1st trigger the enemy LMG team would stop firing. (to me it gave the impression the enemy where re loading).

Once the player entered the warehouse he would trigger off the 2nd trigger (mirror image of the 1st) so as he's inside searching the props he can hear the tin tin of the enemy rounds on the walls.

I had placed the LMG team far enough away & by rocks & trees so it would make it hard to locate them.

Once the players leaves the warehouse & walks to another area close very close by then he would trigger the enemy to break contact & bug out. The player (after locating the FP) would then patrol to the area to investigate but all he would find is empty LMG cases or a roll mat maybe.

 

That is exactly what I'm trying to create & as I said before guys, last year it was working with the original script above.

 

Many thanks

Share this post


Link to post
Share on other sites

You're probably right. BI sometimes changes some code regardless of what was written by scripters before.

Small example: you could leave a blank condition field of a trigger (erasing this), that worked as true (always) condition before 1.68. Now, writing true is mandatory.

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

×