OpenXcom Forum

OpenXcom Forks => More Forks => Brutal AI => Topic started by: Stormtrooper on January 31, 2025, 06:01:47 pm

Title: Realistic accuracy without brutal AI?
Post by: Stormtrooper on January 31, 2025, 06:01:47 pm
Hi, I've just discovered realistic accuracy thing and it seems it's everything I want, but sadly it seems to be a part of brutal ai fork. The problem is, I play xcom files and I want nothing beyond "vanilla" xcom files and realistic accuracy. I know brutal ai is configurable and stuff, but nevertheless it's a different fork and I found some discussions about subtle yet impactful changes etc, so my question is: Is there a simple way to achieve what I want? If not, could realistic accuracy be extracted into a separate mod that can be installed alongside "regular" oxce?
Title: Re: Realistic accuracy without brutal AI?
Post by: Xilmi on January 31, 2025, 09:29:24 pm
Hi, I've just discovered realistic accuracy thing and it seems it's everything I want, but sadly it seems to be a part of brutal ai fork. The problem is, I play xcom files and I want nothing beyond "vanilla" xcom files and realistic accuracy. I know brutal ai is configurable and stuff, but nevertheless it's a different fork and I found some discussions about subtle yet impactful changes etc, so my question is: Is there a simple way to achieve what I want? If not, could realistic accuracy be extracted into a separate mod that can be installed alongside "regular" oxce?
I'd like to know about the sutle yet impactful changes you saw discussions about.

I can try to list all of the ones I remember that do not have a separate option and then ask which ones you think are problematic.

1. Aggressive Retaliation => Changed how aliens search for X-Com Bases to prevent exploit of hiding bases in unreachable positions, retaliations also triggered by successful ground-missions.
2. Equipment-logic => When you don't manually equip your gear soldiers will try to autoequip a little smarter: Heavier weapons are more likely to be matched with stronger soldiers, it tries to fill up soldiers in a round-robin way so everyone has something of a kind of item before someone gets two, if enough items are there soldiers are filled to capacity.
3. Production queue => You can queue items for production and as long as you don't actually assign engineers it doesn't take up space. I think this was also included in regular OXCE since.

Other than that I'm not really aware of anything that needs to be specifically enabled in order to have any impact.
Title: Re: Realistic accuracy without brutal AI?
Post by: Stormtrooper on February 02, 2025, 01:04:20 pm
All the things you mentioned I don't care about, because 2 and 3 are only some gui stuff and I don't play with aggressive retaliation, but I'm just confused in general when it comes to available options. Lots of them I can simply turn off if I'm here only for realistic accuracy and nothing else, but then there are some I have no idea how to configure to preserve the original x-files enemy behaviour.

