Page 1 of 1

Class-based teleporter

Posted: 04 Nov 2017, 09:27
by Lightning Hunter
I'm sure this will be a piece of cake for you coders out there (AlCapowned? Lol). I need a teleporter that only works for a specified class, similar to triggers that are set to TT_ClassProximity.

Re: Class-based teleporter

Posted: 04 Nov 2017, 09:31
by Krull0r
I‘m also interested in such a Teleporter for my project :)

Re: Class-based teleporter

Posted: 04 Nov 2017, 19:36
by AlCapowned
https://www.mediafire.com/file/lcy3jxre5g02x4x/ClassTeleporter_11_4_17_1.zip

I realized after making this that the class check isn't set up the same way as it is in triggers, but it works fine. Instead of specifying the full class (ie. class'unreali.krall') you just put in the class name (krall).

Re: Class-based teleporter

Posted: 04 Nov 2017, 20:53
by Krull0r
I tested it. I had problems to compile it. ( I'm using Unreal 227 )

I had to change the line: Dest.Accept( Other, self); to Dest.Accept(Other);

But it works exactly the way it should :) thank you!

Re: Class-based teleporter

Posted: 04 Nov 2017, 21:16
by Lightning Hunter
I thought all code that works in UT99 is also supposed to work in 227? I had no problems compiling that code, but I wonder if it will be compatible with 227 or not. I will definitely need someone to test RyS in 227 during the beta testing phase.

Re: Class-based teleporter

Posted: 05 Nov 2017, 15:14
by gopostal
Lightning Hunter wrote:I will definitely need someone to test RyS in 227 during the beta testing phase.


:WavesHandEnthusiastically:

Re: Class-based teleporter

Posted: 11 Nov 2017, 21:09
by Masterkent
Krull0r wrote:I had to change the line: Dest.Accept( Other, self); to Dest.Accept(Other);

But it works exactly the way it should :) thank you!

That change may be insufficient if you plan to support network game and the teleporter is supposed to be enabled/disabled at some moment during game. Unlike UT clients, Unreal clients (including 227) are not supposed to simulate teleportation client-side and they do not replicate bEnabled in order to make correct client-side simulation possible.

A portable implementation that would correctly work under UT and Unreal could look like this:

Code: Select all

class ClassTeleporter expands Teleporter;

var() class<Actor> ExactClasses[32];
var() class<Actor> BaseClasses[32];
var() name ExactClassNames[32];
var() name BaseClassNames[32];

simulated function Touch(Actor A)
{
   if (bEnabled && CanTeleportActor(A))
      super.Touch(A);
}

simulated function bool CanTeleportActor(Actor A)
{
   local int i;

   if (!A.bCanTeleport)
      return false;

   for (i = 0; i < ArrayCount(ExactClasses) && ExactClasses[i] != none; ++i)
      if (A.Class == ExactClasses[i])
         return true;

   for (i = 0; i < ArrayCount(BaseClasses) && BaseClasses[i] != none; ++i)
      if (ClassIsChildOf(A.Class, BaseClasses[i]))
         return true;

   for (i = 0; i < ArrayCount(ExactClassNames) && ExactClassNames[i] != ''; ++i)
      if (A.Class.Name == ExactClassNames[i])
         return true;

   for (i = 0; i < ArrayCount(BaseClassNames) && BaseClassNames[i] != ''; ++i)
      if (A.IsA(BaseClassNames[i]))
         return true;

   return false;
}

If you don't need portability and prefer to take maximum advantage of 227 features, I would suggest to use something like this instead:

Code: Select all

class ClassTeleporter expands Teleporter;

var() array<class<Actor> > ExactClasses;
var() array<class<Actor> > BaseClasses;
var() array<name> ExactClassNames;
var() array<name> BaseClassNames;

function Touch(Actor A)
{
   if (bEnabled && CanTeleportActor(A))
      super.Touch(A);
}

function bool CanTeleportActor(Actor A)
{
   local int i;

   if (!A.bCanTeleport)
      return false;

   for (i = 0; i < Array_Size(ExactClasses); ++i)
      if (ExactClasses[i] != none && A.Class == ExactClasses[i])
         return true;

   for (i = 0; i < Array_Size(BaseClasses); ++i)
      if (BaseClasses[i] != none && ClassIsChildOf(A.Class, BaseClasses[i]))
         return true;

   for (i = 0; i < Array_Size(ExactClassNames); ++i)
      if (ExactClassNames[i] != '' && A.Class.Name == ExactClassNames[i])
         return true;

   for (i = 0; i < Array_Size(BaseClassNames); ++i)
      if (BaseClassNames[i] != '' && A.IsA(BaseClassNames[i]))
         return true;

   return false;
}

Lightning Hunter wrote:I thought all code that works in UT99 is also supposed to work in 227?

Definitely not. 227 is supposed to maintain compatibility with the most recent official versions of Unreal 1 (developed by Epic MegaGames): 224 - 226. UT includes some modifications of scripts that make any code using such modifications incompatible with 226 and 227. The incompatibility does not necessarily imply that the code won't compile under 226/227 environment (albeit it's a common outcome), you may get a successfully compiled script that won't work correctly under some circumstances.

Re: Class-based teleporter

Posted: 12 Nov 2017, 06:54
by Lightning Hunter
Thanks Masterkent, I will use the first bit of code you posted since this pack is for UT99 and Unreal.

Re: Class-based teleporter

Posted: 12 Nov 2017, 12:02
by Masterkent
Note that all suggested implementations only impose additional restrictions on the set of actors that can be teleported and do not allow teleportation of actors whose bCanTeleport is False. Making a well-working cross-platform implementation of a teleporter that would let you teleport something like projectiles, which cannot be teleported by plain teleporters, would be much more tricky.

Re: Class-based teleporter

Posted: 12 Nov 2017, 19:34
by Krull0r
Masterkent = Mastermind

Thank you very much :)

Re: Class-based teleporter

Posted: 12 Nov 2017, 21:43
by Lightning Hunter
Masterkent wrote:Note that all suggested implementations only impose additional restrictions on the set of actors that can be teleported and do not allow teleportation of actors whose bCanTeleport is False. Making a well-working cross-platform implementation of a teleporter that would let you teleport something like projectiles, which cannot be teleported by plain teleporters, would be much more tricky.


In my case, I am merely teleporting a ScriptedPawn that is not the player, so all is good. 8)