KaylinOwO / Project-Apparatus

A Lethal Company cheat based on Infinite Company
98 stars 43 forks source link

Multiple Improvements #100

Closed TheGreenBandit closed 8 months ago

TheGreenBandit commented 8 months ago

[+] Added Spawning Objects (host) [+] Added Deleting Objects [+] Added Changing Object Value [+] Added if a player is host in the playerlist [+] Added issue templates to clean up repo [+] Added untargetable [/] Changed source directory

TODO if we want to have the client without host be able to spawn shit we would need to figure out a bypass, leaving my non working method in so others can get an idea, SpawnNetworkObjectLocallyCommon in NetworkSpawnManager might allow for bypassing host but i dont wanna look into it

chuxiaaaa commented 8 months ago

I have tried, but both generating and deleting items only take effect on the host. Good luck

TheGreenBandit commented 8 months ago

I have tried, but both generating and deleting items only take effect on the host. Good luck

Im thinking if we patch the check if host it should work just fine when spawning, just gotta find which function actually checks if you are host

chuxiaaaa commented 8 months ago

I have tried, but both generating and deleting items only take effect on the host. Good luck

Im thinking if we patch the check if host it should work just fine when spawning, just gotta find which function actually checks if you are host

I think the reason for the invalidation is the process issue. The process of the game is: server generates items/enemies/monsters -> notifies client -> client generates items/enemies/monsters. This is why it only takes effect on the host, because the client cannot notify the client, and if the client notifies the server, it will be intercepted by the server's local code. However, it is obviously impossible for us to modify the local code of the host.

This is the intercepted code

if (base.OwnerClientId != networkManager.LocalClientId)
{
    if (networkManager.LogLevel <= Unity.Netcode.LogLevel.Normal)
    {
        Debug.LogError("Only the owner can invoke a ServerRpc that requires ownership!");
    }
    return;
}
TheGreenBandit commented 8 months ago

Hm, very weird coding style. Maybe if we set ourselves as the host then reset the host to the original after the function has passed? Could be a simple override

chuxiaaaa commented 8 months ago
private static void \_\_rpc\_handler\_1482204640(NetworkBehaviour target, FastBufferReader reader, \_\_RpcParams rpcParams)
    {
        NetworkManager networkManager = target.NetworkManager;
        if (networkManager == null || !networkManager.IsListening)
        {
            return;
        }
        if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
        {
            if (networkManager.LogLevel <= Unity.Netcode.LogLevel.Normal)
            {
                Debug.LogError("Only the owner can invoke a ServerRpc that requires ownership!");
            }
            return;
        }
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.Server;
        ((StartOfRound)target).ManuallyEjectPlayersServerRpc();
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.None;
    }

This is the execution program that receives the server notification

TheGreenBandit commented 8 months ago
private static void \_\_rpc\_handler\_1482204640(NetworkBehaviour target, FastBufferReader reader, \_\_RpcParams rpcParams)
    {
        NetworkManager networkManager = target.NetworkManager;
        if (networkManager == null || !networkManager.IsListening)
        {
            return;
        }
        if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
        {
            if (networkManager.LogLevel <= Unity.Netcode.LogLevel.Normal)
            {
                Debug.LogError("Only the owner can invoke a ServerRpc that requires ownership!");
            }
            return;
        }
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.Server;
        ((StartOfRound)target).ManuallyEjectPlayersServerRpc();
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.None;
    }

This is the execution program that receives the server notification

now that i think about it most functions such as the spawn check if the player is host by comparing a instance of localclientid such as in NetworkObject

        public bool IsLocalPlayer
        {
            get
            {
                if (NetworkManager != null && IsPlayerObject)
                {
                    return OwnerClientId == NetworkManager.LocalClientId;
                }

                return false;
            }
        }
    if we can write to the localclient id and just change it to the host's when we call a function that requires host and restore it it should work fine
chuxiaaaa commented 8 months ago
private static void \_\_rpc\_handler\_1482204640(NetworkBehaviour target, FastBufferReader reader, \_\_RpcParams rpcParams)
    {
        NetworkManager networkManager = target.NetworkManager;
        if (networkManager == null || !networkManager.IsListening)
        {
            return;
        }
        if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
        {
            if (networkManager.LogLevel <= Unity.Netcode.LogLevel.Normal)
            {
                Debug.LogError("Only the owner can invoke a ServerRpc that requires ownership!");
            }
            return;
        }
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.Server;
        ((StartOfRound)target).ManuallyEjectPlayersServerRpc();
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.None;
    }

This is the execution program that receives the server notification

