Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new Event Trigger after Mission Intro kismet has completed #1406

Open
furudee opened this issue Nov 12, 2024 · 2 comments
Open

Add a new Event Trigger after Mission Intro kismet has completed #1406

furudee opened this issue Nov 12, 2024 · 2 comments

Comments

@furudee
Copy link
Contributor

furudee commented Nov 12, 2024

I suggest adding a new event trigger after Mission Intro kismet has run it's course, just before players enters their first XCOM turn

Reasoning:
missions such as Supply Extraction spawns objective crates and submits new GameStates when the OnTacticalMissionStartBlocking kismet SeqEvent is triggered,
which happens after OnBeginTacticalPlay event trigger, so you don't have a handle for anything that happens in the kismet event, not before your first turn.

I believe it's better to place it after OnTacticalMissionStartBlocking event, not OnTacticalMissionStartNonBlocking,
because the former is supposedly latent thus making sure everything has been initialized correctly, no?

The following code is in X2TacticalGameRuleset, in PostCreateTacticalGame state:

Begin:
	`SETLOC("Start of Begin Block");

	//Posts a game state updating all state objects that they are in play
	BeginTacticalPlay();

	//Let kismet know everything is ready
	`XCOMGRI.DoRemoteEvent('XGBattle_Running_BeginBlockFinished');

	`CURSOR.ResetPlotValueCache( );

	CachedHistory.CheckNoPendingGameStates();

	// immediately before running kismet, allow sitreps to modify values on the kismet canvas
	PostCreateTacticalModifyKismetVariables( );
	class'X2SitRepEffect_ModifyKismetVariable'.static.ModifyKismetVariables();
	SecondWaveModifyKismetVariables( );

	// kick off the mission intro kismet, and wait for it to complete all latent actions
	WorldInfo.TriggerGlobalEventClass(class'SeqEvent_OnTacticalMissionStartBlocking', WorldInfo);


	while (WaitingForVisualizer())
	{
		sleep(0.0);
	}
         ////////////////////////////////////////////////////
         SUGGEST PUTTING EVENT TRIGGER HERE
         ////////////////////////////////////////////////////

	// set up start of match special conditions, including squad concealment
	ApplyStartOfMatchConditions();

         ////////////////////////////////////////////////////
         OR HERE
         ////////////////////////////////////////////////////

	// kick off the gameplay start kismet, do not wait for it to complete latent actions
	WorldInfo.TriggerGlobalEventClass(class'SeqEvent_OnTacticalMissionStartNonBlocking', WorldInfo);

	StartStateCheckAndBattleDataCleanup();

	// give the player a few seconds to get adjusted to the level
	Sleep(0.5f);

	// Catch all screen fade that should make sure that the camera fade is lifted at this point. Normally done as part of the intro sequence above in the
	// visualizer wait loop
	XComTacticalController(class'WorldInfo'.static.GetWorldInfo().GetALocalPlayerController()).ClientSetCameraFade(false, , , 1.0f);

	GotoState(GetNextTurnPhase(GetStateName()));
furudee added a commit to furudee/X2WOTCCommunityHighlander that referenced this issue Nov 12, 2024
furudee added a commit to furudee/X2WOTCCommunityHighlander that referenced this issue Nov 12, 2024
furudee added a commit to furudee/X2WOTCCommunityHighlander that referenced this issue Nov 12, 2024
@Iridar
Copy link
Contributor

Iridar commented Nov 28, 2024

Do you have an actual use case for these events?

@furudee
Copy link
Contributor Author

furudee commented Nov 30, 2024

For example, in my mod that places random explosion events around the map at mission start, I've attempted to make sure that the damage event does not hit a tile that an objective is on.

In the case of supply extraction mission, a GameState containing an objective crate doesn't exist at OnPostBeginPlay, because it's created after the MissionBlocking event is triggered and the mission kismet generates them. Thus in my test case, I wouldn't have an objective crates location to prevent an explosion happening at that tile.

Example on getting all the premium objective crates on supply extraction mission:

foreach `XCOMHISTORY.IterateByClassType(class'XComGameState_InteractiveObject', TestState)
{
		// State does not exist yet at OnPostBeginPlay
		if(TestState.ArchetypePath == "ARC_IA_SupplyCrate_Premium")
		{
			TestState.FindOrCreateVisualizer();
			// Do other stuff
		}
}

furudee added a commit to furudee/X2WOTCCommunityHighlander that referenced this issue Dec 3, 2024
furudee added a commit to furudee/X2WOTCCommunityHighlander that referenced this issue Dec 3, 2024
furudee added a commit to furudee/X2WOTCCommunityHighlander that referenced this issue Dec 3, 2024
furudee added a commit to furudee/X2WOTCCommunityHighlander that referenced this issue Dec 3, 2024
furudee added a commit to furudee/X2WOTCCommunityHighlander that referenced this issue Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants