class'LevelInfo'.bStartUp

Discussions about Coding and Scripting
User avatar
Barbie
Godlike
Posts: 2479
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

class'LevelInfo'.bStartUp

Post by Barbie » Sun Nov 06, 2022 12:12 pm

sektor2111 wrote:
Sun Nov 06, 2022 9:12 am
Replacing/Removing ammo during "Level.bStartUp"
Interesting. Where is this flag (un)set and what part of startup is covered by it? I didn't find anything in the sources.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

Buggie
Godlike
Posts: 1763
Joined: Sat Mar 21, 2020 5:32 am

Re: class'LevelInfo'.bStartUp

Post by Buggie » Sun Nov 06, 2022 1:04 pm

Set in native part. It is guard flag during map load.
It set to true. After that start call chain of events for actors placed on map:
  • eventInitGame
  • eventPreBeginPlay
  • eventBeginPlay
  • SetActorZone
  • eventPostBeginPlay
  • eventSetInitialState
  • SetBase
After that done flag set to false.

Wanna mention chain of events done for all actors in each part, before start next part.

This mean All actors called eventPreBeginPlay only after that come eventBeginPlay.
unlike spawn on runtime where this events goes one after another.

Kismet
Novice
Posts: 4
Joined: Sat Nov 05, 2022 9:45 pm

Re: class'LevelInfo'.bStartUp

Post by Kismet » Sun Nov 06, 2022 6:53 pm

Could you explain each part of the chain in a couple of sentences? When it starts and what happens. I think it will be helpful for all of us.

Buggie
Godlike
Posts: 1763
Joined: Sat Mar 21, 2020 5:32 am

Re: class'LevelInfo'.bStartUp

Post by Buggie » Sun Nov 06, 2022 7:43 pm

When: Each part start after previous done. In general it start on level load, as part of load sequence.
What: Called appropriate event in UnrealScript (eventPreBeginPlay call event PreBeginPlay in UnrealScript) or do some action (SetActorZone - Set Actor Zone :lol: )

It is already described pretty well here: https://wiki.beyondunreal.com/Legacy:Ch ... el_Startup

User avatar
sektor2111
Godlike
Posts: 6030
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: class'LevelInfo'.bStartUp

Post by sektor2111 » Sun Nov 06, 2022 8:14 pm

Barbie wrote:
Sun Nov 06, 2022 12:12 pm
sektor2111 wrote:
Sun Nov 06, 2022 9:12 am
Replacing/Removing ammo during "Level.bStartUp"
Interesting. Where is this flag (un)set and what part of startup is covered by it? I didn't find anything in the sources.
Okay, allow me to explain what's up. Some dude with experience in scripting and servers was writing something for tweaking whatever problem. My "weak" point is that I'm used to look at codes done by those with some experience especially if their content does what it says. I realized later that this is one of methods for applying "Once-Only" tasks. Of course methods for "once-only" tasks are doable in many formats - it depends on your needs or various logic aspects of tweaks applied. You can use a function called in a tick a single time, you can use a timer, auto state, another actor living a short life, etc.
Kismet wrote:
Sun Nov 06, 2022 6:53 pm
Could you explain each part of the chain in a couple of sentences? When it starts and what happens. I think it will be helpful for all of us.
If you can find some resources (they are on Internet) there all code is exposed. If you don't have access to look at them, then chain of events and said variable is probably similar to this old code
Spoiler
Show

Code: Select all

		// Init scripting.
		for( i=0; i<GLevel->Actors.Num(); i++ )
			if( GLevel->Actors(i) )
				GLevel->Actors(i)->InitExecution();

		// Enable actor script calls.
		Info->bBegunPlay = 1;
		Info->bStartup = 1; // exposed to UScript as boolean

		// Init the game.
		if( Info->Game )
			Info->Game->eventInitGame( Options, Error );

		// Send PreBeginPlay.
		for( i=0; i<GLevel->Actors.Num(); i++ )
			if( GLevel->Actors(i) )
				GLevel->Actors(i)->eventPreBeginPlay();

		// Set BeginPlay.
		for( i=0; i<GLevel->Actors.Num(); i++ )
			if( GLevel->Actors(i) )
				GLevel->Actors(i)->eventBeginPlay();

		// Set zones.
		for( i=0; i<GLevel->Actors.Num(); i++ )
			if( GLevel->Actors(i) )
				GLevel->SetActorZone( GLevel->Actors(i), 1, 1 );

		// Post begin play.
		for( i=0; i<GLevel->Actors.Num(); i++ )
			if( GLevel->Actors(i) )
				GLevel->Actors(i)->eventPostBeginPlay();

		// Begin scripting.
		for( i=0; i<GLevel->Actors.Num(); i++ )
			if( GLevel->Actors(i) )
				GLevel->Actors(i)->eventSetInitialState();

		// Find bases
		for( i=0; i<GLevel->Actors.Num(); i++ )
		{
			if( GLevel->Actors(i) ) 
			{
				if ( GLevel->Actors(i)->AttachTag != NAME_None )
				{
					//find actor to attach self onto
					for( INT j=0; j<GLevel->Actors.Num(); j++ )
					{
						if( GLevel->Actors(j) && (GLevel->Actors(j)->Tag == GLevel->Actors(i)->AttachTag) )
						{
							GLevel->Actors(i)->SetBase(GLevel->Actors(j), 0);
							break;
						}
					}
				}
				else if( !GLevel->Actors(i)->Base && GLevel->Actors(i)->bCollideWorld 
				 && (GLevel->Actors(i)->IsA(ADecoration::StaticClass()) || GLevel->Actors(i)->IsA(AInventory::StaticClass()) || GLevel->Actors(i)->IsA(APawn::StaticClass())) 
				 &&	((GLevel->Actors(i)->Physics == PHYS_None) || (GLevel->Actors(i)->Physics == PHYS_Rotating)) )
				{
					 GLevel->Actors(i)->FindBase();
					 if ( GLevel->Actors(i)->Base == Info )
						 GLevel->Actors(i)->SetBase(NULL, 0);
				}
			}
		}
		Info->bStartup = 0; //intialization ends here
	}
Note: The UE1 rebel is LiftCenter getting used to be attached at a lift faster than the rest of actors delegated to have a base...