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]: Infinite battery #68

Closed armorfid closed 9 months ago

armorfid commented 9 months ago

What happened?

title

Current Commit Hash

f45b67c

Injector

If you selected "Others" above, please specify the injector you are using.

No response

Log output

No response

Acknowledgement

winstxnhdw commented 9 months ago

Tried it before, tried it just now. Still no clue how to get it working. If you got a reference, I'd love to see it.

Quesoteric commented 9 months ago

Tried it before, tried it just now. Still no clue how to get it working. If you got a reference, I'd love to see it.

Would love to see this too. You might be able to reference this part from a mod menu.

armorfid commented 9 months ago

never modded LC before but managed to cobble up something from scratch, here you go my good sir, thank you for this project

[HarmonyPatch(typeof(GrabbableObject))]
class UnlimitedBatteryPatch {
    [HarmonyPatch(nameof(GrabbableObject.Update))]
    static void Postfix(ref Battery ___insertedBattery) {
        if (___insertedBattery != null) {
            ___insertedBattery.charge = 1f;
            ___insertedBattery.empty = false;
        }
    }
}
winstxnhdw commented 9 months ago

Yeah, that’s what I tried before. Didn’t work. I thought it was because I was patching the base classes, so I tried patching the Zap Gun’s charge method directly. Still no go.

winstxnhdw commented 9 months ago

@Quesoteric I haven’t given that way a try. Might give it a shot later.

armorfid commented 9 months ago

Yeah, that’s what I tried before. Didn’t work. I thought it was because I was patching the base classes, so I tried patching the Zap Gun’s charge method directly. Still no go.

wdym? this works perfectly for me online when joining as of now, i got infinite jetpack flashlight talkie etc.

winstxnhdw commented 9 months ago

Strange. Guess I'll give it one more go.

EDIT:

Oh wow, I just realised you are patching the Update loop directly. That could be why.

armorfid commented 9 months ago

yep thats the one running every frame, where the battery drain is originally computed

winstxnhdw commented 9 months ago

Done. Thank you for the reference @armorfid :) Maybe it would've been better if you submitted a PR for credits.

armorfid commented 9 months ago

next time fo sho