Conversation
24c8a58 to
19d2afe
Compare
7029e10 to
f916df4
Compare
f916df4 to
b47a533
Compare
This comment has been minimized.
This comment has been minimized.
f98dea9 to
8844ac0
Compare
There was a problem hiding this comment.
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
NitroxClient/GameLogic/Spawning/Metadata/Extractor/StayAtLeashPositionMetadataExtractor.cs:7
- The class name 'StayAtLeastPositionMetadataExtractor' appears inconsistent with the metadata type 'StayAtLeashPositionMetadata'; renaming it to 'StayAtLeashPositionMetadataExtractor' would improve clarity.
public sealed class StayAtLeastPositionMetadataExtractor : EntityMetadataExtractor<Creature, StayAtLeashPositionMetadata>
8844ac0 to
50240e7
Compare
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Perform_Patch.cs
Outdated
Show resolved
Hide resolved
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Perform_Patch.cs
Show resolved
Hide resolved
ae17e14 to
0d25ae2
Compare
0d25ae2 to
063426c
Compare
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Perform_Patch.cs
Show resolved
Hide resolved
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Perform_Patch.cs
Show resolved
Hide resolved
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Perform_Patch.cs
Outdated
Show resolved
Hide resolved
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Evaluate_Patch.cs
Outdated
Show resolved
Hide resolved
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Evaluate_Patch.cs
Outdated
Show resolved
Hide resolved
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Evaluate_Patch.cs
Outdated
Show resolved
Hide resolved
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Evaluate_Patch.cs
Outdated
Show resolved
Hide resolved
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Evaluate_Patch.cs
Show resolved
Hide resolved
|
This comment was marked as spam.
This comment was marked as spam.
063426c to
025ee09
Compare
5704605 to
9ddd1bc
Compare
f1f8670 to
fab078a
Compare
|
PrisonPredatorSwimToPlayer behavior is weird in singleplayer as well :
Which has a weird look & feel when looking at the creature. MoveTowardsTarget is very likely to run after PrisonPredatorSwimToPlayer, which is pretty quick since there's no delay between creatureActions |
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Perform_Patch.cs
Outdated
Show resolved
Hide resolved
fab078a to
a23b4f5
Compare
|
All systems online |
a23b4f5 to
cfe27a8
Compare
Coding-Hen
left a comment
There was a problem hiding this comment.
LGTM CW just a few minor points
| return false; | ||
| } | ||
|
|
||
| // TODO: Add transpiler to add support for held item eat from remote players, we might need to add an equivalent of Inventory.GetHeldItem() |
There was a problem hiding this comment.
Maybe worth creating a issue for this so we don't forget and someone can pick it up later. Let's not delay this, just think worth tracking for something separate and specific in another ticket as another bit of work.
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Evaluate_Patch.cs
Show resolved
Hide resolved
tornac1234
left a comment
There was a problem hiding this comment.
While you're at it, would you patch MeleeAttack.CanDealDamageTo with a prefix like to ensure remote players aren't attacked when they shouldn't be ?
public static bool Prefix(GameObject target, ref bool __result)
{
if (target.TryGetComponent(out RemotePlayerIdentifier remotePlayerIdentifier) && !remotePlayerIdentifier.RemotePlayer.CanBeAttacked())
{
__result = false;
return false;
}
return true;
}
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Evaluate_Patch.cs
Show resolved
Hide resolved
NitroxPatcher/Patches/Dynamic/PrisonPredatorSwimToPlayer_Evaluate_Patch.cs
Show resolved
Hide resolved
| } | ||
|
|
||
| float num = Vector3.Distance(gameobject.transform.position, instance.transform.position); | ||
| if (num > instance.maxDistance || num < instance.minDistance) |
There was a problem hiding this comment.
if we wanted to keep that minDistance logic, we should probably move it to GetNearestTarget so it actually acts as a filter
There was a problem hiding this comment.
I'll remove it, the rings behavior already implies to have a maxDistance
| return 0f; | ||
| } | ||
|
|
||
| if (!creature.GetCanSeeObject(gameobject)) |
There was a problem hiding this comment.
same here, GetCanSeeObject should be moved to IsTargetValid to be an actual filter
The current implementation could lead to situations like this one:
player2 (distance = 50 => not target, GetCanSeeObject=true)
Stalker |||wall||| player1 (distance = 30 => target, GetCanSeeObject=false)
player1 is closer to Stalker so they're picked as target, but then they're forgotten because they can't be seen, while player 2 might be in range and in sight range too (which means they're the only valid target here)
| return 0f; | ||
| } | ||
|
|
||
| LastTarget lastTarget = creature.GetComponent<LastTarget>(); |
There was a problem hiding this comment.
Could you explain why this is important ? (this is not in the base game and it seems to me that this wouldn't have any feedback on the current behaviour which might end up in situations where a player is a locked target so the stalker tries to attack it, but then another player is closer so the stalker randomly starts swimming towards that other player) (also if we were too keep that, we'd probably have to adapt the whole behaviour to drop the player as locked target when they're no longer a valid target)
There was a problem hiding this comment.
Could you explain why this is important ? (this is not in the base game and it seems to me that this wouldn't have any feedback on the current behaviour
Initial issue is that PrisonPredatorSwimToPlayer is using Player.main exclusively to decide behaviors of this Action. Other behaviors almost always have a local state (or another behavior like LastTarget that stores this information) to share the "target" between Evaluate and Perform methods.
So I do need a state to persist this information in whatever form it can take (static states in patch, Custom component, LastTarget, ...). With that being said it's not excluded that other behaviors are also using LastTarget, in fact it's the case for Stalker. Which is why I used SetLockedTarget instead of usual SetTarget.
However it does not prevent other behaviors to have another target state which can be different from LastTarget. But that's up to SN devs that implemented behaviors that can conflict with each other, that's not really the result of my choices (see #2255 (comment))
As a side note PrisonPredatorSwim behavior guarantee that the creature is inside the prison, thereferore they're friendly and all the agressive behaviors are disabled. Which can limit the weird behaviors between conflicting behaviors
also if we were too keep that, we'd probably have to adapt the whole behaviour to drop the player as locked target when they're no longer a valid target
I can implement that in Perform if needed
public static void Perform(PrisonPredatorSwimToPlayer instance, Creature creature, float time)
{
LastTarget lastTarget = creature.GetComponent<LastTarget>();
if (!lastTarget)
{
Log.ErrorOnce($"[{nameof(PrisonPredatorSwimToPlayer_Perform_Patch)}]: Creature {creature} does not have a LastTarget component.");
return;
}
if (!IsValidTarget(lastTarget.target))
{
lastTarget.UnlockTarget();
return;
}
Transform targetTransform = lastTarget.target ? lastTarget.target.transform : null;
if (targetTransform && time > instance.timeNextSwim)
{
instance.timeNextSwim = time + instance.swimInterval;
instance.swimBehaviour.SwimTo(targetTransform.position, instance.swimVelocity);
}
lastTarget.UnlockTarget();
}
CreatureFlinch[X]CreatureFear[X]PrisonCreatureBehaviour[X]AvoidObstacles[X]StayAtLeashPosition[X]Will need work after this PR :
Closes #2250
Closes #2243
Contributes to #2627