Native - PawnList and NavigationPointList iterators snippets

Discussions about Coding and Scripting
Post Reply
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Native - PawnList and NavigationPointList iterators snippets

Post by Higor »

Utilized in the Native Branch of FerBotZ, exposed here.

UnrealScript:

Code: Select all

//*****************************PawnActors - Pawnlist iterator
native final function iterator PawnActors( class<Pawn> PawnClass, out pawn P, optional float Distance, optional vector VOrigin, optional bool bHasPRI);

//*****************************NavigationActors - navigationPointList iterator
native final function iterator NavigationActors( class<NavigationPoint> NavClass, out NavigationPoint P, optional float Distance, optional vector VOrigin, optional bool bVisible);
//Visible parameter not used yet, sorry about that

C++:
PawnActors

Code: Select all

void ABotz::execPawnActors(FFrame &Stack, RESULT_DECL)
{
	guard(ABotz::execPawnActors);
	P_GET_CLASS(BaseClass);
	P_GET_PAWN_REF(P);
	P_GET_FLOAT_OPTX(dist,0.0);
	P_GET_VECTOR_OPTX(aVec,this->Location);
	P_GET_UBOOL_OPTX(bPRI,false);
	P_FINISH;

	BaseClass = BaseClass ? BaseClass : APawn::StaticClass();
	APawn *PP = Level->PawnList;
	dist = dist * dist;

	PRE_ITERATOR;
		*P = NULL;
		while( PP && *P == NULL )
		{
			if ( PP->IsA(BaseClass) )
			{
				if ( !bPRI || PP->PlayerReplicationInfo != NULL )
				{
					if ( dist <= 0.0 || FVector(PP->Location - aVec).SizeSquared() < dist )
						*P = (APawn*)PP;
				}
			}
			PP = PP->nextPawn;
		}
		
		if ( *P == NULL )
		{
			Stack.Code = &Stack.Node->Script(wEndOffset + 1);
			break;
		}
	POST_ITERATOR;
	unguard;
}
NavigationActors

Code: Select all

void ABotz::execNavigationActors(FFrame &Stack, RESULT_DECL)
{
	guard(ABotz::execNavigationActors);
	P_GET_CLASS(BaseClass);
	P_GET_NAVIG_REF(N);
	P_GET_FLOAT_OPTX(dist,0.0);
	P_GET_VECTOR_OPTX(aVec,this->Location);
	P_GET_UBOOL_OPTX(bTrace,false);
	P_FINISH;

	BaseClass = BaseClass ? BaseClass : ANavigationPoint::StaticClass();
	ANavigationPoint *NN = Level->NavigationPointList;
	dist = dist * dist;

	PRE_ITERATOR;
		*N = NULL;
		while( NN && *N == NULL )
		{
			if ( NN->IsA(BaseClass) )
			{
				if ( dist <= 0.0 || FVector(NN->Location - aVec).SizeSquared() < dist )
					*N = (ANavigationPoint*)NN;
			}
			NN = NN->nextNavigationPoint;
		}
		
		if ( *N == NULL )
		{
			Stack.Code = &Stack.Node->Script(wEndOffset + 1);
			break;
		}
	POST_ITERATOR;
	unguard;
}
User avatar
Wises
Godlike
Posts: 1089
Joined: Sun Sep 07, 2008 10:59 am
Personal rank: ...

Re: Native - PawnList and NavigationPointList iterators snip

Post by Wises »

MrLoathsome
Inhuman
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Personal rank: I am quite rank.
Location: MrLoathsome fell out of the world!

Re: Native - PawnList and NavigationPointList iterators snip

Post by MrLoathsome »

I think you misunderstood Higors post. (or I did... :wtf: )

He isn't asking for help, he is just providing a preview of some stuff he is doing that
will be useful for those who are interesting in re-writing core parts of the game.

If somebody asked me for a list of people who have already "Mastered" Unreal Classes, I
am pretty sure Higors name would be on there. :mrgreen:
blarg
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: Native - PawnList and NavigationPointList iterators snip

Post by Higor »

MrLoathsome wrote:(or I did... :wtf: )
Not at all.

Also, just managed to save and load a dynamic array into a file.
Now I need to setup the ingame pathnoder interface.
User avatar
Dr.Flay
Godlike
Posts: 3348
Joined: Thu Aug 04, 2011 9:26 pm
Personal rank: Chaos Evangelist
Location: Kernow, UK
Contact:

Re: Native - PawnList and NavigationPointList iterators snip

Post by Dr.Flay »

Indeed, Higor was just showing us mere mortals what inspiration and distilled genius look like :D
[]KAOS[]Casey
Average
Posts: 30
Joined: Fri Mar 30, 2012 7:56 pm

Re: Native - PawnList and NavigationPointList iterators snip

Post by []KAOS[]Casey »

Semi-necro post, but I see you're using the line

Stack.Code = &Stack.Node->Script(wEndOffset + 1);

the Script array is a TArray<BYTE>. Are you on Visual Studio 6.0 to get that to link? I've been trying to get a mod that absolutely requires TArray<BYTE> to compile on VS200x and it doesn't want to link. I tried converting it back down from VS200x to VC6 and it just breaks horribly. The same mod compiles & works fine on 227, but that may be because 227 is actually built on a semi-modern compiler as opposed to over a decade old.
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: Native - PawnList and NavigationPointList iterators snip

Post by Higor »

That code linked under these 2 compilers:
- VC++6 (stock compiler and headers)
- VC++2008 express (heavily modified by myself to compile X64 wii emulator) (with anth's headers)

It's basically how you describe it, it simply moves the current uScript processor right after the ForEach block.
[]KAOS[]Casey
Average
Posts: 30
Joined: Fri Mar 30, 2012 7:56 pm

Re: Native - PawnList and NavigationPointList iterators snip

Post by []KAOS[]Casey »

I know what that does and how it works; but you answered my question. Looks like that particular bit with the TArray<BYTE> was probably linked on VC6.0 and I'm not sure if it would even be feasible to split the particular dll in question to work around the crappy limitation of TArray<BYTE>... There goes the chances of DeusEx coop once again :/
Post Reply