For example (I'll talk about options I found here: https://mod.io/g/openxcom/m/brutal-ai), "targeting behaviour for Brutal AI" - x-files has the sniper-spotter mechanic, so I guess choosing option 1 (vanilla behaviour) is out of question because it allows enemies to only fire at what they personally can see, same for option 2 (because sniper-spotter allows enemies to fire even without seeing anything I believe), so I guess the closest one is 3, but I'm not sure if it's exactly as in x-files. Note I'm not seeking to increase the difficulty further, I just want to be able to fire at what I can see and to see bullets travelling at realistic trajectories. Another things are "aggressivenes-" and "intelligence-mode" as well as "sneaky ai". No clue how they relate to x-files behaviour.

Another thing I noticed is that while "brutal ai" option can't be toggled, the description mentions being able to set it to false via config file. So maybe that's what I should do to get the results I want, turn brutal ai off via units.rul editing and leave realistic accuracy on? But I prefer to ask simply because AI-related changes aren't something I'll be able to instantly spot to tell whether it worked out or not.

Edit: I noticed there are also things like "ai bug hunt", allow explosives on turn one and so on, I really feel lost with what should I set to what and would be thankful for some insights.
Title: Re: Realistic accuracy without brutal AI?
Post by: Xilmi on February 02, 2025, 03:45:27 pm
Okay, I see, it's mostly because it's poorly communicated how it works.

First you go to "Mods" and disable the Mod called "Brutal AI".
This allows you to also disable "Brutal AI" in the Adcanced options for BOXCE. (turns it from purple and locked to yellow and togglable)

Once "Brutal AI" is disabled none of the other options there have any impact on the vanilla AI's behavior. They all only apply for "Brutal AI" when it is enabled!
Title: Re: Realistic accuracy without brutal AI?
Post by: Stormtrooper on February 03, 2025, 09:39:18 pm
Ah I see, thanks a lot, downloaded it and it works like a charm, x-files run correctly, realistic accuracy is taking its toll, brutal ai is off and on top of that noticed saving and loading the game runs faster than in oxce! Also love the removal of timer setup in grenade priming, combined with instant grenade explosions at last throwing grenades looks like proper act of throwing grenades, not C4 planting.

I guess the problem simply boils down to having two options essentially mean the same thing and the screenshot where brutal ai is forced on doesn't help either. Since the fork is called brutal ai in the first place, I think it would help to simply have the brutal ai mod removed and leave only the config option always toggable.
Title: Re: Realistic accuracy without brutal AI?
Post by: Delian on February 03, 2025, 10:04:53 pm
saving and loading the game runs faster than in oxce!

Fast saving and loading is OXCE 8.0 feature. BOXCE 9.2.2 and higher uses OXCE 8.0 as base.
Title: Re: Realistic accuracy without brutal AI?
Post by: Stormtrooper on February 05, 2025, 03:50:43 am
Well, what can I tell? As soon as I switched to brutal ai version saving and loading became faster. Not gonna complain about that... ::)
Title: Re: Realistic accuracy without brutal AI?
Post by: jnarical on February 19, 2025, 01:27:20 pm
Well, what can I tell? As soon as I switched to brutal ai version saving and loading became faster. Not gonna complain about that... ::)
Could you report ANY accuracy-related inconveniences? Most players most of the time just ignore bugs (until they're game-breaking), there's not enough feedback. Better create an issue at "Realistic Accuracy" github but I wouldn't mind any other ways to get it
Title: Re: Realistic accuracy without brutal AI?
Post by: Stormtrooper on March 10, 2025, 12:27:29 am
Sorry I took a while, but I just wanted to play a bit more with it to see how it works in practice rather than give info after only few battles. Bugs? What bugs? There are no bugs! ;D Or at least I'm oblivious enough to not notice them, it's not like I checked the algorithm and verified the calculations are correct with each shot I take or something. But nothing visible to the player, at least.

But as far as "inconveniences" go, well... there are some things I'm not a fan of:

Well, that's everything I could think of so far, but otherwise amazing feature, as amazing as expected. Out of the 4 points I made, only the first one is something that causes real frustration, the other 3 are just loose ideas/thoughts of mine and if you don't agree with them then fine, I won't bother. But please, please make soldiers raise weapon to aim even if it's a standing snap/auto shot. :D

If you prefer these written as issues in github just let me know, I just written it here since they're not technical bugs or something, just suggestions.
Title: Re: Realistic accuracy without brutal AI?
Post by: Xilmi on March 14, 2025, 10:25:57 pm
That's some really good feedback!

I'll ping jnarical on Discord to have him read it!
Title: Re: Realistic accuracy without brutal AI?
Post by: jnarical on March 15, 2025, 03:09:14 pm
One of the selling points of this feature is "if you can see it you can shoot it", however for some weird reason it only works with aimed shot or when kneeling down... why limit it to only certain conditions?
Realism in games is controversial topic. One should mark a line somewhere, and we're talking about the game where enemies take turns, and collision models for units are cylinders. I conceive the idea of different LoS/LoF for auto/snap fire both as a game convention and gameplay element, and a little bit as tribute to original game. It's kind of tradeoff: you have better cover, peeking out safely - but you can't open rapid fire as easy as someone staying in the open field with his finger on the trigger. I fired up the game just to make sure and can say it still looks justified.

Your opinion makes sense, I just wanted to elaborate mine. If needed, menu option could be easily implemented ))

Quote
Spread being affected by type of shot - maybe it'd be better to have it affected by chance to hit?.. my personal preference would be to have chance to hit dictate the spread
It does, to extent. Overall, the whole topic is extremely complicated. I spent weeks figuring it out, and had numerous heated discussions with people)) Imagine being me, trying to make accuracy mod for 30 years old game. What should it looks like? First of all, people who would possibly want to play mod are the same people who played OG and OXC and they are used to "old" accuracy. You couldn't change numbers arbitrarily. But the worst part is "realism" - in real life, distances of typical XCom gunfight are too short to miss. Be sure, first iterations of RA design were based on calculating realistic probabilities - but that didn't work well for close-range combat. So, after a while I came to current RA where bullets whizz around the target with (I hope so) "realistic" feel, for a price of fire spread cone changing with distance.

In a nutshell, spread depends on weapon 1/2-hand type, shot type, and distance. Chance to hit doesn't affect it 'cause for similar mentioned conditions, 100% visible target should get the same spread as almost fully covered, albeit chance to hit would be absolutly different.

Quote
100%+ shots... was brought back because mods and stuff, but well, I do play modded (x-files) and I don't like these guaranteed shots... 95% cap is something I guess.
Yes, I changed that back and forth... Firstly there was no cap, then I made it 95%, then I removed it again. 100%+ accuracy in mods like XCF sometimes affects damage so it's crucial to keep. If I recall right I was trying to add cap option to menu but decided to ditch the idea 'cause the algorith was already buggy and overcomplicated at the moment. I mean, I spent days and weeks in debugger. I could consider adding that option but it gives me flashbacks ))

