Jump to content
pierremgi

SAM system reloading - strange behavior

Recommended Posts

Hi all,

Trying to make an automatic reload for the S-750 Rhea, i discovered a strange Arma engine behavior.

 

I placed via editor one player, one S-750 and R-750 (sensors are active by default).

Then a black Wasp as enemy, disabled damage and a loiter waypoint around the SAM system in order to make it fire again and again.

 

So, when out of missile, you need to reload the SAM.

I placed in init field of the launcher:

this addEventHandler ["fired",{
  params ["_unit"];
  if (magazinesAmmo _unit select 0 select 1 == 1) then {
   _unit addMagazineTurret ["magazine_Missile_s750_x4",[0],4]

  }

}];

 

That works, but there is no delay to reload the SAM and I'd like to add a decent one for more realism. So I tried, as test, to spawn a code:

 

this addEventHandler ["fired",{
  params ["_unit"];
  if (magazinesAmmo _unit select 0 select 1 == 1) then {
   _unit spawn {
    params ["_unit"];
    waitUntil {magazinesAmmo _unit isEqualTo []};
    sleep 5;
    _unit addMagazineTurret ["magazine_Missile_s750_x4",[0],4]
   }

  }

}];

 

This last code doesn't work. Not a script question. The magazines are added but the launcher remains empty and don't fire. I added a loadMagazine with no more success.

The strange thing: If I remove the simple line: sleep 5;  the code works again (but missiles are loaded with no delay.)

 

Any clue?

 

 

Share this post


Link to post
Share on other sites

Odd. Why not put all code inside? Like so:

this addEventHandler ["Fired",
{
	_this spawn
	{
		params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
		if (((magazinesAmmo _unit select 0) select 1) isEqualTo 1) then
		{
			waitUntil {magazinesAmmo _unit isEqualTo []};
			sleep 5;
			_unit addMagazineTurret ["magazine_Missile_s750_x4", [0], 4];
		};
  };
}];

Also...  Try using the magazinesTurret command instead. Have you tried debugging to see if magazinesAmmo returns an actual empty array, etc?

Share this post


Link to post
Share on other sites
3 hours ago, HazJ said:

Odd. Why not put all code inside? Like so:


this addEventHandler ["Fired",
{
	_this spawn
	{
		params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
		if (((magazinesAmmo _unit select 0) select 1) isEqualTo 1) then
		{
			waitUntil {magazinesAmmo _unit isEqualTo []};
			sleep 5;
			_unit addMagazineTurret ["magazine_Missile_s750_x4", [0], 4];
		};
  };
}];

Also...  Try using the magazinesTurret command instead. Have you tried debugging to see if magazinesAmmo returns an actual empty array, etc?

 

As I wrote, it's not a script question. It's easy to reproduce that. The condition works fine. The only thing which breaks the reloading is the sleep command (in a scheduled scopre...) So, there is something weird with the SAM. Just try that.

Share this post


Link to post
Share on other sites

Hi. Maybe you just need make them to reload, after your sleep where they set no ammo left.

Anyway the time how long weapon reload take place you can set by setWeaponReloadingTime.

Try always put sleep inside waituntil scope, if you want one just after or for slown down evaluation.

0 = this setWeaponReloadingTime [gunner this, "magazine_Missile_s750_x4", 1]; 
 this addEventHandler ["fired",{ 
 	 params ["_unit"]; 
	  if (magazinesAmmo _unit select 0 select 1 == 1) then { 
  	 	_unit addMagazineTurret ["magazine_Missile_s750_x4",[0],4] 
	};
}]; 

 

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, davidoss said:

Hi. Maybe you just need make them to reload, after your sleep where they set no ammo left.

Anyway the time how long weapon reload take place you can set by setWeaponReloadingTime.

Try always put sleep inside waituntil scope, if you want one just after or for slown down evaluation.

 

 

That doesn't work (anywhere i write the setWeaponReloadingTime in the script).

In all cases:

