winstxnhdw / lc-hax

A powerful, feature-rich and highly performant internal cheat for the co-op indie horror video game, Lethal Company.
87 stars 26 forks source link

[Feature Request]:Destroy all enemies on Server #31

Closed tslpy1 closed 9 months ago

tslpy1 commented 9 months ago

"kill enemy" function seems to only make oneself unable to see the monsters and avoid getting hurt, but other players can still see the monsters. I found the relevant code in the source code of "IcyRelic", but I'm not sure if it's complete. After testing, it seems to directly kill the enemies, and other players are also affected( can see the corpse. ). Non-killable enemies will also freeze as a result. Here is the related code:

        if (GUILayout.Button("Execute", Array.Empty<GUILayoutOption>()))
        {
            foreach (EnemyAI enemyAI in Hacks.enemies)
            {
                bool destroy = false;
                if (enemyAI.GetType() == typeof(ForestGiantAI) || enemyAI.GetType() == typeof(FlowermanAI) || enemyAI.GetType() == typeof(SandWormAI) || enemyAI.GetType() == typeof(BlobAI) || enemyAI.GetType() == typeof(DressGirlAI) || enemyAI.GetType() == typeof(PufferAI) || enemyAI.GetType() == typeof(SpringManAI) || enemyAI.GetType() == typeof(DocileLocustBeesAI) || enemyAI.GetType() == typeof(DoublewingAI))
                {
                    destroy = true;
                }
                enemyAI.KillEnemyServerRpc(destroy);
            }
        }

KillEnemyServerRpc method seems to exist in Assembly-CSharp:

[ServerRpc(RequireOwnership = false)]
public void KillEnemyServerRpc(bool destroy)
{
    NetworkManager networkManager = base.NetworkManager;
    if (networkManager == null || !networkManager.IsListening)
    {
        return;
    }
    if (this.__rpc_exec_stage != NetworkBehaviour.__RpcExecStage.Server && (networkManager.IsClient || networkManager.IsHost))
    {
        ServerRpcParams serverRpcParams;
        FastBufferWriter fastBufferWriter = base.__beginSendServerRpc(1810146992U, serverRpcParams, RpcDelivery.Reliable);
        fastBufferWriter.WriteValueSafe<bool>(destroy, default(FastBufferWriter.ForPrimitives));
        base.__endSendServerRpc(ref fastBufferWriter, 1810146992U, serverRpcParams, RpcDelivery.Reliable);
    }
    if (this.__rpc_exec_stage != NetworkBehaviour.__RpcExecStage.Server || (!networkManager.IsServer && !networkManager.IsHost))
    {
        return;
    }
    Debug.Log(string.Format("Kill enemy server rpc called with destroy {0}", destroy));
    if (destroy)
    {
        this.KillEnemy(destroy);
        return;
    }
    this.KillEnemyClientRpc(destroy);
}
winstxnhdw commented 9 months ago

Hey, from your previous issue, I got the impression that you only wanted to kill enemies from your client-side. That was why I did only that. I assumed you wanted it so that enemies do not bother you but will still bother your teammates. I'll add this too then.

winstxnhdw commented 9 months ago

I have added it. It's still /kill --enemy. I have changed the local enemy kill to /kill --localenemy.

tslpy1 commented 9 months ago

Oh, I didn't realize that, thank you for clarifying that. I will know better next time, thank you again