-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: gain enemy ownership before stunning them
- Loading branch information
1 parent
97b314d
commit ebb1ad3
Showing
1 changed file
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
using GameNetcodeStuff; | ||
using Hax; | ||
using UnityEngine; | ||
|
||
internal interface IStun { } | ||
|
||
internal static class IStunMixin { | ||
internal static void Stun(this IStun _, Vector3 position, float radius, float duration = 1.0f) => | ||
internal static void Stun(this IStun _, Vector3 position, float radius, float duration = 1.0f) { | ||
if (Helper.LocalPlayer is not PlayerControllerB localPlayer) return; | ||
|
||
Physics.OverlapSphere(position, radius, 524288) | ||
.ForEach(collider => { | ||
if (!collider.TryGetComponent(out EnemyAICollisionDetect enemy)) return; | ||
enemy.mainScript.ChangeEnemyOwnerServerRpc(localPlayer.actualClientId); | ||
enemy.mainScript.SetEnemyStunned(true, duration); | ||
}); | ||
} | ||
} |
ebb1ad3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confused on what this does too
ebb1ad3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't stun an enemy you don't have ownership over.
ebb1ad3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does that mean? whats ownership? XD
ebb1ad3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Lethal Company, the AI computation is run on the ‘owner’ of the enemy. In vanilla, the ‘owner’ of the enemy is usually the target of the enemy. For example, when a coil-head chases after you, the computation for that chasing is done by your computer. Basically, you are telling the coil-head to chase you.
Thus, to control the enemy, you must first gain ownership of the enemy. You can do that by sending a request to host to ask for ownership permission, which they would usually give almost all the time. Once you have ownership of the enemy, you can do anything you want to it and the server will respect it. This includes being stunned, killed, or possessed.
ebb1ad3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request to host to ask for the ownership permission? its automatic when we perform certain command right?
im just dumb to think that we are asking the server host to give us permission XDD
ebb1ad3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap. If the host is not modded, it is automatically given without issues.
ebb1ad3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modded? i got some of the server i joined is using Control Company... this affects?