tapahob / BG2RadarOverlay

An overlay program for Baldurs Gate EE (1, 2) showing nearest enemies, their resistances, buffs and its durations
MIT License
25 stars 3 forks source link

Missing immunities? #1

Closed gatperdut closed 2 years ago

gatperdut commented 2 years ago

This is absolutely fantastic. Very cool and nice looking! Going to try it out tomorrow.

One quick question, how come the golem does not show immunities like charm? They are immune to that, if I'm not mistaken. Or maybe the demo is outdated and I haven't seen the whole thing?

tapahob commented 2 years ago

Yes the demo is a little dated and I got that fixed.

The issue is - the patch 2.6 made the game 64bit so all the memory addresses are invalid now.

gatperdut commented 2 years ago

I'll make a fresh 2.5 install and give it a try, then. Let me say that again, this is awesome.

tapahob commented 2 years ago

I'll make a fresh 2.5 install and give it a try, then. Let me say that again, this is awesome.

In that case, there might be some immunities missing which are coming from the gear - some of the immunities are managed by invisible rings e.g. Lich immunities.

gatperdut commented 2 years ago

Oh, those are not displayed? Pity! I guess item-based immunities are out of the scope of this project?

Also, this is exclusively for BG2EE and not BGEE, right?

tapahob commented 2 years ago

Yes the project is far from completion and I stopped working on that after 2.6 I wanted to have all the immunities and magical defenses in real-time.

If the EeEx docs were to be updated for x64 I'd continue the project.

I did not test it with BG1 but honestly, you don't need such tool for BG1

gatperdut commented 2 years ago

Hey, so your project was mentioned in the gibberlings3 discord and apparently EEEx does support 2.6, it's the documentation that's outdated (done by different people). But very likely the structures with the memory offsets and such are present in the source code itself.

tapahob commented 2 years ago

Hey, so your project was mentioned in the gibberlings3 discord and apparently EEEx does support 2.6, it's the documentation that's outdated (done by different people). But very likely the structures with the memory offsets and such are present in the source code itself.

Yep, I don't use EEEx itself, only its documentation as a reference. I tried to have a look into its sources but it looks too complicated for me.

gatperdut commented 2 years ago

new_offsets (1).txt

unsure if this helps you? these are the 2.6 data structures with the field offsets

tapahob commented 2 years ago

new_offsets (1).txt

unsure if this helps you? these are the 2.6 data structures with the field offsets

Wow, yes that sure will be of help, whered you get those? Are there memory patterns for these classes by any chance?

suy commented 2 years ago

To make a long story short, we talked about the issue with Bubb on the G3 Discord.

Note that both the 2.5 and 2.6 versions have available PDB files. Beamdog was very kind of providing them again after we requested them.

Bubb is the one who is more active in reverse engineering and understanding the decompilation of the engine, and the developer of EEex. I've done some toys with Frida scripts which work on both Windows and Linux (I use the latter). My understanding of the internals and my ability to understand reversed assembly/decompilation is very limited, but I got very very interested in how your program works, so I'd be willing to give it a shot in hooking into the game with Frida and writing something that works cross platform, if I find the time. :)

tapahob commented 2 years ago

To make a long story short, we talked about the issue with Bubb on the G3 Discord.

Note that both the 2.5 and 2.6 versions have available PDB files. Beamdog was very kind of providing them again after we requested them.

Bubb is the one who is more active in reverse engineering and understanding the decompilation of the engine, and the developer of EEex. I've done some toys with Frida scripts which work on both Windows and Linux (I use the latter). My understanding of the internals and my ability to understand reversed assembly/decompilation is very limited, but I got very very interested in how your program works, so I'd be willing to give it a shot in hooking into the game with Frida and writing something that works cross platform, if I find the time. :)

Oh I did not know that! What I did was just tinkering with Cheat Engine and the docs I found in google for the file formats. Personally, its my first memory hacking project, I was inspired by CS cheat makers' videos :)

tapahob commented 2 years ago

