Announcement

Collapse
No announcement yet.

Replication from the Mutator Class? How?

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

    #76
    Originally posted by immortius View Post
    The methods are provided to do that only in the same way that a paint set provides the ability to make graffiti. There are multiple ways of implementing most things in UScript, and your concerns as a developer should be to seek out the most efficient and most maintainable ways.
    I couldnt agree with you more! =) so lets get this thread moving towards that most efficient and maintainable direction and unearth some other methods of replicating so we can put these other options to rest.

    Comment


      #77
      I would say that if we need to do it without subclassing and replacing any existing classes, then transmit the variable in a new ReplicationInfo, and deal with it that way.

      Comment


        #78
        How do use a new ReplicationInfo?

        Comment


          #79
          Please look here...

          http://svn2.assembla.com/svn/gneut3/...nfo_JumpMod.uc

          Comment


            #80
            Alright folks, i have made some ground on this issue. I have the variables themselves replicated, although i dont have access to the Player controller itself yet. I am looking into this.

            Please consult my blog for details.
            http://wordpress.gneu.org/index.php/...script-take-1/

            Tonight i continue. I hope i find the results i need.

            Comment


              #81
              With much assistance from EricBlade i bring you the solution to this debacle.

              In its entirety available here...
              http://svn2.assembla.com/svn/gneut3/...mpMod/Classes/

              Basically its just important that you understand replication. I was using a flag to set that i only wanted the initial replication which made my pawn not get transmitted once the game started.

              Inside the info class my ReplicatedEvent looks like this:
              Code:
              Replication
              {
                      // If its from the server and initial, please send this around
                      if( bNetDirty && ( Role == ROLE_Authority ) && bNetInitial )
                              riMaxNumJumps, riMaxJumpBoost;
                      if(bNetDirty && Role == ROLE_Authority)
                              rPlayerPawn;
              }
              
              simulated event ReplicatedEvent(name VarName)
              {
                  switch (VarName)
                  {
                      case 'rPlayerPawn':
                          rPlayerPawn.MaxMultiJump = riMaxNumJumps;
                          rPlayerPawn.MultiJumpBoost = (riMaxJumpBoost * 40);
                          rPlayerPawn.MultiJumpRemaining = riMaxNumJumps;
                          break;
                      default:
                           Super.ReplicatedEvent(VarName);
                  }
              }
              In my mutator i have two functions of note:

              Code:
              function NotifyLogin(Controller NewPlayer)
              {
                  local Info_JumpMod A;
              
                  if( UTPlayerController( NewPlayer ) != None )
                  {
                      A = Spawn( Class'Info_JumpMod', NewPlayer );
                      A.riMaxNumJumps     = iMaxNumJumps;
                      A.riMaxJumpBoost     = iMaxJumpBoost;
                  }
              
                  Super.NotifyLogin(NewPlayer);
              }
              
              function ModifyPlayer(Pawn P)
              {
                  local Info_JumpMod I;
                  local UTPawn P2;
              
                  foreach P.Controller.ChildActors(class'Info_JumpMod', I)
                  {
                      P2 = UTPawn(P);
                              I.rPlayerPawn = P2;
              
                              P2.MaxMultiJump = iMaxNumJumps;
                      P2.MultiJumpBoost = (iMaxJumpBoost * 40);
                      P2.MultiJumpRemaining = iMaxNumJumps;   
                  }
                  super.ModifyPlayer(P);
              }
              No Tick, All Replicated Event.

              I have tested this code quite a bit and must say that i am really quite impressed.

              Again, thanks to EricBlade for all of his insight.

              Thoughts, Questions, Comments?

              Comment


                #82
                There's no need to be subclassing PlayerReplicationInfo. Maybe subclass ReplicationInfo directly, or perhaps subclass UTLinkedReplicationInfo and then store the replication info in the player's CustomReplicationInfo list(in UTPlayerReplicationInfo) for easier lookup.

                Also, you might want it to have bOnlyRelevantToOwner=true, so that players don't get each other's Info classes. As it is it will be doing odd things like updating other player's pawns every time they become relevant on the client's machine. This is probably a good reason not to subclass UTLinkedReplicationInfo, because you definately shouldn't set that to bOnlyReleventToOwner=true.

                Other than that it is good, it makes the small sacrifice of replicating the owner twice in order to avoid any ticks or timers.

                Comment


                  #83
                  Arent things replicated when they are set?

                  My logs show that the pawn is only set once. I only did player replication b/c it sounded proper. At this point i think i could replicate from anything above it with a ReplicatedEvent event. I'm really more interested in saying this issue has been solved, so unless there are some other major reservations...

                  As you can see this is a general solution b/c we can all subclass this info for our mutators that need to be changed on the pawn. If anyone has issues with replication to other things this method would have to be adapted. Changing the iterator for instance.

                  Ill add that flag and check to make sure it works properly, Tonight.

                  Comment


                    #84
                    I will expand a bit, because i dont think it was clear from my previous posting.

                    In my testing last night i was able to get the jumps replicated and they worked just as they did in the previous version of my mutator.

                    Jump => Jump => Jump => Jump =>Can't Jump => Land => Repeat.

                    I tested this privately as well as on a lan server (i cant really say that its working on the internet although i wouldnt doubt that for anything. Things appear to be working fine and as such i am mainly looking for other major issues.

                    If you are replicating to another class than the pawn it may be useful to use the replacewith function to find the actor you need to grab and set it there.

                    Comment


                      #85
                      Originally posted by Bob_Gneu View Post
                      Arent things replicated when they are set?
                      I meant the pawn is replicated twice because in addition to your variable there is the owner variable from Actor that is replicated too.

                      Comment


                        #86
                        Ah, Yes. I unfortunately dont have access to that variable (Owner) until Tick().

                        Comment


                          #87
                          immortius: The Owner of the Info is the PlayerController, rather than the Pawn itself.

                          I still think there could be a way of setting it from a single Info object, like GameReplicationInfo is, but not positive on that. I think you could at least just sub from ReplicationInfo rather than PlayerReplicationInfo, which has a bunch of additional baggage in it.

                          In this particular case, the ChildActors() iterator, although "slow like AllActors", it's only being called when a Pawn is created, which is already a pretty expensive process, and the native code should only be returning the one object, anyway.

                          I'm going to look at this UTLinkedReplicationInfo, I wasn't aware that there was a list of custom repinfos, that would make that less expensive

                          ...Just looked at it. Just a linked list of ReplicationInfo's that is attached to each player's UTPlayerReplicationInfo .. looks like that'd be useful!

                          Comment


                            #88
                            Originally posted by immortius View Post
                            Also, you might want it to have bOnlyRelevantToOwner=true, so that players don't get each other's Info classes. As it is it will be doing odd things like updating other player's pawns every time they become relevant on the client's machine. This is probably a good reason not to subclass UTLinkedReplicationInfo, because you definately shouldn't set that to bOnlyReleventToOwner=true.
                            I just did a full text search for that variable and its not in the source. Is that something from 2kX?

                            Comment


                              #89
                              immortius: The Owner of the Info is the PlayerController, rather than the Pawn itself.
                              Ah, sorry. Keep getting confused with the inventory implementation.

                              I just did a full text search for that variable and its not in the source. Is that something from 2kX?
                              It is defined in Actor under the Networking Flags section. And it also appears in Inventory's default properties block.

                              Comment


                                #90
                                Originally posted by immortius View Post
                                It is defined in Actor under the Networking Flags section. And it also appears in Inventory's default properties block.

                                I just did a fresh export and scanned through the entirety of the code and found no references to bOnlyReleventToOwner.

                                Comment

                                Working...
                                X