[Pre-Alpha] OldVolumes (Volumes for UT99)!

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:

[Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by Gustavo6046 »

Friendly Warning!
To prevent further... "auto-hassles", I'd like to notify this code is in NO means to be used, I wanted people to know about it, it's complexity and otherwise about how could I fix it.

I've heard about Volumes for Unreal Engine 2, and 3D brush ladders would be a cool addition to UT99. So I though, "why not one"?

This has been a hassling and long day trying to find out why isn't the VolumeLadder (subclass of VolumeModifier, a special architecture for volumes, devised by me of course ^_^, so that volumes can be customized) releasing the player once it untouches any Volume:
OldVolume expands Mover:

Code: Select all

//=============================================================================
// OldVolume.
//=============================================================================
class OldVolume expands Mover;

var()	VolumeModifier	Modifiers;
var()	bool			bDevLog;  // DO NOT set to true if casually mapping!!!!!!!
var		VolumeActors	ActorsInside;
var()	float			ModifierClocking;
var		Actor			GotOut;

function NotifyVolumeTouch(Actor Other)
{
	local VolumeModifier VM;

	for ( VM = Modifiers; VM != None; VM = VM.Next )
		VM.VolumeTouch(Other, self, ActorsInside);
}

function ActorInVolume(Actor Other)
{
	local VolumeActors AI;

	if ( Other == None )
		return;

	Log("Volume"@self@"is being occupied by"@Other);

	NotifyVolumeTouch(Other);

	if ( bDevLog )
	{
		Log(ActorsInside@Other);
	}

	if ( ActorsInside == None )
	{
		ActorsInside = Spawn(class'VolumeActors', self);
		ActorsInside.ThisActor = Other;

		return;
	}

	for ( AI = ActorsInside; AI != None; AI = AI.Next )
	{
		if ( bDevLog )
			Log(AI@AI.ThisActor@AI.Next);

		if ( AI.Next == None )
			return;
	}

	AI.Next = Spawn(class'VolumeActors', self);
	AI.Next.Previous = AI;
	AI.Next.ThisActor = Other;
}

function Touch(Actor Other)
{
	if ( GotOut != None && Other == GotOut )
		return;

	GotOut = None;
	ActorInVolume(Other);
}

function bool EncroachingOn(Actor Other)
{
	local	VolumeModifier	VM;

	if ( Modifiers == None )
		return false;

	for ( VM = Modifiers; VM != None; VM = VM.Next )
	{
		if ( VM.BlockActor(Other) )
		{
			Warn(self@"will have to block"@Other@"because of"@VM$"'s BlockActor("$Other$") returning True");

			return true;
		}

		if ( VM.Next == None )
			return false;
	}

	return false;
}

function UnTouch(Actor Other)
{
	local VolumeModifier VM;
	local VolumeActors AI;

	Log(Other@"unnocupied Volume"@self);

	GotOut = Other;

	if ( Modifiers != None )
		for ( VM = Modifiers; VM != None; VM = VM.Next )
			VM.VolumeUntouch(Other, self, ActorsInside);

	for ( AI = ActorsInside; AI != None; AI = AI.Next )
	{
		if ( AI.ThisActor != None && AI.ThisActor == Other )
		{
			Log("Destroying"@AI@"for containing interrupted contact with Actor:"@Other);

			AI.Remove();
		}

		if ( AI.Next == None )
			return;
	}
}

function Timer()
{
	local VolumeModifier VM;
	local VolumeActors AI;

	for ( AI = ActorsInside; AI != None; AI = AI.Next )
	{
		if ( AI.ThisActor == None || ( Pawn(AI.ThisActor) != None && Pawn(AI.ThisActor).IsInState('Dying') ) )
		{
			if ( AI.ThisActor != None )
				Log("Destroying"@AI@"for containing deceased contact with Actor:"@AI.ThisActor);

			else
				Log("Destroying"@AI@"for containing deceased contact with a NoneType!");


			AI.Remove();
		}

		if ( AI.Next == None )
			break;
	}

	for ( VM = Modifiers; VM != None; VM = VM.Next )
	{
		VM.VolumeClock(ModifierClocking, self, ActorsInside);

		if ( VM.Next == None )
			return;
	}
}

function BeginPlay()
{
	local VolumeModifier VM;

	Log("Occupation detection between"@self@"and other actors:"@bCollideActors);

	for ( VM = Modifiers; VM.Next != None; VM = VM.Next )
		VM.GotVolume(self);

	SetTimer(ModifierClocking, True);
}
VolumeActors expands Info;

Code: Select all

//=============================================================================
// VolumeActors.
//=============================================================================
class VolumeActors expands Info;

var	Actor			ThisActor;
var	VolumeActors	Previous;
var	VolumeActors	Next;

function PostBeginPlay()
{
	if ( ThisActor != None )
		Log(Self@"spawned with actor"@ThisActor);
}

function Remove(optional bool bDestroyActor)
{
	if ( Next != None && Previous != None )
	{
		Next.Previous = Previous;
		Previous.Next = Next;
	}

	if ( bDestroyActor )
		ThisActor.Destroy();

	Log(self@"has removed succesfully from list!");
	Destroy();
}
VolumeModifier expands Actor;

Code: Select all

//=============================================================================
// VolumeModifier.
//=============================================================================
class VolumeModifier expands Actor;

var()	VolumeModifier	Next;

function VolumeTouch(Actor Other, OldVolume Touched, VolumeActors Actors);
function VolumeUntouch(Actor Other, OldVolume Touched, VolumeActors Actors);
function VolumeClock(float ClockInterval, OldVolume Touched, VolumeActors Actors);
function GotVolume(OldVolume Volume);

function bool BlockActor(Actor Other)
{
	return false;
}
VolumeLadder expands VolumeModifier;

Code: Select all

//=============================================================================
// VolumeLadder.
//=============================================================================
class VolumeLadder expands VolumeModifier;

var()	float	LadderSpeedScale;
var		Actor	Ignored;

function VolumeClock(float ClockInterval, OldVolume Touched, VolumeActors Actors)
{
	local VolumeActors	VA;
	local Vector		VDist2D;
	local Vector		MDist2D;

	for ( VA = Actors; VA != None; VA = VA.Next )
		if ( Pawn(VA.ThisActor) != None )
		{
			VDist2D = VA.ThisActor.Velocity;
			VDist2D.Z = 0;

			MDist2D = Vector(Rotation);
			MDist2D.Z = 0;

			VA.ThisActor.Velocity.Z = VSize(VDist2D) * (VDist2D dot MDist2D) * LadderSpeedScale;
			VA.ThisActor.Velocity -= VDist2D;
		}
}

function VolumeTouch(Actor Other, OldVolume Touched, VolumeActors Actors)
{
	if ( Ignored == Other )
		Ignored = None;
}

function VolumeUntouch(Actor Other, OldVolume Touched, VolumeActors Actors)
{
	Ignored = Other;

	Other.SetPhysics(PHYS_Falling);
}
But hey, at least, it already has much functionality!

So I've went on to testing. In the previous tests, it seemed I would get thrown away even if I suicide and sometimes it would suddenly stop and give a massive lag upon re-entering the volume. After those, it was more clear that I was advancing -- but basically by an educated guesswork. :(

Q: Why do you keep putting those code threads around?
A: Because I can learn and at the same time end up creating some cool stuff for UT99. Or at least fun stuff :P
"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
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: [Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by Higor »

This looks like a workaround to the lack of dynamic arrays in UnrealScript.
Each toucher adds an element on a chained list and said elements will then apply a modifier onto the toucher.

Here's some examples from Siege of similar things (far more refined lol).

Suppliers
You stand near them, CompleteBuilding() gets called every 0.1 second and one player receives supply (specified in subclass), here I use the 'Queuers' to rotate the list and supply one player at a time.
https://github.com/CacoFFF/SiegeIV-UT99 ... upplier.uc
https://github.com/CacoFFF/SiegeIV-UT99 ... rQueuer.uc

Stat recovery, doesn't care about how many players it records
The game attempts to identify a new player and sgRURecovery will see if there's an existing saved Queuer actor with a matching ID.
In this case, most of the code is in the Queuers instead of the controller.
https://github.com/CacoFFF/SiegeIV-UT99 ... ecovery.uc
https://github.com/CacoFFF/SiegeIV-UT99 ... yQueuer.uc

Notice how the Setup, Destroy, Loop logics barely change?

Also, this one which has some sorting logic.
Movement affectors that can be stacked onto a player, many things can now alter player movement.
https://github.com/CacoFFF/SiegeIV-UT99 ... yerData.uc
https://github.com/CacoFFF/SiegeIV-UT99 ... ffector.uc
User avatar
jaypeezy
Experienced
Posts: 109
Joined: Fri Feb 26, 2010 1:53 am

Re: [Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by jaypeezy »

Hm, so if the Volume actor works then it would be possible to have ladders in UT99? That's pretty cool! Always wanted that to be a feature (confusing it was in Deus Ex but not UT/Unreal, considering they're on the same engine...)
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: [Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by Barbie »

That Remove() function cannot remove first or last element of the double linked list. Furthermore after removing that element from the list it keeps the pointers to its neighbours - not an error here but a source for future misunderstandings or errors.

I use this in my double linked list (of Objects):

Code: Select all

singular function Delete() {
/******************************************************************************
Removes itself from the list.
******************************************************************************/
	if (Prev != None)
		Prev.Next = Next;
	if (Next != None)
	{
		Next.Prev = Prev;
		Next = None;
	}
	Prev = None;
	// self.Free(); <- does not exist for Objects
}
See also
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: [Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by Gustavo6046 »

Yes, ladders! :D

Also, thanks Higor. That'll probably be of help :)
Barbie wrote:That Remove() function cannot remove first or last element of the double linked list. Furthermore after removing that element from the list it keeps the pointers to its neighbours - not an error here but a source for future misunderstandings or errors.

I use this in my double linked list (of Objects):

Code: Select all

singular function Delete() {
/******************************************************************************
Removes itself from the list.
******************************************************************************/
	if (Prev != None)
		Prev.Next = Next;
	if (Next != None)
	{
		Next.Prev = Prev;
		Next = None;
	}
	Prev = None;
	// self.Free(); <- does not exist for Objects
}
See also
Yeah, you are right. Thanks for that code. Can I use it? Or should I do myself something similiar? :)
"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
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: [Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by Barbie »

Gustavo6046 wrote:Thanks for that code. Can I use it?
Due to the excessive man power needed to develop this, superior quality and amount of code I should put spoiler tags around to make it "closed source". :lol:
Seriously, do what you want with it, burn it, print it, use it, ...
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: [Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by Gustavo6046 »

Barbie wrote:The excessive man power needed to develop this, superior quality and amount of code
Is that a challenge? :wink:
"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
User avatar
papercoffee
Godlike
Posts: 10447
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: [Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by papercoffee »

Gustavo6046 wrote:
Barbie wrote:The excessive man power needed to develop this, superior quality and amount of code
Is that a challenge? :wink:
No, it's a corny joke ;)
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: [Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by Gustavo6046 »

papercoffee wrote:No, it's a corny joke ;)
Ok, but now I just motivated to do something better, original and of course, flexible! :tongue:
"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
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: [Pre-Alpha] OldVolumes (Volumes for UT99)!

Post by Barbie »

If you create linked list items, you should make sure that the length of the name of that created actor does not exceed 1023 chars. See my posting Is MH-Space-Port known for issues for details (the <EDIT>...</EDIT> part).
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Post Reply