kartjom / CoDPlusPlus

Extension Library for CoDUO MP v1.51
GNU General Public License v3.0
12 stars 2 forks source link

imgui not disabling player's looking #1

Closed raphael12333 closed 5 months ago

raphael12333 commented 5 months ago

hello After uncommenting https://github.com/kartjom/CoDPlusPlus/blob/6ca42e5535a9a1b3bb9df1500fb34fbc74f397e9/CoDPlusPlus/src/Utils/ImGuiManager.cpp#L93, i see the imgui demo window when pressing the End key

But that is not disabling the player's looking and by the way causing a strange behavior (https://youtu.be/avJZiXcNrIM) Is there something to uncomment in the code to prevent this?

Regards Raphael btw i would really enjoy to read how you inject the .dll in the game

kungfooman commented 5 months ago

btw i would really enjoy to read how you inject the .dll in the game

You can write your own DLL injector in like 30 lines of Win32 API code or use a tool like Cheat Engine: https://www.youtube.com/watch?v=OmwaAwoUqwQ

Your video is private, so we can't see it - anyway, it just requires better UI integration with idtech3 engine UI handling - you can check ioquake3 etc. as reference how it works.

raphael12333 commented 5 months ago

hi kungfooman it's a pleasant surprise to see you reply here


You can write your own DLL injector in like 30 lines of Win32 API code

i would try this way, thank you


Your video is private, so we can't see it

the video visibility is now modified


it just requires better UI integration with idtech3 engine UI handling - you can check ioquake3 etc. as reference how it works.

i would look into ioquake3 source, thanks i leave the issue open a bit but i would close it soon

kungfooman commented 5 months ago

it's a pleasent surprise to see you here too, you can create a PR and link it to this issue, which automatically closes this issue once merged 👍

kartjom commented 5 months ago

Hey, thanks for clarifying the issue kungfooman, I'll also take a look in my spare time. If you manage to fix it @raphael12333, feel free to PR it.

If you want to automate the injection, you can rename the dll to UMPDC.dll and leave it in the root directory (where CoDUOMP.exe is).

Just keep in mind it's basically DLL hijacking and might not work on some Windows versions or cause crashes in some scenarios, but for me it worked well for entire development.

raphael12333 commented 5 months ago

Ok i would make a PR if i find a fix for this The UMPDC.dll technique works on my Windows 11, thank you for the explanations

raphael12333 commented 5 months ago

hello i'm adding imgui in my codextended-client fork and giving it the mouse using the way iw3xo does (https://github.com/xoxor4d/iw3xo-dev/blob/d367fa6c96a158cfe2fa6cd06d27f10f78b98700/src/components/modules/gui.cpp#L325) and it seems to work great

currently i'm not planning to try to add this way to a CoDPlusPlus pull request but i will maybe later

i said i would close this issue soon but since it seems to be a real issue and not just something to uncomment / a cvar to change, i leave it open

regards

kartjom commented 5 months ago

Thanks for the effort.

I already managed to fix this in a very similar manner basing on RTCW-MP repo. Seems to be working fine now.

You can see the changes here 5eeb9f53e2332fda0a9b8d5c7b4c22c3b4c8de75

raphael12333 commented 5 months ago

Thanks for the effort.

I already managed to fix this in a very similar manner basing on RTCW-MP repo. Seems to be working fine now.

You can see the changes here 5eeb9f5

I just tried your new code, I accidentally pressed the Delete key instead of End key and got surprised

I notice that when closing the imgui demo, the cursor/player's look goes a bit down, it is more easily noticeable when holding the End key

Not using CursorToCenter() prevents this, but then when you exit the imgui demo, the player's look "teleports" to where it should have looked when he was not

I found iw3xo's way when trying to fix this on cod1 this morning, calling In_Shutdown stopped this behavior

I appreciate neat projects like yours

kartjom commented 5 months ago

This 'snapping' you're talking about is in fact caused by my mistake in calculating the center. I did not account for window borders and X Y offsets. In perfect scenario (fullscreen and no other offsets) this didn't happen.

I just pushed a fix for it here 2dac644d183cc097b43b936ed42bc113179c8c8b

raphael12333 commented 5 months ago

I just tried your new code and it works perfectly for me too :)

raphael12333 commented 5 months ago

FTR I replaced In_Shutdown by IN_DeactivateMouse+IN_ActivateMouse in my extension fork this way:

if (!menuIsDisplayed)
{
    displayMenu = true;
    ((void(*)())0x4616b0)(); //IN_DeactivateMouse
    *mouseActive = 0;
    *mouseInitialized = 0;
}
else
{
    displayMenu = false;
    *mouseInitialized = 1;
    ((void(*)())0x461730)(); //IN_ActivateMouse
}

It seems to be a nice/the way to do, using these there is no need to manually handle the cursor position and the window capture. In_Shutdown was not ideal because when setting mouseInitialized back to 1, some stuff were not reactivated Regards