Help with Vortex Match Mutator!

Discussions about Coding and Scripting
Post Reply
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Help with Vortex Match Mutator!

Post by Gustavo6046 »

Today I've done a mutator. Basically it would spawn vortexes in random NavigationPoints with random Pawn owners.

(ChaosUT vortexes! ;) )

I've done the following code.

Code: Select all

//=============================================================================
// VortexMatch.
//=============================================================================
class VortexMatch expands Mutator;

var	bool			bHasVMPawnInfo;
var	bool			bHasVMPathInfo;
var	VMPawnInfo		PawnInfo;
var	VMPathInfo		PathNodeInfo;
var	int				PawnInfos;
var	int				PNInfos;
var	VMVortexInfo	VortexInfo;
var	int				VortexInfos;

function PostBeginPlay()
{
	local Pawn P;
	local NavigationPoint N;
	local VMPawnInfo i;
	local VMPathInfo i2;

	foreach AllActors (class'Pawn', P)
	{
		if ( !bHasVMPawnInfo )
		{
			PawnInfo = Spawn(class'VMPawnInfo');
			PawnInfo.CPawn = P;
			bHasVMPawnInfo = True;
			PawnInfos = 1;
		}
		else
		{
			for (i = PawnInfo; i != None; i = i.NextInfo)
				if ( i.NextInfo == None )
				{
					i.NextInfo = Spawn(class'VMPawnInfo');
					i.NextInfo.CPawn = P;
					i.NextInfo.PreviousInfo = i;
					PawnInfos++;
					break;
				}
		}
	}

	foreach AllActors (class'NavigationPoint', N)
	{
		if ( !bHasVMPathInfo )
		{
			PathNodeInfo = Spawn(class'VMPathInfo');
			PathNodeInfo.CPathNode = N;
			bHasVMPathInfo = True;
			PNInfos = 1;
		}
		else
			for (i2 = PathNodeInfo; i2 != None; i2 = i2.NextInfo)
				if ( i2.NextInfo == None )
				{
					i2.NextInfo = Spawn(class'VMPathInfo');
					i2.NextInfo.CPathNode = N;
					i2.NextInfo.PreviousInfo = i2;
					PNInfos++;
					break;
				}
	}

	SetTimer(30, true);
}

function Timer()
{
	local int i;
	local int MaxI;
	local VMPawnInfo i2;
	local Pawn Owner;
	local int MaxI2;
	local VMPathInfo i3;
	local NavigationPoint Target;
	local VMVortexInfo i4;

	if ( PawnInfo == None || PathNodeInfo == None )
		return;

	i2 = PawnInfo;
	MaxI = RandRange(0, PawnInfos);
	MaxI2 = RandRange(0, PNInfos);
	i3 = PathNodeInfo;

	for (i = 0; i < MaxI; i++)
		i2 = i2.NextInfo;

	for (i = 0; i < MaxI2; i++)
		i3 = i3.NextInfo;

	if ( VortexInfos == 0 )
	{
		VortexInfo = Spawn(class'VMVortexInfo');
		VortexInfo.CVortex = Spawn(class'ChaosUT.vortex', i2.CPawn, 'MutatorVortex', i3.CPathNode.Location, i3.CPathNode.Rotation);
		VortexInfos = 1;
	}
	else
		for (i4 = VortexInfo; i4 != None; i4 = i4.NextInfo)
			if ( i4.NextInfo == None )
			{
				i4.NextInfo = Spawn(class'VMVortexInfo');
				i4.NextInfo.CVortex = Spawn(class'ChaosUT.vortex', i2.CPawn, 'MutatorVortex', i3.CPathNode.Location, i3.CPathNode.Rotation);
				i4.NextInfo.PreviousInfo = i4;
				VortexInfos++;
				break;
			}
}

//=============================================================================
// VMVortexInfo.
//=============================================================================
class VMVortexInfo expands VMInfo;

var	VMVortexInfo	NextInfo;
var	VMVortexInfo	PreviousInfo;
var	Vortex			CVortex;

//=============================================================================
// VMPawnInfo.
//=============================================================================
class VMPawnInfo expands VMInfo;

var	VMPawnInfo	NextInfo;
var	VMPawnInfo	PreviousInfo;
var	Pawn		CPawn;

//=============================================================================
// VMPathInfo.
//=============================================================================
class VMPathInfo expands VMInfo;

var	VMPathInfo		NextInfo;
var	VMPathInfo		PreviousInfo;
var	NavigationPoint	CPathNode;

//=============================================================================
// VMInfo.
//=============================================================================
class VMInfo expands Info abstract;
So yes, it's quite some code. Don't worry with VMInfo, it's just a abstract class for organization for Vortex Match linked lists.

I ran in DM-SpaceParking map with the mutator and MindReader, and no vortex spawned anywhere! I will try logging stuff when running each piece of code. This might add in some info.

Thanks for the help in advance! :)

EDIT: I've added logs in the PostBeginPlay and Timer functions, but none seemed to be displayed in the console. :/
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
Post Reply