Honestly, I feel it would be best if someone could integrate this tool with EE Ex lua binding

gatperdut commented 2 years ago

So I'm trying to get it working but something's not right.

I did install .NET core 3.1, so in the shell dotnet --version returns 3.1.419.

The config.cfg file (this was auto-generated) seems to point to the right location:

GameFolder=C:\nirvana\Baldur's Gate II Enhanced Edition
Locale=en_US

Any idea where I might be going wrong?

tapahob commented 2 years ago

So I'm trying to get it working but something's not right.

  • Got BG2 2.5.16.6, fresh install.
  • Downloaded the BG2RadarOverlay release with BGOverlayUI.exe and extracted to the game folder.
  • Start BG2, then swapped windows, started the .exe. Then back to BG2.
  • Load a saved game. Mimicking your youtube video, so in Irenicus Dungeon right next to the golem.
  • Can't really see the list on the top left. Right-clicking the golem just issues the creature's sound.

I did install .NET core 3.1, so in the shell dotnet --version returns 3.1.419.

The config.cfg file (this was auto-generated) seems to point to the right location:

GameFolder=C:\nirvana\Baldur's Gate II Enhanced Edition
Locale=en_US

Any idea where I might be going wrong?

Hard to say without any kind of a message or logs but .. make sure you are using window mode.

I've checked it for myself and it does not seem to be able find anyone. Need to check the addresses

gatperdut commented 2 years ago

Nah, no luck. Tried several things, windowed mode, starting BG2RadarOverlay before loading, after loading, changed the game path to BG2EE and updated config.cfg in case that caused issues, also moving away from the golem so it disappears in the fog of war, then move back to it...

The only difference I can see is in your demo the executable is inside the folder netcoreapp3.1 and it's called WPFFrontend.exe while mine is in the game folder (next to Baldur.exe) and it's called BGOverlayUI.exe.

I can see a tiny, tiny window when in windowed mode that contains an orange dot (?) but it never does anything. I can drag it around though.

Anyway, was worth a shot!

tapahob commented 2 years ago

Nah, no luck. Tried several things, windowed mode, starting BG2RadarOverlay before loading, after loading, changed the game path to BG2EE and updated config.cfg in case that caused issues, also moving away from the golem so it disappears in the fog of war, then move back to it...

The only difference I can see is in your demo the executable is inside the folder netcoreapp3.1 and it's called WPFFrontend.exe while mine is in the game folder (next to Baldur.exe) and it's called BGOverlayUI.exe.

I can see a tiny, tiny window when in windowed mode that contains an orange dot (?) but it never does anything. I can drag it around though.

Anyway, was worth a shot!

I'll notify you once I get that fixed

suy commented 2 years ago

Recently on the EEEx thread someone reported the launcher being blocked by the antivirus. From the experience of Project Infinity, this is a very common problem, as Windows Defender and some other AV software just blocks the whole thing from starting, silently.

tapahob commented 2 years ago

@gatperdut could you please check the new release?

@suy I do use a mouse hooker here which is a system level hook so the antivirus has all the rights to blame it

gatperdut commented 2 years ago

I just tried it quickly with the same results. However, from the commits, it'd look like it's an identical release to the previous one?

Maybe missed pushing something?

tapahob commented 2 years ago

I just tried it quickly with the same results. However, from the commits, it'd look like it's an identical release to the previous one?

Nope its the new binary, I just did not push the changes. Looks like I do not understand something about the memory allocations.

Like, the previous release was working for me back then, but now the addresses seem to be very different even though I use the same game version and I have static pointer as an origin.

Wonder if I actually have to do the full process memory scan for it. Sounds wrong

tapahob commented 2 years ago

@gatperdut Quick question, do you use a proper new character or a predefined one? There is a bug currently with a predefined character

gatperdut commented 2 years ago

@gatperdut Quick question, do you use a proper new character or a predefined one? There is a bug currently with a predefined character

Hah, that was it. Amazing! I used a newly created character and started seeing stuff 😁 Definitely not while on fullscreen, I was wondering why mouse-scrolling wasn't working 😅