Quote
Horizontal vs vertical spread
It should be less in vertical I guess, but maybe the rate is insufficient? OK, I've checked the code, basic (unmodified) vertical deviation is equal to unit's radius (except for big units, where it's radius/2). I could change it to 3/4 or 2/3 of radius, so spread shape will be elliptical. Statistically, round shape should've been working good, due the way it's used. When there's a rolled miss in accuracy - the game looks for valid missing trajectory. For round spread shape with center on the unit and radius equal to 1/2 of its size - most missing shots go to the sides, even after increasing spread - it's much more likely to miss to the side than to narrow areas above and below the unit.

===

As for bugs - I must confess there are known ones, but I didn't have time, will and energy to fix them. For example, suicide protection fails sometimes when shooting from Skyranger ramp, and off-center shooting is broken for a good amound of cases, including reaction fire. It feels in narrow passages.

I have long overdue obligation to make video tutorial for Freecad on YT, and couldn't devote myself to RA support until it's done, but I could at least make small updates. I guess it's time. I should say, positive feedback is encouraging. It's really is. Thank you)
Title: Re: Realistic accuracy without brutal AI?
Post by: Stormtrooper on March 15, 2025, 04:01:49 pm
Quote
Realism in games is controversial topic

Having seen some discussions about Cataclysm: Dark Days Ahead roguelike... yeeeeeah...  ::)

Quote
and a little bit as tribute to original game

I thought openxcom exists as that and extended is for people who want more changes and then there's this fork that's even more changes...  But fair enough, this game is older than me, so that's probably why I never understood this - I have no nostalgia and childhood memories related to it.

Quote
It's kind of tradeoff: you have better cover, peeking out safely - but you can't open rapid fire as easy as someone staying in the open field with his finger on the trigger.

Fair point, but the other side of the coin is an open window through which you can see yet somehow blocks your line of fire. But to each their own I guess and if you're willing to make an option and it's easy for you then I'm glad to hear that and everyone will be able to use what they want and everyone will be happy.  ;D

Quote
n a nutshell, spread depends on weapon 1/2-hand type, shot type, and distance. Chance to hit doesn't affect it 'cause for similar mentioned conditions, 100% visible target should get the same spread as almost fully covered, albeit chance to hit would be absolutly different.

Good point and I'm not going to argue further. I guess I just miss the implementation from UFO: Alien Invasion open source game, if I remember correctly this game didn't roll chance to hit but rather used accuracy to compute cone of fire and the displayed chance to hit was a matter of deviating visible target surface by total surface of cone cross-section. As a consequence that game had no 100%+ shots, no unreasonable misses and sniper misses were narrow while machinegun suppressive fire resulted in a bit wider spread. But again, fair enough, in this game it works different and I don't expect anyone to put any effort into implementing what I've just described so let's wrap it up here I guess.

Quote
I could consider adding that option but it gives me flashbacks ))

If it's that much of a traumatic experience to you then I don't expect you to go back to the dark times. ;) Besides, to really avoid problem of guaranteed shots simple 95% cap is not enough, it'd require complicated changes to implement accuracy gains as diminishing returns, because at some point you're already a master and further practice and DNA improvements can hardly make you better because you're still limited by laws of physics and stuff. But again, I don't expect anything, let alone balance this enough to make sure it works reasonably with x-files.

Quote
100%+ accuracy in mods like XCF sometimes affects damage so it's crucial to keep
Wait what? I always thought it was about accuracy of a soldier/gun, not the percentage chance to hit in a particular situation!

Quote
most missing shots go to the sides, even after increasing spread - it's much more likely to miss to the side than to narrow areas above and below the unit.

Yep, most do, just breaks immersion when I see a shot landing on the ground halfway between me and the target. Let alone when it lands closer to me, seriously xcom? I know real rifles are heavier than plastic toys, but come on, at least do raise them to the target's level  :P

But to sum this up, great mod, the bugs you described I haven't noticed so I guess if I forget your reply they don't exist, I'm no longer frustrated at IRL shotgun spread being tighter than sniper rile spread in xcom and the possibility of adding option to always be able to fire at things you see makes me happy.  :D Take whatever time you need, this is good enough as it is.
Title: Re: Realistic accuracy without brutal AI?
Post by: Yankes on March 15, 2025, 05:01:10 pm
For "100% accuracy", I think (in perfect game) split accuracy of shooter and accuracy of weapon. Each barrel could have inherent minimal angle of spread that can't be overcome by shooter accuracy. Image that you put weapon on bench and shoot from fixed position, it still should miss target in some conditions.
Title: Re: Realistic accuracy without brutal AI?
Post by: jnarical on March 15, 2025, 06:09:28 pm
Good point and I'm not going to argue further. I guess I just miss the implementation from UFO: Alien Invasion open source game, if I remember correctly this game didn't roll chance to hit but rather used accuracy to compute cone of fire and the displayed chance to hit was a matter of deviating visible target surface by total surface of cone cross-section.
That's how I initially tried to implement that. But either close-combat is broken (cone inside a target) or long-range shots have huge spread and low accuracy... And also I haven't my math good enough to code cross-sectioning voxel object with plane in 3D. Or, to be precise - check if a shot hits that cross-section.

