Skip to content

Creature Sync EPIC #2627

@dartasen

Description

@dartasen

[EPIC] Creature Sync

Supersedes #113

For version 1.8, efforts were made to begin synchronizing creatures in order to make multiplayer gameplay more immersive. Previously, some creature movements were indirectly synchronized, which could give the illusion that they were synchronized.

Point of Interests for the current system :

  • Creature_ChooseBestAction_Patch
  • CreatureAction_Perform, StartPerform, StopPerform
  • NitroxClient.AI

How ?

Before starting work on synchronizing a creature, it is necessary to provide a status report in the PullRequest.
This should include a list of behaviors (detailed in steps below). For each one, mention if there are things to synchronize, if it is unnecessary, if it is being added to the whitelist, if it is already synchronized, etc.

i.e:
O => Things to sync
X => Nothing to do
CAW => Needs Creature Action Whitelisting

* Stalker : **[O]** FindNest can change leashPosition
* StayAtLeashPosition : **[X]** Nothing interesting
* SwimToHeroPeeper **[CAW]** Only activating animations, which is safe
* PrisonPredatorSwimToPlayer **[O]** Evaluate and Perform need to be adapted so they can also target remote player
* ...
  1. You can add the creature you're syncing inside AI.syncedCreatureWhitelist, that will allow Creature.ChooseBestAction() to run for such creature, allowing you to test your CreatureAction you'll synced.

  2. For a given creature, list all MonoBehaviors (i.e: using debugger) that are either a CreatureAction or responsible for a specific behavior of the creature.

Note

Don't forget to look at methods inside the class representing the Creature. Class technical names are listed in this issue.

  1. For MonoBehaviors that ARE NOT CreatureAction : Check if some methods should be cancelled/broadcasted depending on the simulation state of the creature (i.e: StalkerTooth Drop can't be played by all players, that would duplicate tooth)

  2. For MonoBehaviors that ARE CreatureAction : Check if StartPerform/StopPerform are doing some processing that needs proper syncing (i.e: creature state : leash position, target, ...) not animations or visual stuff, if those two methods are safe and don't need any sync : They can be added to AI.creatureActionWhitelist

Note

Creature Action Whitelist allows CreatureActions to run StartPerform/StopPerform on remote clients. Most of the time those are useless and might cause data desync . For example, FleeOnDamage will set the leashPosition to something that is likely different than the other users' leashPosition for the same creature. Thus we cannot add this behaviour to creatureActionWhitelist.

Actions concerning the creature movement should be ignored as it's already done through SplineFollowing

  1. For all MonoBehaviors check if some methods might need to be adapted, for example some methods creature will use to scan for targets might use hardcoded Player class, which will cause the host to be the only one attacked, since RemotePlayer won't be scanned by simulated entities : i.e: SeaDragonAggressiveTowardsSharks_GetAggressionTarget_Patch

  2. All done, thank's :D

Creature List

List extracted from Creature file, those are technical names that do not necessarily correspond to the name by which they are known.

https://subnautica.fandom.com/wiki/Fauna

Warning

Some creatures might been already partially synced and this list doesn't reflect that (i.e: CrashFish, Stalker, basic fishes like Peeper)

CreatureAction

  • AttachAndSuck
  • AttachToVehicle
  • AttackCyclops : Done by Sync leviathans gameplay #2106
  • AttackLastTarget : Done by Sync leviathans gameplay #2106
  • AvoidEscapePod : Worked on Add sync for stalkers #2255
  • AvoidObstacles
  • AvoidPosition
  • AvoidTerrain
  • BirdsFlapping
  • Breach
  • BurryInSand
  • CircleAroundPlayer
  • CircleAroundPlayerWhenCurious
  • CircleAroundSameKind
  • Coil
  • CollectShiny
  • CrawlerAttackLastTarget
  • CrawlerAvoidEdges
  • CrawlerJumpRandom
  • DescendToGround
  • DescentToLava
  • EMPAttack
  • FeedOnGroundWhenHungry
  • FleeOnDamage : Worked on Add sync for stalkers #2255
  • FleeWhenScared
  • FlyAboveMinHeight
  • FlyAwayWhenScared
  • Hide
  • JumperDrift
  • JumperWalkOnGround
  • LavaLiazardRangedAttack
  • MoveOnGround
  • MoveOnSurface
  • MoveTowardsTarget
  • MushroomAttack
  • PlayAnimation
  • Poop : Done by Sync leviathans gameplay #2106
  • PrisonPredatorSwimToPlayer : Worked on Add sync for stalkers #2255
  • ProtectCrashHome
  • PullCreatures
  • RangedAttackLastTarget : Done by Sync leviathans gameplay #2106
  • Roost
  • StareAtNearbyPlayer
  • StayAtLeashPosition
  • SwimFigureEight
  • SwimInGroup
  • SwimInSchool
  • SwimRandom
  • SwimToEnzymeCloud
  • SwimToEnzymes
  • SwimToHeroPeeper
  • SwimToMeat
  • SwimToMushroom
  • SwimToTarget
  • SwimToVent
  • TreaderMoveOnSurface
  • TreaderStayAtLeashPosition
  • WalkOnGroud
  • WarperInspectPlayer
  • WarpOut

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: AIRelated to state machines (as used by the fish)Complexity: hardRequires deep understanding and/or hard to setup and verify

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions