Page 7 of 57

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 11:33 am
by iRobot
Then surely the issue lies with your connection itself if your ping varies so wildly?

I would be in touch with my ISP if it was that inconsistent.

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 11:57 am
by Ollievrthecool
Talking of lag in connections, when i am playing ballistic, i get spikes of packet loss. You may think this is my problem but when i play on the race/assault server, it never happens. This is either a coincidence or thetr is summit wrong with the server. Also, on the note of ping comp, you say it works client side, will it effect fps issues being in the cache folder or in the system folder, because since it was added, i have continuous fps spikes as my screen freezes. Which this never happens on race/assault.

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 12:32 pm
by Azarael

Code: Select all

class MutPingCompensation extends Mutator;

var PlayerController LocalPlayer;

simulated function Tick(float DeltaTime)
{
  local Actor A;
  local float Ping;
  
  //only active on clients
  if ( Level.NetMode != NM_Client ) {
    Disable('Tick');
    return;
  }
  
  //return if no local controller / demo
  if ( LocalPlayer == None )
    LocalPlayer = Level.GetLocalPlayerController();
  if ( LocalPlayer == None )
    return;
  else if ( LocalPlayer.IsA('DemoRecSpectator') ) {
    Disable('Tick');
    return;
  }
  
  //this particular var is updated on call of LongClientAdjustPosition() (possibly very frequent)
  Ping = LocalPlayer.ExactPing;
  //iterate through all actors capable of movement and adjust their prepivot value (offset for where they're rendered)
  foreach DynamicActors(class'Actor', A) {
    if ( A.bProjTarget && A.Physics != PHYS_None && A.Physics != PHYS_Rotating
        && (A.Velocity != vect(0,0,0) || A.Acceleration != vect(0,0,0))
        && A.RotationRate == rot(0,0,0) && A.bCollideActors && A.Role < ROLE_Authority
        && (Projectile(A) != None && !A.IsA('FlakShell') || Pawn(A) != None && Pawn(A).Health > 0) ) {
      if ( A.bCollideWorld && (Vehicle(A) != None || A.IsA('UnrealPawn')) )
        A.PrePivot = 0.5 * (A.PrePivot + PredictLocation(A, Ping, 2) - A.Location);
      else
        A.PrePivot = 0.5 * (A.PrePivot + PredictLocation(A, Ping) - A.Location);
    }
    else if ( A.PrePivot != vect(0,0,0) )
      A.PrePivot = vect(0,0,0);
  }
}

static simulated function vector PredictLocation(Actor Other, float PredictedTime, optional int CheckWalls)
{
  local vector StartLocation, PredictedLocation, ErrorDiff;
  local vector HitLocation, HitNormal;
  
  // calculate predicted location without taking level geometry into account
  if ( Other.Physics == PHYS_Falling || Other.Physics == PHYS_Karma )
    PredictedLocation = Square(PredictedTime) * Other.PhysicsVolume.Gravity / 4
        + PredictedTime * Other.Velocity + Other.Location;
  else {
    PredictedLocation = Other.Velocity * PredictedTime + Other.Location;
    
    // adjust direction for walking players
    if ( Other.Physics == PHYS_Walking && Other.Trace(HitLocation, HitNormal,
        PredictedLocation - vect(0,0,1) * VSize(Other.Velocity), PredictedLocation, False,
        vect(0,0,1) * Other.CollisionHeight + vect(1,1,0) * Other.CollisionRadius) != None )
      PredictedLocation = HitLocation;
  }
  
  StartLocation = Other.Location;
  ErrorDiff = PredictedLocation - StartLocation;
  
  // check for walls and adjust predicted location
  while ( CheckWalls > 0 && Other.Trace(HitLocation, HitNormal, ErrorDiff + StartLocation, StartLocation,
      False, vect(0,0,1) * Other.CollisionHeight + vect(1,1,0) * Other.CollisionRadius) != None ) {
    // HitLocation is a point on the plane the player will most likely hit
    // HitNormal is that plane's normal vector
    
    ErrorDiff = PredictedLocation - HitLocation;
    if ( HitNormal.Z < -0.7 )
      PredictedLocation -= 2 * (ErrorDiff dot HitNormal) * HitNormal; // bounce off a ceiling
    else
      PredictedLocation -= (ErrorDiff dot HitNormal) * HitNormal; // project the predicted location onto the plane
    
    // If the player can land on this plane, i.e. if this is the ground, then adjust the predicted location.
    // (the player will most probably not run in the same direction after landing)
    if ( HitNormal.Z > 0.7 && Other.Physics == PHYS_Falling )
      PredictedLocation = 0.3 * PredictedLocation + 0.7 * HitLocation; // it's close enough to the real thing
        
    StartLocation = HitLocation;
    CheckWalls--;
  }
  
  return PredictedLocation;
}
I'm going to put a disable in for this. Those of you experiencing issues, please add to UT2004.ini:

Code: Select all

[PingCompensationConfig.MutPingCompensation]
bEnabled=False
I see a bug in it as well:

Code: Select all

    else if ( A.PrePivot != vect(0,0,0) )
      A.PrePivot = vect(0,0,0);
This assumes A never had a PrePivot to begin with, and explains why nodes are displaced.

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 3:08 pm
by Skaldy
It's always interesting to see other ppl's code :geek:

I note that it's using "LocalPlayer.ExactPing" (with an explicit comment about frequency) - perhaps some sort of smoothed or average ping would give a better feel during play. But whatever.

Many thanks for the .ini option - I'll give it a go with pleasure. I would have thought that only ppl with ping > 80 would be that bothered about having it enabled anyway.

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 3:31 pm
by Azarael
I added that particular comment, since there's more than one Ping variable in UT. The NewPing variable is updated every 4 seconds, by contrast to this one.

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 3:50 pm
by iRobot
Is disabling it likely to have any effect on those with low ping?

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 4:32 pm
by Azarael
No.

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 4:40 pm
by Butcher
Wow, thanks Aza...
Read the code, and it seems looking for an approximation. To me it looks like "You are most likely to follow the same momentum " so the position calculated is always in the same direction adding the time delay in agreement to the physics module (except when there is a blocking object as a ceiling/wall to bounce or a floor that stops you)... This is ok meanwhile you are in the air, but in the ground I avoid going in the same line
what I find not very good is this:
(the player will most probably not run in the same direction after landing)
I avoid doing this always because while you are in the air you may not change your direction, and is easy to predict where to shoot... with this one knows where to shoot after someone has jumped or dodged and/or land...
I look forward to see if there is any difference to it turned on or off... maybe just add a button in ballistic menu for those who want it off :)... and rest that do not have issues may still use it :)

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 4:45 pm
by Azarael
I can't give a button to turn it off in the Ballistic menu without including it in BW itself, which is not an option.

Re: Decreasing playerbase

Posted: Thu 29 May , 2014 5:54 pm
by Calypto
Best option would be to disable it by default if players left because of "delay."