边缘世界 RimWorld

边缘世界 RimWorld

评价数不足
Better Grenade Handling
   
奖励
收藏
已收藏
取消收藏
Mod, 1.6
文件大小
发表于
529.203 KB
10 月 24 日 上午 12:02
1 项改动说明 ( 查看 )

订阅以下载
Better Grenade Handling

描述
Better Grenade Handling v1.0.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


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)

  • (🚧 WIP) 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 (🚧 WIP) - a capability the vanilla game clearly lacks.

  • (🚧 WIP) 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.

  • 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.
热门讨论 查看全部(1)
0
20 小时以前
置顶: Bug report
UracosVereches
7 条留言
ZX Zero 8 小时以前 
Mods saves lifes GJ :steamthumbsup:
could this be extended to incoming meteors as well? :summercat2023:
hunlord11 10 小时以前 
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  [作者] 16 小时以前 
да, это работает только между союзниками, иначе взрывчатка вообще станет бесполезна
veoba 16 小时以前 
Ааа...это уворот лишь от своих гранат и снарядов. Я думал от любых.
UracosVereches  [作者] 16 小时以前 
согласен. но либо это, либо дополнительный микро-менеджмент. если попробовать это обосновать, то союзники тебя типо предупреждают заранее перед запуском снаряда. чтобы ты мог спокойно оставить команду миномётчиков, которые будут автономно поражать цели, не попадая по своим. скоро попробую сделать настройки, чтобы можно было отдельные функции мода отключать по своему желанию
veoba 16 小时以前 
Ну, интересно, конечно. Но уворот от зоны взрыва или уж тем более от снаряда миномёта выглядит, как жульничество.