RimWorld

RimWorld

31 ratings
Better Grenade Handling
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.6
File Size
Posted
Updated
570.124 KB
24 Oct @ 12:02am
27 Oct @ 3:56am
2 Change Notes ( view )

Subscribe to download
Better Grenade Handling

Description
This mod is for people who want their colonists to behave professionally while wielding explosives. Avoiding friendly fire is the core feature.

Better Grenade Handling v1.1.0

🚧 Work In Progress
This mod is fresh out of the oven. Expect a lot of bugs. If you encounter any of them - let me know. I'll try to fix them as soon as I can.

Showcase
Never target enemies if friendly fire is possible



Automatically target non-stunned mechs



Pawns are more careful with explosives around



Partial mortar support


Full list of features
  • Pawns will avoid launching an explosive if there is at least 1 ally in blast radius + forced miss radius, including friendly factions/caravans too.

  • Pawns will, however, launch incendiary projectiles, such as molotov, if overall heat armor of an ally is >90% or flammability is less than 10% (impids, phoenix armor)

  • Pawns will launch toxic projectiles if allies in affected area have sufficient protection, like gasmask.
    Toxic raiders launch toxic projectiles no matter what.

  • Pawns avoid traversing over area where explosive is about to impact or is already present. Only works for friendly factions. Mortars are supported

  • If pawn is forced to launch an explosive(bypasses friendly fire checks) then any ally that happens to be in the blast area will flee out of it. Mortars are supported

  • Pawns equpped with EMP won't target already EMP-stunned mechs - eliminates the dumb behavior when they target the same mech over and over again. Also they automatically target enemies wearing shield-belts - a capability the vanilla game clearly lacks.

  • Pawns try to cause as much damage with explosives as possible by choosing much more tightly packed groups of enemies through the in-game target score system. Increases the DPS.

  • You can customize some parts of the mod to your liking. Supported languages: English and Russian.

  • All of the above applies to enemy raiders too. Now they will value their own lives more and won't shoot rockets at you if it involves any friendly fire.
Source code/No-Steam version
[github.com]

Technical debrief
This mod was particularly challenging to optimize. Since you have to check for pawns in a specific radius - you always have +1 loop to deal with. Achieving considerable performance was roughly ~80% of total effort. This mod is still probably going to add 0.1-0.2 ms overhead that scales linearly depending on how many grenadiers and targets you have on the map. But it barely matters, we’re bringing an entire weapon category back to life after the devs abandoned it. And outside of any combat it is barely visible in profiler.

How it works:
Firstly, we check for friendlies initially when a pawn enters combat(drafted or whatever). Not always the case though.

Then we check for friendlies every time any Thing in game changes its position(Thing.Position set method patch). It is built on 2 assumptions:
1) Initially, we assume that moved thing is an ally that we don't want to hit. It's a cheap O(1) check - just compare distance from target to ally. Add target we're aiming at to blacklist if conditions are met.
2) After that we assume that moved thing may be an enemy that is moving towards our ally. This time it's O(n) since we need to search for any possible ally in blast radius around our target. Add target to blacklist if at least 1 ally has been found.

I tried to be brief though, there is a lot more little details under the hood.

There is also trajectory prediction system that I've been working on, but abandoned shortly after. Check it out on github if you ever want to finish it.
Popular Discussions View All (1)
0
24 Oct @ 12:03am
PINNED: Bug report
UracosVereches
12 Comments
Halfelfaedyn 27 Oct @ 4:54am 
holy crap, okay, now they're usable!
UracosVereches  [author] 27 Oct @ 3:59am 
just dropped a new update, lads. mod settings, various fixes for emp weapons and enhanced targetting system to increase DPS. let me know if you have any issues. if this update is breaking your game - you can roll back to previous v1.0.0 version https://github.com/UracosVereches/BetterGrenadeHandling/releases/tag/v1.0.0
Harpuea 26 Oct @ 11:26pm 
Subscribed. Thanks..
UracosVereches  [author] 25 Oct @ 12:46pm 
ofc, i'll add mod settings shortly so you can customize every feature
renegade_sock 25 Oct @ 10:01am 
Hey awesome mod, is there a way to enable only certain features? The target selection features (including correct usage of EMP grenades) are really cool but the dodging features seem a bit OP for my tastes.
ZX Zero 24 Oct @ 11:36am 
Mods saves lifes GJ :steamthumbsup:
could this be extended to incoming meteors as well? :summercat2023:
hunlord11 24 Oct @ 9:25am 
This mod got on my list, thank you!

I'm not sure if you are looking for suggestions, but you should consider assigning this to the pawn skills. Poor grenade handling with low ranged skill makes sense. Also, there are certain traits that can trigger this (Nimble), or any military background.
UracosVereches  [author] 24 Oct @ 3:54am 
да, это работает только между союзниками, иначе взрывчатка вообще станет бесполезна
veoba 24 Oct @ 3:53am 
Ааа...это уворот лишь от своих гранат и снарядов. Я думал от любых.