now that i think about it most functions such as the spawn check if the player is host by comparing a instance of localclientid such as in NetworkObject

        public bool IsLocalPlayer
        {
            get
            {
                if (NetworkManager != null && IsPlayerObject)
                {
                    return OwnerClientId == NetworkManager.LocalClientId;
                }

                return false;
            }
        }
    if we can write to the localclient id and just change it to the host's when we call a function that requires host and restore it it should work fine

I think it's just tricking yourself, because other clients don't think you are the host, so they won't execute the commands you send

TheGreenBandit commented 8 months ago

I think it's just tricking yourself, because other clients don't think you are the host, so they won't execute the commands you send

maybe, it will have to be tested, let me see if i can write something up quick and if you have anyone to test with try it

chuxiaaaa commented 8 months ago
private static void \_\_rpc\_handler\_1482204640(NetworkBehaviour target, FastBufferReader reader, \_\_RpcParams rpcParams)
    {
        NetworkManager networkManager = target.NetworkManager;
        if (networkManager == null || !networkManager.IsListening)
        {
            return;
        }
        if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
        {
            if (networkManager.LogLevel <= Unity.Netcode.LogLevel.Normal)
            {
                Debug.LogError("Only the owner can invoke a ServerRpc that requires ownership!");
            }
            return;
        }
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.Server;
        ((StartOfRound)target).ManuallyEjectPlayersServerRpc();
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.None;
    }

This is the execution program that receives the server notification

now that i think about it most functions such as the spawn check if the player is host by comparing a instance of localclientid such as in NetworkObject

        public bool IsLocalPlayer
        {
            get
            {
                if (NetworkManager != null && IsPlayerObject)
                {
                    return OwnerClientId == NetworkManager.LocalClientId;
                }

                return false;
            }
        }
    if we can write to the localclient id and just change it to the host's when we call a function that requires host and restore it it should work fine

I think it's just tricking yourself, because other clients don't think you are the host, so they won't execute the commands you send

maybe, it will have to be tested, let me see if i can write something up quick and if you have anyone to test with try it

private static void \_\_rpc\_handler\_1482204640(NetworkBehaviour target, FastBufferReader reader, \_\_RpcParams rpcParams)
    {
        NetworkManager networkManager = target.NetworkManager;
        if (networkManager == null || !networkManager.IsListening)
        {
            return;
        }
        if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
        {
            if (networkManager.LogLevel <= Unity.Netcode.LogLevel.Normal)
            {
                Debug.LogError("Only the owner can invoke a ServerRpc that requires ownership!");
            }
            return;
        }
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.Server;
        ((StartOfRound)target).ManuallyEjectPlayersServerRpc();
        target.\_\_rpc\_exec\_stage = NetworkBehaviour.\_\_RpcExecStage.None;
    }

This is the execution program that receives the server notification

now that i think about it most functions such as the spawn check if the player is host by comparing a instance of localclientid such as in NetworkObject

        public bool IsLocalPlayer
        {
            get
            {
                if (NetworkManager != null && IsPlayerObject)
                {
                    return OwnerClientId == NetworkManager.LocalClientId;
                }

                return false;
            }
        }
    if we can write to the localclient id and just change it to the host's when we call a function that requires host and restore it it should work fine

I think it's just tricking yourself, because other clients don't think you are the host, so they won't execute the commands you send

maybe, it will have to be tested, let me see if i can write something up quick and if you have anyone to test with try it

Good luck. I'm going to bed. I'll wait for your good news.

TheGreenBandit commented 8 months ago

just pushed a mockup, try it once you are able to

TheGreenBandit commented 8 months ago

might have to change name of pr with how much im adding lol. Thinking of changing the gui to something a little better than black and white. Wish i could get imgui.net working

TheGreenBandit commented 8 months ago

Items can be generated but cannot be picked up.

Nice! All we need to do then is set the item in the inventory then and we have it? Does it retain its scrap balue? Have you tried spawning enemies?

realbillie commented 8 months ago

Back to Minecraft hack days in factions lmao. Remember the whole set offhand thing. That's what this vibe gives me.

TheGreenBandit commented 8 months ago

Try spawning something like a bigbolt or metalsheet

chuxiaaaa commented 8 months ago

According to the above rpc_handler method, I believe we cannot succeed because the code to determine whether the host is on another player is in the client side, but we cannot modify the code of other clients.

TheGreenBandit commented 8 months ago

All we should need to do is set it into the players hands after spawning, then it should be fine

chuxiaaaa commented 8 months ago

Sounds like a feasible method. I will try it

TheGreenBandit commented 8 months ago

try this, also where do you find this stuff? localVisor = GameObject.Find("Systems/Rendering/PlayerHUDHelmetModel/");

TheGreenBandit commented 8 months ago

Cant grab. I think only the host can get it