- the SAM can fire each loaded missile every ~ 5 or 6 sec;

- can reload (with unscheduled/scheduled with small* delay code). Then, the animation is instantaneous but the next first missile of 4 can't be fired sooner as ~13 sec.

 

The setWeaponReloadingTime doesn't have any effect. (I failed in all cases).

 

* I did some tests and I can confirm that SAM is reloaded if the delay (sleep) is up to 3 sec. The reload fails with 4 sec or more. I didn't chase for the exact limit.

So, there is a little slot in the SAM macro to reload it. If overshot, you have an empty SAM.

 

The question is: how to reload it each 10 minutes?

Share this post


Link to post
Share on other sites

The sleep shouldn't break it... You could try uiSleep though.

Share this post


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

The sleep shouldn't break it... You could try uiSleep though.

uiSleep or sleep doesn't make difference. As I said, it's not a script question. It's something related with the time spent after the SAM is totally empty.

It seems to me the engine (SAM macro: _generalMacro = "StaticMGWeapon"; is same as MG static by the way) probably continues to run for some animation or else, during less than 4 sec. The reload is possible within this slot, but no more after, with the same code. No clue why.

I checked also the weapon: "weapon_s750Launcher" is supposed to autoreload: autoReload = 1; and the reloadTime = 4; (between 2 missiles)

 

Thank you for your suggestion. It's easy to reproduce what I get (see first post).

 

If anyone has a workaround (one more in Arma!)...

Share this post


Link to post
Share on other sites

No idea then. Is this the SAM from RHS or some other mod? Maybe ask in the official thread as they might be able to help you further.

Share this post


Link to post
Share on other sites
6 minutes ago, HazJ said:

No idea then. Is this the SAM from RHS or some other mod? Maybe ask in the official thread as they might be able to help you further.

No, the vanilla one (since Encore update).

Share this post


Link to post
Share on other sites

Ah. That one. Not messed with it too much, I'll do some testing / messing around with later on.

Share this post


Link to post
Share on other sites

BI naming convention strikes again, setWeaponReloadingTime doesn't do what the name implies at a first glance,

same for playerViewChanged EH (which still confuses the heck out of me how BI came up with that name considering the functionality of the EH, go figure).

Spoiler

2gqkba.jpg

 

setWeaponReloadingTime only affects reloading single rounds, not magazines.

Check the comments on the page for further info.

 

Cheers

  • Haha 1

Share this post


Link to post
Share on other sites

@pierremgi

 

Try this. Worked for me.

this addEventHandler ["fired",{
    params ["_unit"];    
    _unit spawn {
        params ["_unit"];
        if (count (magazinesAmmo _unit) == 0) then {
            sleep 20;
            _unit addMagazineTurret ["magazine_Missile_mim145_x4",[0],4];        
        };
    };
}];

Note that's the NATO SAM. Not the CSAT one.

 

I think your issue is that by the time 4 seconds has passed your SAM has fired its last missile. Meaning magazinesAmmo _unit select 0 select 1 == 1 evaluates false. Either that or BI fixed it since you posted.

 

On a related note, the SAM fires off all its missiles ridiculously fast. Which may or may not be realistic but it does mean the turret wastes 4 missiles on 1 plane. And 4 turrets wasted 16 missiles on 1 plane. Which looks even sillier. So I wrote this:

 

this addEventHandler ["fired",{
  params ["_unit"];	
   _unit spawn {
    params ["_unit"];
	(group _unit) setCombatMode "BLUE"; 
    sleep 20;
	(group _unit) setCombatMode "RED";	
	if (count (magazinesAmmo _unit) == 0) then {
		 _unit addMagazineTurret ["magazine_Missile_mim145_x4",[0],4];		
	};
   };
}];

 

  • Like 1

Share this post


Link to post
Share on other sites
_thisIsMySAMToReload addEventHandler ["Fired",{_this spawn {uiSleep 30; (_this select 0) setVehicleAmmo 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

×