Mutators and... the rest of mutators

Development assistance and tutorials here.
Post Reply
Nelsona
Posts: 1693
Joined: Sat Sep 30, 2017 5:03 am

Mutators and... the rest of mutators

Post by Nelsona »

Idea of a Revenge mutator it's cute in a way - IF WE HAVE codes not excuses.
These:

Code: Select all

ScriptWarning: Revenge DM-[BBST]-Thailand-Rmx.Revenge0 (Function Revenge.Revenge.listPlayers:0032) Accessed array out of bounds (32/32)
ScriptWarning: Revenge DM-[BBST]-Thailand-Rmx.Revenge0 (Function Revenge.Revenge.listPlayers:0032) Accessed array out of bounds (33/32)
ScriptWarning: Revenge DM-[BBST]-Thailand-Rmx.Revenge0 (Function Revenge.Revenge.listPlayers:0032) Accessed array out of bounds (34/32)
ScriptWarning: Revenge DM-[BBST]-Thailand-Rmx.Revenge0 (Function Revenge.Revenge.listPlayers:0032) Accessed array out of bounds (35/32)
ScriptWarning: Revenge DM-[BBST]-Thailand-Rmx.Revenge0 (Function Revenge.Revenge.listPlayers:0032) Accessed array out of bounds (36/32)
For some coding start if exist a candidate we can discuss what is this... you'll find words at your will.
Mutators contains variables in fixed arrays

Code: Select all

var pawn killers[32], player[32];
var config int  iRevengeBonus;
Then we have some wrapping... or less wrapping

Code: Select all

function listPlayers()	//assigns each pawn a unique ID
{
	local Pawn P;
	local int pnum;
	pnum = 0;
	for(P = Level.Pawnlist; P != None; P = P.Nextpawn)
	{ 
		player[pnum] = P;	//.playerreplicationinfo.playername;
		pnum++;
	}
}
Can you see the problem ?
Hint from log:

Code: Select all

ScriptWarning: WSRabbit DM-[BBST]-Thailand-Rmx.WSRabbit0 (Function Animal_PACK1.WSRabbit.Evade.PickDestination:000D) Accessed None
Did you get the problem ? No ? Okay, let me in.
Map has some "decoration" pawns - of course with codes copied from stock which are sh!tty if you look at internal state and function. By any matter, at these pawns we cannot speak about "//.playerreplicationinfo.playername;" and then we don't have anything but we can even move over a 32 elements array. Can we have revenge messages ? Maybe not, as long as we drop variables to nowhere... out of array, yeah... array, array.

What's the deal ?

#1 We can discard any crow, bird, rabbit, crappit, stupidizour, fartizant, pig, elephant and so on by not allowing non-players in stage and reducing design originality - server setup
#2 We can wrap code - even if we don't have a MonsterHunt, Coop here, we won't have a pain in butt guaranteed if we are using some checker

Code: Select all

function listPlayers()	//assigns each pawn a unique ID
{
	local Pawn P;
	local int pnum;
	pnum = 0;
	for(P = Level.Pawnlist; P != None; P = P.Nextpawn)
	{ 
		if ( P.PlayerReplicationInfo != None && P.bIsPlayer && !P.IsA('Spectator') ) //or such
		{
			player[pnum] = P;	//.playerreplicationinfo.playername;
			pnum++;
		}
	}
}
We have... let me count... 3 new lines > 1 code checker and 2 brackets or even a bit more for various speed-up executions.
UncodeX Stuff
Not often maintained
My UT Mapping works...
Learn the rules like a pro, so you can break them like an artist.
- Pablo Picasso -
User avatar
SC]-[WARTZ_{HoF}
Site Admin
Posts: 421
Joined: Wed May 10, 2017 7:08 am

Re: Mutators and... the rest of mutators

Post by SC]-[WARTZ_{HoF} »

Thanks for looking at that code Nels. Will you be uploading the fix for this?
Nelsona
Posts: 1693
Joined: Sat Sep 30, 2017 5:03 am

Re: Mutators and... the rest of mutators

Post by Nelsona »

Update will self-operate at rebooting time by server itself.

Big Ass Sniper Server is updated, this is Generation 2 - no version mismatch has been encountered so far.
UncodeX Stuff
Not often maintained
My UT Mapping works...
Learn the rules like a pro, so you can break them like an artist.
- Pablo Picasso -
Nelsona
Posts: 1693
Joined: Sat Sep 30, 2017 5:03 am

Re: Mutators and... the rest of mutators

Post by Nelsona »

The next over and over again type.
Actually here PostBeginPlay for some mutators in chain can be called more times:

Code: Select all

event PostBeginPlay()
{
	Super.PostBeginPlay();
	if (int(ConsoleCommand("get ini:Engine.Engine.GameEngine XC_Version")) >= 11)
		AddToPackageMap();
	SaveConfig(); //Create ini if doesn't exist.
	if (NextMutator != None)
		NextMutator.PostBeginPlay();
}
PostBeginPlay is called by Engine automatically else nothing would work - if not explain me how is initialized first one in chain.
Here code does a Super call and then again to NextMutator. Why calling NextMutator ? This is not TakeDamage, ModifyPlayer, ect. It's just causing a duplicated execution.
Code here is executed again if other mutator is calling this again because doesn't have protection for a twice execution.
Actually for me this code it's like here:

Code: Select all

event PostBeginPlay()
{
	if (!bInit)
	{
		if (int(ConsoleCommand("get ini:Engine.Engine.GameEngine XC_Version")) >= 11)
			AddToPackageMap();
		bInit=True;
		SaveConfig(); //Create ini if doesn't exist.

	}
}
Code is executed if it's not Initialized else nothing is added again in packages.
Allow me to turn on the light with class UnGame.cpp
UnGame.cpp wrote:

Code: Select all

		if( !GLevel->IsServer() )
		{
			for( INT i=0; i<GLevel->Actors.Num(); i++ )
			{
				AActor* Actor = GLevel->Actors(i);
				if( Actor )
				{
					if( Actor->bStatic || Actor->bNoDelete )
						Exchange( Actor->Role, Actor->RemoteRole );
					else
						GLevel->DestroyActor( Actor );
				}
			}
		}

		// 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;

		// 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;
	}