Wait what? I always thought it was about accuracy of a soldier/gun, not the percentage chance to hit in a particular situation!
I'm not sure about details, just been told about it.

For "100% accuracy", I think (in perfect game) split accuracy of shooter and accuracy of weapon. Each barrel could have inherent minimal angle of spread that can't be overcome by shooter accuracy. Image that you put weapon on bench and shoot from fixed position, it still should miss target in some conditions.
Even more precise, it's weapon+ammo which gives minimal accuracy. I'm sure there are games where such things as recoil etc. are simulated, but we love xcom not for that )
Title: Re: Realistic accuracy without brutal AI?
Post by: Stormtrooper on March 15, 2025, 06:46:45 pm
Quote
I'm sure there are games where such things as recoil etc. are simulated

Yeah, simulating recoil and imperfection of the gun+ammo themselves are a plus if you want realistic shooter, but in tactical games at the end of the day player still sees just chance to hit and bullets flying at or next to the target. It'd be a waste of effort that's better spent on perfecting the accuracy formula to be immersive and realistic - at least for as long as you focus on what's happening in game instead of verifying the guts of the algorithm.

Quote
That's how I initially tried to implement that. But either close-combat is broken (cone inside a target) or long-range shots have huge spread and low accuracy... And also I haven't my math good enough to code cross-sectioning voxel object with plane in 3D. Or, to be precise - check if a shot hits that cross-section.

Interesting to see you had the same idea, but I can hardly blame you for not following it. Maybe in that game it worked better due to firefights having longer ranges in general, it wasn't as cqb-heavy as xcom simply because maps were bigger, sometimes much bigger and unlike in xcom there was no "visibility range" - I noticed in xcom you just can't see past certain distance even in broad daylight, in UFO: AI you could, so no problem spotting an alien on the other side of long map for as long as line of sight remained unobstructed. Meanwhile cqb was brutal, aliens missing you from up close meant you might as well buy a lottery ticket. (So given xcom ranges I see why this would be game-breaking) Well, from far away too, they were deadly accurate and you needed solid cover to not get hit. Sad this project never got finished... Also to be fair I'm not 100% sure if I remember the whole cone cross-section thing correctly - maybe their chance to hit calculator was good enough to give such impression...
Title: Re: Realistic accuracy without brutal AI?
Post by: Delian on March 15, 2025, 08:02:46 pm
100%+ accuracy in mods like XCF sometimes affects damage so it's crucial to keep.

It does not. Accuracy formula and damage formula of a weapon are independent of each other. You must've misunderstood something.

Technically, OXC has a hidden RNG built into firing trajectory generator, which is why it's possible to miss 100% accuracy shots. You could say that all shots are already 95% chance-to-hit shots. That's why there was nothing wrong with a 95% cap, assuming Realistic Accuracy bypasses the original trajectory RNG.
Title: Re: Realistic accuracy without brutal AI?
Post by: jnarical on March 18, 2025, 01:26:00 am
One of the selling points of this feature is "if you can see it you can shoot it"
Done. Will be added in next release.
Also, changed wording for RA options, to make them shorter / clearer.
Title: Re: Realistic accuracy without brutal AI?
Post by: Stormtrooper on March 18, 2025, 10:06:48 pm
OMG yes I'm so happy thank you so much you're awesome this feature is awesome everything is awesome.
Title: Re: Realistic accuracy without brutal AI?
Post by: jnarical on March 21, 2025, 01:23:11 am
Horizontal vs vertical spread - another suggestion of mine is to have the latter lowered compared to the former
Done, now fire cone is elliptical, I added to horizontal spread a little (x1.2) and reduced vertical (x0.65)
I'll do my best to test it better tomorrow. Next release should be in a couple of days, and if I won't be too lazy and slow - I'll expose all RA-related variables to yaml file, so modders could edit them. And tuning them will be up to you  :)

100%+ shots...  but 95% cap is something I guess
Done. I moved RA config to ruleset, you can either edit it directly (openxcom/standart/xcom1/realisticAccuracy.rul) or create small mod.

Upd:
Revamped spread calculation, made the whole set of parameters and algorithm itself much more clear for understanding and editing. Now testing it.