The list on the top left displayed a few strange things (like Branwen), but I don't think I would be using it too much since it's enough to right-click on the character that I want to know more about.

I teleported to the Crooked Crane for a quick test with the Lich there but couldn't see any immunities (except against +X weapons and up to 5th spell level), I wonder why the ones from the items aren't displayed anywhere (charm, confusion, etc). I also noticed that the Lich's elemental resistances were all 0 (though Ctrl+Q shows it's 127 against fire, for example).

Super excited about the possibilities of this.

tapahob commented 2 years ago

Oh thats nice to hear!

I disabled the list filtering for this build for you to be more likely to see at least anything :) Could you share the save with the Lich you are talking about?

gatperdut commented 2 years ago

Yep, here it is, just before going through the door at the back of the inn. You can also get there with the cheat console, it's area AR0021.

I can't always get the overlay working though, but it was fine a couple of times. I think it had trouble when loading a game. 000000001-Quick-Save-3.zip

tapahob commented 2 years ago

@gatperdut got it fixed in the new release

As for individual spell immunities - its not yet implemented

gatperdut commented 2 years ago

Awesome, I'm going to check it out tomorrow morning!

gatperdut commented 2 years ago

It's definitely more reliable! I was able to reload a game several times and it kept working fine 👍

Here's some feedback:

I want to try this next with SCS, which gives enemies weapon proeficiencies - so I think I should be able to see them on characters other than PCs. Like, they show for Imoen (Shortsword +, e.g.) but not for anyone else, but I think this is just how the vanilla game was made.

I also want to give this a try together with EEEx, for the spell buff effects list it has integrated (shift + hover over an enemy displays stuff like Minor Globe of Invulnerability, Spell Turning, etc. which is very useful). Though I am not so sure about it, since EEEx needs a different executable to be run to start the game, but maybe the process name is the same? Edit: They didn't work together.

tapahob commented 2 years ago
gatperdut commented 2 years ago
  • Regarding Spell Immunities, I need some help there

Oh I see. I'm a little lost on the exact words. Spell immunities are against specific spells, e.g. immunity against spell levels 1-5, or against "Pierce Shield" specifically? And status effect immunities are against stuff like charm, paralyze, blindness, stun, etc? Did I get that right?

In any case the guys at G3 will know a lot for sure. Thanks a lot!

tapahob commented 2 years ago
  • Regarding Spell Immunities, I need some help there

Oh I see. I'm a little lost on the exact words. Spell immunities are against specific spells, e.g. immunity against spell levels 1-5, or against "Pierce Shield" specifically? And status effect immunities are against stuff like charm, paralyze, blindness, stun, etc? Did I get that right?

In any case the guys at G3 will know a lot for sure. Thanks a lot!

There are multiple kinds of immunities, if you are to open CDerivedStats you'll see CImmunitiesSpellList, CImmunitiesEffect etc, and I don't have the docs of how its stored there

tapahob commented 2 years ago

@gatperdut could you please check the new release? Its better to remove the existing config file beforehand.

I've changed the memory scan algorithm - if it would work - it should be much more efficient. Added a Borderless fullscreen option (its On by default)

Oh and Radar Radius is also configurable now (via config file)

gatperdut commented 2 years ago

Nice! It didn't show anything in my first try (even though I had removed config.cfg beforehand) but, after closing the overlay and opening it again, it was back there. Something odd was that, now, the Golem in the starting dungeon wasn't recognized. I used the previous release to double-check and, oddly enough, it wasn't recognized there either. Weird!

I am not sure what the Borderless option is doing but I'm running the game in maximized windowed mode anyway while running your overlay, so can't provide much feedback on that, unfortunately.

