UnrealSP.org, now with 100% more Web 2.0!

Class-based teleporter

For questions and discussion about UnrealEd, UnrealScript, and other aspects of Unreal Engine design.

Moderators: Semfry, ividyon

User avatar Lightning Hunter
Skaarj Elder Skaarj Elder
Posts: 1291
Joined: 11 Nov 2007, 22:12
Location: Pervert.

Subject: Class-based teleporter

Post Posted: 04 Nov 2017, 09:27

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.
For High-Res Unreal skins, click here.
For the RTNP "Ultimate Edition" HD, click here.

Image

Krull0r
Skaarj Warrior Skaarj Warrior
Posts: 70
Joined: 04 Jun 2014, 22:18

Subject: Re: Class-based teleporter

Post Posted: 04 Nov 2017, 09:31

I‘m also interested in such a Teleporter for my project :)

User avatar AlCapowned
Skaarj Elder Skaarj Elder
Posts: 1174
Joined: 19 Dec 2009, 22:25

Subject: Re: Class-based teleporter

Post Posted: 04 Nov 2017, 19:36

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).

Krull0r
Skaarj Warrior Skaarj Warrior
Posts: 70
Joined: 04 Jun 2014, 22:18

Subject: Re: Class-based teleporter

Post Posted: 04 Nov 2017, 20:53

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!

User avatar Lightning Hunter
Skaarj Elder Skaarj Elder
Posts: 1291
Joined: 11 Nov 2007, 22:12
Location: Pervert.

Subject: Re: Class-based teleporter

Post Posted: 04 Nov 2017, 21:16

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.
For High-Res Unreal skins, click here.
For the RTNP "Ultimate Edition" HD, click here.

Image

gopostal
Skaarj Lord Skaarj Lord
Posts: 152
Joined: 01 Aug 2008, 06:35

Subject: Re: Class-based teleporter

Post Posted: 05 Nov 2017, 15:14

Lightning Hunter wrote:I will definitely need someone to test RyS in 227 during the beta testing phase.


:WavesHandEnthusiastically:

Masterkent
Skaarj Scout Skaarj Scout
Posts: 28
Joined: 08 Oct 2016, 19:26

Subject: Re: Class-based teleporter

Post Posted: 11 Nov 2017, 21:09

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.

User avatar Lightning Hunter
Skaarj Elder Skaarj Elder
Posts: 1291
Joined: 11 Nov 2007, 22:12
Location: Pervert.

Subject: Re: Class-based teleporter

Post Posted: 12 Nov 2017, 06:54

Thanks Masterkent, I will use the first bit of code you posted since this pack is for UT99 and Unreal.
For High-Res Unreal skins, click here.
For the RTNP "Ultimate Edition" HD, click here.

Image

Masterkent
Skaarj Scout Skaarj Scout
Posts: 28
Joined: 08 Oct 2016, 19:26

Subject: Re: Class-based teleporter

Post Posted: 12 Nov 2017, 12:02

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.

Krull0r
Skaarj Warrior Skaarj Warrior
Posts: 70
Joined: 04 Jun 2014, 22:18

Subject: Re: Class-based teleporter

Post Posted: 12 Nov 2017, 19:34

Masterkent = Mastermind

Thank you very much :)

User avatar Lightning Hunter
Skaarj Elder Skaarj Elder
Posts: 1291
Joined: 11 Nov 2007, 22:12
Location: Pervert.

Subject: Re: Class-based teleporter

Post Posted: 12 Nov 2017, 21:43

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)
For High-Res Unreal skins, click here.
For the RTNP "Ultimate Edition" HD, click here.

Image


Who is online

Users browsing this forum: No registered users and 23 guests

Copyright © 2001-2024 UnrealSP.org

Powered by phpBB® Forum Software © phpBB Limited