A little while ago I was playing around with intercepting DirectX calls and re-familiarize myself with C++. A project that was hinted at that spawned from this is as the title says Project Nepgeardam. I have made a few additions that are hopefully noteworthy. Without further ado let us dive into it.
So this was a little frustrating for a number of reasons. These vary from quirks with the way the game handles input in addition to old APIs.
So normally to send input to an application I would just use virtual keys, this, however, was not possible because of how Direct Input works. To get around this I ended up looking around for documentation for Direct Input to find a way of manipulating it. My search leads me to discover that Direct Input uses keyboard scan codes to receive input. Great now I know how it works but now I have no idea how the keyboard is mapped to scancodes and dozens of documents I checked had keys that did not map 100% until I found this. From there it was pretty easy sending inputs from them.
State-Based Input System
This is not so much an issue as an annoyance. So quite a few games revolve around having input state based that they can then check when needed. The problem comes when I press a key down then up in the span of a frame. This causes the state to be toggled down then up resulting in the state reporting back that the key is up so no action is performed. To get around this I have the key down for at least a frame before I send a key up scan code.
Frame Perfect Inputs
This is a weird one I noticed that some UI and menus in the game break when you send interact with them to quickly. This has lead to fun bugs where either the UI will disappear or stop taking input. To get around this there are some moments where I wait for a few frames (Damm this was hard to test with a physical keyboard and mouse). These are more obscure bugs that I have not happen to me in actual playthroughs.
Detecting the Game State
With input sorted the next issue to deal with was knowing when to send them. To do this I ended up using a few different things as follows
- Texture Descriptions
- Draw Call Order
- Number of Draw Calls
- Assigned Render Textures
I have not has to examine textures or extract mesh data yet which I am happy about.
With that sorted, the next tasks will be to have it walking around the dungeons automatically in addition to a basic battle AI. These I am not too sure as to how to go about but I am sure I will figure something out.