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);
}
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();
}
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;
}
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);
}
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