let me try putting it in our inventory while we are host

TheGreenBandit commented 8 months ago

try this, spawning enemy might work now

TheGreenBandit commented 8 months ago

hm, for the planned feature in the readme if we just get the enemies, patch their update function with

 if(notargetme && enemy.targetplayer == localplayer)
 {
 enemy.targetplayer = get the closest other player
}

that should be it

edit: actually if we just patch playeristargetable it should work just fine im a dumbass

TheGreenBandit commented 8 months ago

hmm why tf is this shit not letting me use mouse in gui, or any features like noclip working now

TheGreenBandit commented 8 months ago

did not mean to close, dumb close with comment button

TheGreenBandit commented 8 months ago

Can you try using gift boxes to generate items?

that may work, except how would we spawn the gift box

TheGreenBandit commented 8 months ago

Your menu is broken and none of the functions work. New version

Do you know which commit did it? Did it work before the recent commits?

TheGreenBandit commented 8 months ago

Ok good to know, i will have to see about different ways of getting the object to go into inventory

TheGreenBandit commented 8 months ago

just fixed the menu, i do see the problem, even when host you cannot pick up the item.

TheGreenBandit commented 8 months ago

deleting seems to be working, idk if it works as nonhost however.

TheGreenBandit commented 8 months ago

it seems that the current way i have for setting host just wont work. ill look into it more but will probably get rid of it for this pr

TheGreenBandit commented 8 months ago

im going to go to sleep but maybe GrabbableObject.ChangeOwnershipOfPropServerRPC will work, untargetable can be improved by patching the PlayerTripWebServerRpc to do nothing

TheGreenBandit commented 8 months ago

Can someone test carrydeadbody?

TheGreenBandit commented 8 months ago

~once that is tested and confirmed working the only 2 things left to do are find out why items with spaces dont wanna spawn and how to display the itemname of a object for the deleteobject~

Edit: figured out how to display itemname, also why objects with spaces didn't want to spawn. Just need to figure out if teleport dead body is working

TheGreenBandit commented 8 months ago

I suggest when adding prs to squash and merge this way the commit history doesn't appear with it. Cause this branch has a lot lol

TheGreenBandit commented 8 months ago

if you would like to test yet dont want to build go here to download

TheGreenBandit commented 8 months ago

Oh shit i forgot to add back changelog n shit

TheGreenBandit commented 8 months ago

I can

Alright, tell me the results when you are able to

TheGreenBandit commented 8 months ago

Carry dead body didnt work

Alright, thanks for testing, I'll look into it

Toaaa commented 8 months ago

Why did you remove the changelog and the credits? Or is it just not loading properly for me?

image

TheGreenBandit commented 8 months ago

Oh shit i forgot to add back changelog n shit

Forgot to add back, was debugging

Toaaa commented 8 months ago

Looks awesome! Do you guys want to make any changes or can I merge it?

TheGreenBandit commented 8 months ago

Looks awesome! Do you guys want to make any changes or can I merge it?

Carry dead body needs to be fixed other than that it's ready to go, i might just look at how the player grabs objects then use that to make a grabbing function that we could use for future features too

Btw could you take a look at my better hotkeys branch? Im having trouble getting if the user pressed a button with getasynckeystate

TheGreenBandit commented 8 months ago

this should work if someone wants to try carrydeadbody now

TheGreenBandit commented 8 months ago

https://github.com/TheGreenBandit/Project-Apparatus/releases/tag/updateddeadbody new dll incase yall dont wanna build

TheGreenBandit commented 8 months ago

might be an issue with how im getting the dead body, ill remove it from the pr and then ill look into adding it in another pr as this is ready without it, before i do anything though im going to test if it works with normal objects

TheGreenBandit commented 8 months ago

ok seems the pickup works, just dont go in your hands or have any of that function.

TheGreenBandit commented 8 months ago

should be ready to go, leaving pickup util in so it can be fixed just as the host override. Also noticed a game bug (not menu bug) that if u can a item with a worth of 10k or more it breaks the scanner

Toaaa commented 8 months ago

should be ready to go, leaving pickup util in so it can be fixed just as the host override. Also noticed a game bug (not menu bug) that if u can a item with a worth of 10k or more it breaks the scanner

Teleport All Items doesn't seem to work in your branch 🤷‍♀️

TheGreenBandit commented 8 months ago

should be ready to go, leaving pickup util in so it can be fixed just as the host override. Also noticed a game bug (not menu bug) that if u can a item with a worth of 10k or more it breaks the scanner

Teleport All Items doesn't seem to work in your branch 🤷‍♀️

~Hm ill look into it when i get home, i think i modified it testing something and forgot to revert it back~

Nvm got it over anydesk lol