Announcement

Collapse
No announcement yet.

Vehicle + CTFFlag = Access none

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Vehicle + CTFFlag = Access none

    This could be old news but I havent seen any posts about it. If a player takes the flag and then jumps into a vehicle which allows the player to carry the flag while driving or flying. The CTFSqaudAI starts to go crazy with access nones.

    For Example: CTFSquadAI (Function UnrealGame.CTFSquadAI.CheckSquadObjectives:07D6) Accessed None 'FlagCarrier'

    If someone could post a fix or a correction would be great! If not then Thank you anyways....

    Thank you

    Windex

    #2
    Just blind guess but it might be the way ut2004 (ut2003?) handles entering vehicles by player. Whenever player (either human or bot) enters vehicle player's Controller.Pawn starts to point to vehicle pawn instead of player pawn (flag carrier in that case).

    Comment


      #3
      Could be but what you think of about this?

      CTFSquadAI (Function UnrealGame.CTFSquadAI.CheckSquadObjectives:07D6) Accessed None 'FlagCarrier'

      CTFSquadAI = the script that the function is calling the access none from.

      CheckSquadObjectives= the function that is called inside the CTFSQuadAI script.

      The CheckSquadObjectives says:

      function bool CheckSquadObjectives(Bot B)
      {
      local bool bSeeFlag;
      local actor FlagCarrierTarget;
      local controller FlagCarrier;

      if ( B.PlayerReplicationInfo.HasFlag == EnemyFlag )
      return OrdersForFlagCarrier(B);

      AddTransientCosts(B,1);
      if ( !FriendlyFlag.bHome )
      {
      bSeeFlag = B.LineOfSightTo(FriendlyFlag.Position());
      if ( Team.Size == 1 )
      {
      if ( B.NeedWeapon() && B.FindInventoryGoal(0) )
      {
      B.SetAttractionState();
      return true;
      }

      // keep attacking if 1-0n-1
      if ( (FriendlyFlag.Holder != None) || (VSize(B.Pawn.Location - FriendlyFlag.Position().Location) > VSize(B.Pawn.Location - EnemyFlag.Position().Location)) )
      return FindPathToObjective(B,EnemyFlag.Position());
      }
      if ( bSeeFlag )
      {
      if ( FriendlyFlag.Holder == None )
      {
      if ( GoPickupFlag(B) )
      return true;
      }
      else
      {
      if ( (B.Enemy.PlayerReplicationInfo != None) && (B.Enemy.PlayerReplicationInfo.HasFlag != FriendlyFlag) )
      FindNewEnemyFor(B,(B.Enemy != None) && B.LineOfSightTo(B.Enemy));
      if ( Level.TimeSeconds - LastSeeFlagCarrier > 6 )
      {
      LastSeeFlagCarrier = Level.TimeSeconds;
      B.SendMessage(None, 'OTHER', B.GetMessageIndex('ENEMYFLAGCARRIERHERE'), 10, 'TEAM');
      }
      B.GoalString = "Attack enemy flag carrier";
      if ( B.IsSniping() )
      return false;
      B.bPursuingFlag = true;
      return ( TryToIntercept(B,FriendlyFlag.Holder,EnemyFlag.Hom ebase) );
      }
      }

      if ( GetOrders() == 'Attack' )
      {
      // break off attack only if needed
      if ( B.bPursuingFlag || bSeeFlag || (B.LastRespawnTime > FriendlyFlag.TakenTime) || NearHomeBase(B)
      || ((Level.TimeSeconds - FriendlyFlag.TakenTime > FriendlyFlag.HomeBase.BaseExitTime) && !NearEnemyBase(B)) )
      {
      B.bPursuingFlag = true;
      B.GoalString = "Go after enemy holding flag rather than attacking";
      if ( FriendlyFlag.Holder != None )
      return TryToIntercept(B,FriendlyFlag.Holder,EnemyFlag.Hom ebase);
      else if ( GoPickupFlag(B) )
      return true;

      }
      else if ( B.bReachedGatherPoint )
      B.GatherTime = Level.TimeSeconds - 10;

      }
      else if ( (PlayerController(SquadLeader) == None) && !B.IsSniping()
      && ((CurrentOrders != 'Defend') || bSeeFlag || (B.bPursuingFlag && FlagNearBase())) )
      {
      // FIXME - try to leave one defender at base
      B.bPursuingFlag = true;
      B.GoalString = "Go find my flag";
      if ( FriendlyFlag.Holder != None )
      return TryToIntercept(B,FriendlyFlag.Holder,EnemyFlag.Hom ebase);
      else if ( GoPickupFlag(B) )
      return true;
      }
      }
      B.bPursuingFlag = false;

      if ( (SquadObjective == EnemyFlag.Homebase) && (B.Enemy != None) && FriendlyFlag.Homebase.BotNearObjective(B)
      && (Level.TimeSeconds - B.LastSeenTime < 3) )
      {
      if ( !EnemyFlag.bHome && (EnemyFlag.Holder == None ) && B.LineOfSightTo(EnemyFlag.Position()) )
      return FindPathToObjective(B,EnemyFlag.Position());

      B.SendMessage(None, 'OTHER', B.GetMessageIndex('INCOMING'), 15, 'TEAM');
      B.GoalString = "Intercept incoming enemy!";
      return false;
      }

      if ( EnemyFlag.Holder == None )
      {
      if ( !EnemyFlag.bHome || EnemyFlag.Homebase.BotNearObjective(B) )
      {
      B.GoalString = "Near enemy flag!";
      return FindPathToObjective(B,EnemyFlag.Position());
      }
      }
      else if ( (GetOrders() != 'Defend') && !SquadLeader.IsA('PlayerController') )
      {
      // make flag carrier squad leader if on same squad
      FlagCarrier = EnemyFlag.Holder.Controller;
      if ( (SquadLeader != FlagCarrier) && IsOnSquad(FlagCarrier) )
      SetLeader(FlagCarrier);

      if ( (B.Enemy != None) && B.Enemy.LineOfSightTo(FlagCarrier.Pawn) )
      {
      B.GoalString = "Fight enemy threatening flag carrier";
      B.FightEnemy(true,0);
      return true;
      }

      if ( ((FlagCarrier.MoveTarget == FriendlyFlag.HomeBase)
      || (FlagCarrier.RouteCache[1] == FriendlyFlag.HomeBase))
      && (B.Enemy != None)
      && B.LineOfSightTo(FriendlyFlag.HomeBase) )
      {
      B.GoalString = "Fight enemy while waiting for flag carrier to score";
      if ( B.LostContact(7) )
      B.LoseEnemy();
      if ( B.Enemy != None )
      {
      B.FightEnemy(false,0);
      return true;
      }
      }

      if ( (AIController(FlagCarrier) != None) && (FlagCarrier.MoveTarget != None)
      && (FlagCarrier.InLatentExecution(FlagCarrier.LATENT_ MOVETOWARD)) )
      {
      if ( (FlagCarrier.RouteCache[0] == FlagCarrier.MoveTarget)
      && (FlagCarrier.RouteCache[1] != None) )
      FlagCarrierTarget = FlagCarrier.RouteCache[1];
      else
      FlagCarrierTarget = FlagCarrier.MoveTarget;
      }
      else
      FlagCarrierTarget = FlagCarrier.Pawn;
      FindPathToObjective(B,FlagCarrierTarget);
      if ( (B.MoveTarget == FlagCarrierTarget) || (B.MoveTarget == FlagCarrier.MoveTarget) )
      {
      if ( B.Enemy != None )
      {
      B.GoalString = "Fight enemy while waiting for flag carrier";
      if ( B.LostContact(7) )
      B.LoseEnemy();
      if ( B.Enemy != None )
      {
      B.FightEnemy(false,0);
      return true;
      }
      }
      if ( !B.bInitLifeMessage )
      {
      B.bInitLifeMessage = true;
      B.SendMessage(EnemyFlag.Holder.PlayerReplicationIn fo, 'OTHER', B.GetMessageIndex('GOTYOURBACK'), 10, 'TEAM');
      }
      if ( (B.MoveTarget == FlagCarrier.Pawn)
      && ((VSize(B.Pawn.Location - FlagCarrier.Pawn.Location) < 250) || (FlagCarrier.Pawn.Acceleration == vect(0,0,0))) )
      return false;
      if ( B.Pawn.ReachedDestination(FlagCarrierTarget) || (FlagCarrier.Pawn.Acceleration == vect(0,0,0))
      || (FlagCarrier.MoveTarget == FriendlyFlag.HomeBase) || (FlagCarrier.RouteCache[1] == FriendlyFlag.HomeBase) )
      {
      B.WanderOrCamp(true);
      B.GoalString = "Back up the flag carrier!";
      return true;
      }
      }

      B.GoalString = "Find the flag carrier - move to "$B.MoveTarget;
      return ( B.MoveTarget != None );
      }
      return Super.CheckSquadObjectives(B);
      }


      ////End of function

      I am guessing like in the strangelove of today and from the original super Strangelove by Yrns, that they had to add some code about the vehicle.

      In the strangelove they changed the Function SetHolder in the CTF Flags to handle the flags being carried.

      For Example: Strangelove34

      function SetHolder(Controller C)
      {
      local int i;

      log("SL_CTFFlag:SetHolder()");

      LogTaken(c);
      if(UnrealPawn(C.Pawn) != none)
      {
      Holder = UnrealPawn(C.Pawn);
      }
      else if(Vehicle(C.Pawn) != none && UnrealPawn(Vehicle(C.Pawn).Driver) != none)
      {
      Holder = UnrealPawn(Vehicle(C.Pawn).Driver);
      }
      Holder.DeactivateSpawnProtection();
      HolderPRI = TeamPlayerReplicationInfo(Holder.PlayerReplication Info);
      C.PlayerReplicationInfo.HasFlag = self;
      C.PlayerReplicationInfo.NetUpdateTime = Level.TimeSeconds - 1;

      GotoState('Held');

      /// End of Function


      See the "if(Vehicle(C.Pawn) != none && UnrealPawn(Vehicle(C.Pawn).Driver) != none)" This is important to avoid the access nones I would guess and for some other important assist code.

      Since the Function call inside the CTFSquadAI has no reference to the vehicles... That in its self is none when a player grabs the flag and takes off in a vehicle. The Vehicle is set to none. Sever goes crazy, players get lag well we know the rest..

      This is guess on my part and I hope someone can step forward with some kind fix...of solution besides for not to carry the flag in a vehicle... PLEASE!!!

      Thank you

      Sincerely

      Windex

      Comment


        #4
        Originally posted by Windex
        if(UnrealPawn(C.Pawn) != none)
        {
        Holder = UnrealPawn(C.Pawn);
        }
        else if(Vehicle(C.Pawn) != none && UnrealPawn(Vehicle(C.Pawn).Driver) != none)
        {
        Holder = UnrealPawn(Vehicle(C.Pawn).Driver);
        }
        ....
        See the "if(Vehicle(C.Pawn) != none && UnrealPawn(Vehicle(C.Pawn).Driver) != none)" This is important to avoid the access nones I would guess and for some other important assist code.
        The code above have no sense! (This case if you enter vehicle holder will point to vehicle instead of xpawn.)
        Yes I see that "if..." but 'cause it is in else statement then that if will never be true (dead code);

        I would do it like this:
        Code:
        if(C.Pawn!=None){
            if(C.Pawn.IsA('Vehicle'))
                Holder=Vehicle(C.Pawn).Driver;
            else
                Holder=C.Pawn;
        }

        Comment


          #5
          Or just get rid of that else from your original code in SetHolder() and it should work.
          ... but not sure - I don't like these casts to vehicle from non-vehicle pawns :weird:

          Comment


            #6
            I might be wrong in my two posts above...
            I'm not sure how explicit casting in utscript works :noob: but if casting from class Vehicle to UnrealPawn gives None then that code is correct

            Comment


              #7
              I don't know?

              I really don't know, I really should just take some courses in C++ or basic programing. .. I can only guess from testing and trail and error... All I do know is that when someone takes the flag in a vehicle the bot AI goes crazy... I will try what you suggested, just one more problem the script belongs in the package UnrealGame.u... I think I wait for a patch but I play with it localy to see what happens...

              Thank you for your help!

              Windex

              Comment

              Working...
              X