Team Teleporter SpecialCost problem

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

CoolDude

New Member
Feb 22, 2003
914
0
0
Netherlands
Visit site
I'm beginning to go crazy (I probably miss something simple here).

I'm trying to make a team dependent teleporter. For that I use an extra team property "TeamNumber" to set the team which is allowed to use the teleporter.
The Touch() function is no problem, I'm refused when I step into the wrong teleporter.
However, I also use the SpecialCost() function, so the bots won't use teleporter.
For some reason the TeamNumber in SpecialCost() always is "1" (however in Touch() it's OK).
This means the BLUE teleporter works OK, also with bots.
The RED teleporter works OK for humans, but not for bots.
BLUE bots still think they can use the RED teleporter.

I stripped down the code to the essentials only. SpecialCost() is where the problem lies:
Code:
//===================================================
// TeamTeleporter
//========================================================
class TeamTeleporter extends Teleporter
	placeable;


// =========================================
// Variables
// =========================================
var(TeamTeleporter) int TeamNumber;   // Team supposed to use the Teleporter


// =========================================
// Touch
// =========================================
event Touch(actor Other)
{
  if( (Level.Game.bTeamGame) && (Other.IsA('Pawn')) )
  {
    if (Pawn(Other).PlayerReplicationInfo != None)
    {
      if (Pawn(Other).PlayerReplicationInfo.Team.TeamIndex == TeamNumber)
      {
        log("Touch "@Pawn(Other).PlayerReplicationInfo.PlayerName@"PlayerTeamIndex="@Pawn(Other).PlayerReplicationInfo.Team.TeamIndex@" TeleporterTeamNumber="@TeamNumber@" ALLOWED");
        Super.Touch(Other);
      } 
      else
      {
        log("Touch "@Pawn(Other).PlayerReplicationInfo.PlayerName@"PlayerTeamIndex="@Pawn(Other).PlayerReplicationInfo.Team.TeamIndex@" TeleporterTeamNumber="@TeamNumber@" REFUSED");
      }
    }
  }
  else
  {
    Super.Touch(Other);
  }
}


//========================================================
// SpecialCost
//========================================================
event int SpecialCost(Pawn Other, ReachSpec Path)
{
  if ( (Level.Game.bTeamGame) && (Other.PlayerReplicationInfo != None) )
  {
    if (Other.PlayerReplicationInfo.Team.TeamIndex != TeamNumber)
    {
      log("SpecialCost "@Other.PlayerReplicationInfo.PlayerName@"PlayerTeamIndex="@Other.PlayerReplicationInfo.Team.TeamIndex@" TeleporterTeamNumber="@TeamNumber@" EXTRACOST");
      return 100000000;
    }
    else
    {
      log("SpecialCost "@Other.PlayerReplicationInfo.PlayerName@"PlayerTeamIndex="@Other.PlayerReplicationInfo.Team.TeamIndex@" TeleporterTeamNumber="@TeamNumber@" OK");
      Super.SpecialCost(Other,Path);
    }
  }
  else
  {
    Super.SpecialCost(Other,Path);
  }
}
This is the result for a RED teleporter and a BLUE player:
Code:
ScriptLog: SpecialCost  CoolDude PlayerTeamIndex= 1  [B]TeleporterTeamNumber= 1[/B]  OK
ScriptLog: SpecialCost  CoolDude PlayerTeamIndex= 1  [B]TeleporterTeamNumber= 1[/B]  OK
ScriptLog: Touch  CoolDude PlayerTeamIndex= 1  TeleporterTeamNumber= 0  REFUSED
ScriptLog: Touch  CoolDude PlayerTeamIndex= 1  TeleporterTeamNumber= 0  REFUSED
For SpecialCosts() it should say TeleporterTeamNumber=0 EXTRACOST.
Maybe anybody can tell me what I am missing?
 
Last edited:

CoolDude

New Member
Feb 22, 2003
914
0
0
Netherlands
Visit site
Your hunch was correct Wormbo, the map has got two team teleporters.
When I'm in the neighbourhood of TeamTeleporter0, it seems to call the SpecialCost() function of TeamTeleporter2 ?!? :eek:
Code:
ScriptLog: [B]Autoplay.TeamTeleporter2[/B] SpecialCost  CoolDude PlayerTeamIndex= 1  TeleporterTeamNumber= 1  OK
ScriptLog: [B]Autoplay.TeamTeleporter2[/B] SpecialCost  CoolDude PlayerTeamIndex= 1  TeleporterTeamNumber= 1  OK
ScriptLog: Autoplay.TeamTeleporter0 Touch  CoolDude PlayerTeamIndex= 1  TeleporterTeamNumber= 0  REFUSED
ScriptLog: Autoplay.TeamTeleporter0 Touch  CoolDude PlayerTeamIndex= 1  TeleporterTeamNumber= 0  REFUSED

The only thing I can think of is some dirty fix in SpecialCost() where I calculate the distance between the Pawn Other and all TeamTeleporters and then return the value based on the shortage distance.

But there must be a proper way to fix this ... isn't there?


// edit: strange btw that JailBreak calls SpecialCost() also for human players, whereas TeamDeathMatch (my testmap) only calls it for Bots. But then both gametypes give the same wrong result, calling the wrong (last?) SpecialCost() function.
 
Last edited:

Mychaeel

New Member
CoolDude said:
// edit: strange btw that JailBreak calls SpecialCost() also for human players, whereas TeamDeathMatch (my testmap) only calls it for Bots. But then both gametypes give the same wrong result, calling the wrong (last?) SpecialCost() function.
Jailbreak uses an invisible, server-side "scout" pawn to measure distances in the path network for several purposes -- among them finding out which objective a human player is approaching (to dsplay "attacking" or "defending" in the scoreboard even for humans), and finding out which of the bots to send to a new objective (i.e. the one closest to it). That's probably the reason you see SpecialCost calls which are unrelated to any visible player or bot approaching your NavigationPoint.

Those distances are cached, though, under the silent assumption that they (1) do not change over time and (2) aren't team-specific. The latter is obviously incorrect, here.

However, none of this should actually cause bots to navigate towards the wrong TeamTeleporter -- even though Jailbreak might incorrectly assume a certain bot is most suited to going somewhere (through a TeamTeleporter that'd actually not work for it), the bots find their way on their own (and with their actual TeamIndex) once ordered to go somewhere.

Did you actually find out through testing that red bots will attempt to use blue TeamTeleporters, or are you making that assumption based on your observation that "TeamIndex in SpecialCost is always 1"?
 

CoolDude

New Member
Feb 22, 2003
914
0
0
Netherlands
Visit site
I'm desperate...

I've got a working RedTeleporter and BlueTeleporter now in my TDM-Testmap, the SpecialCost() function is called OK (don't ask me why seeing the mentioned TeamTeleporter problem above).

If I now open another DM-map (or CTF or JB) and place the RedTeleporter/BlueTeleporters in there my SpecialCost() functions are never called, resulting in bots trying to enter the wrong teleporter. Copying them instead of placing, or rebuilding the complete map, or recompiling the teleporters doesn't help.

Sometimes, mysteriously they seem to work OK for some reason. I once copied them into CTF-EpicBoy2k4 succesfully and SpecialCost() was called correctly. But most of the time they won't, without any logical reason.

Attached is my TDM-testmap. I left the log-info in so it can be tested easily. You can see it works correct by spectating a couple of bots in TournamentDeathmatch and looking at the log (type "showlog" in the console). If you now place/copy these teleporter actors in another map, the SpecialCost() functions are not called anymore and bots will try to enter both colours of teleporter.

What on earth is going on with this SpecialCost() function?
It worked OK in the old UT, it's used in the normal Teleporter code itself (for blocking Vehicles) in UT2004.

I don't know anymore, I hope anyone else does ...
 

Attachments

  • DM-TeamTeleporterProblem.zip
    20.3 KB · Views: 12

G.Lecter

Registered Tester
Dec 31, 2004
1,257
3
38
36
Spain
www.oscarcrego.com
Off topic...

I don't know anything about coding, but if making this is too dificult, you could place a normal teleporter behind a team-triggered door. (I've already seen team-triggers in some maps...) :rolleyes:
 

Jrubzjeknf

Registered Coder
Mar 12, 2004
1,276
0
36
36
The Netherlands
I've done the same with the specialcost stuff, and it works for me. Even though the bots head for the wrong teleporter occaisonally, they never enter it or try to use it. I think the problem rather lies in your map than your coding. If a bot wants to get to the other side of the map, he has to go past a teleporter, even though he might not want to enter it.

Anyways, I'm currently working on this stuff, along with some other Team specific actors. I hope to (beta)release them very soon.