It's called usually even Event, I'm not sure if definition "function" hurts but... in native call it's "event" from January 01 to December 31...
UncodeX Stuff
Not often maintained
My UT Mapping works...
Learn the rules like a pro, so you can break them like an artist.
- Pablo Picasso -
User avatar
SC]-[WARTZ_{HoF}
Site Admin
Posts: 421
Joined: Wed May 10, 2017 7:08 am

Re: Mutators and... the rest of mutators

Post by SC]-[WARTZ_{HoF} »

Noted. Thanks.


EDIT: I had forgot my convo with Higor on that Nextmutator.
CacoFFF12/28/2019
Level.Game.BaseMutator.AddMutator(Self);
NOOOOOOOOOOOOPE
Get rid of that.
if ( NextMutator != None )
NextMutator.PreBeginPlay();

Also, get rid of this.
And get rid of the v400 kludge
if(bInitialized)
return;
bInitialized=True;
var bool bInitialized;
User avatar
SC]-[WARTZ_{HoF}
Site Admin
Posts: 421
Joined: Wed May 10, 2017 7:08 am

Re: Mutators and... the rest of mutators

Post by SC]-[WARTZ_{HoF} »

SC]-[WARTZToday at 11:20 AM
Ok which one of you is right about that bInitialized.
You told me to remove from a mod but Nels says is needed.

CacoFFFToday at 11:21 AM
That's a v400 thing.
Not needed as of v432
Nelsona
Posts: 1693
Joined: Sat Sep 30, 2017 5:03 am

Re: Mutators and... the rest of mutators

Post by Nelsona »

Technically if mutators are well done you don't need protection against duplicate execution.
If one of them in chain is calling other one for me this is not needed at all - Engine does this for all. Aside, will head to a double execution which in some mutators means double iterations cycles, depending on what they do, some of them it's not wise to be twice executed, MH with X mover tweaks is a sample, call that twice and you get closer to iterations boundary right at beginning. For this reason, in a later MH2 which I did, I spread Mover hacks later in slow cycles just because Monsters are crazy in iterations too when it's about teaming deals - these also I moved in XC_MonsterHunt. Because of such "early" cycles I simply don't need to see twice executions because PostBegin Prebegin are not game functions, these if you look well are executed before to see log "Unreal Engine Initialized...". Next spawned actors also are executing these without being needed a twice call unless you have some "special" modifications but actor is initiated too fast.
We need chaining in TakeDamage, ModifyPlayer, ModifyLogin, ect.

___
Okay, I figured how to use clocking from XC stuff without having any XC thing in compiling deps, just... defining clock,... lol, some of these exist in Core but Epic geniuses did not open access at them. Why my curiosity ? I figured that from PreBeginPlay to the end of PostBeginPlay there are... Cycles... a lot, zones, relevance, skybox, ect. Engine has a lot of work to do until game is ready, the last thing which I need is executing these multiple times, there is no reason for that.
I was able to count connections opened, but so far I cannot see which one is in use and which one should be closed, and... How to do that.

These weapons
You can take in account that I modified these in Gen 2 and... crashes are out as first thing, then all PostBeginPlay stuff is called without anything else - just look at logs and at game. I have to admit that Higor might have other resources and logs and I think his points are indeed good...

If he would come around we could spread some "toys" on the floor and resulting more experience for everyone, viewers and writers.
UncodeX Stuff
Not often maintained
My UT Mapping works...
Learn the rules like a pro, so you can break them like an artist.
- Pablo Picasso -
Post Reply