Add sync for stalkers
- [x] Stalker FindNest
- [x] Stalker DropTooth
- [x] AttackLastTarget (Done through current system)
- [x] MoveTowardsTarget (Done through current system)
- [x] FleeOnDamage
- [x] SwimToHeroPeeper
- [x] AggressiveWhenSeeTarget (Done through current system)
- [x] MeleeAttack
- [x] PrisonPredatorSwimToPlayer
- [x] ~CreatureFlinch~
- [x] ~CreatureFear~
- [x] ~PrisonCreatureBehaviour~
- [x] ~AvoidObstacles~
- [x] ~StayAtLeashPosition~
- [x] AvoidEscapePod
Will need work after this PR :
- MeleeAtack (Pickup held item from remote player)
- CreatureFriend System
- CollectShiny
Closes #2250 Closes #2243
using System.Collections.Generic; using UnityEngine; using Nitrox.Patches;
public class StalkerSync : MonoBehaviour { private Stalker stalker; private Vector3 lastPosition; private bool isFleeing;
void Start()
{
stalker = GetComponent<Stalker>();
lastPosition = stalker.transform.position;
isFleeing = false;
}
void Update()
{
SyncStalkerPosition();
SyncStalkerBehavior();
}
private void SyncStalkerPosition()
{
if (Vector3.Distance(stalker.transform.position, lastPosition) > 0.1f)
{
lastPosition = stalker.transform.position;
// Send position update to other players
SendPositionUpdate(lastPosition);
}
}
private void SyncStalkerBehavior()
{
if (stalker.IsFleeing() != isFleeing)
{
isFleeing = stalker.IsFleeing();
// Send behavior update to other players
SendBehaviorUpdate(isFleeing);
}
}
private void SendPositionUpdate(Vector3 position)
{
// Code to send position update over the network
// For example, using RPC or another networking method
}
private void SendBehaviorUpdate(bool fleeing)
{
// Code to send behavior update over the network
// For example, using RPC or another networking method
}
}
Explanation of the Code: Class StalkerSync: This class is responsible for synchronizing stalkers. Start(): Initializes the stalker and sets the initial position. Update(): This method checks for changes in the position and behavior of the stalker. SyncStalkerPosition(): Checks if the stalker's position has changed and sends an update if it has. SyncStalkerBehavior(): Checks if the stalker's behavior (e.g., whether it is fleeing) has changed and sends an update. SendPositionUpdate() and SendBehaviorUpdate(): These methods should contain the code to send data over the network. Notes: You will need to integrate this code into the existing architecture of the Nitrox mod. Make sure you have access to networking methods to send updates to other players. You may need to adapt the code depending on the specific implementation of stalkers in your mod. This code is a basic example and may require further refinement based on your needs and the architecture of the project.
- Cameras are super desynced with stalkers grabbing them, I don't see the camera in the position that the other client does and they can pick it up after the stalker drops it to dupe cameras
- yellow goo attack VFX is not shown on the other client and neither is the SFX
- cuddlefish can escape alien containment through animation with player(probably out of scope for the PR)
- Stalkers hatched in alien containment but we did not see any change in behavior when we entered the room or the tank
Massive props to @dartasen for the work on stalker sync β creature AI, loot drop mechanics, and even behavioral patches for predator logic.
But damn, the amount of review churn and indecision around merging this makes me wonder:
Are we syncing stalkers, or becoming them? π β Teeth drop sync β AvoidEscapePod logic β Transpiled behavior patches β IL injection of PrisonPredator decision trees β Copilot passive-aggressively reviewing 16 files β Comment chains on function access modifiers
β Merge
Welcome to Nitrox.
Test Results
247 testsβ +4βββ246 β +4βββ7s β±οΈ Β±0s ββ1 suites Β±0βββββ1 π€ Β±0β ββ1 filesββ Β±0βββββ0 β Β±0β
Results for commit 57046050.βΒ± Comparison against base commit e50c7d2d.
:recycle: This comment has been updated with latest results.