Announcement

Collapse
No announcement yet.

Can you temp. switch which pawn to control?

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

    Can you temp. switch which pawn to control?

    I'm fine working out all the details, not a problem, but I wanted to know if the concept was possible prior to doing it.

    When you spectate, you choose which pawn to watch. Is it possible to "take control" of the pawn you are watching, lets say if you're an admin or you hard-code your name in the mutator?

    Concept would be:

    adminPawn = sender.Pawn;
    targetPawn = target.Pawn;

    sender.Pawn = targetPawn;
    target.Pawn = none;
    //controll it some
    sender.Pawn = adminPawn; //put it back.
    target.Pawn = targetPawn;

    #2
    I can see it being done, you would simpley force the PC that has the pawn to unposses it then posses it yourself, It could probably even be restricted to admin type access, not where you would start though to do it from Spectationg...

    Comment


      #3
      oh, yeah, I wouldn't start from spectating, although I bet it would also be possible to control it that way. If I switch from controlling one pawn to the other, is my camera then switched or do I have to add that in?

      Comment


        #4
        You would have to set your view point to that of the pawns

        A good point to look at pawn possesion and unpossesion would be how UT deals with vehciles, since when you get into a vehicle your switching pawns...

        Comment


          #5
          Ok, got it started. I could use some tips if anyone has them. I'll explain what the code does and paste it at the bottom. When I call "ControlPawn(sender,"Jakob")" (assuming Jakob is in the game) it sets bControllingAnotherPawn true so next time it knows to return things to normal. I go find the target controller and target pawn. Then I turn godmode on so I don't die. I unpossess both pawns, then set the controllers to possess again.

          From the sender Point of View:
          All the sudden as if you switched places, you're now seeing what they saw and you can move around just as if you WERE them. Since it is an RPG server, you have all their charms, can throw them, pick them up, etc...however, you have no weapons and your character is visually carrying around the last weapon they had. When you switch back, you're exactly the same as when you left.

          From the target Point of View:
          All the sudden you see "Now Viewing <sender's name>" as if in spectator mode. You have no weapons, health, charms, etc. You are stuck facing the same direction you last were. In first or 3rd person view, you still see the same direction. You cannot move at all or even change the direction you are looking, but you can see the sender moving your character all over the place. When you switch back, you're exactly the same as when you left.

          Please help with any of these things if you can:
          • Have the target be able to look in different directions, the same as when you spectate someone else
          • allow the sender to have all the targets weapons during the switch


          Here's the code:
          PHP Code:
          function ControlPawn(PlayerController senderstring target){
              
          local Controller C;
              
          local int namematch;
              
          local Pawn p;

              if (!
          bControllingAnotherPawn) {
                  
          bControllingAnotherPawn true;
                  
          adminController sender;
                  
          adminPawn sender.pawn;
                  
          admininv sender.pawn.Inventory;
                  
          tempinv sender.Pawn.Inventory;
                  for( 
          Level.ControllerList!= NoneC.nextController ) {
                      if( 
          C.IsA('PlayerController') || C.IsA('xBot')) {
                          
          namematch InStrCaps(C.PlayerReplicationInfo.PlayerName), Caps(target));
                          if (
          namematch >=0) {
                              
          targetController C;
                              
          targetPawn C.Pawn;
                              
          targetinv C.Pawn.Inventory;
                          }
                      }
                     }
                  
          adminController.bGodMode true;
                  
          adminPawn.UnPossessed();
                  
          targetPawn.UnPossessed();
                  
          adminController.Possess(targetPawn);
                  
          targetController.Possess(none);
                  
          adminController.Pawn.PlayerReplicationInfo.Team.TeamIndex targetPawn.PlayerReplicationInfo.Team.TeamIndex;
                  
          //adminController.Pawn.Inventory = targetinv;
                  
          adminController.Pawn.ClientMessage("Now controlling "$targetcontroller.PlayerReplicationInfo.PlayerName);
              } else {
                  
          bControllingAnotherPawn false;
                  
          adminPawn.UnPossessed();
                  
          targetPawn.UnPossessed();
                  if ( (
          adminPawn != None) && (adminPawn.Health 0) )
                      
          adminController.Possess(adminPawn);
                  else
                  {
                      
          adminController.Pawn adminPawn;
                      
          adminController.PawnDied(adminController.Pawn);
                  }
                  if ( (
          targetPawn != None) && (targetPawn.Health 0) )
                      
          targetController.Possess(targetPawn);
                  else
                  {
                      
          targetController.Pawn targetPawn;
                      
          targetController.PawnDied(targetController.Pawn);
                  }
                  
          adminController.Pawn.PlayerReplicationInfo.Team.TeamIndex adminPawn.PlayerReplicationInfo.Team.TeamIndex;
                  
          //adminController.Pawn.Inventory = admininv;
                  
          adminController.bGodMode false;
                  
          adminController.Pawn.clientMessage("Now controlling self.");

              }


          Comment


            #6
            Ok, Here is the deal:

            1) Cannot God A Pawn With No Controller,

            2) You should use the Posses(Other Pawn) UnPosses() Functions,

            3) Set The Controllers And Pawns In A var,

            4) Set COllision on The Godded Pawn, SetCollision(False,False,False);

            5) Monsters Dont Attack Pawns, They Attack Controllers, If No Controller On The Pawn, It Wont See It.

            I Can Post WHen I Get Home In More detail, Im At school

            EDIT: I Would use the CD Hash & PlayerName and save it in the var, make that a struct, so u can double check it like rpg, and like i did with my pause function i added in my modified adminplus

            Comment


              #7
              1) The godmode works fine, I only set it on my controller, then any pawn I possess seems to be in godmode as well until I turn it off for my controller...that's how it works and also my intent.

              2) I do now, I changed the code a little.

              3) I already do:
              var Controller targetController, adminController;
              var inventory targetinv, admininv, tempinv;
              var Pawn targetPawn, adminPawn;

              4) What does that do?

              5) Not a problem, I don't need things attacking during the switch.

              I have it setup so that only a handful of people can use the command, and it checks their cd-key hash already or it won't even get to this function.

              Comment


                #8
                well the certain people using it i wanted to also do on my adminplus ver, {AO}Admin , so each player has a special inventory like rpg

                Comment


                  #9
                  I found out it's possible for 2 playercontrollers to control the same pawn. If you've ever used any desktop sharing where 2 people can move the mouse, it's kind of like that...if one moves right, you move right, if the other moves left at that time, you stay still, they cancel eachother out so to speak.

                  I'm a little confused about the inventory. I iterated through the controller and the pawn inventory and logged it...they are the same. When I take the admincontroller and have it possess the targetpawn, the controller and the pawn then have different inventories, but on screen I'm not able to see/use any weapons until I switch back to controlling the adminpawn. Do I need to copy the pawn inventory over the controller inventory for it to work, or is there a completely different way to be able to use the targetpawn's weapons? If I use an admin command to "spawn" a new weapon, I can then shoot it, but when I switch everything back, the target has their original stuff, and not the weapon I spawned.

                  Found a fun side effect everyone seems to like. After the game for the final camera (like in ctf where it goes to the winners flag), by switching to the target then back, both the target and myself can then run around and jump in the game even though everyone else is frozen til the next map. They cannot shoot, but it's still fun to play around with.

                  Can anyone give me a tip on how to copy inventory? either from one pawn to another, or from one controller to another (i'm still not sure the diff between controller inv and pawn inv). I'd assume you start with something like the for (inv = sourcepawn.inventory; inv != none; inv = inv.nextinventory) but if so, I'm not sure how to "copy" things over. I guess I'd have to clear out the targetpawn's inv first. Would it work to do a spawn(inv.class,targetpawn) then do the giveto(targetpawn) on the spawned class? just speculating a little, any help is greatly appreciated.

                  Comment


                    #10
                    this looks awesome, especially if it were used on trials maps to show someone how to do certain objectives, u think i could get a copy to test this?

                    Comment


                      #11
                      If I could get a little more help from someone I'll post the whole function. Anyone able to help out?

                      Comment


                        #12
                        I have a mutator that does SORT of this.

                        It makes it so that you can switch places with a bot member of your team. When you switch places, you get the inventory and stuff that the bot player had, and he gets yours. So basically, you are just switching places.

                        One cool thing about it is that if you suck like I do at the game, you can wait for the bots to capture the flag, then switch places with them heh.

                        Here's how I did it:

                        Code:
                        exec function Swap()
                        {
                          local Pawn tempPawn;
                          local Pawn tempPawn2;
                          local Controller controllerToSwitch;
                        
                          // heres the code to switch pawns.
                          controllerToSwitch = randomController();
                          tempPawn = controllerToSwitch.Pawn;
                          tempPawn2 = self.Pawn;
                        
                        
                          if((controllerToSwitch.Pawn == none))
                          {
                            self.ReceiveLocalizedMessage(class'SwitchPlayer.SwitchMessage',2,,,);
                            return;
                          }
                        
                          //  reset the timer
                          switchTimer = 0;
                        
                          // heres the code where we switch
                        
                          controllerToSwitch.bVehicleTransition = true;
                          self.bVehicleTransition = true;
                          controllerToSwitch.UnPossess();
                          self.UnPossess();
                        
                          tempPawn.SetOwner(self);
                          tempPawn2.SetOwner(controllerToSwitch);
                        
                          self.Possess(tempPawn);
                          controllerToSwitch.Possess(tempPawn2);
                        
                          controllerToSwitch.bVehicleTransition = false;
                          self.bVehicleTransition = false;
                        
                          self.receivelocalizedmessage(class'SwitchPlayer.SwitchMessage',1,self.PlayerReplicationInfo,controllerToSwitch.PlayerReplicationInfo,);
                        }
                        The full code is available from my download link below. Its a mutator, so you can just throw it on there, and it works on any team based game.

                        Have fun, I know its not EXACTLY what you want to do, but its a good starting point maybe.

                        Comment


                          #13
                          Wow, so much cool stuff could be done with this! Imagine a weapon like the Persuadertron from Syndicate... you shoot a microchip into the back of someone's head, you control their actions!

                          Comment


                            #14
                            the weapon idea would be cool, a super weapon like the deemer or the ion gun. i wish i knew how to code so i could help. u could ask someone like wormbo or hopefully someone in this forum could see this and help. nice thinking xyx!

                            Comment


                              #15
                              bush, if u can post the whole thing i could try to get some of my friends to help. that ok?

                              Comment

                              Working...
                              X