Announcement

Collapse
No announcement yet.

Replication from the Mutator Class? How?

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

    #31
    Originally posted by immortius View Post
    MaxMultiJump on the Pawn.
    Hmm.. looking at other examples in the core code I get something like:

    Code:
    simulated function ReplicatedEvent(name VarName)
    {
    	if (VarName == 'iMaxNumJumps')
    	{
    		SetJumpNum();
    	}
    
    	Super.ReplicatedEvent(VarName);
    }
    
    simulated function SetJumpNum() {
    	UTPawn(Owner).MaxMultiJump = iMaxNumJumps;
            UTPawn(Owner).MultiJumpRemaining = iMaxNumJumps;
    }
    Is that what you mean?

    Comment


      #32
      No, that still doesn't set MaxMultiJump on the pawn server-side.

      Comment


        #33
        Mutators DO NOT EXIST on clients, because they are accessed from the GAMEINFO which also does not exist on clients. Replication is not possible. There is nothing for you to replicate TO.

        Comment


          #34
          Originally posted by Bonehed316 View Post
          Mutators DO NOT EXIST on clients, because they are accessed from the GAMEINFO which also does not exist on clients. Replication is not possible. There is nothing for you to replicate TO.
          I also find THAT capitalising random words MAKES my statements truth.

          None of the mutator functions will be called on the client, because GameInfo doesn't exist on the client. This is true. However, the mutator actor itself can still exist on the client if you set its RemoteRole and bAlwaysRelevent settings to do so.

          If you put a simulated tick function that logs something in the a mutator which is set to bAlwaysRelevent=true and RemoteRole=ROLE_SimulatedProxy, then the client's log is going to be full of log statements from your mutator.

          Really, you'ld only use it to do something really simple - like if your mutator changed the mesh of a bNoDelete actor in the PostBeginPlay().

          Comment


            #35
            Originally posted by KewlAzMe View Post
            ...Is that what you mean?
            Putting the code to change the jump stuff into a function is nice, but like immortius said, you still need to put in a call to SetJumpNum() somewhere that will work on the server. Somewhere in Inventory.uc there is bound to be a function that is always called when the item is spawned and which is not declared simulated. Put it in there.

            Comment


              #36
              Also be careful that you set the new MaxJumpNum in the inventory class before the function to set it on the pawn is called. So you can't call it from PostBeginPlay().

              Comment


                #37
                Originally posted by Mr Evil View Post
                Putting the code to change the jump stuff into a function is nice, but like immortius said, you still need to put in a call to SetJumpNum() somewhere that will work on the server. Somewhere in Inventory.uc there is bound to be a function that is always called when the item is spawned and which is not declared simulated. Put it in there.
                I assume this one:
                Code:
                function GivenTo( Pawn thisPawn, optional bool bDoNotActivate )
                {
                	SetJumpNum();
                	Super.GivenTo(Pawn thisPawn, optional bool bDoNotActivate);
                }
                am I warmer?

                Tho I thought modifyplayer ran serverside.. what's the purpose of modifyplayer in the mutator class?

                Comment


                  #38
                  Originally posted by KewlAzMe View Post
                  Tho I thought modifyplayer ran serverside.. what's the purpose of modifyplayer in the mutator class?
                  You could do it in ModifyPlayer if you want, but it would be better to keep all the player-modifying code in one class.

                  Comment


                    #39
                    Originally posted by Mr Evil View Post
                    You could do it in ModifyPlayer if you want, but it would be better to keep all the player-modifying code in one class.
                    so was GivenTo correct? and should i remove the ModifyPlayer function from the mutator class ?

                    Comment


                      #40
                      Originally posted by KewlAzMe View Post
                      so was GivenTo correct? and should i remove the ModifyPlayer function from the mutator class ?
                      GivenTo should work (you could just try it you know...).

                      In ModifyPlayer you still need to create the inventory item, just don't modify the player's variables directly from there.

                      Comment


                        #41
                        Originally posted by Mr Evil View Post
                        GivenTo should work (you could just try it you know...).

                        In ModifyPlayer you still need to create the inventory item, just don't modify the player's variables directly from there.
                        hehe well I tried it last night and it compiled but didn't work. But that was without the GivenTo part. I'm at work on VNC usually when discussing on the forums so I can't test it. Tho I can build it and test for syntax errors.

                        I will try it with GivenTo tongiht.
                        Thx!

                        Comment


                          #42
                          You will need to modify the mutator so that it sets the new MaxJumpNum in the inventory item before giving it to the player, if you haven't already.

                          Comment


                            #43
                            Originally posted by immortius View Post
                            You will need to modify the mutator so that it sets the new MaxJumpNum in the inventory item before giving it to the player, if you haven't already.
                            You mean from this:
                            Code:
                            function ModifyPlayer(Pawn Other)
                            {
                            	local UTPawn P;
                            	local MultiJumpInv MJI;
                            
                                P = UTPawn(Other);
                            	if (P != None)
                            	{
                            		MJI = P.CreateInventory(class'MultiJump.MultiJumpInv');
                            		MJI.iMaxNumJumps = iMaxNumJumps;
                            	}
                            	Super.ModifyPlayer(Other);
                            }
                            to this:

                            Code:
                            function ModifyPlayer(Pawn Other)
                            {
                            	local UTPawn P;
                            	local MultiJumpInv MJI;
                            
                                P = UTPawn(Other);
                            	if (P != None)
                            	{
                                            MJI  = spawn(class'MultiJump.MultiJumpInv');               
                                            MJI.iMaxNumJumps = iMaxNumJumps;	
                                            P.CreateInventory(MJI);	
                            	}
                            	Super.ModifyPlayer(Other);
                            }
                            ??

                            Comment


                              #44
                              Well that wasn't working for the compiler but in researching i came up with this:

                              Code:
                              function ModifyPlayer(Pawn Other)
                              {
                              	local MultiJumpInv MJI;
                              	Super.ModifyPlayer(Other);
                              
                              	MJI = Spawn(class'MultiJump.MultiJumpInv');
                              	if (MJI != None) {
                              	    MJI.iMaxNumJumps = iMaxNumJumps;
                              	    MJI.GiveTo(Other);
                              	}
                              }
                              Which compiled but i can't test till i get home.

                              Comment


                                #45
                                Ok I added some logging. Basically a log command in each function.
                                I had a friend join my server to test it. He said it didn't work, but I could follow the process pretty well...

                                From what I could follow:
                                NetComeGo: Open TheWorld 01/10/08 11:36:31 87.xxx.xxx.xx:50143
                                Log: Client netspeed is 10000
                                Log: UTPlayerController_0 got player TcpipConnection_0
                                ScriptLog: Spawning MJI -- Spawned a copy of the MultiJumpInv class
                                ScriptLog: MJI exists -- the MJI != none
                                ScriptLog: MJI.iMaxnumJumps =4 -- the MJI variable of iMaxNumJumps was set to 4
                                ScriptLog: GivenTo was run -- GivenTo was called from the MJI inventory class
                                ScriptLog: SetJumpNum was called -- When GivenTo is run, it calls SetJumpNum() which is where I am setting the pawn's maxmultijump property
                                ScriptLog: START MATCH
                                ScriptLog: Num Matches Played: 0
                                ScriptLog: Spawning MJI -- Now it seems to repeat
                                ScriptLog: MJI exists
                                ScriptLog: MJI.iMaxnumJumps =4
                                ScriptLog: GivenTo was run
                                ScriptLog: SetJumpNum was called
                                NetComeGo: Close TcpipConnection_0 87.xxx.xxx.xx:50143 01/10/08 11:37:44
                                But I have a log set in my ReplicatedEvent function that never gets called. This is where I call SetJumpNum() on the client so I assume this is the missing piece to getting it to work. Im looking at other classes that use this ReplicatedEvent and it seems to be correct, complete with the repnotify variables... so Im still trying to figure it out.

                                Comment

                                Working...
                                X