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:
This is the result for a RED teleporter and a BLUE player:
For SpecialCosts() it should say TeleporterTeamNumber=0 EXTRACOST.
Maybe anybody can tell me what I am missing?
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);
}
}
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
Maybe anybody can tell me what I am missing?
Last edited: