Jump to content
Jun Xiao

When the vehicle has no ammunition, trigger condition code?

Recommended Posts

Hi, I have an idea.
When the RHS L39C trainer has finished launching the s-5 rocket, or the remaining s-5 rocket in the L39C, the pilot returns to a target point.
But I don't know how to write code the trigger condition, I only know rhs_weap_s5m1 is S - 5 rocket.
Who can help me? Thank you!

Share this post


Link to post
Share on other sites
6 hours ago, stanhope said:

Use the event handler firedman and check if the guy still has ammo on him.

Okey,Thanks. stanhope.

But it's too hard for me. Is there a simpler way, like using a trigger?

Share this post


Link to post
Share on other sites

Is it a unit you want to do something after shooting a round or a vehicle?  And after 1 round is shot or when all the ammunition is used?

Share this post


Link to post
Share on other sites
21 hours ago, Jun Xiao said:

Hi, I have an idea.
When the RHS L39C trainer has finished launching the s-5 rocket, or the remaining s-5 rocket in the L39C, the pilot returns to a target point.
But I don't know how to write code the trigger condition, I only know rhs_weap_s5m1 is S - 5 rocket.
Who can help me? Thank you!

 

A few ways to go on about this, most straightforward one:

//vehicle init
this addEventHandler ["Fired",{

	params ["_veh"];
	//grab all magazines containing "s5" and check if empty, if all of them are empty set flag to true
	_toCheck = "S5";
	_magsToCheck = magazinesAllTurrets _veh select {(toUpper (_x#0)) find _toCheck >= 0};
	_emptyMagsAmount = count (_magsToCheck select {(_x#2) isEqualTo 0});
	missionNamespace setVariable ["TAG_fnc_lastS5shot",count _magsToCheck isEqualTo _emptyMagsAmount,true];

}];

This will set the TAG_fnc_lastS5shot variable to true, once the last magazine containing S5 in the name is empty, in the trigger condition field simply put:

missionNamespace getVariable ["TAG_fnc_lastS5shot",false];

This will return false and only return true if the plane fired the last S5 rocket.

 

Cheers

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

×