pogoman / Smarter-Raider-AI

Lightweight intelligent decision making mod for RimWorld Raid AI
3 stars 0 forks source link

Poor decisions in open desert #3

Closed llunak closed 1 month ago

llunak commented 1 month ago

I play on extreme desert and there is something wrong with the mod when it comes to seeking cover. The problem is that raiders have a tendency to rush my colonists, even if they have guns and should rather seek cover. I don't remember the problem with 1.4 previously, but my previous playthrough wasn't in such open terrain.

As an example, load test2.rws.zip and let it run. There are 2 raiders, the lower one with a rifle does a good job of seeking cover. But the upper one with a pistol will simply run towards my colonists and cover on the opposite side of the same wall, which is dumb. If the mod is disabled, the raider will instead take cover behind the marble chunks above, which is a better decision.

(Also, the mod's About.xml lacks Harmony in the dependencies and the game disables the mod with rather cryptic errors if Harmony is not loaded because of this.)

pogoman commented 1 month ago

The lines affecting the functionality you are describing are here and here; basically anyplace where i touch job expiryInterval.

The original value is: new IntRange(450, 550);

The result of these changes is that raider's check for enemies more frequently than in vanilla. In vanilla rimworld the raider receives a new job every 4.5 - 5.5s. When a job finishes/expires if there are no enemies within attack range, the raider continues on with whatever non-attack job they were assigned with (i.e. job starts again). If one of your pawns is nearby during this timer the raider will not react to the pawn until the 4-5s has expired. So in your vanilla test the raider makes it all the way to cover.

In my mod the value is much lower so the raider in your scenario stops halfway to cover and engages as the job timers are short and a colonist has come into combat range of the raider.

So my recommendation would be to restore those expiryIntervals to default, but be careful as i changed them specifically because of slow reaction times of raiders. I dont play rimworld much anymore but when i did i made the game as hard as i could, and slow reaction times from raiders meant you could easily cheese them by moving in and out of attack range with a faster colonist and abusing their job timers. An unfortunate side effect of knowing how the AI works i suppose.

EDIT: I should probably mention i used to play with combat extended where getting the first shot off was more important than getting into half cover. If you are playing without it then cover probably makes more sense as combat takes a lot longer, so as you say a raider firing in the middle of an open field is less valuable than it finishing the move job into cover

llunak commented 1 month ago

I think you misunderstood the problem (I assume you have not actually tried the save?). The situation is like this:

                   c1
pc2
                                r

c = cover, p = (my) pawn, r = raider In vanilla, the raider runs to place 1 and then starts shooting. With the mod, the raider runs to place 2 and only then stars shooting. While running towards 2, the raider is a sitting (well, running) duck - it both extends the time to get hit and also makes it easier to get hit.

I don't understand how this is related to how often the AI updates a job. To me this seems like poor decision of where to go.

Also, do I understand it correctly that you basically want me to fix it and then send a PR? I can do that (I consider the mod useless with this problem), but it'd still help to know where to look for the problem.

pogoman commented 1 month ago

My apologies you are right. I made an assumption and didnt check your save. I see the issue. Will take me awhile to determine the root cause will get back to you. Thanks for the report!

pogoman commented 1 month ago

Ok can you please try again. I have published an update. Make sure you have it before testing, it should say version 1.5.1 in the mod description: image

Also added harmony as a dependency thanks

llunak commented 1 month ago

The testcase now works fine for me. I do not have any actual gameplay saves with the problem, but I assume those have been fixed too. Thank you for the fix.