I did a bit more of testing with the Lich from the Crooked Crane. In the screenshot you can see some discrepancies I found with the elemental resistances to illustrate better what I meant before. Maybe the overlay is reading from the wrong positions? Like I mentioned, the "Cold resistance" value is off in nearly every character I examined. In the case of this Lich, the "Magic fire resistance" is off as well (though it's not very relevant), and "Poison resistance" is missing. Might be worth a look? lich_elemental_discrepancy

If you look at this forum thread page 37 and search for my post there (username gatperdut, can't link to the post directly), you'll find the answer to it from Bubb/Eeks, the author of EEEx, a few posts down. Apparently he was stuck with the interface for showing all the information with a nice interface. I think yours looks great! He seemed to have a pretty good idea on how to deal with the item-based immunities which you mentioned having trouble with.

Have you seen EEEx's Spell Effect module? It's running "inside" the game (don't know the right word, but if you have used it you'll know what I mean). Merging your overlay information card with what he has would basically mean complete information on any character is available on realtime.

tapahob commented 2 years ago

@gatperdut We took very different approaches to the problem. He made an EEEx injector library which intercepts the game engines internal Lua calls so he can manipulate the engine from the inside. What I do is basically dumpster diving into the process memory poking it like a blind kitten hoping for the best. So I can't interact with EEEx in any way. I just use its documentation to find out which exact data structure I stumble upon

tapahob commented 2 years ago

Got the effect resistances to work @gatperdut Its kinda funny seeing Imoen's immunities with the belt :))

screen

gatperdut commented 2 years ago

Got the effect resistances to work @gatperdut

jonah-hill-yay

I'm going to check this out when you release it.

I'm trying my hand at replicating EEEx's spell effect menu, with a different key binding, and something simple for the moment... resistance to a single status effect, like stun. I'm wondering if it does the calculation for me of which status effects apply, so I wouldn't need to manually traverse the equipped items to check for it.

tapahob commented 2 years ago

@gatperdut here it is - new release

gatperdut commented 2 years ago

@gatperdut here it is - new release

Hmm... I'm starting it like before, and I see a green-ish thing on the top left. When I click it though the mouse becomes a bit unresponsive and then the overlay process crashes, I believe. It disappears from the running processes for sure.

tapahob commented 2 years ago

@gatperdut here it is - new release

Hmm... I'm starting it like before, and I see a green-ish thing on the top left. When I click it though the mouse becomes a bit unresponsive and then the overlay process crashes, I believe. It disappears from the running processes for sure.

Is it with SCS installed?

gatperdut commented 2 years ago

Is it with SCS installed?

It's me being a dummy :) I downloaded the 2.6 for some tests and forgot to replace it with 2.5 before using your overlay. Will get back to you.

Is SCS needed?

tapahob commented 2 years ago

Is it with SCS installed?

It's me being a dummy :) I downloaded the 2.6 for some tests and forgot to replace it with 2.5 before using your overlay. Will get back to you.

Is SCS needed?

No but it would be nice to know how it behaves with SCS. e.g. with spell protections - if you are to check my old screenshot it shows spell protections for lesser clay golem (pierce magic\lower resist) and now I don't see those. But now I am without SCS and backthen it was with SCS.

How smooth are the animations for you?

gatperdut commented 2 years ago

Ok, this is amazing. Reloaded and tried to break it a few times but couldn't. Here's some feedback:

jaheira_poison

tapahob commented 2 years ago

Last release of the week - ding @gatperdut

Removed Magic Fire / Magic Cold Added Resist Magic Damage / Poison Class kits are now displayed instead of base classes when possible Added backstab immunity info Added See invisible info Fixed Level display Proficiencies now take one line.

Proficiencies are not realtime now - its the data from the archive which will be outdated for your party members but will be correct for the enemies

tapahob commented 2 years ago

Guess what was implemented? screen

New release

gatperdut commented 2 years ago

That looks awesome! The lack of feedback is what frustrates me the most about BG and your project solves that perfectly :D

I'm going to give it a thorough try later today when I'm done with work (silly mondays...) and get back to you with detailed feedback. I'm thinking it might be better to open separate issues? This one became huge.

tapahob commented 2 years ago

Okki - Im closing this one then