Jump to content

Follower replica leader oversight


hoxi
  • Pending

It's possible for players to leave behind a follower entity enough for entity sleep/networking range, while leaving said entity within range of another player, meaning they won't teleport.

 

That in itself is another deal and is technically intentional, however, the issue in question is that non-leader players won't know who the follower entity's leader is, due to entity sleep/networking range despawning entities locally for clients.

This results in being able to accidentally attack them when force-attacking with keybinds, which normally shouldn't happen otherwise. This also applies with non-player leaders and so, it's not just restricted to players (but normally only the player tag on the leader is checked, so technically nothing should be affected in the same way).

 

Obviously, this won't lead to Winona's catapults or things like that to accidentally hit them, since that's server-sided and the server has all the necessary data, this is specifically for clients selecting a target and syncing it to the server, and similar.

 

It's a very specific case, but it's relevant enough I feel due to potential accidents it could lead to.

 

This could be simply solved by doing something as shown below, and changing some of the checks in combat_replica and other similar places a bunch to account for the changes (search for replica.follower, there aren't that many cases of it).

local Follower = Class(function(self, inst)
    self.inst = inst

    self._leader = net_entity(inst.GUID, "follower._leader")
    self._leaderisplayer = net_bool(inst.GUID, "follower._leaderisplayer")
end)

function Follower:SetLeader(leader)
    self._leader:set(leader)

    local isplayer = leader ~= nil and leader:IsValid() and (leader.isplayer or leader:HasTag("player"))
    self._leaderisplayer:set(isplayer and true or false)
end

function Follower:GetLeaderIsPlayer()
    return self._leaderisplayer:value()
end

Of course, another simple alternative would be to set a unique tag on the follower and check for that instead, but that there's a limit to tags, this might not be ideal. These are just suggestions.

 

If other tags were to be used with follower replica leader checks, you could instead sync some specific tags with a net_array, but that's more expensive and it might not be needed, plus you'd need to account for the tags being added or removed.


Steps to Reproduce

Two players are needed for this mainly due to the entity sleep mechanics.

  1. Have player A recruit a Bunnyman.
  2. Let the Bunnyman try to sleep during the day, or put them to sleep with a Pan Flute.
  3. Try to force attack as player B (with just keybinds, not combining force attack + clicking with your mouse). Notice how you won't automatically attack.
  4. You can also see that hovering your mouse over while wielding a weapon (and not holding force attack) shows the option to examine instead of attack.
  5. Now, have player B stay near this Bunnyman, and make player A go far away, enough to for entity sleep/networking range to kick in, and despawn from the player's B client.
  6. Repeat steps 3 and 4 and notice the difference.
  • Big Ups 1



User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...