Jump to content
Zjajo

Guidance for triggering mission ending

Recommended Posts

I'm making a hybrid TDM/CTM mission that works for both dedicated and player hosts. I have the TDM portion taken care of but I need some guidance for CTF triggering. 

 

Each of the 3 sides(Opfor, Blufor, Indep) have 3 empty flag poles. Once a side has two of the same flags raised, game ends. 

 

My thoughts: One trigger for each side. Once one flag is raised(getForcedFlagTexture flagpole != ""), call script to loop as it checks other two flagpoles on that side(getForcedFlagTexture flagpole == getForcedFlagTexture otherFlagPoles), sleeping 5 seconds between loops, triggering mission end if returns true. But this seems like it would be very taxing on performance if all sides had at least one flag.

 

Can anyone offer some guidance on how to best tackle this?

Share this post


Link to post
Share on other sites

I have had missions where there were 6 conditions. If any 2 conditions were met then the scenario ends.  So I created 15 triggers. Each trigger has a message stating which 2 conditions have been met.

 

If condition 1 and condition 2 are met fire trigger 1
If condition 1 and condition 3 are met fire trigger 2
If condition 1 and condition 4 are met fire trigger 3
If condition 1 and condition 5 are met fire trigger 4
If condition 1 and condition 6 are met fire trigger 5
If condition 2 and condition 3 are met fire trigger 6
If condition 2 and condition 4 are met fire trigger 7
If condition 2 and condition 5 are met fire trigger 8
If condition 2 and condition 6 are met fire trigger 9
If condition 3 and condition 4 are met fire trigger 10
If condition 3 and condition 5 are met fire trigger 11
If condition 3 and condition 6 are met fire trigger 12
If condition 4 and condition 5 are met fire trigger 13
If condition 4 and condition 6 are met fire trigger 14
If condition 5 and condition 6 are met fire trigger 15
 

  • Like 1

Share this post


Link to post
Share on other sites

BIS_fnc_animateFlag and its associated scriptedEventHandler ?

Spoiler

//initServer.sqf

TAG_flags = [ nameGivenToFlagPole1, nameGivenToFlagPole2, nameGivenToFlagPole3 ];
TAG_flagCapturedBy = [ sideUnknown, sideUnknown, sideUnknown ];
TAG_flagTextures = [ "OpforFlagTexture", "BluforFlagTexture", "IndepFlagTexture" ]; //insert texture names

{
	[ _x, "FlagAnimationDone", {
		params[ "_flag", "_phaseEnd" ];
		
		if ( _phaseEnd isEqualTo 0 ) then {
			TAG_flagCapturedBy set[ TAG_flags find _flag, sideUnknown ];
		};
		
		if ( _phaseEnd isEqualTo 1 ) then {
			_flagTexture = getForcedFlagTexture _flag;
			_side = [ east, west, independent ] select ( TAG_flagTextures find _flagTexture );
			TAG_flagCapturedBy set[ TAG_flags find _flag, _side ];
			if ( { _x == _side }count TAG_flagCapturedBy > 1 ) then {
				[ "Winner", true, true ] remoteExec[ "BIS_fnc_endMission", _side ];
				{
					[ "Loser", false, 5 ] remoteExec[ "BIS_fnc_endMission", _x ];
				}forEach ( [ east, west, independent ] - [ _side ] );
				if ( isDedicated ) then {
					_nul = [] spawn {
						sleep 5;
						[ "END1" ] call BIS_fnc_endMission;
					};
				};
			};
		};
	} ] call BIS_fnc_addScriptedEventHandler;
}forEach TAG_flags;

Untested, more as an example idea

 

  • Thanks 1

Share this post


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

BIS_fnc_animateFlag and its associated scriptedEventHandler ?

  Hide contents



//initServer.sqf

TAG_flags = [ nameGivenToFlagPole1, nameGivenToFlagPole2, nameGivenToFlagPole3 ];
TAG_flagCapturedBy = [ sideUnknown, sideUnknown, sideUnknown ];
TAG_flagTextures = [ "OpforFlagTexture", "BluforFlagTexture", "IndepFlagTexture" ]; //insert texture names

{
	[ _x, "FlagAnimationDone", {
		params[ "_flag", "_phaseEnd" ];
		
		if ( _phaseEnd isEqualTo 0 ) then {
			TAG_flagCapturedBy set[ TAG_flags find _flag, sideUnknown ];
		};
		
		if ( _phaseEnd isEqualTo 1 ) then {
			_flagTexture = getForcedFlagTexture _flag;
			_side = [ east, west, independent ] select ( TAG_flagTextures find _flagTexture );
			TAG_flagCapturedBy set[ TAG_flags find _flag, _side ];
			if ( { _x == _side }count TAG_flagCapturedBy > 1 ) then {
				[ "Winner", true, true ] remoteExec[ "BIS_fnc_endMission", _side ];
				{
					[ "Loser", false, 5 ] remoteExec[ "BIS_fnc_endMission", _x ];
				}forEach ( [ east, west, independent ] - [ _side ] );
				if ( isDedicated ) then {
					_nul = [] spawn {
						sleep 5;
						[ "END1" ] call BIS_fnc_endMission;
					};
				};
			};
		};
	} ] call BIS_fnc_addScriptedEventHandler;
}forEach TAG_flags;

Untested, more as an example idea

 

 

 

Thanks @Larrow. This will work just fine.

 

Quick question: 

I'd like to be able to have the "FlagAnimationDone scriptedEventHandler" take care of all the work and not have to create another method to send notification messages when the animation phase reaches a certain point, like when it reaches the top or when a player takes flag off of pole. How could I pass arguments to the scriptedEventHandler? Namely, (side player) and (name player), maybe even the side that the flag belongs to as well. I've messed around with trying to add _caller and _target from the addAction I attached to the flags but I cannot seem to give it what it wants. I keep getting "Undefined variable in expression" no matter what I try.

Share this post


Link to post
Share on other sites
Spoiler
10 hours ago, Joe98 said:

I have had missions where there were 6 conditions. If any 2 conditions were met then the scenario ends.  So I created 15 triggers. Each trigger has a message stating which 2 conditions have been met.

 

If condition 1 and condition 2 are met fire trigger 1
If condition 1 and condition 3 are met fire trigger 2
If condition 1 and condition 4 are met fire trigger 3
If condition 1 and condition 5 are met fire trigger 4
If condition 1 and condition 6 are met fire trigger 5
If condition 2 and condition 3 are met fire trigger 6
If condition 2 and condition 4 are met fire trigger 7
If condition 2 and condition 5 are met fire trigger 8
If condition 2 and condition 6 are met fire trigger 9
If condition 3 and condition 4 are met fire trigger 10
If condition 3 and condition 5 are met fire trigger 11
If condition 3 and condition 6 are met fire trigger 12
If condition 4 and condition 5 are met fire trigger 13
If condition 4 and condition 6 are met fire trigger 14
If condition 5 and condition 6 are met fire trigger 15
 

 

@Joe98, thanks for the reply. I could probably get this to work but I want to avoid using so many triggers. 

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

×